Repository navigation
fix(rules): redact secrets in the URLs leaked-secrets findings name #2270 - #2274
Merged
Merged
Conversation
…2270 Signed-off-by: Nik Cubrilovic <[email protected]>
Signed-off-by: Nik Cubrilovic <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
security/leaked-secretsnamed page and script URLs verbatim, so a secret in the URL itself (/config.json?key=sk_live_...,/api/<token>/data.js) was printed in plain text next to the finding that warns about it.Every URL the rule's result shows now goes through
redactSecretsInUrl(inpackages/rules/src/security/leaked-secrets.ts). This covers the item label,sourcePages,meta.occurrences(page and script), and the item ids ofleaked-secrets-omitted,-unscannedand-unfetched(including held-back scripts).How it decides what to mask:
scanContent. Each query and fragment pair is also scanned askey="value", so the genericapi_key/access_tokenassignment patterns apply.prefix…suffix. The mask is first six and last four characters (first four at most for 12 or fewer), so it shows no more than the item id's existingmaskSecretdoes.user:password@password is always masked, and only where it sits, so a short password cannot mask matching text in the host or path.Closes #2270
Acceptance criteria
leaked-secrets-url-redaction-2270.test.ts, tests "a script URL with a detected key in its query string is shown masked" (label...config.js?key=sk_liv…5tU7&v=2), "...path segment is shown masked, in the label and the occurrences" (label andsourcePages), and "a script that could not be read is listed with the secret in its URL masked". Messages contain no URLs.JSON.stringify(checks)contains neither secret. They fail (3 of 5) with the redaction stubbed to identity.v=1.2.3andutm_*, a numeric?variant=,%20path,q=hello+world).packages/audit-engine/tests/leaked-secrets-url-redaction-formats-2270.test.tsrenders the real rule's result throughrenderLlm,renderMarkdown,renderJsonandrenderHtml(4 pass; 4 fail with the redaction stubbed).Gates
packages/rules: format:check, lint, typecheck all exit 0.bun run scripts/test-suites.ts --run rules: 12720 pass, 24 todo, 0 fail.packages/audit-engine: format:check, lint, typecheck all exit 0.bun run scripts/test-suites.ts --run audit-engine: 2437 pass, 3 skip, 0 fail.docs/:make validateexit 0.bun scripts/changelog.ts check: OK.Notes and residual risk
?key=AIza...) are masked too, since their ids are already masked.sourcePagesentry no longer equals the crawled page URL, so canonical folding and page-level ignore matching do not apply to that page for this item. This only affects pages whose own URL holds a detected secret.docs/rules/security/leaked-secrets.mdxdescribes the URL masking. Changelog:changelog.d/2270-leaked-secrets-url-redaction.security.md.