Skip to content

feat: content filtering to block secrets in messages#2

Merged
Killea merged 2 commits intoKillea:mainfrom
bertheto:feat/content-filter
Feb 28, 2026
Merged

feat: content filtering to block secrets in messages#2
Killea merged 2 commits intoKillea:mainfrom
bertheto:feat/content-filter

Conversation

@bertheto
Copy link
Contributor

Problem

Messages could expose secrets if an agent/user pastes API keys or tokens in a thread.

Solution

Regex-based content filter in msg_post() before any DB write.

Changes

  • New src/content_filter.py: SECRET_PATTERNS + check_content() + ContentFilterError
  • src/config.py: CONTENT_FILTER_ENABLED env var (default: true)
  • src/db/crud.py: filter in msg_post() before insertion
  • src/main.py: HTTP 400 on ContentFilterError
  • src/tools/dispatch.py: JSON error via MCP tool
  • test_content_filter_unit.py: 14 unit + CRUD-level tests
  • test_e2e.py: 4 integration tests

Patterns: AWS keys, GitHub tokens (ghp/gho/ghs), private keys, Slack tokens, Google API keys

Backward Compatible: set AGENTCHATBUS_CONTENT_FILTER_ENABLED=false to disable. No schema changes.

Tests: 14 passed in 0.99s (unit + CRUD, no server required)

bertheto and others added 2 commits February 27, 2026 16:34
Block known secret patterns (AWS keys, GitHub tokens, private keys, JWT,
Slack tokens) from being persisted in messages.

- New src/content_filter.py: regex-based SECRET_PATTERNS + check_content()
- src/config.py: CONTENT_FILTER_ENABLED env var (default: enabled)
- src/db/crud.py: content check in msg_post() before DB insertion
- src/main.py: HTTP 400 response when ContentFilterError raised
- src/tools/dispatch.py: JSON error response via MCP tool
- test_content_filter_unit.py: 14 unit and CRUD-level tests (no server needed)
- test_e2e.py: 4 integration tests for running server

Backward-compatible: AGENTCHATBUS_CONTENT_FILTER_ENABLED=false to disable.
No schema changes required.

Made-with: Cursor
@Killea Killea merged commit 64544b1 into Killea:main Feb 28, 2026
1 check failed
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