Skip to content

fix(rules): leaked-secrets keeps sample-data matches and reports elided values as partial - #1546

Closed
nc9 wants to merge 3 commits into
mainfrom
fix/leaked-secrets-keep-seed-elided
Closed

nc9 wants to merge 3 commits into
mainfrom
fix/leaked-secrets-keep-seed-elided

Conversation

@nc9

@nc9 nc9 commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

security/leaked-secrets dropped two shapes on structure or surface evidence that cannot prove the value is not a credential. This keeps both (Nik: "we shouldn't be dropping any true positives", via squirrelscan-53).

1. Sample-data matches (seedDataVerdict "skip"). A generic secret in a table of same-keyed rows whose emails are all on reserved domains, or beside two puzzle or generator markers (or one marker inside a same-shaped table), was continued. It is now kept and labelled exactly like the matches that were already kept (Possible Demo Login (seed data table), medium), with a hint that says what the evidence was (sample data (reserved-domain emails or sample markers around it): usually not a working login, but the structure cannot prove it, against the existing real-domain hint). The verdicts themselves are unchanged; only the drop is gone.

2. Elided values (isElidedValue). A value of up to 12 characters followed by ... or … was dropped inside isImplausibleSecretValue. The drop is removed. The generic path now reports it as Partial Secret Value Visible (elided) at the informational tier, in its own leaked-secrets-partial check (status info, never counted as a leak), value masked like the others. It is not put in leaked-secrets-info, whose message is about expired and session tokens. A longer cut-off token (13 or more characters before the dots) still reports at medium as before. A bare mask (••••, ...) is still dropped.

Fail closed: no new drop path. The two gates are removed; what was dropped is reported.

Not in scope and untouched: isJoinedIdentifier. A value like U...ng... that another gate already drops (the entropy floor) is still dropped by that gate.

