Repository navigation
Conversation
…an#1592 Signed-off-by: Nguyễn Tuấn Anh <[email protected]>
…an#1592 Signed-off-by: Nguyễn Tuấn Anh <[email protected]>
…an#1592 Signed-off-by: Nguyễn Tuấn Anh <[email protected]>
…an#1592 Signed-off-by: Nguyễn Tuấn Anh <[email protected]>
|
Thanks, this is a good fix. Code, tests and typecheck look right: classification and overlap suppression run on the full value, the cut happens when the record is built, and the new test plus all existing leaked-secrets tests pass. One change before we merge, in docs/rules/security/leaked-secrets.mdx (the worst-case sentence): the site budget also admits copies of kept values, up to another cap of 10,000 records, so the bound is about 40M characters (about 82 MB as UTF-16), not 20M (41 MB). The same paragraph already says "at most as much again for copies of kept values", so the new figure contradicts it. Please state the 40M / 82 MB bound, or say the figure excludes copies. Optional, non-blocking: a test where the cut lands inside a surrogate pair, and a line in the docs that two values sharing the same first 2,048 characters now collapse into one finding. nik |
|
Reviewed head: 5bdc863 Verdict: pending maintainer review. The change requested in the earlier maintainer review is still open on this head (no commits since that review).
Checked and fine: the cut happens in the record builder in nik |
|
Thank you for this. It landed in #1603: your commits, rebased onto main with your authorship kept, plus one docs correction (the worst-case figure now counts the copies of kept values the site budget also admits, about 40M characters). It goes out in the next release, closing #1592. Closing this PR as superseded by the merge. nik |
Closes #1592
Problem
The caps on
security/leaked-secretscount findings, not bytes. A genericsecret value has no length cap:
scanPageForSecretson an inlineconst password="<1MB>";keeps two records with 1,024,022-character values(the page pass and the inline-script pass). A crawl of 100 such pages with
distinct values stays far below every finding and page ceiling while
retaining over 100 MB of value text.
Fix
STORED_VALUE_MAX_LENGTH(2,048characters) at the single construction point (
buildinscanInto), soevery path that produces findings is covered: page scans, external-script
scans, and decoded-blob scans. The cut is surrogate-safe via the repo's
own
clampItemString.structured secret whole (a 2048-bit PEM private key is about 1,675
characters; fixed-format tokens and connection strings are far shorter),
while bounding a site at the 10,000-finding site cap to about 20M
characters of value text.
so a value over the cap is still reported, never skipped.
LeakedSecret.truncatedis set, and the rule'scheck item carries
truncated: trueinmeta(which the JSON, LLM andXML renderers carry through verbatim), while
lengthkeeps the fulllength so a reader can tell how much was cut.
docs/rules/security/leaked-secrets.mdxno longercalls value text unbounded, and states the new worst case. CHANGELOG
[Unreleased]carries the bullet, calling out the new check-itemtruncatedfield.Notes for the reviewer
maskSecretfrom thestored (cut) value, so for a cut value its last 4 characters are the
tail of the cut, not of the original. The type, the recognisable head,
the
truncatedflag and the fulllengthstill identify the match.sharing a 2,048-character prefix merge into one record. Both are still
reported in the sense of the issue (cut and marked, never skipped).
the same way; it stays reported with its type, head, flag and length.
How it was verified
1,024,022 characters. After the fix: 2 records of 2,048 characters,
truncated: true,length1,024,011.packages/rules/tests/security/leaked-secrets-value-cap-1592.test.ts(4 tests, explicit 30 s timeouts, no process-wide patches): 1 MB value
cut and marked but still reported; a value exactly at the cap kept whole
and unmarked; an ordinary short value untouched; the rule check carries
truncated: trueand the full length inmeta.restored, all 4 pass.
packages/rules/tests/security/suite: 2,943 tests pass, 0 fail(includes the corpus snapshot test, unchanged).
bun run typecheckinpackages/rules: clean. New test file:oxfmt --checkandoxlintclean.bun run docs:check: 62 pass.bun run scripts/test-suites.ts --check: new file covered by the rulessuite.
leaked-secrets.tsis not formatted or linted by CI forthis package, so it was left unformatted (reformatting it would churn
~960 lines); the edited regions introduce no new formatter diff.