|
@@ -36,10 +36,9 @@ func TestDetect(t *testing.T) {
|
|
|
fragment: Fragment{
|
|
fragment: Fragment{
|
|
|
Raw: `awsToken := \
|
|
Raw: `awsToken := \
|
|
|
|
|
|
|
|
- \"AKIALALEMEL33243OKIA\ // gitleaks:allow"
|
|
|
|
|
|
|
+ \"AKIALALEMEL33243OKIA\ // gitleaks:allow"
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- `,
|
|
|
|
|
|
|
+ `,
|
|
|
FilePath: "tmp.go",
|
|
FilePath: "tmp.go",
|
|
|
},
|
|
},
|
|
|
expectedFindings: []report.Finding{},
|
|
expectedFindings: []report.Finding{},
|
|
@@ -60,6 +59,7 @@ func TestDetect(t *testing.T) {
|
|
|
Secret: "AKIALALEMEL33243OKIA",
|
|
Secret: "AKIALALEMEL33243OKIA",
|
|
|
Match: "AKIALALEMEL33243OKIA",
|
|
Match: "AKIALALEMEL33243OKIA",
|
|
|
File: "tmp.go",
|
|
File: "tmp.go",
|
|
|
|
|
+ Line: `awsToken := \"AKIALALEMEL33243OKIA\"`,
|
|
|
RuleID: "aws-access-key",
|
|
RuleID: "aws-access-key",
|
|
|
Tags: []string{"key", "AWS"},
|
|
Tags: []string{"key", "AWS"},
|
|
|
StartLine: 0,
|
|
StartLine: 0,
|
|
@@ -81,6 +81,7 @@ func TestDetect(t *testing.T) {
|
|
|
Description: "PyPI upload token",
|
|
Description: "PyPI upload token",
|
|
|
Secret: "pypi-AgEIcHlwaS5vcmcAAAAAAAAAA-AAAAAAAAAA-AAAAAAAAAA-AAAAAAAAAA-AAAAAAAAAA-AAAAAAAAAAB",
|
|
Secret: "pypi-AgEIcHlwaS5vcmcAAAAAAAAAA-AAAAAAAAAA-AAAAAAAAAA-AAAAAAAAAA-AAAAAAAAAA-AAAAAAAAAAB",
|
|
|
Match: "pypi-AgEIcHlwaS5vcmcAAAAAAAAAA-AAAAAAAAAA-AAAAAAAAAA-AAAAAAAAAA-AAAAAAAAAA-AAAAAAAAAAB",
|
|
Match: "pypi-AgEIcHlwaS5vcmcAAAAAAAAAA-AAAAAAAAAA-AAAAAAAAAA-AAAAAAAAAA-AAAAAAAAAA-AAAAAAAAAAB",
|
|
|
|
|
+ Line: `pypi-AgEIcHlwaS5vcmcAAAAAAAAAA-AAAAAAAAAA-AAAAAAAAAA-AAAAAAAAAA-AAAAAAAAAA-AAAAAAAAAAB`,
|
|
|
File: "tmp.go",
|
|
File: "tmp.go",
|
|
|
RuleID: "pypi-upload-token",
|
|
RuleID: "pypi-upload-token",
|
|
|
Tags: []string{"key", "pypi"},
|
|
Tags: []string{"key", "pypi"},
|
|
@@ -103,6 +104,7 @@ func TestDetect(t *testing.T) {
|
|
|
Description: "AWS Access Key",
|
|
Description: "AWS Access Key",
|
|
|
Secret: "AKIALALEMEL33243OLIA",
|
|
Secret: "AKIALALEMEL33243OLIA",
|
|
|
Match: "AKIALALEMEL33243OLIA",
|
|
Match: "AKIALALEMEL33243OLIA",
|
|
|
|
|
+ Line: `awsToken := \"AKIALALEMEL33243OLIA\"`,
|
|
|
File: "tmp.go",
|
|
File: "tmp.go",
|
|
|
RuleID: "aws-access-key",
|
|
RuleID: "aws-access-key",
|
|
|
Tags: []string{"key", "AWS"},
|
|
Tags: []string{"key", "AWS"},
|
|
@@ -125,6 +127,7 @@ func TestDetect(t *testing.T) {
|
|
|
Description: "Sidekiq Secret",
|
|
Description: "Sidekiq Secret",
|
|
|
Match: "BUNDLE_ENTERPRISE__CONTRIBSYS__COM=cafebabe:deadbeef;",
|
|
Match: "BUNDLE_ENTERPRISE__CONTRIBSYS__COM=cafebabe:deadbeef;",
|
|
|
Secret: "cafebabe:deadbeef",
|
|
Secret: "cafebabe:deadbeef",
|
|
|
|
|
+ Line: `export BUNDLE_ENTERPRISE__CONTRIBSYS__COM=cafebabe:deadbeef;`,
|
|
|
File: "tmp.sh",
|
|
File: "tmp.sh",
|
|
|
RuleID: "sidekiq-secret",
|
|
RuleID: "sidekiq-secret",
|
|
|
Tags: []string{},
|
|
Tags: []string{},
|
|
@@ -148,6 +151,7 @@ func TestDetect(t *testing.T) {
|
|
|
Match: "BUNDLE_ENTERPRISE__CONTRIBSYS__COM=\"cafebabe:deadbeef\"",
|
|
Match: "BUNDLE_ENTERPRISE__CONTRIBSYS__COM=\"cafebabe:deadbeef\"",
|
|
|
Secret: "cafebabe:deadbeef",
|
|
Secret: "cafebabe:deadbeef",
|
|
|
File: "tmp.sh",
|
|
File: "tmp.sh",
|
|
|
|
|
+ Line: `echo hello1; export BUNDLE_ENTERPRISE__CONTRIBSYS__COM="cafebabe:deadbeef" && echo hello2`,
|
|
|
RuleID: "sidekiq-secret",
|
|
RuleID: "sidekiq-secret",
|
|
|
Tags: []string{},
|
|
Tags: []string{},
|
|
|
Entropy: 2.6098502,
|
|
Entropy: 2.6098502,
|
|
@@ -170,6 +174,7 @@ func TestDetect(t *testing.T) {
|
|
|
Match: "http://cafeb4b3:d3adb33f@enterprise.contribsys.com:",
|
|
Match: "http://cafeb4b3:d3adb33f@enterprise.contribsys.com:",
|
|
|
Secret: "cafeb4b3:d3adb33f",
|
|
Secret: "cafeb4b3:d3adb33f",
|
|
|
File: "tmp.sh",
|
|
File: "tmp.sh",
|
|
|
|
|
+ Line: `url = "http://cafeb4b3:d3adb33f@enterprise.contribsys.com:80/path?param1=true¶m2=false#heading1"`,
|
|
|
RuleID: "sidekiq-sensitive-url",
|
|
RuleID: "sidekiq-sensitive-url",
|
|
|
Tags: []string{},
|
|
Tags: []string{},
|
|
|
Entropy: 2.984234,
|
|
Entropy: 2.984234,
|
|
@@ -216,6 +221,7 @@ func TestDetect(t *testing.T) {
|
|
|
Description: "Discord API key",
|
|
Description: "Discord API key",
|
|
|
Match: "Discord_Public_Key = \"e7322523fb86ed64c836a979cf8465fbd436378c653c1db38f9ae87bc62a6fd5\"",
|
|
Match: "Discord_Public_Key = \"e7322523fb86ed64c836a979cf8465fbd436378c653c1db38f9ae87bc62a6fd5\"",
|
|
|
Secret: "e7322523fb86ed64c836a979cf8465fbd436378c653c1db38f9ae87bc62a6fd5",
|
|
Secret: "e7322523fb86ed64c836a979cf8465fbd436378c653c1db38f9ae87bc62a6fd5",
|
|
|
|
|
+ Line: `const Discord_Public_Key = "e7322523fb86ed64c836a979cf8465fbd436378c653c1db38f9ae87bc62a6fd5"`,
|
|
|
File: "tmp.go",
|
|
File: "tmp.go",
|
|
|
RuleID: "discord-api-key",
|
|
RuleID: "discord-api-key",
|
|
|
Tags: []string{},
|
|
Tags: []string{},
|
|
@@ -246,6 +252,7 @@ func TestDetect(t *testing.T) {
|
|
|
Description: "Generic API Key",
|
|
Description: "Generic API Key",
|
|
|
Match: "Key = \"e7322523fb86ed64c836a979cf8465fbd436378c653c1db38f9ae87bc62a6fd5\"",
|
|
Match: "Key = \"e7322523fb86ed64c836a979cf8465fbd436378c653c1db38f9ae87bc62a6fd5\"",
|
|
|
Secret: "e7322523fb86ed64c836a979cf8465fbd436378c653c1db38f9ae87bc62a6fd5",
|
|
Secret: "e7322523fb86ed64c836a979cf8465fbd436378c653c1db38f9ae87bc62a6fd5",
|
|
|
|
|
+ Line: `const Discord_Public_Key = "e7322523fb86ed64c836a979cf8465fbd436378c653c1db38f9ae87bc62a6fd5"`,
|
|
|
File: "tmp.py",
|
|
File: "tmp.py",
|
|
|
RuleID: "generic-api-key",
|
|
RuleID: "generic-api-key",
|
|
|
Tags: []string{},
|
|
Tags: []string{},
|
|
@@ -356,6 +363,7 @@ func TestFromGit(t *testing.T) {
|
|
|
EndLine: 20,
|
|
EndLine: 20,
|
|
|
StartColumn: 19,
|
|
StartColumn: 19,
|
|
|
EndColumn: 38,
|
|
EndColumn: 38,
|
|
|
|
|
+ Line: "\n awsToken := \"AKIALALEMEL33243OLIA\"",
|
|
|
Secret: "AKIALALEMEL33243OLIA",
|
|
Secret: "AKIALALEMEL33243OLIA",
|
|
|
Match: "AKIALALEMEL33243OLIA",
|
|
Match: "AKIALALEMEL33243OLIA",
|
|
|
File: "main.go",
|
|
File: "main.go",
|
|
@@ -377,6 +385,7 @@ func TestFromGit(t *testing.T) {
|
|
|
EndColumn: 36,
|
|
EndColumn: 36,
|
|
|
Secret: "AKIALALEMEL33243OLIA",
|
|
Secret: "AKIALALEMEL33243OLIA",
|
|
|
Match: "AKIALALEMEL33243OLIA",
|
|
Match: "AKIALALEMEL33243OLIA",
|
|
|
|
|
+ Line: "\n\taws_token := \"AKIALALEMEL33243OLIA\"",
|
|
|
File: "foo/foo.go",
|
|
File: "foo/foo.go",
|
|
|
Date: "2021-11-02T23:48:06Z",
|
|
Date: "2021-11-02T23:48:06Z",
|
|
|
Commit: "491504d5a31946ce75e22554cc34203d8e5ff3ca",
|
|
Commit: "491504d5a31946ce75e22554cc34203d8e5ff3ca",
|
|
@@ -402,6 +411,7 @@ func TestFromGit(t *testing.T) {
|
|
|
StartColumn: 17,
|
|
StartColumn: 17,
|
|
|
EndColumn: 36,
|
|
EndColumn: 36,
|
|
|
Secret: "AKIALALEMEL33243OLIA",
|
|
Secret: "AKIALALEMEL33243OLIA",
|
|
|
|
|
+ Line: "\n\taws_token := \"AKIALALEMEL33243OLIA\"",
|
|
|
Match: "AKIALALEMEL33243OLIA",
|
|
Match: "AKIALALEMEL33243OLIA",
|
|
|
Date: "2021-11-02T23:48:06Z",
|
|
Date: "2021-11-02T23:48:06Z",
|
|
|
File: "foo/foo.go",
|
|
File: "foo/foo.go",
|
|
@@ -479,6 +489,7 @@ func TestFromFiles(t *testing.T) {
|
|
|
EndColumn: 35,
|
|
EndColumn: 35,
|
|
|
Match: "AKIALALEMEL33243OLIA",
|
|
Match: "AKIALALEMEL33243OLIA",
|
|
|
Secret: "AKIALALEMEL33243OLIA",
|
|
Secret: "AKIALALEMEL33243OLIA",
|
|
|
|
|
+ Line: "\n\tawsToken := \"AKIALALEMEL33243OLIA\"",
|
|
|
File: "../testdata/repos/nogit/main.go",
|
|
File: "../testdata/repos/nogit/main.go",
|
|
|
RuleID: "aws-access-key",
|
|
RuleID: "aws-access-key",
|
|
|
Tags: []string{"key", "AWS"},
|
|
Tags: []string{"key", "AWS"},
|
|
@@ -499,6 +510,7 @@ func TestFromFiles(t *testing.T) {
|
|
|
EndColumn: 35,
|
|
EndColumn: 35,
|
|
|
Match: "AKIALALEMEL33243OLIA",
|
|
Match: "AKIALALEMEL33243OLIA",
|
|
|
Secret: "AKIALALEMEL33243OLIA",
|
|
Secret: "AKIALALEMEL33243OLIA",
|
|
|
|
|
+ Line: "\n\tawsToken := \"AKIALALEMEL33243OLIA\"",
|
|
|
File: "../testdata/repos/nogit/main.go",
|
|
File: "../testdata/repos/nogit/main.go",
|
|
|
RuleID: "aws-access-key",
|
|
RuleID: "aws-access-key",
|
|
|
Tags: []string{"key", "AWS"},
|
|
Tags: []string{"key", "AWS"},
|