Refactor secrets detection into pattern registry (#18)
authorMax Wolf <redacted>
Sun, 11 Jan 2026 17:55:34 +0000 (18:55 +0100)
committerGitHub <redacted>
Sun, 11 Jan 2026 17:55:34 +0000 (18:55 +0100)
commitd71269c4a737db0f253f1fb9d19ce2ec2c700b95
treef2f92f4fda0b9a67a8da2f8d58d07018512fa4aa
parent4f592d6a7f4123707773236afd1551cc53f69dc9
Refactor secrets detection into pattern registry (#18)

* Add PatternDetector and DetectionResult interfaces for secrets detection registry

* Move all interfaces to patterns/types.ts and use the existing SecretesDetectionResult interface instead of the new DetectionResult

* Move pattern detection utility to new patterns/utils.ts module

* Refactor secrets detection using a registry system

- Create privateKeysDetector, apiKeysDetector, tokensDetector modules
- Refactor detectSecrets() to use the pattern registry
- Re-export types from detect.ts for backwards compatibility

* Change default secrets_detection action to redaction

Hint: The example config still shows `action: block` explicitly, with a comment noting
that `redact` is the default action if not specified

* Fix README default action references and improve overall structure / formatting

- Update all references from 'block (default)' to 'redact (default)'
- Fix Bearer token documentation (20+ → 40+ chars)
- Reorganize Configuration section with consistent headers
- Improve table formatting and section descriptions
- Use references to reduce duplications and maintenance overhead

* Improve type safety in PatternDetector interface

Use SecretEntityType instead of string for enabledTypes Set parameter

* Update docs to reflect redact as new default action

Reorder actions to show default first

---------

Co-authored-by: Stefan Gasser <redacted>
12 files changed:
README.md
config.example.yaml
docs/concepts/secrets-detection.mdx
docs/configuration/secrets-detection.mdx
src/config.ts
src/secrets/detect.ts
src/secrets/patterns/api-keys.ts [new file with mode: 0644]
src/secrets/patterns/index.ts [new file with mode: 0644]
src/secrets/patterns/private-keys.ts [new file with mode: 0644]
src/secrets/patterns/tokens.ts [new file with mode: 0644]
src/secrets/patterns/types.ts [new file with mode: 0644]
src/secrets/patterns/utils.ts [new file with mode: 0644]
git clone https://git.99rst.org/PROJECT