]> git.99rst.org Git - sgasser-llm-shield.git/commit
Fix masked content not logged when secrets are detected
authorStefan Gasser <redacted>
Wed, 10 Jun 2026 12:03:49 +0000 (14:03 +0200)
committerStefan Gasser <redacted>
Wed, 10 Jun 2026 12:13:05 +0000 (14:13 +0200)
commitc982e62e461b88139f4a7d0cb53d8920c1cc5171
treea0050d18a641aaf07e54dcfc5f091f617879f46f
parent4007fceaa7327bb44b063d807a3d8e5da06d1b15
Fix masked content not logged when secrets are detected

Masked content was never stored whenever secrets were detected, ignoring
the log_masked_content setting. The dashboard then showed a misleading
"Masked content not logged (log_masked_content: false)" message.

With secrets_detection.action "mask" (the default), maskedContent already
has both PII and secrets replaced by placeholders by the time it reaches
the logger, so it is safe to store. Gate on log_masked_content plus
whether detected secrets were actually masked, via a pure
shouldLogMaskedContent helper. The secrets-masked condition keeps route
mode with action "route_local" safe: there secrets are intentionally left
raw for the trusted local provider and must never be persisted.

This also enforces log_masked_content centrally for the openai/anthropic/
codex routes, which previously passed masked content unconditionally.

The helper lives in its own module so the unit test can import it without
tripping over the wholesale logger mock used by other route tests.

Fixes #91
src/routes/utils.ts
src/services/log-content.test.ts [new file with mode: 0644]
src/services/log-content.ts [new file with mode: 0644]
src/services/logger.ts
git clone https://git.99rst.org/PROJECT