File tree Expand file tree Collapse file tree 4 files changed +21
-3
lines changed
Expand file tree Collapse file tree 4 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -114,9 +114,11 @@ When adding new API key patterns to `internal/masker/`:
114114### Pattern Ordering
115115- Place more specific patterns before general ones to avoid false matches
116116- Example: ` sk-ant- ` must be before ` sk- ` to prevent Anthropic keys from matching OpenAI pattern
117+ - Example: AWS Secret Access Key (` [a-zA-Z0-9+/]{40} ` ) must be last due to its generic pattern
117118
118- ### Supported Patterns
119- - AWS Access Key ID: ` AKIA[0-9A-Z]{16} `
119+ ### Supported Patterns (in order of application)
120+ - AWS Access Key ID (permanent): ` AKIA[0-9A-Z]{16} `
121+ - AWS Access Key ID (temporary/SSO): ` ASIA[0-9A-Z]{16} `
120122- GitHub Tokens: ` gh[pousr]_[a-zA-Z0-9]{36,} `
121123- GitLab PAT: ` glpat-[a-zA-Z0-9\-_]{20,} `
122124- Slack Tokens: ` xox[baprs]-[0-9a-zA-Z\-]+ `
@@ -125,6 +127,7 @@ When adding new API key patterns to `internal/masker/`:
125127- Supabase Secret Key: ` sb_secret_[a-zA-Z0-9\-_]+ `
126128- JWT Tokens: ` eyJ[a-zA-Z0-9_-]*\.eyJ[a-zA-Z0-9_-]*\.[a-zA-Z0-9_-]* `
127129- Private Key Headers: ` -----BEGIN\s+(RSA|DSA|EC|OPENSSH|PGP)\s+PRIVATE\s+KEY----- `
130+ - AWS Secret Access Key: ` [a-zA-Z0-9+/]{40} ` (must be last due to generic pattern)
128131
129132### Pattern Update Workflow
1301331 . Add regex pattern to ` internal/masker/masker.go `
Original file line number Diff line number Diff line change @@ -109,6 +109,7 @@ AWS_ACCESS_KEY_ID=********************
109109
110110Supported patterns:
111111- AWS Access Key ID
112+ - AWS Secret Access Key
112113- GitHub Tokens (` ghp_ ` , ` gho_ ` , ` ghs_ ` , ` ghr_ ` )
113114- GitLab Personal Access Tokens
114115- Slack Tokens
Original file line number Diff line number Diff line change @@ -6,8 +6,10 @@ import (
66)
77
88var patterns = []* regexp.Regexp {
9- // AWS Access Key ID
9+ // AWS Access Key ID (permanent)
1010 regexp .MustCompile (`AKIA[0-9A-Z]{16}` ),
11+ // AWS Access Key ID (temporary, STS/SSO)
12+ regexp .MustCompile (`ASIA[0-9A-Z]{16}` ),
1113 // GitHub Tokens (ghp_, gho_, ghs_, ghr_)
1214 regexp .MustCompile (`gh[pousr]_[a-zA-Z0-9]{36,}` ),
1315 // GitLab Personal Access Token
@@ -24,6 +26,8 @@ var patterns = []*regexp.Regexp{
2426 regexp .MustCompile (`eyJ[a-zA-Z0-9_-]*\.eyJ[a-zA-Z0-9_-]*\.[a-zA-Z0-9_-]*` ),
2527 // Private Key Headers
2628 regexp .MustCompile (`-----BEGIN\s+(RSA|DSA|EC|OPENSSH|PGP)\s+PRIVATE\s+KEY-----` ),
29+ // AWS Secret Access Key (must be last due to generic pattern that could match other secrets)
30+ regexp .MustCompile (`[a-zA-Z0-9+/]{40}` ),
2731}
2832
2933// Mask replaces sensitive patterns in content with asterisks of the same length
Original file line number Diff line number Diff line change @@ -18,6 +18,16 @@ func TestMask(t *testing.T) {
1818 input : "aws_access_key_id = AKIAIOSFODNN7EXAMPLE" ,
1919 want : "aws_access_key_id = " + strings .Repeat ("*" , 20 ),
2020 },
21+ {
22+ name : "AWS Access Key (temporary/SSO)" ,
23+ input : "aws_access_key_id = ASIAISEXAMPLEKEY1234" ,
24+ want : "aws_access_key_id = " + strings .Repeat ("*" , 20 ),
25+ },
26+ {
27+ name : "AWS Secret Access Key" ,
28+ input : "aws_secret_access_key = wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" ,
29+ want : "aws_secret_access_key = " + strings .Repeat ("*" , 40 ),
30+ },
2131 {
2232 name : "GitHub Personal Access Token" ,
2333 input : "token: ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" ,
You can’t perform that action at this time.
0 commit comments