Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(secret): find aws secrets ending with a comma or dot #5921

Merged
merged 1 commit into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/fanal/secret/builtin-rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const (
quote = `["']?`
connect = `\s*(:|=>|=)?\s*`
startSecret = `(^|\s+)`
endSecret = `(\s+|$)`
endSecret = `[.,]?(\s+|$)`

aws = `aws_?`
)
Expand Down
8 changes: 4 additions & 4 deletions pkg/fanal/secret/scanner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ func TestSecretScanner(t *testing.T) {
Severity: "CRITICAL",
StartLine: 5,
EndLine: 5,
Match: `aws_sec_key "****************************************"`,
Match: ` "created_by": "ENV aws_sec_key "****************************************",`,
Code: types.Code{
Lines: []types.Line{
{
Expand All @@ -444,8 +444,8 @@ func TestSecretScanner(t *testing.T) {
},
{
Number: 5,
Content: "aws_sec_key \"****************************************\"",
Highlighted: "aws_sec_key \"****************************************\"",
Content: " \"created_by\": \"ENV aws_sec_key \"****************************************\",",
Highlighted: " \"created_by\": \"ENV aws_sec_key \"****************************************\",",
IsCause: true,
FirstCause: true,
LastCause: true,
Expand Down Expand Up @@ -662,7 +662,7 @@ func TestSecretScanner(t *testing.T) {
inputFilePath: filepath.Join("testdata", "aws-secrets.txt"),
want: types.Secret{
FilePath: filepath.Join("testdata", "aws-secrets.txt"),
Findings: []types.SecretFinding{wantFinding5, wantFinding9, wantFinding10},
Findings: []types.SecretFinding{wantFinding5, wantFinding10, wantFinding9},
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion pkg/fanal/secret/testdata/aws-secrets.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
AWS_ACCESS_KEY_ID=AKIA0123456789ABCDEF
"aws_account_ID":'1234-5678-9123'
AWS_example=AKIAIOSFODNN7EXAMPLE
aws_sec_key "KEYKEYKEYKEYKEYKEYKEYKEYKEYKEYKEYKEYKEYK"
"created_by": "ENV aws_sec_key "KEYKEYKEYKEYKEYKEYKEYKEYKEYKEYKEYKEYKEYK",