fix(redact): value-aware secret redaction across all output surfaces (#4 HIGH-2, #7)#123
Merged
Merged
Conversation
HIGH-2, #7) Beta feedback #4 (HIGH-2): the "bundle is sanitised" promise was value-blind. Five copies of the same recursive redactor (diag.ts, export-config.ts, threat-model.ts, genome.ts, score.ts) keyed ONLY on object-KEY names, so a secret-shaped VALUE in a field NOT named secret/token/key β e.g. a token pasted into a `vars` entry β sailed straight into the `harness diag --bundle` output a user pastes into a GitHub issue. New src/redact.ts is the single source of truth (also #4 finding #7 β was 5 duplicated regexes): - looksLikeSecretValue(s): conservative, precision-favouring β known provider prefixes (sk-/ghp_/AKIA/ AIza/glpat/xoxβ¦), PEM blocks, JWTs, and generic β₯40-char MIXED-CASE alphanumeric tokens. The mixed-case+digit rule deliberately EXCLUDES lowercase-hex git SHAs, uppercase-hex digests, and dashed UUIDs so common non-secret identifiers are not redacted. - redactSecretsDeep(value, {keyRe, replacement}): redacts by key name AND by value shape; each call site keeps its own keyRe + replacement token (`<redacted>` for bundles, `[REDACTED]` for score/genome/threat), so existing behaviour is preserved and only MORE is redacted. Also removes a dead branch in diag.sanitiseManifest (an `else if` that re-tested the key). Live-verified via real `harness diag --bundle`: a secret-shaped value under a non-secret key redacts to `<redacted>`, an ordinary value and a git SHA are kept, and the raw secret appears nowhere in the bundle. 20 new tests (redact.ts precision + key/value redaction + the diag-bundle leak integration); full create-agent-harness suite 381/381; tsc clean. Co-Authored-By: claude-flow <ruv@ruv.net>
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.
What / why
Fixes HIGH-2 from the AQE beta-feedback (#4): the "bundle is sanitised" promise was value-blind. Five copies of the same recursive redactor (
diag.ts,export-config.ts,threat-model.ts,genome.ts,score.ts) keyed only on object-KEY names, so a secret-shaped value in a field not namedsecret/token/keyβ e.g. a token pasted into avarsentry β sailed straight into theharness diag --bundleoutput that the docs tell users to paste into a GitHub issue.Also closes finding #7 for this surface: the 5 duplicated redaction regexes become one source of truth.
Change β new
src/redact.tslooksLikeSecretValue(s)β conservative, precision-favouring: known provider prefixes (sk-/ghp_/AKIA/AIza/glpat/xoxβ¦), PEM blocks, JWTs, and generic β₯40-char mixed-case alphanumeric tokens. The mixed-case+digit rule deliberately excludes lowercase-hex git SHAs, uppercase-hex digests, and dashed UUIDs, so common non-secret identifiers are not redacted.redactSecretsDeep(value, {keyRe, replacement})β redacts by key name and by value shape. Each call site keeps its ownkeyRe+ replacement token (<redacted>for bundles,[REDACTED]for score/genome/threat), so existing behaviour is preserved and only more is redacted (strictly safer).diag.sanitiseManifest(anelse ifthat re-tested the key).Live-verify (real
harness diag --bundle)Raw secret occurrences in the bundle: 0.
Tests
redact.test.ts):looksLikeSecretValueprecision (7 real tokens redact; SHA/UUID/version/path/sentence kept),redactSecretsDeepkey + value + nested + array + token cases, and the diag--bundleleak integration (secret-shaped value in a non-secret manifest field is absent from the bundle).create-agent-harnesssuite 381/381;tscclean.Not in this PR (noted for follow-up)
secrets.tsHIGH-2 part (a) βsecrets fetchprints the raw secret to stdout "for piping" (documented behaviour) andvalidate-tokenleaks the exact char-length. Changing the print default is a CLI-UX decision better made by a maintainer; happy to follow up.π€ Generated with claude-flow