Skip to content

fix(secrets_detection): preserve secret field names during redaction - #142

Merged
gandhipratik203 merged 2 commits into
mainfrom
user/luca/preserve-secret-field-names
Jul 21, 2026
Merged

gandhipratik203 merged 2 commits into
mainfrom
user/luca/preserve-secret-field-names

Conversation

@lucarlig

Copy link
Copy Markdown
Collaborator

Summary

  • redact only the detected value for aws_secret_access_key assignments, preserving the field name, separator, whitespace, and quotes
  • apply the same value-only replacement contract to generic_api_key_assignment
  • strengthen exact-output regression coverage for AWS assignment formats and every supported detector
  • bump secrets_detection to 0.3.10

Root cause

The AWS detector matched the full labeled assignment and captured the value, but the scanner only used capture-group spans for the base64 detector. Redaction therefore replaced the detector's full match, including the field name. The generic API-key assignment detector had the same whole-assignment replacement behavior and did not expose a value capture.

Impact

An input such as:

Aws Secret Access Key = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"

is now returned as:

Aws Secret Access Key = "[REDACTED]"

instead of replacing the entire assignment.

Validation

  • make ci in plugins/rust/python-package/secrets_detection
  • 96 Rust tests passed
  • 114 plugin-framework integration tests passed
  • formatting, Clippy with warnings denied, wheel build/install, and benchmark compilation passed

Tracker

Addresses the follow-up reported in WatsonOrchestrate/wo-tracker#78411.

Signed-off-by: lucarlig <luca.carlig@ibm.com>
@lucarlig
lucarlig marked this pull request as ready for review July 21, 2026 09:39

@gandhipratik203 gandhipratik203 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean fix, and the exact-output tests are a nice upgrade. One non-blocking nit: the README Notes only mention capture-group redaction for base64_24, but this now applies to aws_secret_access_key and generic_api_key_assignment too — worth a one-line doc update.

@gandhipratik203 gandhipratik203 self-assigned this Jul 21, 2026
Signed-off-by: lucarlig <luca.carlig@ibm.com>
@gandhipratik203
gandhipratik203 merged commit 760a223 into main Jul 21, 2026
23 checks passed
@gandhipratik203
gandhipratik203 deleted the user/luca/preserve-secret-field-names branch July 21, 2026 15:26
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.

2 participants