From 21307f6642a66dca043809e540992669f38ef1c1 Mon Sep 17 00:00:00 2001 From: Robin Geffroy Date: Wed, 7 Apr 2021 14:25:15 +0200 Subject: [PATCH] Make Git patch works Git patch format is slightly different from unified diff / svn diff. The hunk format changes, and the function name is added after the last @@. The regex has to be changed to ensure the hunk is recognized, so the line numbers are correct. --- flawfinder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flawfinder.py b/flawfinder.py index f157ed8..3c72a3d 100644 --- a/flawfinder.py +++ b/flawfinder.py @@ -173,7 +173,7 @@ def print_warning(message): diff_index_filename = re.compile(r'^Index:\s+(?P.*)') diff_git_filename = re.compile(r'^diff --git a/.* b/(?P.*)$') diff_newfile = re.compile(r'^\+\+\+\s(?P.*)$') -diff_hunk = re.compile(r'^@@ -\d+(,\d+)?\s+\+(?P\d+)[, ].*@@$') +diff_hunk = re.compile(r'^@@ -\d+(,\d+)?\s+\+(?P\d+)[, ].*@@') diff_line_added = re.compile(r'^\+[^+].*') diff_line_del = re.compile(r'^-[^-].*') # The "+++" newfile entries have the filename, followed by a timestamp