diff --git a/audit/audit_test.go b/audit/audit_test.go index 2e54ec6d..f620fa7c 100644 --- a/audit/audit_test.go +++ b/audit/audit_test.go @@ -366,6 +366,16 @@ func TestAudit(t *testing.T) { }, wantPath: "../test_data/test_local_repo_two_whitelist_commits.json", }, + { + description: "test local repo two deletion", + opts: options.Options{ + RepoPath: "../test_data/test_repos/test_repo_2", + Report: "../test_data/test_local_repo_two_leaks_deletion.json.got", + ReportFormat: "json", + Deletion: true, + }, + wantPath: "../test_data/test_local_repo_two_leaks_deletion.json", + }, } for _, test := range tests { diff --git a/audit/repo.go b/audit/repo.go index da720d1e..ab6a1a3d 100644 --- a/audit/repo.go +++ b/audit/repo.go @@ -213,10 +213,7 @@ func (repo *Repo) AuditUncommitted() error { diffs := diffmatchpatch.New().DiffMain(prevFileContents, currFileContents, false) var diffContents string for _, d := range diffs { - switch d.Type { - case diffmatchpatch.DiffInsert: - diffContents += fmt.Sprintf("%s\n", d.Text) - case diffmatchpatch.DiffDelete: + if d.Type == diffmatchpatch.DiffInsert { diffContents += fmt.Sprintf("%s\n", d.Text) } } @@ -312,8 +309,13 @@ func (repo *Repo) Audit() error { if repo.timeoutReached() { return nil } + if parent == nil { + // shouldn't reach this point but just in case + return nil + } + start := time.Now() - patch, err := c.Patch(parent) + patch, err := parent.Patch(c) if err != nil { return fmt.Errorf("could not generate patch") } diff --git a/audit/util.go b/audit/util.go index 4f424d68..71fc2142 100644 --- a/audit/util.go +++ b/audit/util.go @@ -33,7 +33,7 @@ func inspectPatch(patch *object.Patch, c *object.Commit, repo *Repo) { continue } for _, chunk := range f.Chunks() { - if chunk.Type() == fdiff.Delete || chunk.Type() == fdiff.Add { + if chunk.Type() == fdiff.Add || (repo.Manager.Opts.Deletion && chunk.Type() == fdiff.Delete){ InspectFile(chunk.Content(), getFileFullPath(f), c, repo) } } @@ -294,8 +294,11 @@ func inspectCommitPatches(c *object.Commit, repo *Repo) error { if repo.timeoutReached() { return nil } + if parent == nil { + return nil + } start := time.Now() - patch, err := c.Patch(parent) + patch, err := parent.Patch(c) if err != nil { return fmt.Errorf("could not generate patch") } diff --git a/options/options.go b/options/options.go index 3cc400d6..d3159d8a 100644 --- a/options/options.go +++ b/options/options.go @@ -56,6 +56,7 @@ type Options struct { CommitUntil string `long:"commit-until" description:"Audit commits older than a specific date. Ex: '2006-01-02' or '2006-01-02T15:04:05-0700' format."` Timeout string `long:"timeout" description:"Time allowed per audit. Ex: 10us, 30s, 1m, 1h10m1s"` Depth int `long:"depth" description:"Number of commits to audit"` + Deletion bool `long:"include-deletion" description:"Scan for patch deletions in addition to patch additions"` // Hosts Host string `long:"host" description:"git hosting service like gitlab or github. Supported hosts include: Github, Gitlab"` diff --git a/test_data/test_local_owner_aws_leak.json b/test_data/test_local_owner_aws_leak.json index 69631205..373ab673 100644 --- a/test_data/test_local_owner_aws_leak.json +++ b/test_data/test_local_owner_aws_leak.json @@ -12,19 +12,6 @@ "date": "2019-10-24T09:29:27-04:00", "tags": "key, AWS" }, - { - "line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"", - "offender": "AKIALALEMEL33243OLIB", - "commit": "f61cd8587b7ac1d75a89a0c9af870a2f24c60263", - "repo": "test_repo_2", - "rule": "AWS Manager ID", - "commitMessage": "rm secrets again\n", - "author": "zach rice", - "email": "zricer@protonmail.com", - "file": "secrets.md", - "date": "2019-10-25T13:12:32-04:00", - "tags": "key, AWS" - }, { "line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"", "offender": "AKIALALEMEL33243OLIB", @@ -41,32 +28,6 @@ { "line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"", "offender": "AKIALALEMEL33243OLIA", - "commit": "996865bb912f3bc45898a370a13aadb315014b55", - "repo": "test_repo_2", - "rule": "AWS Manager ID", - "commitMessage": "committing pem\n", - "author": "zach rice", - "email": "zricer@protonmail.com", - "file": "secrets.md", - "date": "2019-10-25T13:07:41-04:00", - "tags": "key, AWS" - }, - { - "line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"", - "offender": "AKIALALEMEL33243OLIA", - "commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c", - "repo": "test_repo_2", - "rule": "AWS Manager ID", - "commitMessage": "wait this is actually adding an aws secret\n", - "author": "zach rice", - "email": "zricer@protonmail.com", - "file": "secrets.md", - "date": "2019-10-25T13:01:27-04:00", - "tags": "key, AWS" - }, - { - "line": "Here's an AWS secret: AKIALALEMEL33243OLIAE", - "offender": "AKIALALEMEL33243OLIA", "commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c", "repo": "test_repo_2", "rule": "AWS Manager ID", @@ -90,19 +51,6 @@ "date": "2019-10-25T12:58:39-04:00", "tags": "key, AWS" }, - { - "line": "const AWSKEY = \"AKIALALEMEL33243OLIAE\"", - "offender": "AKIALALEMEL33243OLIA", - "commit": "cd5eb8bef855f73c46b97b4c088badffdc40ebe9", - "repo": "test_repo_3", - "rule": "AWS Manager ID", - "commitMessage": "rm secrets\n", - "author": "zach rice", - "email": "zricer@protonmail.com", - "file": "secrets.md", - "date": "2019-10-25T13:54:26-04:00", - "tags": "key, AWS" - }, { "line": "const AWSKEY = \"AKIALALEMEL33243OLIAE\"", "offender": "AKIALALEMEL33243OLIA", @@ -116,19 +64,6 @@ "date": "2019-10-25T13:54:08-04:00", "tags": "key, AWS" }, - { - "line": "AWS secret: \"AKIALALEMEL33243OLIAE\"", - "offender": "AKIALALEMEL33243OLIA", - "commit": "64cfcee9aad1c84581631636bfc54f2050718d1a", - "repo": "test_repo_3", - "rule": "AWS Manager ID", - "commitMessage": "rm secrets\n", - "author": "zach rice", - "email": "zricer@protonmail.com", - "file": "secrets.md", - "date": "2019-10-25T13:36:22-04:00", - "tags": "key, AWS" - }, { "line": "AWS secret: \"AKIALALEMEL33243OLIAE\"", "offender": "AKIALALEMEL33243OLIA", diff --git a/test_data/test_local_owner_aws_leak_depth_2.json b/test_data/test_local_owner_aws_leak_depth_2.json index fdc33650..940ab7ca 100644 --- a/test_data/test_local_owner_aws_leak_depth_2.json +++ b/test_data/test_local_owner_aws_leak_depth_2.json @@ -12,19 +12,6 @@ "date": "2019-10-24T09:29:27-04:00", "tags": "key, AWS" }, - { - "line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"", - "offender": "AKIALALEMEL33243OLIB", - "commit": "f61cd8587b7ac1d75a89a0c9af870a2f24c60263", - "repo": "test_repo_2", - "rule": "AWS Manager ID", - "commitMessage": "rm secrets again\n", - "author": "zach rice", - "email": "zricer@protonmail.com", - "file": "secrets.md", - "date": "2019-10-25T13:12:32-04:00", - "tags": "key, AWS" - }, { "line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"", "offender": "AKIALALEMEL33243OLIB", @@ -38,19 +25,6 @@ "date": "2019-10-25T13:12:08-04:00", "tags": "key, AWS" }, - { - "line": "const AWSKEY = \"AKIALALEMEL33243OLIAE\"", - "offender": "AKIALALEMEL33243OLIA", - "commit": "cd5eb8bef855f73c46b97b4c088badffdc40ebe9", - "repo": "test_repo_3", - "rule": "AWS Manager ID", - "commitMessage": "rm secrets\n", - "author": "zach rice", - "email": "zricer@protonmail.com", - "file": "secrets.md", - "date": "2019-10-25T13:54:26-04:00", - "tags": "key, AWS" - }, { "line": "const AWSKEY = \"AKIALALEMEL33243OLIAE\"", "offender": "AKIALALEMEL33243OLIA", diff --git a/test_data/test_local_owner_aws_leak_whitelist_repo.json b/test_data/test_local_owner_aws_leak_whitelist_repo.json index e914a103..bf79793c 100644 --- a/test_data/test_local_owner_aws_leak_whitelist_repo.json +++ b/test_data/test_local_owner_aws_leak_whitelist_repo.json @@ -1,17 +1,4 @@ [ - { - "line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"", - "offender": "AKIALALEMEL33243OLIB", - "commit": "f61cd8587b7ac1d75a89a0c9af870a2f24c60263", - "repo": "test_repo_2", - "rule": "AWS Manager ID", - "commitMessage": "rm secrets again\n", - "author": "zach rice", - "email": "zricer@protonmail.com", - "file": "secrets.md", - "date": "2019-10-25T13:12:32-04:00", - "tags": "key, AWS" - }, { "line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"", "offender": "AKIALALEMEL33243OLIB", @@ -28,32 +15,6 @@ { "line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"", "offender": "AKIALALEMEL33243OLIA", - "commit": "996865bb912f3bc45898a370a13aadb315014b55", - "repo": "test_repo_2", - "rule": "AWS Manager ID", - "commitMessage": "committing pem\n", - "author": "zach rice", - "email": "zricer@protonmail.com", - "file": "secrets.md", - "date": "2019-10-25T13:07:41-04:00", - "tags": "key, AWS" - }, - { - "line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"", - "offender": "AKIALALEMEL33243OLIA", - "commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c", - "repo": "test_repo_2", - "rule": "AWS Manager ID", - "commitMessage": "wait this is actually adding an aws secret\n", - "author": "zach rice", - "email": "zricer@protonmail.com", - "file": "secrets.md", - "date": "2019-10-25T13:01:27-04:00", - "tags": "key, AWS" - }, - { - "line": "Here's an AWS secret: AKIALALEMEL33243OLIAE", - "offender": "AKIALALEMEL33243OLIA", "commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c", "repo": "test_repo_2", "rule": "AWS Manager ID", @@ -77,19 +38,6 @@ "date": "2019-10-25T12:58:39-04:00", "tags": "key, AWS" }, - { - "line": "const AWSKEY = \"AKIALALEMEL33243OLIAE\"", - "offender": "AKIALALEMEL33243OLIA", - "commit": "cd5eb8bef855f73c46b97b4c088badffdc40ebe9", - "repo": "test_repo_3", - "rule": "AWS Manager ID", - "commitMessage": "rm secrets\n", - "author": "zach rice", - "email": "zricer@protonmail.com", - "file": "secrets.md", - "date": "2019-10-25T13:54:26-04:00", - "tags": "key, AWS" - }, { "line": "const AWSKEY = \"AKIALALEMEL33243OLIAE\"", "offender": "AKIALALEMEL33243OLIA", @@ -103,19 +51,6 @@ "date": "2019-10-25T13:54:08-04:00", "tags": "key, AWS" }, - { - "line": "AWS secret: \"AKIALALEMEL33243OLIAE\"", - "offender": "AKIALALEMEL33243OLIA", - "commit": "64cfcee9aad1c84581631636bfc54f2050718d1a", - "repo": "test_repo_3", - "rule": "AWS Manager ID", - "commitMessage": "rm secrets\n", - "author": "zach rice", - "email": "zricer@protonmail.com", - "file": "secrets.md", - "date": "2019-10-25T13:36:22-04:00", - "tags": "key, AWS" - }, { "line": "AWS secret: \"AKIALALEMEL33243OLIAE\"", "offender": "AKIALALEMEL33243OLIA", diff --git a/test_data/test_local_repo_four_alt_config_entropy.json b/test_data/test_local_repo_four_alt_config_entropy.json index 85e81cce..4d8f8a17 100644 --- a/test_data/test_local_repo_four_alt_config_entropy.json +++ b/test_data/test_local_repo_four_alt_config_entropy.json @@ -1,17 +1,4 @@ [ - { - "line": "const AWSSECRET = \"99432bfewaf823ec3294e231\"", - "offender": "\"99432bfewaf823ec3294e231\"", - "commit": "cd5eb8bef855f73c46b97b4c088badffdc40ebe9", - "repo": "test_repo_4", - "rule": "entropy", - "commitMessage": "rm secrets\n", - "author": "zach rice", - "email": "zricer@protonmail.com", - "file": "secrets.md", - "date": "2019-10-25T13:54:26-04:00", - "tags": "entropy" - }, { "line": "const AWSSECRET = \"99432bfewaf823ec3294e231\"", "offender": "\"99432bfewaf823ec3294e231\"", @@ -25,19 +12,6 @@ "date": "2019-10-25T13:54:08-04:00", "tags": "entropy" }, - { - "line": " const AWSSECRET = \"99432bfewaf823ec3294e231\"", - "offender": "\"99432bfewaf823ec3294e231\"", - "commit": "f61cd8587b7ac1d75a89a0c9af870a2f24c60263", - "repo": "test_repo_4", - "rule": "entropy", - "commitMessage": "rm secrets again\n", - "author": "zach rice", - "email": "zricer@protonmail.com", - "file": "secrets.md", - "date": "2019-10-25T13:12:32-04:00", - "tags": "entropy" - }, { "line": " const AWSSECRET = \"99432bfewaf823ec3294e231\"", "offender": "\"99432bfewaf823ec3294e231\"", diff --git a/test_data/test_local_repo_four_leaks_commit_timerange.json b/test_data/test_local_repo_four_leaks_commit_timerange.json index 4516d306..45a6391c 100644 --- a/test_data/test_local_repo_four_leaks_commit_timerange.json +++ b/test_data/test_local_repo_four_leaks_commit_timerange.json @@ -1,17 +1,4 @@ [ - { - "line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"", - "offender": "AKIALALEMEL33243OLIB", - "commit": "f61cd8587b7ac1d75a89a0c9af870a2f24c60263", - "repo": "test_repo_4", - "rule": "AWS Manager ID", - "commitMessage": "rm secrets again\n", - "author": "zach rice", - "email": "zricer@protonmail.com", - "file": "secrets.md", - "date": "2019-10-25T13:12:32-04:00", - "tags": "key, AWS" - }, { "line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"", "offender": "AKIALALEMEL33243OLIB", @@ -28,32 +15,6 @@ { "line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"", "offender": "AKIALALEMEL33243OLIA", - "commit": "996865bb912f3bc45898a370a13aadb315014b55", - "repo": "test_repo_4", - "rule": "AWS Manager ID", - "commitMessage": "committing pem\n", - "author": "zach rice", - "email": "zricer@protonmail.com", - "file": "secrets.md", - "date": "2019-10-25T13:07:41-04:00", - "tags": "key, AWS" - }, - { - "line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"", - "offender": "AKIALALEMEL33243OLIA", - "commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c", - "repo": "test_repo_4", - "rule": "AWS Manager ID", - "commitMessage": "wait this is actually adding an aws secret\n", - "author": "zach rice", - "email": "zricer@protonmail.com", - "file": "secrets.md", - "date": "2019-10-25T13:01:27-04:00", - "tags": "key, AWS" - }, - { - "line": "Here's an AWS secret: AKIALALEMEL33243OLIAE", - "offender": "AKIALALEMEL33243OLIA", "commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c", "repo": "test_repo_4", "rule": "AWS Manager ID", diff --git a/test_data/test_local_repo_three_leaks.json b/test_data/test_local_repo_three_leaks.json index 024003a4..a12b88c3 100644 --- a/test_data/test_local_repo_three_leaks.json +++ b/test_data/test_local_repo_three_leaks.json @@ -1,17 +1,4 @@ [ - { - "line": "AWS secret: \"AKIALALEMEL33243OLIAE\"", - "offender": "AKIALALEMEL33243OLIA", - "commit": "64cfcee9aad1c84581631636bfc54f2050718d1a", - "repo": "test_repo_3", - "rule": "AWS Manager ID", - "commitMessage": "rm secrets\n", - "author": "zach rice", - "email": "zricer@protonmail.com", - "file": "secrets.md", - "date": "2019-10-25T13:36:22-04:00", - "tags": "key, AWS" - }, { "line": "AWS secret: \"AKIALALEMEL33243OLIAE\"", "offender": "AKIALALEMEL33243OLIA", @@ -25,19 +12,6 @@ "date": "2019-10-25T13:35:03-04:00", "tags": "key, AWS" }, - { - "line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"", - "offender": "AKIALALEMEL33243OLIB", - "commit": "f61cd8587b7ac1d75a89a0c9af870a2f24c60263", - "repo": "test_repo_3", - "rule": "AWS Manager ID", - "commitMessage": "rm secrets again\n", - "author": "zach rice", - "email": "zricer@protonmail.com", - "file": "secrets.md", - "date": "2019-10-25T13:12:32-04:00", - "tags": "key, AWS" - }, { "line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"", "offender": "AKIALALEMEL33243OLIB", @@ -54,32 +28,6 @@ { "line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"", "offender": "AKIALALEMEL33243OLIA", - "commit": "996865bb912f3bc45898a370a13aadb315014b55", - "repo": "test_repo_3", - "rule": "AWS Manager ID", - "commitMessage": "committing pem\n", - "author": "zach rice", - "email": "zricer@protonmail.com", - "file": "secrets.md", - "date": "2019-10-25T13:07:41-04:00", - "tags": "key, AWS" - }, - { - "line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"", - "offender": "AKIALALEMEL33243OLIA", - "commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c", - "repo": "test_repo_3", - "rule": "AWS Manager ID", - "commitMessage": "wait this is actually adding an aws secret\n", - "author": "zach rice", - "email": "zricer@protonmail.com", - "file": "secrets.md", - "date": "2019-10-25T13:01:27-04:00", - "tags": "key, AWS" - }, - { - "line": "Here's an AWS secret: AKIALALEMEL33243OLIAE", - "offender": "AKIALALEMEL33243OLIA", "commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c", "repo": "test_repo_3", "rule": "AWS Manager ID", diff --git a/test_data/test_local_repo_two_leaks.json b/test_data/test_local_repo_two_leaks.json index 136bb6eb..5c8d75f8 100644 --- a/test_data/test_local_repo_two_leaks.json +++ b/test_data/test_local_repo_two_leaks.json @@ -1,17 +1,4 @@ [ - { - "line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"", - "offender": "AKIALALEMEL33243OLIB", - "commit": "f61cd8587b7ac1d75a89a0c9af870a2f24c60263", - "repo": "test_repo_2", - "rule": "AWS Manager ID", - "commitMessage": "rm secrets again\n", - "author": "zach rice", - "email": "zricer@protonmail.com", - "file": "secrets.md", - "date": "2019-10-25T13:12:32-04:00", - "tags": "key, AWS" - }, { "line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"", "offender": "AKIALALEMEL33243OLIB", @@ -28,32 +15,6 @@ { "line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"", "offender": "AKIALALEMEL33243OLIA", - "commit": "996865bb912f3bc45898a370a13aadb315014b55", - "repo": "test_repo_2", - "rule": "AWS Manager ID", - "commitMessage": "committing pem\n", - "author": "zach rice", - "email": "zricer@protonmail.com", - "file": "secrets.md", - "date": "2019-10-25T13:07:41-04:00", - "tags": "key, AWS" - }, - { - "line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"", - "offender": "AKIALALEMEL33243OLIA", - "commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c", - "repo": "test_repo_2", - "rule": "AWS Manager ID", - "commitMessage": "wait this is actually adding an aws secret\n", - "author": "zach rice", - "email": "zricer@protonmail.com", - "file": "secrets.md", - "date": "2019-10-25T13:01:27-04:00", - "tags": "key, AWS" - }, - { - "line": "Here's an AWS secret: AKIALALEMEL33243OLIAE", - "offender": "AKIALALEMEL33243OLIA", "commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c", "repo": "test_repo_2", "rule": "AWS Manager ID", diff --git a/test_data/test_local_repo_two_leaks_commit_from.json b/test_data/test_local_repo_two_leaks_commit_from.json index 47c7f306..d33fc6ce 100644 --- a/test_data/test_local_repo_two_leaks_commit_from.json +++ b/test_data/test_local_repo_two_leaks_commit_from.json @@ -2,32 +2,6 @@ { "line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"", "offender": "AKIALALEMEL33243OLIA", - "commit": "996865bb912f3bc45898a370a13aadb315014b55", - "repo": "test_repo_2", - "rule": "AWS Manager ID", - "commitMessage": "committing pem\n", - "author": "zach rice", - "email": "zricer@protonmail.com", - "file": "secrets.md", - "date": "2019-10-25T13:07:41-04:00", - "tags": "key, AWS" - }, - { - "line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"", - "offender": "AKIALALEMEL33243OLIA", - "commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c", - "repo": "test_repo_2", - "rule": "AWS Manager ID", - "commitMessage": "wait this is actually adding an aws secret\n", - "author": "zach rice", - "email": "zricer@protonmail.com", - "file": "secrets.md", - "date": "2019-10-25T13:01:27-04:00", - "tags": "key, AWS" - }, - { - "line": "Here's an AWS secret: AKIALALEMEL33243OLIAE", - "offender": "AKIALALEMEL33243OLIA", "commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c", "repo": "test_repo_2", "rule": "AWS Manager ID", diff --git a/test_data/test_local_repo_two_leaks_commit_range.json b/test_data/test_local_repo_two_leaks_commit_range.json index b8cb7046..c2d015d2 100644 --- a/test_data/test_local_repo_two_leaks_commit_range.json +++ b/test_data/test_local_repo_two_leaks_commit_range.json @@ -2,32 +2,6 @@ { "line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"", "offender": "AKIALALEMEL33243OLIA", - "commit": "996865bb912f3bc45898a370a13aadb315014b55", - "repo": "test_repo_2", - "rule": "AWS Manager ID", - "commitMessage": "committing pem\n", - "author": "zach rice", - "email": "zricer@protonmail.com", - "file": "secrets.md", - "date": "2019-10-25T13:07:41-04:00", - "tags": "key, AWS" - }, - { - "line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"", - "offender": "AKIALALEMEL33243OLIA", - "commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c", - "repo": "test_repo_2", - "rule": "AWS Manager ID", - "commitMessage": "wait this is actually adding an aws secret\n", - "author": "zach rice", - "email": "zricer@protonmail.com", - "file": "secrets.md", - "date": "2019-10-25T13:01:27-04:00", - "tags": "key, AWS" - }, - { - "line": "Here's an AWS secret: AKIALALEMEL33243OLIAE", - "offender": "AKIALALEMEL33243OLIA", "commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c", "repo": "test_repo_2", "rule": "AWS Manager ID", diff --git a/test_data/test_local_repo_two_leaks_commit_to.json b/test_data/test_local_repo_two_leaks_commit_to.json index 2d589fbc..0c20936e 100644 --- a/test_data/test_local_repo_two_leaks_commit_to.json +++ b/test_data/test_local_repo_two_leaks_commit_to.json @@ -1,17 +1,4 @@ [ - { - "line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"", - "offender": "AKIALALEMEL33243OLIB", - "commit": "f61cd8587b7ac1d75a89a0c9af870a2f24c60263", - "repo": "test_repo_2", - "rule": "AWS Manager ID", - "commitMessage": "rm secrets again\n", - "author": "zach rice", - "email": "zricer@protonmail.com", - "file": "secrets.md", - "date": "2019-10-25T13:12:32-04:00", - "tags": "key, AWS" - }, { "line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"", "offender": "AKIALALEMEL33243OLIB", @@ -24,18 +11,5 @@ "file": "secrets.md", "date": "2019-10-25T13:12:08-04:00", "tags": "key, AWS" - }, - { - "line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"", - "offender": "AKIALALEMEL33243OLIA", - "commit": "996865bb912f3bc45898a370a13aadb315014b55", - "repo": "test_repo_2", - "rule": "AWS Manager ID", - "commitMessage": "committing pem\n", - "author": "zach rice", - "email": "zricer@protonmail.com", - "file": "secrets.md", - "date": "2019-10-25T13:07:41-04:00", - "tags": "key, AWS" } ] diff --git a/test_data/test_local_repo_two_leaks_deletion.json b/test_data/test_local_repo_two_leaks_deletion.json new file mode 100644 index 00000000..ead87d57 --- /dev/null +++ b/test_data/test_local_repo_two_leaks_deletion.json @@ -0,0 +1,80 @@ +[ + { + "line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"", + "offender": "AKIALALEMEL33243OLIB", + "commit": "f61cd8587b7ac1d75a89a0c9af870a2f24c60263", + "repo": "test_repo_2", + "rule": "AWS Manager ID", + "commitMessage": "rm secrets again\n", + "author": "zach rice", + "email": "zricer@protonmail.com", + "file": "secrets.md", + "date": "2019-10-25T13:12:32-04:00", + "tags": "key, AWS" + }, + { + "line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"", + "offender": "AKIALALEMEL33243OLIB", + "commit": "b2eb34a61c988afd9b4aaa9dd58c8dd7d5f14dba", + "repo": "test_repo_2", + "rule": "AWS Manager ID", + "commitMessage": "adding another one\n", + "author": "zach rice", + "email": "zricer@protonmail.com", + "file": "secrets.md", + "date": "2019-10-25T13:12:08-04:00", + "tags": "key, AWS" + }, + { + "line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"", + "offender": "AKIALALEMEL33243OLIA", + "commit": "996865bb912f3bc45898a370a13aadb315014b55", + "repo": "test_repo_2", + "rule": "AWS Manager ID", + "commitMessage": "committing pem\n", + "author": "zach rice", + "email": "zricer@protonmail.com", + "file": "secrets.md", + "date": "2019-10-25T13:07:41-04:00", + "tags": "key, AWS" + }, + { + "line": "Here's an AWS secret: AKIALALEMEL33243OLIAE", + "offender": "AKIALALEMEL33243OLIA", + "commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c", + "repo": "test_repo_2", + "rule": "AWS Manager ID", + "commitMessage": "wait this is actually adding an aws secret\n", + "author": "zach rice", + "email": "zricer@protonmail.com", + "file": "secrets.md", + "date": "2019-10-25T13:01:27-04:00", + "tags": "key, AWS" + }, + { + "line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"", + "offender": "AKIALALEMEL33243OLIA", + "commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c", + "repo": "test_repo_2", + "rule": "AWS Manager ID", + "commitMessage": "wait this is actually adding an aws secret\n", + "author": "zach rice", + "email": "zricer@protonmail.com", + "file": "secrets.md", + "date": "2019-10-25T13:01:27-04:00", + "tags": "key, AWS" + }, + { + "line": "\nHere's an AWS secret: AKIALALEMEL33243OLIAE", + "offender": "AKIALALEMEL33243OLIA", + "commit": "b10b3e2cb320a8c211fda94c4567299d37de7776", + "repo": "test_repo_2", + "rule": "AWS Manager ID", + "commitMessage": "adding aws key\n", + "author": "zach rice", + "email": "zricer@protonmail.com", + "file": "secrets.md", + "date": "2019-10-25T12:58:39-04:00", + "tags": "key, AWS" + } +] diff --git a/test_data/test_local_repo_two_whitelist_commits.json b/test_data/test_local_repo_two_whitelist_commits.json index 338a095b..0c20936e 100644 --- a/test_data/test_local_repo_two_whitelist_commits.json +++ b/test_data/test_local_repo_two_whitelist_commits.json @@ -1,17 +1,4 @@ [ - { - "line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"", - "offender": "AKIALALEMEL33243OLIB", - "commit": "f61cd8587b7ac1d75a89a0c9af870a2f24c60263", - "repo": "test_repo_2", - "rule": "AWS Manager ID", - "commitMessage": "rm secrets again\n", - "author": "zach rice", - "email": "zricer@protonmail.com", - "file": "secrets.md", - "date": "2019-10-25T13:12:32-04:00", - "tags": "key, AWS" - }, { "line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"", "offender": "AKIALALEMEL33243OLIB",