Skip to content

Conversation

@ainergiz
Copy link

@ainergiz ainergiz commented Jan 7, 2026

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 redaction
  • should_skip_file_content() - File blocklist for sensitive files
  • get_redacted_file_placeholder() - Placeholder for redacted file content

Automatically redacted patterns:

  • API keys: sk-*, ghp_*, gho_*, xoxb-*, xoxp-*, AKIA*, npm_*, pypi-*
  • JWT tokens
  • Generic secrets: 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:

Variable Default Description
BRAINTRUST_REDACT_ENABLED true Enable/disable redaction
BRAINTRUST_REDACT_PATTERNS (empty) Additional regex patterns
BRAINTRUST_SKIP_FILES (empty) Additional file patterns to skip

Files modified

  • hooks/common.sh - Added redaction functions (+136 lines)
  • hooks/post_tool_use.sh - Apply redaction to tool I/O
  • hooks/stop_hook.sh - Apply redaction to conversations
  • SKILL.md - Document new options

Testing

Users can verify redaction is working by:

  1. Enabling debug mode: BRAINTRUST_CC_DEBUG=true
  2. Checking logs: tail -f ~/.claude/state/braintrust_hook.log
  3. Searching for [REDACTED] in their Braintrust traces

Closes #10

- 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
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.

secret pruning

1 participant