Skip to content

feat: add configurable sensitive word detection#5

Open
Timik232 wants to merge 1 commit into
KikuAI-Lab:mainfrom
Timik232:feature/sensitive-words
Open

feat: add configurable sensitive word detection#5
Timik232 wants to merge 1 commit into
KikuAI-Lab:mainfrom
Timik232:feature/sensitive-words

Conversation

@Timik232

@Timik232 Timik232 commented May 5, 2026

Copy link
Copy Markdown

Summary

Adds a new SENSITIVE_WORD entity type that allows detecting user-defined sensitive words via the MASKER_SENSITIVE_WORDS environment variable.

Changes

  • New entity type: SENSITIVE_WORD added to EntityType
  • Config: MASKER_SENSITIVE_WORDS env var (comma-separated word list)
  • Detection: Case-insensitive regex with \b word boundaries
  • Overlap handling: Lowest priority — loses to EMAIL, CARD, PHONE, PERSON
  • Masking/Redaction: Full support via existing endpoints
  • Policy: sensitive_word: mask in default policy

Usage

MASKER_SENSITIVE_WORDS="secret,confidential,password" python -m app.main
curl -X POST /api/v1/detect -d '{"text": "This is a secret document"}'
# Returns: {"entities": [{"type": "SENSITIVE_WORD", "value": "secret", ...}]}

Testing

  • Added tests/test_sensitive_words.py with class-based tests
  • All existing tests pass without modification
  • Tested with Cyrillic words (e.g., MASKER_SENSITIVE_WORDS="СВО")

Add SENSITIVE_WORD entity type that detects user-defined words
from MASKER_SENSITIVE_WORDS env var (comma-separated).

- Case-insensitive word boundary matching
- Lowest priority in overlap resolution (EMAIL/CARD/PHONE/PERSON win)
- Full support for detect, mask, and redact endpoints
- Policy entry in default.yaml
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.

1 participant