feat: opt-in secret/credential redaction for snapshot data#2207
Closed
vivekchand wants to merge 1 commit into
Closed
feat: opt-in secret/credential redaction for snapshot data#2207vivekchand wants to merge 1 commit into
vivekchand wants to merge 1 commit into
Conversation
Adds opt-in redaction layer (off by default) that scrubs secrets from session transcript snapshots before they leave the machine. Covers Bearer tokens, OpenAI sk- keys, GitHub/GitLab PATs, Slack tokens, and generic api_key/password/token assignments. Enable with config.redact.enabled = true; configure replacement text, scope (snapshot vs ingest), and custom patterns as needed. Closes #2198 Co-Authored-By: Claude <noreply@anthropic.com>
Owner
Author
|
Superseded by the already-merged #2204 ( #2204 redacts inside Differences I checked, just to be thorough:
Closing as duplicate. The work was solid — just landed second. 🤖 Filed by Claude Code |
6 tasks
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.
Closes #2198
Summary
clawmetry/redact.py(new, ~96 LOC):compile_patterns()caches compiled regexes for 10 default secret shapes (Bearer tokens,sk-*,ghp_*,gho_*,glpat-*,xox[baprs]-*, AWS keys, and genericapi_key/password/token/secretassignments);redact_value()recurses dict/list/str;build_redactor(config)returns a bound callable orNonewhen disabled.clawmetry/sync.py(~12 LOC changed):_project_snapshot_messages()gains an optionalredactorparam — secrets are scrubbed after theraw-key strip and before size-capping, so truncated text is also clean._build_transcripts()loads config, builds the redactor, and passes it down.tests/test_redact.py(new, ~170 LOC): 22 unit tests covering each default pattern, nested dict/list/str recursion, no-match passthrough, default-off behaviour, custom replacement text, custom patterns, bad-pattern graceful fallback, and empty-input edge cases.Test plan
python -m pytest tests/test_redact.py -v→ 22 passedpython -m py_compile clawmetry/redact.pypassesbuild_redactor({})returnsNone){"redact": {"enabled": true}}in config; verifycurl -H 'Authorization: Bearer sk-abc…'appears as[REDACTED]in snapshot messagesGenerated by Claude Code