Skip to content

refactor(security): consolidate the two one-off secret-redaction helpers into one shared autobot_shared util #12242

Closed

Description

@mrveiss

Consolidation opportunity — one shared secret-redaction util (surfaced during #11302)

The SLM backend now has two independent, one-off secret-redaction implementations with different coverage, and there is no shared redactor in autobot_shared:

Why consolidate

  • Drift/coverage risk (security): a redactor is a security control. Two copies with different pattern sets means a secret redacted in one path can leak in the other; hardening must be applied in N places.
  • Reuse: both backends emit logs/telemetry that should be redacted consistently; a shared util (line-level + kv/dict-level) belongs in autobot_shared (e.g. autobot_shared/security/redaction.py) alongside the existing secret-file helpers.

Proposed

  • Add autobot_shared/security/redaction.py with redact_text(str) -> str (line/text) and redact_mapping(dict) -> dict (kv), sharing ONE canonical secret-key/pattern set.
  • Replace _redact_app_log_line and _mask_secret_extra_vars with calls into it (behaviour-preserving; add tests for both shapes).
  • Audit other ad-hoc masking (sed 's/password/***/' etc.) to adopt it.

Discovered during #11302 (SLM application-log viewer). No behaviour change intended — DRY + consistent coverage of a security control.

Activity

  1. mrveiss commented on Jul 24, 2026

    @mrveiss
    OwnerAuthor

    Resolved by #12332 (squash-merged). The two SLM-backend one-off redactors (monitoring._redact_app_log_line + code_sync._mask_secret_extra_vars) consolidated into canonical autobot_shared/security/redaction.py (redact_text/redact_mapping); union of rules preserved (behavior-preserving), both call sites delegate, 29+38 tests. Minor pre-existing client_secret text-regex gap tracked as #12333.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions