feat: add secret redaction before sending data to Braintrust #11
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.
Summary
Adds automatic secret redaction to prevent sensitive data from being uploaded to Braintrust. This addresses the security concern raised in #10.
Changes
New features in
common.sh:redact_secrets()- Pattern-based secret detection and redactionshould_skip_file_content()- File blocklist for sensitive filesget_redacted_file_placeholder()- Placeholder for redacted file contentAutomatically redacted patterns:
sk-*,ghp_*,gho_*,xoxb-*,xoxp-*,AKIA*,npm_*,pypi-*password=,secret=,api_key=,token=,database_url=Files with content automatically redacted:
.env,.env.*,.env.local,.env.production*credentials*,*secrets**.pem,*.key,*.p12,id_rsa*,id_ed25519*New environment variables:
BRAINTRUST_REDACT_ENABLEDtrueBRAINTRUST_REDACT_PATTERNSBRAINTRUST_SKIP_FILESFiles modified
hooks/common.sh- Added redaction functions (+136 lines)hooks/post_tool_use.sh- Apply redaction to tool I/Ohooks/stop_hook.sh- Apply redaction to conversationsSKILL.md- Document new optionsTesting
Users can verify redaction is working by:
BRAINTRUST_CC_DEBUG=truetail -f ~/.claude/state/braintrust_hook.log[REDACTED]in their Braintrust tracesCloses #10