Skip to content

fix(secret-alerts): finding spans name the secret's file and line - #1184

Merged
hyperpolymath merged 4 commits into
mainfrom
claude/kind-clarke-aqpe7a-secret-alert-location
Nov 16, 2026
Merged

hyperpolymath merged 4 commits into
mainfrom
claude/kind-clarke-aqpe7a-secret-alert-location

Conversation

@hyperpolymath

@hyperpolymath hyperpolymath commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

Follow-up to #1024. Its review thread on span.file was left to the owner, who chose to use the real location.

Problem

SSA001, SSA003 and SSA004 set a finding's file to the secret type (for example github_personal_access_token). The verdict span (span.file) therefore named a file that does not exist.

Change

  • Location lookup. For each alert that a rule reports at a file, the rule reads the alert's locations_url:
    • SSA001 looks up open alerts; SSA003 stale open alerts; SSA004 alerts resolved without an accepted reason.
    • SSA002, the repository summary, looks up none. scan/2 and sweep/2 look up the union once.
    • Lookups follow the next link, on the API host only (the token goes with each request), up to 10 pages of 100.
    • The first commit location is used. A wiki_commit path belongs to <repo>.wiki.git, not this repository.
  • File and line. The finding's file and line come from that location. GitHub's leading slash is stripped, so the path is repository-relative. The verdict span becomes {file, start_line, end_line} of the secret.
  • No file location. A secret found in a wiki, an issue or a comment, a failed lookup, or a missing URL gives a repository-level finding (file: "."). detail.location records the reason. A lookup failure is never fatal and is never reported as a file.
  • Suppression. A located path may be vendored or generated (node_modules/, dist/, deps/, test/). Only a .hypatia-ignore entry that names secret_scanning_alerts can suppress these findings. Universal excludes, default exemptions and any-rule entries cannot, because they would hide a leaked credential.
  • Main scan path. hypatia scan builds these findings in Hypatia.CLI.normalize_secret_alert/1, which keeps line and detail.
  • SSA002. Its file is now ".", and owner/repo moves to detail.repo.
  • One fetch in scan/2. scan/2 used to fetch the alerts four times, once per rule. It now fetches them once; a failed fetch is still logged and gives no findings, as before.

The secret type stays in detail.secret_type. The bash/jq secret-scanning sweep reads only status and total, so it is unaffected.

API cost: one extra request per located alert, more only when its first commit location is past page one. Alerts resolved as revoked, used_in_tests, pattern_deleted or pattern_edited are never looked up.

Evidence

  • test/secret_scanning_alerts_test.exs passes: 41 tests, 0 failures, 16 of them new.
    • Run under ExUnit against Jason built from source, on Elixir 1.14. Not via mix test: Hex is unreachable from the authoring session.
    • The CLI normalizer was run from its own source text in a stub module.
  • CI on f803ee1 ran the full suite: mix test --include integration, 3562 tests, 0 failures. CI on the current head is the authoritative run.
  • Mutation checks: reverting any one fix (location choice, API-host guard, suppression clause, wiki rule, per-rule lookups, kept line, kept detail, slash stripping, pagination) makes at least one test fail.

Generated by Claude Code

SSA001, SSA003 and SSA004 put the secret type in `file`, so a verdict
span (`span.file`) pointed at a file that does not exist (raised on
#1024, left to the owner, decided: use the real location).

- fetch_alerts reads each file-scoped alert's `locations_url` once
  (one page of up to 100 locations, API host only, since the token goes
  with it) and records the first location with a path.
- The finding's `file` and `line` come from that location, so the
  verdict span is `{file, start_line, end_line}` of the secret.
- A secret found outside the repository's files (issue, pull-request
  comment), a failed lookup or a missing URL gives the repository-level
  file "." and `detail.location` records the reason; a lookup failure is
  never fatal and never reported as a file.
- SSA002, the repo summary, uses "." too; `owner/repo` moves to
  `detail.repo`.
- `scan/2` now fetches once for all four rules (it fetched four times),
  logging a failure and returning no findings as before.

