Skip to content

Commit

Permalink
fix: write debug log for binary files (#190)
Browse files Browse the repository at this point in the history
* fix: write debug log for binary files

It took several hours to find out why package-lock.json file was not being scanned. Turns out it was marked a binary and therefore was skipped. Verbose logging would have saved tons of time.

* fix lint issue

Co-authored-by: Joey Wilhelm <tarkatronic@gmail.com>
  • Loading branch information
dclayton-godaddy and tarkatronic authored Jun 11, 2021
1 parent b481f7d commit 21e5e1d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tartufo/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,10 +388,11 @@ def _iter_diff_index(
"""
diff: git.Diff
for diff in diff_index:
file_path = diff.b_path if diff.b_path else diff.a_path
printable_diff: str = diff.diff.decode("utf-8", errors="replace")
if printable_diff.startswith("Binary files"):
self.logger.debug("Binary file skipped: %s", file_path)
continue
file_path = diff.b_path if diff.b_path else diff.a_path
if self.should_scan(file_path):
yield (printable_diff, file_path)

Expand Down

0 comments on commit 21e5e1d

Please sign in to comment.