Skip to content

Conversation

@mplzik
Copy link
Contributor

@mplzik mplzik commented Sep 25, 2025

Description:

With its original code, Trufflehog was returning a zero exit code in
cases when an error was encountered during a scan. This led to some
unexpected situations, such as succeeding if a git repo was not cloned
correctly or if a non-existent commit was referenced from
--since-commit.

This PR proposes adding a new flag --fail-on-scan-errors that, if
enabled, will propagate scan errors further (alongside with the current
behavior of reporting them on console), ensuring that Trufflehog returns
a non-zero exit code.

The change should be fairly safe, as it is hidden behind a flag and if
not activated, the original behavior is retained.

See also: #4218

Signed-off-by: Milan Plzik [email protected]

Checklist:

  • Tests passing (make test-community)?
  • Lint passing (make lint this requires golangci-lint)?

With its original code, Trufflehog was returning a zero exit code in
cases when an error was encountered during a scan. This led to some
unexpected situations, such as succeeding if a git repo was not cloned
correctly or if a non-existent commit was referenced from
`--since-commit`.

This PR proposes adding a new flag `--fail-on-scan-errors` that, if
enabled, will propagate scan errors further (alongside with the current
behavior of reporting them on console), ensuring that Trufflehog returns
a non-zero exit code.

The change should be fairly safe, as it is hidden behind a flag and if
not activated, the original behavior is retained.

See also: trufflesecurity#4218

Signed-off-by: Milan Plzik <[email protected]>
@CLAassistant
Copy link

CLAassistant commented Sep 25, 2025

CLA assistant check
All committers have signed the CLA.

@mplzik mplzik marked this pull request as ready for review September 25, 2025 12:44
@mplzik mplzik requested a review from a team as a code owner September 25, 2025 12:44
Copy link
Contributor

@rosecodym rosecodym left a comment

Choose a reason for hiding this comment

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

Thank you for this!

@rosecodym rosecodym merged commit 7746b2c into trufflesecurity:main Sep 29, 2025
13 checks passed
@mplzik
Copy link
Contributor Author

mplzik commented Sep 30, 2025

@rosecodym happy to help. Also, I was being fairly conservative with adding the change behind a flag -- since a fair amount of users might have this failing silently, it might be worth to gradually roll this out as an enabled-by-default flag (e.g. slowly add a warning about not using the flag, then make the flag enabled by default; then remove the option altogether, if it makes sense). This is a choice that lies on the Trufflehog maintainers, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants