Skip to content

feat: mask sensitive keys in events - #7

Merged
naji247 merged 2 commits into
mainfrom
feat/mask-sensitive-keys
Nov 26, 2026
Merged

naji247 merged 2 commits into
mainfrom
feat/mask-sensitive-keys

Conversation

@naji247

@naji247 naji247 commented Nov 26, 2026

Copy link
Copy Markdown
Member

Summary

EventPipeline.run / EventPipeline.normalize (custom events)
└── sanitize_and_truncate
    ├── Sanitization.sanitize_event
    ├── mask_sensitive_keys(event)               NEW: parameters, response, error
    │   └── SensitiveKeys.mask_sensitive_keys    NEW lib/agentcat/sensitive_keys.rb
    └── Truncation.truncate_event
→ AgentCat API body, AgentCat.fake and every exporter (Datadog, Sentry, OTLP, PostHog)

Evidence

  • Before: the sent event carried parameters.extra.requestInfo.headers.authorization as received (for example Bearer abc.def), and test_tracking.rb asserted the raw extra.authInfo Hash and _meta.progressToken = 3.
    After: the pipeline test sends Authorization, Cookie and X-Api-Key through a real Rack env; the sender gets [redacted] for all three, keeps user-agent, x-anthropic-client and mcp-session-id, and the captured request Hash keeps the raw values. COVERAGE=1 bundle exec rake: 827 runs, 3310 assertions, 0 failures (97.59% line coverage). bundle exec rake test:e2e: 25 runs, 0 failures. The vectors test checks all 233 key cases and 17 tree cases.

Merge Danger

Door: one-way

Events sent before the merge keep their raw headers, and masked values cannot come back.

Blast Radius: wide

Every event now shows [redacted] for credential headers, authInfo, _meta.progressToken, and tool arguments or results under secret key names such as pageToken, api_key or auth_type. A dashboard view or customer query that read those values gets [redacted]. No option turns the mask off.

Port the shared sensitive key mask to lib/agentcat/sensitive_keys.rb and
run it once in EventPipeline, after sanitization and before truncation,
on parameters, response and error. Credential headers in
parameters.extra.requestInfo.headers, authInfo and secret-named tool
arguments now go out as "[redacted]". A field the mask fails on is
dropped and logged. The shared vectors file checks the port.
@naji247
naji247 merged commit c891f5c into main Nov 26, 2026
63 checks passed
@github-actions github-actions Bot mentioned this pull request Nov 26, 2026
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.

2 participants