Просмотр исходного кода

Fixing patch direction and making additions the default (#408)

* Fixing patch direction and making additions the default

* adding test
Zachary Rice 5 лет назад
Родитель
Сommit
cfbb600fcb

+ 10 - 0
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 {

+ 7 - 5
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")
 			}

+ 5 - 2
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")
 		}

+ 1 - 0
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"`

+ 0 - 65
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",

+ 0 - 26
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",

+ 0 - 65
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",

+ 0 - 26
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\"",

+ 0 - 39
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",

+ 0 - 52
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",

+ 0 - 39
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",

+ 0 - 26
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",

+ 0 - 26
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",

+ 0 - 26
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"
  }
 ]

+ 80 - 0
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"
+ }
+]

+ 0 - 13
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",