Преглед изворни кода

Fix dotgit regex again (#507)

* fix dotgit regex again

* Revert accidentally modified files

Co-authored-by: Seb Elttam <seb@elttam.com>
seb-elttam пре 5 година
родитељ
комит
c0a9580a65

+ 1 - 1
config/allowlist.go

@@ -6,7 +6,7 @@ import (
 
 // used for ignoring .git directories when the --no-git flag is set
 // related issue: https://github.com/zricethezav/gitleaks/issues/486
-const dotGit = `\.git/`
+const dotGit = `/\.git/`
 
 // AllowList is struct containing items that if encountered will allowlist
 // a commit/line of code that would be considered a leak.

+ 32 - 0
test_data/test_allow_list_docx_no_git.json

@@ -46,5 +46,37 @@
   "file": "../test_data/test_repos/test_repo_10/gitfile.txt",
   "date": "0001-01-01T00:00:00Z",
   "tags": "key, extensions"
+ },
+ {
+  "line": "",
+  "lineNumber": 1,
+  "offender": "Filename or path offender: ../test_data/test_repos/test_repo_10/creds.git",
+  "commit": "",
+  "repo": "",
+  "repoURL": "",
+  "leakURL": "",
+  "rule": "Block dangerous filetypes",
+  "commitMessage": "",
+  "author": "",
+  "email": "",
+  "file": "../test_data/test_repos/test_repo_10/creds.git",
+  "date": "0001-01-01T00:00:00Z",
+  "tags": "key, extensions"
+ },
+ {
+  "line": "",
+  "lineNumber": 1,
+  "offender": "Filename or path offender: ../test_data/test_repos/test_repo_10/somedir.git/secret.key",
+  "commit": "",
+  "repo": "",
+  "repoURL": "",
+  "leakURL": "",
+  "rule": "Block dangerous filetypes",
+  "commitMessage": "",
+  "author": "",
+  "email": "",
+  "file": "../test_data/test_repos/test_repo_10/somedir.git/secret.key",
+  "date": "0001-01-01T00:00:00Z",
+  "tags": "key, extensions"
  }
 ]

+ 16 - 0
test_data/test_allow_list_file_no_git.json

@@ -1,4 +1,20 @@
 [
+{
+  "line": "",
+  "lineNumber": 1,
+  "offender": "Filename or path offender: ../test_data/test_repos/test_repo_10/somedir.git/secret.key",
+  "commit": "",
+  "repo": "",
+  "repoURL": "",
+  "leakURL": "",
+  "rule": "Block dangerous filetypes",
+  "commitMessage": "",
+  "author": "",
+  "email": "",
+  "file": "../test_data/test_repos/test_repo_10/somedir.git/secret.key",
+  "date": "0001-01-01T00:00:00Z",
+  "tags": "key, extensions"
+ },
  {
   "line": "",
   "lineNumber": 1,

+ 1 - 1
test_data/test_configs/allowlist_docx.toml

@@ -1,6 +1,6 @@
 [[rules]]
 	description = "Block dangerous filetypes"
-	file = '''(.*?)(gitfile.txt|gitignore|pdf|doc|docx|zip|xls|tfplan|tfstate|tfvars|vault_pass|vagrant|pyc|key|cache)$'''
+	file = '''(.*?)(creds.git|gitfile.txt|gitignore|pdf|doc|docx|zip|xls|tfplan|tfstate|tfvars|vault_pass|vagrant|pyc|key|cache)$'''
 	tags = ["key", "extensions"]
 	[rules.allowlist]
 		paths = ['''.docx''']

+ 0 - 0
test_data/test_repos/test_repo_10/creds.git


+ 1 - 0
test_data/test_repos/test_repo_10/somedir.git/secret.key

@@ -0,0 +1 @@
+hah