fix: stop disabling TruffleHog verification for verified-only scans - #110
Open
lelia wants to merge 4 commits into
Open
fix: stop disabling TruffleHog verification for verified-only scans#110lelia wants to merge 4 commits into
lelia wants to merge 4 commits into
Conversation
Turning trufflehog_show_unverified off passed --no-verification, which disabled verification outright instead of returning only verified findings. Severity is derived from each finding's Verified flag, so every result came back Verified: false -> low severity -> non-blocking. On the setting's default path no secret could ever block a run: the exact inverse of intent. Verification now always runs, and the setting selects result types only: --results=verified when off, --results=verified,unverified,unknown when on (the latter matching TruffleHog's own default). Verified findings stay critical/blocking, unverified stay low/non-blocking. --include-detectors=all is now passed unconditionally so detector selection no longer changes as a side effect of the setting. TruffleHog already defaults to all detectors, so this is a no-op in practice. Verified against the pinned trufflesecurity/trufflehog:3.96.0 binary: an unverifiable private key is returned under the "on" filter and dropped under the "off" filter. Two upgrade consequences, documented in the changelog: runs with the setting off will start reporting blocking critical findings previously downgraded to low, and verification is a live check, so TruffleHog now makes outbound requests to third-party credential-validation endpoints. Also corrects TruffleHog parameter docs (exclude paths accept files and globs, not just directories; show-unverified widens result types rather than toggling verification) and a JSON config example that named a nonexistent show_unverified key. Fixes CE-351 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Only the environment loader coerces bool params (config.py:924). A Socket dashboard config is passed through verbatim (config.py:1309) and outranks env, so a dashboard-supplied string "false" reached the connector as a truthy value. Under the old --no-verification code that misread was a harmless no-op: it selected --include-detectors=all, which is TruffleHog's default anyway. Now it would select --results=verified,unverified,unknown and report unverified secrets to someone who explicitly asked for verified-only, so the same latent misread became a real behavioral bug. Covers "false"/"False"/"0"/"no", the true forms, and the unset cases (None and the empty string an unset action input forwards). Verified the new test fails against the truthiness read and passes with coerce_bool. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Any non-zero exit was logged and converted into an empty result, so a malformed exclude pattern or a broken install silently zeroed out every secret finding while the run exited green. A scanner that could not scan looked identical to a repository with no secrets. Non-zero exits and a missing trufflehog binary now raise SystemExit with the exit code and TruffleHog's own stderr. SystemExit is deliberate: the connector manager catches Exception, and this must not be downgraded to a skipped connector. The exclude-file cleanup in the finally block still runs on the failure path. This closes the last open acceptance criterion from CE-347 ("a malformed/unopenable exclude value no longer causes trufflehog to silently return zero findings for the whole run"). Its other two criteria shipped in 2.2.1 via #94, which referenced CE-347 without closing it. Matches the fail-closed idiom already used for an unresolvable changed_files scope, which also raises SystemExit with an actionable message. test_scan_cleans_exclude_file_when_trufflehog_fails asserted the old swallowing behavior; it now expects the failure to surface while still asserting the temp filter file is cleaned up. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
Author
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 64cf028. Configure here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stabilizes the TruffleHog experience further (building off #94) for a single upcoming release.
1. Verification always runs, while result filtering stays configurable
Turning Show Unverified Secrets off passed
--no-verification, which disabled verification outright instead of filtering the returned findings.Severity is derived from each finding's
Verifiedflag, so disabling verification made every findingVerified: false→low→ non-blocking. On the setting's default path, no secret could ever block a run—the inverse of the intended behavior.Verification now always runs, and the setting selects result types only:
trufflehog_show_unverified--results=verified,unknown--results=verified,unverified,unknownKeeping
unknownin the default result set is deliberate. TruffleHog uses that state when verification cannot complete because of a network or API error; dropping it would let an air-gapped or broken-verification run appear clean. Alerts now exposeprops.verificationStatus(verified,unknown, orunverified) and the detailed report no longer labels unknown as a negative verification result.--include-detectors=allis passed unconditionally so detector selection no longer changes as a side effect of the setting. TruffleHog already defaults to all detectors, so this is a no-op in practice.Boolean values are read through
coerce_boolfortrufflehog_show_unverified,secret_scanning_enabled, and the TruffleHogscan_allfallback. The environment loader produces booleans, but dashboard/JSON configuration can supply strings at higher priority; values such as"false"must not enable scanning, include unverified findings, or widen a staged-file scan.2. A TruffleHog run that cannot complete no longer looks clean
The wrapper previously logged any non-zero exit and converted it into an empty result. A malformed exclude pattern, broken installation, or other execution error could therefore zero out secret findings while the workflow exited green.
The command now passes
--fail-on-scan-errors, which makes TruffleHog return non-zero for source and enumeration errors that it otherwise only logs. The wrapper fails the run on that non-zero exit and when thetrufflehogbinary is missing, including the exit code and TruffleHog stderr in the error.SystemExitis deliberate: the connector manager catchesException, so an ordinary connector exception would be downgraded to a skipped connector and the run would still appear successful. The exclude-file cleanup in thefinallyblock still runs on this path.Behavioral changes on upgrade
unknownfindings by default. They are low severity and non-blocking, but the scan no longer silently reports zero findings solely because validation could not complete.These choices favor transparent, fail-closed secret scanning while reserving blocking behavior for credentials TruffleHog confirms are live.
Validation
uv run --with pytest pytest -q— 353 passedtrufflesecurity/trufflehog:3.96.0binary:Verified: falseplusVerificationErrorunder--results=unknown, confirming the status signal used by the alert mapping.--fail-on-scan-errors; the same command exited 1 with the flag.--results=verified,unverified,unknownand omitted by the old verified-only filter.--no-verificationis absent in both setting states and detector selection is identical.git diff --check.tests/test_trufflehog_verification.pynow covers both result-filter states, unknown/unverified/verified alert mapping, string boolean forms, the disabled-scanner path, staged-file fallback with string"false", the scan-error flag, non-zero exits, and a missing binary.Docs
Updated
docs/parameters.md,docs/github-action.md,action.yml, andconnectors.yamlto explain:trufflehog_show_unverifiedadds definitively unverified candidates; andtrufflehog_exclude_diraccepts directory names, file names, and glob patterns.Also corrected the JSON configuration example from the nonexistent
show_unverifiedkey totrufflehog_show_unverified.Fixes CE-351
Fixes CE-347