Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions detect_secrets/core/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ def scan_for_allowlisted_secrets_in_file(filename: str) -> Generator[PotentialSe
except IOError:
log.warning(f'Unable to open file: {filename}')
return
except ValueError:
log.warning(f'Unable to scan file: {filename}. Please ignore if file is empty.')
return
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest checking if lines: above instead - that way we'll be specifically addressing the issue (as opposed to any ValueError exception) and we won't need to execute the line yield from _scan_for_allowlisted_secrets_in_lines(enumerate(lines, start=1), filename) at all

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback, I added the suggested modifications.



def scan_for_allowlisted_secrets_in_diff(diff: str) -> Generator[PotentialSecret, None, None]:
Expand Down