mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-30 05:04:22 +01:00
Dotgit bug (#488)
* fix allowlist bug * Adding new repo for testing allowlisting * adding additional constraints on the dotgit regex
This commit is contained in:
1 parent
2d58f1f94e
commit
f036dce6ab
5 files changed
+41
-3
No files matched your search
+6
-2
@@ -4,6 +4,10 @@ import (
|
|||||||
"regexp"
|
"regexp"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// used for ignoring .git directories when the --no-git flag is set
|
||||||
|
// related issue: https://github.com/zricethezav/gitleaks/issues/486
|
||||||
|
const dotGit = `\.git/`
|
||||||
|
|
||||||
// AllowList is struct containing items that if encountered will allowlist
|
// AllowList is struct containing items that if encountered will allowlist
|
||||||
// a commit/line of code that would be considered a leak.
|
// a commit/line of code that would be considered a leak.
|
||||||
type AllowList struct {
|
type AllowList struct {
|
||||||
@@ -45,9 +49,9 @@ func (a *AllowList) RepoAllowed(repo string) bool {
|
|||||||
return anyRegexMatch(repo, a.Repos)
|
return anyRegexMatch(repo, a.Repos)
|
||||||
}
|
}
|
||||||
|
|
||||||
// IgnoreDotGit appends a `.git$` rule to ignore all .git paths. This is used for --no-git scans
|
// IgnoreDotGit appends a `\.git` rule to ignore all .git paths. This is used for --no-git scans
|
||||||
func (a *AllowList) IgnoreDotGit() error {
|
func (a *AllowList) IgnoreDotGit() error {
|
||||||
re, err := regexp.Compile(".git")
|
re, err := regexp.Compile(dotGit)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,20 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"line": "",
|
||||||
|
"lineNumber": 1,
|
||||||
|
"offender": "Filename or path offender: ../test_data/test_repos/test_repo_10/.gitignore",
|
||||||
|
"commit": "",
|
||||||
|
"repo": "",
|
||||||
|
"repoURL": "",
|
||||||
|
"leakURL": "",
|
||||||
|
"rule": "Block dangerous filetypes",
|
||||||
|
"commitMessage": "",
|
||||||
|
"author": "",
|
||||||
|
"email": "",
|
||||||
|
"file": "../test_data/test_repos/test_repo_10/.gitignore",
|
||||||
|
"date": "0001-01-01T00:00:00Z",
|
||||||
|
"tags": "key, extensions"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"line": "",
|
"line": "",
|
||||||
"lineNumber": 1,
|
"lineNumber": 1,
|
||||||
@@ -14,5 +30,21 @@
|
|||||||
"file": "../test_data/test_repos/test_repo_10/bad.zip",
|
"file": "../test_data/test_repos/test_repo_10/bad.zip",
|
||||||
"date": "0001-01-01T00:00:00Z",
|
"date": "0001-01-01T00:00:00Z",
|
||||||
"tags": "key, extensions"
|
"tags": "key, extensions"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"line": "",
|
||||||
|
"lineNumber": 1,
|
||||||
|
"offender": "Filename or path offender: ../test_data/test_repos/test_repo_10/gitfile.txt",
|
||||||
|
"commit": "",
|
||||||
|
"repo": "",
|
||||||
|
"repoURL": "",
|
||||||
|
"leakURL": "",
|
||||||
|
"rule": "Block dangerous filetypes",
|
||||||
|
"commitMessage": "",
|
||||||
|
"author": "",
|
||||||
|
"email": "",
|
||||||
|
"file": "../test_data/test_repos/test_repo_10/gitfile.txt",
|
||||||
|
"date": "0001-01-01T00:00:00Z",
|
||||||
|
"tags": "key, extensions"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
[[rules]]
|
[[rules]]
|
||||||
description = "Block dangerous filetypes"
|
description = "Block dangerous filetypes"
|
||||||
file = '''(.*?)(pdf|doc|docx|zip|xls|tfplan|tfstate|tfvars|vault_pass|vagrant|pyc|key|cache)$'''
|
file = '''(.*?)(gitfile.txt|gitignore|pdf|doc|docx|zip|xls|tfplan|tfstate|tfvars|vault_pass|vagrant|pyc|key|cache)$'''
|
||||||
tags = ["key", "extensions"]
|
tags = ["key", "extensions"]
|
||||||
[rules.allowlist]
|
[rules.allowlist]
|
||||||
paths = ['''.docx''']
|
paths = ['''.docx''']
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
a dot git ignore file
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
a git file
|
||||||
Reference in new issue
Block a user