feat: add secret redaction before sending data to Braintrust#11
Open
ainergiz wants to merge 1 commit intobraintrustdata:mainfrom
Open
feat: add secret redaction before sending data to Braintrust#11ainergiz wants to merge 1 commit intobraintrustdata:mainfrom
ainergiz wants to merge 1 commit intobraintrustdata:mainfrom
Conversation
- Add redact_secrets() function with pattern-based detection - Add file blocklist for sensitive files (.env, .pem, credentials, etc.) - Apply redaction to tool inputs/outputs in post_tool_use.sh - Apply redaction to conversation content in stop_hook.sh - Add configurable options via environment variables: - BRAINTRUST_REDACT_ENABLED (default: true) - BRAINTRUST_REDACT_PATTERNS (custom regex patterns) - BRAINTRUST_SKIP_FILES (custom file patterns) - Update SKILL.md documentation Closes braintrustdata#10
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.
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