-
-
Notifications
You must be signed in to change notification settings - Fork 257
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 5 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,27 @@ | ||
| """Contract checks, not a claim that a model followed the reporting instructions.""" | ||
| from pathlib import Path | ||
| import unittest | ||
|
|
||
| SKILL = (Path(__file__).resolve().parents[2] / "skills/vuln-scanner/SKILL.md").read_text() | ||
|
|
||
|
|
||
| class ScannerStatusContract(unittest.TestCase): | ||
| 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -142,9 +142,20 @@ fi | |
| if command -v trufflehog >/dev/null 2>&1; then | ||
| trufflehog filesystem . --only-verified --json \ | ||
| > /tmp/vuln-scan/trufflehog.json 2>/dev/null || true | ||
| # Also scan full git history for secrets | ||
| trufflehog git file://. --only-verified --json \ | ||
| > /tmp/vuln-scan/trufflehog-git.json 2>/dev/null || true | ||
| # Also scan full git history for secrets — BOUNDED. An unbounded `trufflehog git` | ||
| # walks every commit's every tree, and a large packed history (measured: 200 | ||
| # commits / ~369MB on one real run) can eat the whole turn budget by itself, | ||
| # with nothing to show it happened until the run reports "success" anyway | ||
| # having produced no report at all. `timeout` turns that silent budget-burn | ||
| # into an ordinary, honestly-recorded `fail` — same as an install failure, | ||
| # never a reason to write a "still running, will resume" placeholder as the | ||
| # final output. There is no resume: a workflow_dispatch run is one shot, and | ||
| # a note promising to pick back up later is not truthful about what a single | ||
| # run can actually do. | ||
| timeout 300 trufflehog git file://. --only-verified --json \ | ||
| > /tmp/vuln-scan/trufflehog-git.json 2>/dev/null | ||
| TRUFFLEHOG_GIT_RC=$? | ||
| [ "$TRUFFLEHOG_GIT_RC" = 124 ] && echo "VULN_SCANNER_TIMEOUT: trufflehog git history scan exceeded 300s on a large packed history — recorded as fail, not retried, not left unfinished" | ||
| else | ||
| echo "VULN_SCANNER_SKIPPED: trufflehog not available" | ||
| fi | ||
|
|
@@ -181,6 +192,15 @@ fi | |
| # Record what succeeded (empty output ≠ clean, could be tool failure) | ||
| echo "semgrep=$([ -s /tmp/vuln-scan/semgrep.json ] && echo ok || echo fail)" > /tmp/vuln-scan/sources.txt | ||
| echo "trufflehog=$([ -s /tmp/vuln-scan/trufflehog.json ] && echo ok || echo fail)" >> /tmp/vuln-scan/sources.txt | ||
| # Recorded separately from the filesystem pass above: they can genuinely diverge | ||
| # (filesystem scan clean and fast, git-history scan timed out on a large packed | ||
| # repo, or vice versa) and collapsing both into one trufflehog= line hides | ||
| # whichever one actually failed. | ||
| if [ "${TRUFFLEHOG_GIT_RC:-1}" = 124 ]; then | ||
| echo "trufflehog-git=timeout" >> /tmp/vuln-scan/sources.txt | ||
| else | ||
| echo "trufflehog-git=$([ -s /tmp/vuln-scan/trufflehog-git.json ] && echo ok || echo fail)" >> /tmp/vuln-scan/sources.txt | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ISSUE] Determine success from the TruffleHog exit code, not whether its JSON output is non-empty. A successful clean |
||
| fi | ||
| echo "osv=${OSV_STATUS:-fail}" >> /tmp/vuln-scan/sources.txt | ||
| ``` | ||
|
|
||
|
|
@@ -605,7 +625,25 @@ Append to `memory/vuln-scanned.json` (create if missing) so future runs skip thi | |
|
|
||
| ### A7. Write local report | ||
|
|
||
| Save to `output/articles/vuln-scan-${today}.md` with sections for: repo metadata, scanner sources (ok/fail per tool), candidate count, confirmed findings with severity and channel, PoC gate status (`verified` with verifier/chain/block, `not-required` with reason, or `needs-verification`), and dedup note. Do **not** include exploit details for findings disclosed via PVR — redact file/line and link to the advisory ID instead. | ||
| **There is no resume.** The git-history pass has a timeout; this does not bound | ||
| every other scanner or installation step. If you are running low on turns, finish | ||
| the report with whatever scanners actually completed, record the rest `fail` in | ||
| `sources.txt` (§A3's rule: unfinished is `fail`, not a pending state), and write | ||
| A7/A8 now. A single `workflow_dispatch` run is one shot with no continuation — | ||
| writing "still running, will pick this up automatically" as the final output is | ||
| not true of this run path (it was live-observed: a run reported workflow | ||
| `success` having written that sentence instead of a report, with no ledger entry | ||
| at all — the operator had to notice and re-dispatch by hand). A shorter, honest | ||
| report with some scanners marked `fail` is a completed task; a promise to | ||
| resume is not. | ||
|
|
||
| Save to `output/articles/vuln-scan-${today}.md` with sections for: repo metadata, scanner sources (ok/fail per tool — `trufflehog` and `trufflehog-git` are two separate rows, not one; folding a timed-out history scan into a clean filesystem-scan's `ok` is exactly the silent-masking this split exists to prevent), candidate count, confirmed findings with severity and channel, PoC gate status (`verified` with verifier/chain/block, `not-required` with reason, or `needs-verification`), and dedup note. Do **not** include exploit details for findings disclosed via PVR — redact file/line and link to the advisory ID instead. | ||
|
|
||
| Copy each scanner status from `sources.txt` into the report, notification and log. | ||
| Keep `trufflehog` (filesystem) and `trufflehog-git` (history) separate, preserving | ||
| `timeout` exactly. Missing status is `fail`, never inferred `ok`. If any pass failed | ||
| or timed out, say "limited audit" and name the incomplete coverage, even when zero | ||
| findings were confirmed. Do not describe incomplete coverage as a clean audit. | ||
|
|
||
| ### A8. Notify | ||
|
|
||
|
|
@@ -615,13 +653,15 @@ Use `./notify`. One paragraph. Lead with the verdict. | |
| *Vuln Scanner — <repo>* | ||
| <N> confirmed findings (<severity-summary>). | ||
| Disclosed via: <PVR: advisory #123 | public PR #45 | skipped (no channel)> | ||
| Scanners: semgrep=<ok|fail>, trufflehog=<ok|fail>, osv=<ok|fail>, fuzz=<ok|fail|skip>. PoC gate: <verified|not-required|needs-verification>. | ||
| Scanners: semgrep=<ok|fail>, trufflehog=<ok|fail>, trufflehog-git=<ok|fail|timeout>, osv=<ok|fail>, fuzz=<ok|fail|skip>. PoC gate: <verified|not-required|needs-verification>. | ||
| ``` | ||
|
|
||
| If the audit was clean: | ||
| `trufflehog-git=timeout` must always be spelled out here, never folded into a plain `trufflehog=ok` — a clean filesystem pass and a timed-out history pass are different facts, and this is the durable line an operator actually reads. Silently dropping the git-history state here reproduces the exact masking this field exists to prevent. | ||
|
|
||
| If no findings were confirmed (choose clean or limited according to actual coverage): | ||
| ``` | ||
| *Vuln Scanner — <repo>* | ||
| Clean audit. <M> candidates reviewed, 0 confirmed. Scanners: semgrep=ok, trufflehog=ok, osv=ok, fuzz=skip, agentic=ok. | ||
| <Clean audit | Limited audit — name incomplete passes>. <M> candidates reviewed, 0 confirmed. Scanners: semgrep=<ok|fail>, trufflehog=<ok|fail>, trufflehog-git=<ok|fail|timeout>, osv=<ok|fail|none|skipped>, fuzz=<ok|fail|skip>, agentic=<ok|skipped>. | ||
| ``` | ||
|
|
||
| Then log per the **Log** section below with `Mode: scan`. | ||
|
|
@@ -983,7 +1023,7 @@ specific bullets. | |
| - Candidates: N | Confirmed: M | ||
| - Channels used: PVR (x), public PR (y), skipped (z) | ||
| - Prior-art check: N candidates checked, 0 matches | matched #123 → skipped/commented | ||
| - Scanner status: semgrep=ok trufflehog=ok osv=ok fuzz=ok|fail|skip agentic=ok|skip poc=verified|not-required|needs-verification | ||
| - Scanner status: semgrep=ok|fail trufflehog=ok|fail trufflehog-git=ok|fail|timeout osv=ok|fail|none|skipped fuzz=ok|fail|skip agentic=ok|skip poc=verified|not-required|needs-verification | ||
| - Advisory/PR links: [...] | ||
| ``` | ||
|
|
||
|
|
||
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.