Skip to content

fix(scanners): parse ThreatCrush text output instead of non-existent --json - #895

Merged
ralyodio merged 1 commit into
masterfrom
fix/threatcrush-adapter
Aug 1, 2026
Merged

fix(scanners): parse ThreatCrush text output instead of non-existent --json#895
ralyodio merged 1 commit into
masterfrom
fix/threatcrush-adapter

Conversation

@ralyodio

@ralyodio ralyodio commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

The adapter called threatcrush scan <path> --json. That flag does not exist — the CLI rejects it with unknown option '--json', so every scan failed and parseJson() never saw JSON. The adapter's own comment already flagged --json as assumed.

Verified against the published bundle (@profullstack/threatcrush 0.2.2):

.command("scan").description("Scan codebase for vulnerabilities and secrets")
  .argument("[path]", "Path to scan", ".")

A path and nothing else. Only harden accepts --json.

What changed

Drops the flag and parses the CLI's actual block output:

 CRITICAL  AWS Access Key
  File: secrets/config.env:23
  Info: Possible AWS Access Key detected
  Code: ****************

Four details, each of which caused a bug when I first wrote this parser elsewhere:

Detail Handling
Severity is bare for CRITICAL, bracketed for [HIGH]/[MEDIUM]/[LOW] One regex covers both; a single shape misses half the findings
Paths are relative to the scanned directory Re-joined with req.path so they stay resolvable
Whole-file findings report line :0 Suffix omitted rather than emitting :0
Code: lines are redacted excerpts Skipped — matching them double-counted every finding

JSON is still tried first, so if scan ever gains a machine-readable mode the adapter picks it up with no further change. The existing JSON mapping and its test are untouched.

Verified

  • 11 tests pass, package typechecks clean.
  • Added test/scan-output.txt, captured verbatim from a live scan, so the parser is tested against observed behaviour rather than an assumption. It parses all 9 findings with correct severities and paths.
  • A tsc error (string | undefined) surfaced during review and is fixed.

Note: README.md is generated by scripts/gen-module-readmes.mjs, so I left it alone rather than have edits overwritten.

🤖 Generated with Claude Code

…--json

The adapter called `threatcrush scan <path> --json`, which the CLI rejects with
"unknown option '--json'". Its own comment flagged --json as assumed; it is
not. Verified against the published bundle (0.2.2), where scan is declared as:

    .command("scan").argument("[path]", "Path to scan", ".")

A path and nothing else. Only `harden` accepts --json, so every scan failed
and parseJson never saw JSON.

Drops the flag and parses the CLI's block output: a severity and title line,
then File:, then Info:. Severity is bare for CRITICAL and bracketed for the
rest. Code: lines are skipped, being redacted excerpts rather than locations —
matching them double-counted every finding. Line :0 means a whole-file finding
and no longer produces a ':0' suffix. Paths are reported relative to the
scanned directory, so they are re-joined with the request path to stay
resolvable.

JSON is still tried first, so a future machine-readable scan mode is picked up
with no further change.

Adds test/scan-output.txt, captured verbatim from a live run, so the parser is
tested against observed behaviour rather than an assumption. 11 tests pass and
the package typechecks.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown

ThreatCrush security scan

0 finding(s) in files changed by this PR (scanned 3 changed file(s); 88 further finding(s) elsewhere in the repository are not attributed to this PR).

No new findings in the files this PR changes.

ThreatCrush CLI ran locally in the runner (npm i -g @profullstack/threatcrush); no code left the container.

@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown

vu1nz Security Review

0 finding(s) in PR #?

No security issues found.

@ralyodio
ralyodio merged commit 6a218ec into master Aug 1, 2026
7 checks passed
@ralyodio
ralyodio deleted the fix/threatcrush-adapter branch August 1, 2026 09:23
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.

1 participant