@@ -47,7 +47,7 @@ def main():
47
47
for regex in rules :
48
48
regexes [regex ] = rules [regex ]
49
49
do_entropy = str2bool (args .do_entropy )
50
- output = find_strings (args .git_url , args .since_commit , args .max_depth , args .output_json , args .do_regex , do_entropy )
50
+ output = find_strings (args .git_url , args .since_commit , args .max_depth , args .output_json , args .do_regex , do_entropy , surpress_output = False )
51
51
project_path = output ["project_path" ]
52
52
shutil .rmtree (project_path , onerror = del_rw )
53
53
@@ -206,7 +206,7 @@ def regex_check(printableDiff, commit_time, branch_name, prev_commit, blob, comm
206
206
regex_matches .append (foundRegex )
207
207
return regex_matches
208
208
209
- def diff_worker (diff , curr_commit , prev_commit , branch_name , commitHash , custom_regexes , do_entropy , do_regex , printJson ):
209
+ def diff_worker (diff , curr_commit , prev_commit , branch_name , commitHash , custom_regexes , do_entropy , do_regex , printJson , surpress_output ):
210
210
issues = []
211
211
for blob in diff :
212
212
printableDiff = blob .diff .decode ('utf-8' , errors = 'replace' )
@@ -221,8 +221,9 @@ def diff_worker(diff, curr_commit, prev_commit, branch_name, commitHash, custom_
221
221
if do_regex :
222
222
found_regexes = regex_check (printableDiff , commit_time , branch_name , prev_commit , blob , commitHash , custom_regexes )
223
223
foundIssues += found_regexes
224
- for foundIssue in foundIssues :
225
- print_results (printJson , foundIssue )
224
+ if not surpress_output :
225
+ for foundIssue in foundIssues :
226
+ print_results (printJson , foundIssue )
226
227
issues += foundIssues
227
228
return issues
228
229
@@ -234,7 +235,7 @@ def handle_results(output, output_dir, foundIssues):
234
235
output ["foundIssues" ].append (result_path )
235
236
return output
236
237
237
- def find_strings (git_url , since_commit = None , max_depth = 1000000 , printJson = False , do_regex = False , do_entropy = True , custom_regexes = {}):
238
+ def find_strings (git_url , since_commit = None , max_depth = 1000000 , printJson = False , do_regex = False , do_entropy = True , surpress_output = True , custom_regexes = {}):
238
239
output = {"foundIssues" : []}
239
240
project_path = clone_git_repo (git_url )
240
241
repo = Repo (project_path )
@@ -265,12 +266,12 @@ def find_strings(git_url, since_commit=None, max_depth=1000000, printJson=False,
265
266
continue
266
267
else :
267
268
diff = prev_commit .diff (curr_commit , create_patch = True )
268
- foundIssues = diff_worker (diff , curr_commit , prev_commit , branch_name , commitHash , custom_regexes , do_entropy , do_regex , printJson )
269
+ foundIssues = diff_worker (diff , curr_commit , prev_commit , branch_name , commitHash , custom_regexes , do_entropy , do_regex , printJson , surpress_output )
269
270
output = handle_results (output , output_dir , foundIssues )
270
271
prev_commit = curr_commit
271
272
# Handling the first commit
272
273
diff = curr_commit .diff (NULL_TREE , create_patch = True )
273
- foundIssues = diff_worker (diff , curr_commit , prev_commit , branch_name , commitHash , custom_regexes , do_entropy , do_regex , printJson )
274
+ foundIssues = diff_worker (diff , curr_commit , prev_commit , branch_name , commitHash , custom_regexes , do_entropy , do_regex , printJson , surpress_output )
274
275
output = handle_results (output , output_dir , foundIssues )
275
276
output ["project_path" ] = project_path
276
277
output ["clone_uri" ] = git_url
0 commit comments