Skip to content

Tighten CLI parity, monorepo annotations, and workflow noise#19

Merged
Conalh merged 1 commit into
mainfrom
tighten-cli-paths-workflow
May 22, 2026
Merged

Tighten CLI parity, monorepo annotations, and workflow noise#19
Conalh merged 1 commit into
mainfrom
tighten-cli-paths-workflow

Conversation

@Conalh
Copy link
Copy Markdown
Owner

@Conalh Conalh commented May 22, 2026

Summary

Bundles four small, related fixes that make v0 more trustworthy and consistent — surfaced by a Cursor review of CapabilityEcho end-to-end. Each is tight and testable; none touches the detection schema or API.

  • CLI --fail-onsrc/index.ts always returned 0 regardless of findings, so the CLI couldn't gate local pre-commit / non-GHA CI runs. Added --fail-on none|low|medium|high|critical mirroring the Action behavior; returns 1 when rating meets threshold, 2 on invalid input.
  • Monorepo path normalization (correctness bug)src/git-diff.ts normalizeGitDiffPath did lastIndexOf('/src/') etc., which mangled apps/web/src/foo.tssrc/foo.ts and misplaced GitHub annotations onto the wrong file. Git already gives repo-relative paths through b/<path>; stripped the heuristic and kept only b/ + Windows drive normalization.
  • Workflow URL gatingsrc/detectors/workflow-permissions.ts detectExternalCurl flagged any curl/wget/fetch( regardless of URL. Now requires an external https?:// URL or a variable substitution ($VAR / ${{...}}), excluding localhost/127.0.0.1/0.0.0.0/::1. detectSecretExfil is untouched, so secret-adjacent network calls still flag.
  • README fixture alignment — README demo bullet referenced src/telemetry/client.ts; the local fixture is at src/api/sync.ts. Aligned the bullet with the actual fixture.

Also deduplicated severityRank — exported once from report.ts and consumed by both action.ts and index.ts.

Why batched

These are all "make v0 trustworthy" fixes (one correctness bug, one parity gap, one false-positive reduction, one docs fix). No API breaks, small surface, obvious tests. Larger items from the same review (Python dep manifests, suppression/baseline, SARIF, PR-comment posting) each warrant their own PR with a design pass — explicitly deferred here.

Test plan

  • npm test — 73 passing (was 64; +9 new):
    • CLI: default exits 0 with findings, --fail-on HIGH returns 1, below-threshold returns 0, invalid value returns 2
    • Git diff: monorepo paths apps/web/src/api.ts and packages/core/src/util.ts survive normalization
    • Workflow detector: literal URL flagged, variable URL flagged, localhost skipped, non-network curl mentions skipped
  • npm run build — clean tsc + ncc bundle
  • Reviewer: confirm --fail-on exit-code semantics match expectations for local pre-commit usage
  • Reviewer: spot-check the URL-gating regex against your own workflow corpus for unexpected misses

🤖 Generated with Claude Code

- Add --fail-on threshold to the CLI matching the Action behavior so
  local pre-commit and non-GHA CI runs can fail on findings instead of
  always exiting 0.
- Strip the /src/, /.github/workflows/, /package.json lastIndexOf
  heuristic from normalizeGitDiffPath. Git already gives repo-relative
  paths; the heuristic mangled monorepo paths (apps/web/src/foo.ts ->
  src/foo.ts), misplacing GitHub annotations.
- URL-gate detectExternalCurl so curl/wget/Invoke-WebRequest/fetch lines
  only flag when an external https?:// URL or a variable substitution is
  present. Excludes localhost/127.0.0.1/0.0.0.0/::1 and benign mentions.
  detectSecretExfil is untouched.
- Share severityRank between report.ts and action.ts; CLI uses the same
  export.
- Align the README demo bullet with the actual fixture file
  (src/api/sync.ts).

Adds 9 tests (73 total, all passing).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@Conalh Conalh merged commit 902bd9f into main May 22, 2026
4 checks passed
@Conalh Conalh deleted the tighten-cli-paths-workflow branch May 22, 2026 23:55
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