Skip to content

Commit

Permalink
Merge pull request #30 from ivanolin/fix/valid-one-liners
Browse files Browse the repository at this point in the history
fix(password-secret): valid regex for one-liner files
  • Loading branch information
grinish21 authored Aug 11, 2021
2 parents 0f519db + a677136 commit b63c30b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
6 changes: 3 additions & 3 deletions config/rules/password-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ rules:
- CWE-257
- CWE-259
- Code: 3065
Pattern: heroku.*[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}
Pattern: heroku.{0,55}[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}
Caption: Heroku key
Category: password-secret
Example: 'heroku: ''A0AAA0AA-aAaa-AAAA-aaAA-Aa00AaAA0a0A'''
Expand Down Expand Up @@ -600,7 +600,7 @@ rules:
- CWE-257
- CWE-259
- Code: 3067
Pattern: facebook.*['"'"'"][0-9a-f]{32,255}['"'"'"]
Pattern: facebook.{0,55}['"'"'"][0-9a-f]{32,255}['"'"'"]
Caption: Facebook key
Category: password-secret
Example: 'facebook: ''a00000aa0aaa0aa0a00aa00a00000aaa0a000a0a0aaa0a0a0a00aa00a000aaa0'''
Expand All @@ -614,7 +614,7 @@ rules:
- CWE-257
- CWE-259
- Code: 3068
Pattern: twitter.*['"'"'"][a-zA-Z0-9]{35,44}['"'"'"]
Pattern: twitter.{0,55}['"'"'"][a-zA-Z0-9]{35,44}['"'"'"]
Caption: Twitter key
Category: password-secret
Example: 'twitter: ''0aaAaA0AAAA0000a0a0A0a0aaa0AaAA0a0a'''
Expand Down
20 changes: 20 additions & 0 deletions pkg/scan/scan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,26 @@ func Test_scanLine(t *testing.T) {
},
wantIsHit: false,
},
{
name: "Find twitter API key as a password",
args: args{
line: Line{
LineValue: `twitterApiSecret:"111aAa222bBb333cCc444dDd555eEe666fFf777"`,
},
fileLines: fileLines,
},
wantIsHit: true,
},
{
name: "Ignore potential twitter API key separated by too many characters",
args: args{
line: Line{
LineValue: `twitter="twitter";//This LineValue emulates extremely long one-liner code files that can cause false positives "111aAa222bBb333cCc444dDd555eEe666fFf777"`,
},
fileLines: fileLines,
},
wantIsHit: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit b63c30b

Please sign in to comment.