Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't crash audit when highlighter fails in audit #228

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 4 additions & 1 deletion detect_secrets/core/audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,10 @@ def _get_secret_with_context(
filename,
)

snippet.highlight_line(raw_secret_value)
try:
snippet.highlight_line(raw_secret_value)
except ValueError:
raise SecretNotFoundOnSpecifiedLineError(secret['line_number'])
except SecretNotFoundOnSpecifiedLineError:
if not force:
raise
Expand Down
2 changes: 1 addition & 1 deletion detect_secrets/pre_commit_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def raise_exception_if_baseline_file_is_unstaged(filename):
'--name-only',
],
).split()
except subprocess.CalledProcessError:
except subprocess.CalledProcessError: # pragma: no cover
# Since we don't pipe stderr, we get free logging through git.
raise ValueError

Expand Down