Skip to content

Commit 3f67eb5

Browse files
committed
don't rescan commits
2 parents 1e1974b + 3284a24 commit 3f67eb5

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

truffleHog/truffleHog.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import datetime
99
import argparse
1010
import uuid
11+
import hashlib
1112
import tempfile
1213
import os
1314
import re
@@ -261,11 +262,17 @@ def find_strings(git_url, since_commit=None, max_depth=1000000, printJson=False,
261262
# if not prev_commit, then curr_commit is the newest commit. And we have nothing to diff with.
262263
# But we will diff the first commit with NULL_TREE here to check the oldest code.
263264
# In this way, no commit will be missed.
265+
diff_hash = hashlib.md5((str(prev_commit) + str(curr_commit)).encode('utf-8')).digest()
264266
if not prev_commit:
265267
prev_commit = curr_commit
266268
continue
269+
elif diff_hash in already_searched:
270+
prev_commit = curr_commit
271+
continue
267272
else:
268273
diff = prev_commit.diff(curr_commit, create_patch=True)
274+
# avoid searching the same diffs
275+
already_searched.add(diff_hash)
269276
foundIssues = diff_worker(diff, curr_commit, prev_commit, branch_name, commitHash, custom_regexes, do_entropy, do_regex, printJson, surpress_output)
270277
output = handle_results(output, output_dir, foundIssues)
271278
prev_commit = curr_commit

0 commit comments

Comments
 (0)