diff --git a/config/allowlist.go b/config/allowlist.go index daaed7db..8055a9bf 100644 --- a/config/allowlist.go +++ b/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. diff --git a/test_data/test_allow_list_docx_no_git.json b/test_data/test_allow_list_docx_no_git.json index 50e44713..6cd05d39 100644 --- a/test_data/test_allow_list_docx_no_git.json +++ b/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" } ] diff --git a/test_data/test_allow_list_file_no_git.json b/test_data/test_allow_list_file_no_git.json index 200638be..d019602e 100644 --- a/test_data/test_allow_list_file_no_git.json +++ b/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, diff --git a/test_data/test_configs/allowlist_docx.toml b/test_data/test_configs/allowlist_docx.toml index e76bde28..baeee4d3 100644 --- a/test_data/test_configs/allowlist_docx.toml +++ b/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'''] diff --git a/test_data/test_repos/test_repo_10/creds.git b/test_data/test_repos/test_repo_10/creds.git new file mode 100644 index 00000000..e69de29b diff --git a/test_data/test_repos/test_repo_10/somedir.git/secret.key b/test_data/test_repos/test_repo_10/somedir.git/secret.key new file mode 100644 index 00000000..70b8a06c --- /dev/null +++ b/test_data/test_repos/test_repo_10/somedir.git/secret.key @@ -0,0 +1 @@ +hah