The secret type stays in `detail.secret_type`. The bash/jq sweep reads
only `status` and `total`, so it is unaffected.

Tests: 8 new cases in test/secret_scanning_alerts_test.exs (location
choice, no-file error, per_page request, off-host refusal, failure
recording, which alerts are looked up, finding fields, verdict span).
The file passes, 33 tests, 0 failures, run under ExUnit against Jason
1.4.5 built from source (Hex is unreachable from this session, so not
via `mix test`; Elixir 1.14 locally, CI uses 1.19). Ignoring the
location, or dropping the API-host guard, makes tests fail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P4yFkxW5Heb8p2YW7ZYs9F
@hyperpolymath
hyperpolymath marked this pull request as ready for review November 16, 2026 19:36
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-16T19:52:58.871662Z 502435f New commits
🔒 Security Review ❌ Failed 2026-11-16T19:50:11.266370Z
We couldn’t complete this review. Comment @codex security review to try again.
502435f New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Repository owner deleted a comment from chatgpt-codex-connector Bot Nov 16, 2026
Repository owner deleted a comment from coderabbitai Bot Nov 16, 2026
@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 28 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 1979bd20-123b-4959-bd43-69a7c6707269
Commits

Reviewing files that changed from the base of the PR and between 7340de1 and 502435f.

Files selected for processing: 4

  • lib/hypatia/cli.ex
  • lib/hypatia/scanner_suppression.ex
  • lib/rules/secret_scanning_alerts.ex
  • test/secret_scanning_alerts_test.exs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e6320d704b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/rules/secret_scanning_alerts.ex Resolved
Comment thread lib/rules/secret_scanning_alerts.ex Resolved
Comment thread lib/rules/secret_scanning_alerts.ex Resolved
Comment thread lib/rules/secret_scanning_alerts.ex Resolved
…leak

Four findings from the Codex review of #1184, each verified and pinned
by a test that fails without its fix.

- A located secret's path could be vendored or generated
  (`node_modules/`, `dist/`, `deps/`, `test/`), and the uniform
  suppression pass then dropped the whole critical finding. Secret-
  scanning alerts are GitHub findings, not local pattern noise: only a
  `.hypatia-ignore` entry that names `secret_scanning_alerts` suppresses
  one now; universal excludes, default exemptions and any-rule entries
  do not.
- The main scan path's normalizer copied `file` but not `line`, so
  `hypatia scan` still emitted line 0. The normalizer is now
  `CLI.normalize_secret_alert/1` and keeps the located line.
- A `wiki_commit` location has a path, but in `<repo>.wiki.git`. Only a
  `commit` location becomes a file span; others stay repository-level.
- Each rule looks up locations only for the alerts it reports: SSA001
  open, SSA003 stale open, SSA004 suspiciously resolved, SSA002 none.
  scan/2 and sweep/2 look up the union once.

Tests: 4 new cases in test/secret_scanning_alerts_test.exs; the file
passes, 37 tests, 0 failures, run under ExUnit against Jason built
from source (Hex is unreachable from this session; Hypatia.CLI's
normalizer was run from its own source text in a stub module). Each
fix reverted makes one test fail. Formatting checked (Elixir 1.14
locally; CI checks on 1.19).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P4yFkxW5Heb8p2YW7ZYs9F
@chatgpt-codex-connector

Copy link
Copy Markdown

This security review couldn’t start because the paying account has exhausted its Codex allowance and has insufficient available credits. The payer can check their balance and add credits in the Codex usage dashboard, then try again. If you do not manage the paying account, contact this repository's admins.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: efdffaefa5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/rules/secret_scanning_alerts.ex Resolved
Comment thread lib/rules/secret_scanning_alerts.ex Resolved
Comment thread lib/hypatia/cli.ex Resolved
Three findings from Codex's second review of #1184, each verified and
pinned by a test that fails without its fix.