Tests (packages/rules/tests/security/leaked-secrets-sample-data.test.ts, 46): each shape has fixtures that must report (reserved-domain tables, puzzle and generator markers, a marker inside a table, the secret's own rows with reserved emails, five elided stubs under password, secret and pwd, the rule-level partial check with its masked id); the negatives that must stay out are unchanged (masks, labels, env references, code spans, joined identifiers). Fake shapes are built from parts.

Mutants (each separately, the file restored after each): the elided gate restored (2 fail), the seed continue restored (5), skip not relabelled (5), the partial branch removed (2), partial lumped with the expired-token check (1), partial at medium (3), the 12-character bound widened (1, after adding a 13+ character case). One survivor, equivalent: with MASK_RE disabled the mask fixtures are still dropped by the generic entropy floor.

Gates run: every leaked-secrets test file, one at a time (the corpus suite tests/security/leaked-secrets.test.ts 2,431 tests, tests/leaked-secrets.test.ts, precision, providers, public tiers, critical, samples, confidence, decode and the rest): 0 fail; tsgo; docs make validate; the changelog guard. Docs: the elided stub line, the sample-data section and the new check; CHANGELOG entry.

Hold-list change (security rule): not for merge before Nik decides.

Skill: no change needed.

nik

…eports a value that ends in an ellipsis as a partial value, never dropped

Signed-off-by: Nik Cubrilovic <[email protected]>
@claude

claude Bot commented Nov 2, 2026

Copy link
Copy Markdown

Review of #1546. Static read only; CI was still pending and I did not run the tests.

The change does what it says. The two drops are gone, the partial branch is gated on generic && seedVerdict === undefined, and the new check stays out of leaked-secrets-info. The docs, the changelog and the tests move together.

  • (medium) packages/rules/src/security/leaked-secrets.ts (isNotACredentialValue -> isImplausibleSecretValue): removing isElidedValue from the shared gate also stops dropping elided stubs for non-generic patterns that go through it. The new partial branch only covers generic matches. The PR summary says "generic path", so please confirm that no non-generic pattern can capture a short ... value and now report at its full tier. A test for that case would settle it.
  • (low) The golden pins (streaming-rules-canonical-golden.test.ts, golden-finding-messages-229.test.ts) are not mentioned as run. AGENTS.md says to run them when a rule's output changes. This change adds a check name and relabels findings, so run both and confirm perRuleTally and healthScore do not move.
  • (low) isElidedValue is now used only for labelling, but its name and its position next to the other "implausible" gates still read as a drop predicate. Rename it (for example isElidedStub) or keep the JSDoc as the only signal. The JSDoc is already clear.
  • (nit) A seed-data skip and a demo-login now share one report type and confidence, and only the hint text differs. A skip finding that is purely sample data will now show up at medium. That is the stated intent, but it adds noise for users, and the changelog entry says so accurately.
  • (nit) The rule-level test builds RuleContext through an as unknown as cast. It works, but a shared helper would be more robust if the context shape changes.

@claude

claude Bot commented Nov 2, 2026

Copy link
Copy Markdown

Reviewed the diff. The change is small, matches the stated intent, and drops no new paths.

  • (medium) packages/rules/src/security/leaked-secrets.ts:3790: the elided check is generic && seedVerdict === undefined && isElidedValue(body). An elided value inside a seed table or beside markers is labelled Possible Demo Login at medium and is never reported as partial. That's probably fine, because it's reported either way. But the docs say every elided stub is reported as partial, and there's no test for the overlap. Please add one test that pins which label wins, or document the precedence.
  • (low) leaked-secrets.ts:3779: seedVerdict === "skip" now reports at medium. Reserved-domain demo tables are the shape most likely to be non-credentials, so this is a deliberate precision trade-off. It raises medium-count noise on sites with seed or demo tables. The hint is honest about it. Consider whether it should sit lower, but that's a product call.
  • (low) packages/rules/tests/security/leaked-secrets-sample-data.test.ts: the golden pins (streaming-rules-canonical-golden and golden-finding-messages-229) aren't mentioned in the PR body. The synthetic site probably never hits these paths, but please confirm.
  • (nit) leaked-secrets.ts:3779-3787: the nested ternary for the hint would read more easily as two named constants.
  • (nit) The test title "a single word of 8 or 12 mixed-case letters ... (likely UI text)" describes a gate that no longer exists. Rename it.

I did not run the tests myself.

@claude

claude Bot commented Nov 2, 2026

Copy link
Copy Markdown

Review of #1546. I read the diff and the surrounding code in leaked-secrets.ts. I did not run the tests; the sign-off check passes and CodeQL and the review job are still pending.

  • (medium) leaked-secrets.ts (removal of isElidedValue from isImplausibleSecretValue): this function also feeds isNotACredentialValue for every pattern, not only the generic assignments. The new PARTIAL_VALUE_TYPE branch is gated on generic. A non-generic or context pattern whose value ends in ... or … is therefore no longer dropped, and it is reported with its normal type and confidence, which can be medium or high. That is more than the changelog says. Either keep the elision drop for non-generic patterns, or add a test showing the behaviour is intended.
  • (medium) Sample-data findings now go from "not reported" to medium (Possible Demo Login). The medium tier is what produces a warn and counts toward the score. Reserved-domain example.com/.test seed tables and CTF or generator markers are the most likely to be false positives, and they now cost sites score. The PR description should say that the health score or golden pins are unaffected, with the output of streaming-rules-canonical-golden.test.ts and golden-finding-messages-229.test.ts. If a sample-labelled finding is meant to be weaker, consider the info tier for the skip case.
  • (low) leaked-secrets.ts: the new seedVerdict === 'skip' branch replaces known and drops any earlier hints, such as the search-key or admin-key hint set above it. Spread ...known as the search-key branch does.
  • (low) The elided check takes seedVerdict === undefined, so a stub inside a seed table is labelled a demo login with a hint that never mentions the ellipsis. This is probably fine, but it is untested.
  • (nit) The partial-value test names the check leaked-secrets-partial but never asserts that the rule still passes with a leaked-secrets pass check. The test only checks that nothing fails or warns.
  • (nit) The docs page keeps the sentence "A mask of bullets ... A short stub ..." in the skip list, so the list now mixes what is dropped with what is not. It could move to its own paragraph.

Docs and the CHANGELOG are updated. Test coverage for the generic path is good.

nc9 added a commit that referenced this pull request Nov 2, 2026
… in a seed table keeps the seed verdict #1546

Signed-off-by: Nik Cubrilovic <[email protected]>
nc9 added a commit that referenced this pull request Nov 2, 2026
… family stated exactly; stale comment refreshed #1546

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9

nc9 commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

Shipped in v0.0.160. The commits were cherry-picked onto the release branch and rebase-merged: bb092ae cf7666e 98cbefa.

Closing this PR since the change is on main.

nik

@nc9 nc9 closed this Nov 2, 2026
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