Skip to content

Commit 45ff6ae

Browse files
koki-developclaude
andcommitted
docs: add masker patterns documentation to CLAUDE.md
Add comprehensive documentation for masker package including: - Pattern ordering guidelines (specific before general) - Complete list of all supported patterns with regex - Pattern update workflow for adding new API key patterns 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent aaeb24d commit 45ff6ae

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

CLAUDE.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,30 @@ The project uses Release Please for automated releases:
105105
- Unit tests focus on formatters, prettifiers, and core functionality
106106
- Test files follow Go convention: `*_test.go` alongside implementation
107107
- Use table-driven tests where appropriate
108-
- Mock external dependencies when needed
108+
- Mock external dependencies when needed
109+
110+
## Masker Package Patterns
111+
112+
When adding new API key patterns to `internal/masker/`:
113+
114+
### Pattern Ordering
115+
- Place more specific patterns before general ones to avoid false matches
116+
- Example: `sk-ant-` must be before `sk-` to prevent Anthropic keys from matching OpenAI pattern
117+
118+
### Supported Patterns
119+
- AWS Access Key ID: `AKIA[0-9A-Z]{16}`
120+
- GitHub Tokens: `gh[pousr]_[a-zA-Z0-9]{36,}`
121+
- GitLab PAT: `glpat-[a-zA-Z0-9\-_]{20,}`
122+
- Slack Tokens: `xox[baprs]-[0-9a-zA-Z\-]+`
123+
- Anthropic API Key: `sk-ant-[a-zA-Z0-9\-_]+`
124+
- OpenAI API Key: `sk-(?:proj-)?[a-zA-Z0-9_\-]{20,}` (supports both legacy and project formats)
125+
- Supabase Secret Key: `sb_secret_[a-zA-Z0-9\-_]+`
126+
- JWT Tokens: `eyJ[a-zA-Z0-9_-]*\.eyJ[a-zA-Z0-9_-]*\.[a-zA-Z0-9_-]*`
127+
- Private Key Headers: `-----BEGIN\s+(RSA|DSA|EC|OPENSSH|PGP)\s+PRIVATE\s+KEY-----`
128+
129+
### Pattern Update Workflow
130+
1. Add regex pattern to `internal/masker/masker.go`
131+
2. Add test cases to `internal/masker/masker_test.go` with realistic examples
132+
3. Run tests: `go test ./internal/masker/...`
133+
4. Update README.md supported patterns list
134+
5. Test cases should include special characters (`_`, `-`) where applicable

0 commit comments

Comments
 (0)