-
-
Notifications
You must be signed in to change notification settings - Fork 258
fix(vuln-scanner): bound trufflehog git-history scan, no more phantom-success runs #1030
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
Merged
aaronjmars
merged 6 commits into
aeonfun:main
from
Svector-anu:fix/trufflehog-git-history-timeout
Sep 5, 2026
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4eadbe6
fix(vuln-scanner): bound trufflehog git-history scan, no more phantom…
Svector-anu 08c6a4a
fix scanner timeout permissions and refresh integrity receipt
Svector-anu 09e89ae
fix(vuln-scanner): surface trufflehog-git status in every report/noti…
Svector-anu 306a511
preserve history scan status in reports and notifications
Svector-anu ea37f77
reconcile concurrent scanner reporting fix and refresh receipt
Svector-anu 8b4c982
classify trufflehog completion by exit status
Svector-anu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| """Contract checks, not a claim that a model followed the reporting instructions.""" | ||
| from pathlib import Path | ||
| import unittest | ||
| import subprocess | ||
| import tempfile | ||
|
|
||
| SKILL = (Path(__file__).resolve().parents[2] / "skills/vuln-scanner/SKILL.md").read_text() | ||
|
|
||
|
|
||
| class ScannerStatusContract(unittest.TestCase): | ||
| def test_history_status_uses_exit_code_not_finding_count(self): | ||
| block = SKILL.split('if [ "${TRUFFLEHOG_GIT_RC:-1}"', 1)[1].split('\necho "osv=', 1)[0] | ||
| block = 'if [ "${TRUFFLEHOG_GIT_RC:-1}"' + block | ||
| with tempfile.TemporaryDirectory() as directory: | ||
| # Partial findings must not turn a later process failure into ok. | ||
| (Path(directory) / "trufflehog-git.json").write_text('{}\n') | ||
| for rc, expected in [(0, "ok"), (1, "fail"), (124, "timeout"), (137, "fail")]: | ||
| with self.subTest(rc=rc): | ||
| # Execute the actual status block with partial findings. | ||
| script = block.replace("/tmp/vuln-scan", directory) | ||
| result = subprocess.run(["bash", "-c", f"TRUFFLEHOG_GIT_RC={rc}\n{script}"], check=True) | ||
| self.assertEqual(result.returncode, 0) | ||
| rows = (Path(directory) / "sources.txt").read_text().splitlines() | ||
| self.assertEqual(rows[-1], f"trufflehog-git={expected}") | ||
|
|
||
| def test_filesystem_clean_empty_stream_is_ok(self): | ||
| row = next(line for line in SKILL.splitlines() if line.startswith('echo "trufflehog=')) | ||
| with tempfile.TemporaryDirectory() as directory: | ||
| for rc, expected in [(0, "ok"), (1, "fail")]: | ||
| subprocess.run(["bash", "-c", f"TRUFFLEHOG_RC={rc}\n" + row.replace("/tmp/vuln-scan", directory)], check=True) | ||
| self.assertEqual((Path(directory) / "sources.txt").read_text().splitlines()[-1], f"trufflehog={expected}") | ||
|
|
||
| def test_report_preserves_history_status(self): | ||
| report = SKILL.split("### A7. Write local report", 1)[1].split("### A8.", 1)[0] | ||
| self.assertIn("trufflehog-git", report) | ||
| self.assertIn("sources.txt", report) | ||
|
|
||
| def test_both_notification_templates_preserve_history_status(self): | ||
| notify = SKILL.split("### A8. Notify", 1)[1].split("## Arm D", 1)[0] | ||
| rows = [line for line in notify.splitlines() if "Scanners:" in line] | ||
| self.assertEqual(len(rows), 2) | ||
| for row in rows: | ||
| self.assertIn("trufflehog-git=<ok|fail|timeout>", row) | ||
|
|
||
| def test_log_preserves_history_status(self): | ||
| log = SKILL.split("## Log", 1)[1].split("## Network note", 1)[0] | ||
| self.assertIn("trufflehog-git=ok|fail|timeout", log) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[ISSUE]
trufflehog-git=timeoutis not represented in any of the prescribed A7/A8/log status formats (which still expose onlytrufflehog=<ok|fail>), andtimeoutis outside their declaredok|failvocabulary — why it matters: a clean filesystem pass can still be reported astrufflehog=okwhile the timed-out history pass disappears from the durable report and operator notification, preserving the misleading-success failure this change is intended to fix.