You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
NER is the wrong tool for high-entropy, highly-regular secrets: the privacy
model has no API-key class, so it fragments a key (tail -> BITCOINADDRESS,
prefix -> VRM) and can leave the secret part exposed. Add a regex tier that
plugs in as another detector model alongside NER and reuses the whole pipeline.
- core/services/routing/piipattern (leaf; stdlib only): a restricted-regex
grammar validated against the RE2 AST (no '.', no capture groups, capped
{n,m}; every pattern must carry a >=3-char fixed literal anchor, which
admits sk-ant-/ghp_/AKIA shapes but rejects open-ended ones like email or
bare \w+), compiled to RE2 (linear, no backtracking) with leftmost-longest
so a hit grabs the whole key. Curated built-in catalogue (Anthropic, OpenAI,
GitHub, AWS, Google, Slack, Stripe, JWT, PEM private key).
- config: PIIDetection.{Builtins,Patterns} + IsPatternDetector(); Validate
rejects bad patterns/unknown builtins at load (no model file required).
- piidetector.NewPattern: in-process pii.NERDetector (Score 1.0), records a
pattern_pii BackendTrace when tracing is on. PIINERResolver branches to it
for pattern models; MITM inherits it. Per-pattern action overrides fold
into entity_actions.
- meta registry: pii_detection.builtins -> pii-builtins-select (options from
the catalogue) and pii_detection.patterns -> pii-pattern-list, for the
model editor.
- gallery: ready-made secret-filter pattern model (builtins on, default
block, zero VRAM). Docs: new Pattern detector tier section.
Pattern hits union with NER hits and flow through the same policy, events
(score 1.0) and DEBUG logs. UI editors + Traces badge follow in a UI commit.
Assisted-by: claude-code:claude-opus-4-8 [Claude Code]
Description: "Built-in regex patterns for common credentials (API keys, tokens, private keys). Turning any on makes this a pattern detector — it matches high-entropy secrets the NER tier can't, in-process with no model load.",
444
+
Component: "pii-builtins-select",
445
+
Options: builtinPatternOptions(),
446
+
Order: 213,
447
+
},
448
+
"pii_detection.patterns": {
449
+
Section: "pii",
450
+
Label: "Custom Secret Patterns",
451
+
Description: "Operator-defined patterns in a restricted regex subset (e.g. \"sk-prefix-\\w+\"). Each must contain a fixed literal anchor of ≥3 chars; open-ended shapes like emails are rejected (leave those to NER). Matches report under the pattern name as the entity group.",
452
+
Component: "pii-pattern-list",
453
+
Order: 214,
454
+
},
426
455
427
456
// --- Cloud passthrough proxy ---
428
457
// These only have an effect when Backend is set to
0 commit comments