- GitHub writes a location's path with a leading slash
  (`/example/secrets.txt`). It was copied as an absolute path, which
  SARIF could not relativise. It is now repository-relative, like every
  other rule's `file`.
- Only the first page of locations was read, so a commit location behind
  more than 100 wiki or comment locations was missed and the finding
  dropped to repository level. The `next` link is now followed, on the
  API host only, up to 10 pages.
- The scan path's normalizer dropped `detail`, losing the alert number,
  URL and the reason a finding has no file. It now keeps `detail`.

Tests: 4 new cases in test/secret_scanning_alerts_test.exs; the file
passes, 41 tests, 0 failures, under ExUnit against Jason built from
source (Hex is unreachable from this session; the normalizer was run
from its own source text in a stub module). Reverting each fix makes
tests fail. Formatting checked (Elixir 1.14 locally; CI on 1.19).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P4yFkxW5Heb8p2YW7ZYs9F
@chatgpt-codex-connector

Copy link
Copy Markdown

This security review couldn’t start because the paying account has exhausted its Codex allowance and has insufficient available credits. The payer can check their balance and add credits in the Codex usage dashboard, then try again. If you do not manage the paying account, contact this repository's admins.

@sonarqubecloud

Copy link
Copy Markdown

@hyperpolymath
hyperpolymath merged commit 0b8b7d4 into main Nov 16, 2026
99 checks passed
@hyperpolymath
hyperpolymath deleted the claude/kind-clarke-aqpe7a-secret-alert-location branch November 16, 2026 20:23
hyperpolymath added a commit to hyperpolymath/echo-types that referenced this pull request Nov 17, 2026
## Change
`HYPATIA_SHA` in `.github/workflows/hypatia-scan.yml` moves from
`7c10e5d` to `6d8ab66`, hypatia's `main` head on 2026-11-16.

The new scanner includes:
- secret-scanning findings that name the secret's file and line, and are
never hidden by path exclusions (hyperpolymath/hypatia#1184);
- the RSR 3.2.2 verdict from the capability reader
(hyperpolymath/hypatia#1188);
- the parsed workflow model for WH013 (hyperpolymath/hypatia#1192);
- the actions-lock proof ledger (hyperpolymath/hypatia#1187).

The workflow's interface to the scanner is unchanged at that commit:
`hypatia-cli.sh` is still there, and the build is still `mix
escript.build`.

## Findings at the new pin
From [run
43967735672](https://github.com/hyperpolymath/echo-types/actions/runs/43967735672)
on `29278de`:
- **Build.** The cache missed, so the scanner was built fresh from
`6d8ab66` ("Generated escript hypatia").
- **Hypatia.** Both the JSON and SARIF scans report `0 findings >=
medium (critical=0, high=0, medium=0, warn=0, low=0, info=0)`, and the
counts step reports critical 0, high 0, total 0. The gating row is 🟢
clean.
- **Alert-backed rules.** These read 0 observations. The job token can
read code-scanning and Dependabot alerts but not secret-scanning alerts,
which need an App or PAT. That limit is unchanged by this PR.

The 🔴 rows in the rendered grid come from **advisory** fleet reporters
at the pinned `gitbot-fleet` revision, not from Hypatia, and this PR
does not change them:
- **rhodibot (RSR):** 11 high. Most expect `.a2ml` descriptiles
(`ANCHOR.a2ml`, `STATE.a2ml`, `0-AI-MANIFEST.a2ml`,
`.machine_readable/descriptiles/` and others). A2ML is retired
estate-wide, so these rules are stale. They are not answered by creating
`.a2ml` files here; rhodibot's criteria need updating to deeds in
gitbot-fleet.
- **finishingbot:** 2 high and 174 medium, mostly docs that name files
which no longer exist (`All.agda`, `Smoke.agda`, `EchoVsQuotient.agda`,
…). This is a docs clean-up for its own PR.
- **glambot:** 1 medium and 136 minor (line length, heading levels).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01P4yFkxW5Heb8p2YW7ZYs9F

Co-authored-by: Claude <noreply@anthropic.com>
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.

3 participants