fix(#2198): remove dead scan exports, correct injection-scan docs

scanEntropyAnomalies + shannonEntropy were dead exports with zero
production callers — the live hooks (gsd-prompt-guard.js,
gsd-read-injection-scanner.js) inline their own pattern subsets for
hook independence and never called these functions.

Changes:
- Remove scanEntropyAnomalies + shannonEntropy from src/security.cts
- Remove scanEntropyAnomalies test block from tests/security.test.cjs
- Correct REQ-SCAN-INJ-02/-03 in FEATURES.md (EN/zh-CN/ja-JP) to
  describe what actually runs live (injection patterns, invisible
  Unicode) vs CI-only (base64-decode, codebase scan)
- Correct docs/security/baseline.md §2.4 to clarify live hooks inline
  patterns, not import from security.cts
- Add regression test asserting the corrected contract
- scanForInjection retained: it serves as the CI codebase-scanner engine
This commit is contained in:
Tom Boucher
2026-07-11 23:48:05 -04:00
parent 96b632d4eb
commit 8022c5c864
9 changed files with 132 additions and 134 deletions

View File

@@ -133,11 +133,16 @@ file before the job passes.
### 2.4 Locale-safe text scanning
**Control:** Text output and user-facing strings are scanned for locale-unsafe
constructs (non-ASCII homoglyphs, bidirectional override characters, invisible
Unicode) that could be used to obscure malicious content in diffs or logs.
**Control:** Text output and user-facing strings are scanned for invisible
Unicode and bidirectional override characters that could be used to obscure
malicious content in diffs or logs. The live hooks
(`gsd-prompt-guard.js`, `gsd-read-injection-scanner.js`) inline their own
Unicode-detection patterns for hook independence — they do not call
`scanForInjection` from `security.cts`. The centralized `scanForInjection`
function serves as the CI codebase-scanner engine
(`tests/prompt-injection-scan.security.test.cjs`).
**Why it matters:** Unicode homoglyph and BiDi attacks are documented
**Why it matters:** Unicode invisible-character and BiDi attacks are documented
supply-chain vectors (CVE-2021-42574 — "Trojan Source"). Detecting them at scan
time prevents invisible payload injection in source and output files.