fix(trace): preserve password-field selectors during redaction

Merged
MI
19h ago
+90-1

The AI session attached to platform PR #6986 failed ai-config-no-secrets because Betterleaks treated two password-field CSS selectors as credentials: [id="1-password"] and input[name="password"]. Session redaction replaced the selectors, and the policy then reported the resulting generic-password placeholders.

Allowlist only those complete values for generic-password, including their JSON-escaped forms in tool output. Keep the exemption scoped to the matched value so other credentials in the same tool result remain detectable. Bump the redaction ruleset version from 3 to 4.

Regression tests reproduce both detections with the upstream ruleset and verify the selectors survive plain and JSON-encoded output. They also verify that a nearby password and passwords with selector prefixes or suffixes still get redacted. This affects future redaction; it does not rewrite the stored session or its existing policy result.

Validation:

  • go test ./internal/redaction ./pkg/attestation/crafter/materials/aicodingsession ./pkg/attestation/crafter/materials — passed.
  • golangci-lint run --new-from-rev=228dc47b ./internal/redaction/... ./pkg/attestation/crafter/materials/... — no new issues. The unrestricted lint run reports existing warnings in these packages.
  • git diff --check — passed.

AI assistance: Codex.