Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf036dce

Browse files
authored
Dotgit bug (gitleaks#488)
* fix allowlist bug* Adding new repo for testing allowlisting* adding additional constraints on the dotgit regex
1 parent2d58f1f commitf036dce

File tree

5 files changed

+41
-3
lines changed

5 files changed

+41
-3
lines changed

‎config/allowlist.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import (
44
"regexp"
55
)
66

7+
// used for ignoring .git directories when the --no-git flag is set
8+
// related issue: https://github.com/zricethezav/gitleaks/issues/486
9+
constdotGit=`\.git/`
10+
711
// AllowList is struct containing items that if encountered will allowlist
812
// a commit/line of code that would be considered a leak.
913
typeAllowListstruct {
@@ -45,9 +49,9 @@ func (a *AllowList) RepoAllowed(repo string) bool {
4549
returnanyRegexMatch(repo,a.Repos)
4650
}
4751

48-
// IgnoreDotGit appends a `.git$` rule to ignore all .git paths. This is used for --no-git scans
52+
// IgnoreDotGit appends a `\.git` rule to ignore all .git paths. This is used for --no-git scans
4953
func (a*AllowList)IgnoreDotGit()error {
50-
re,err:=regexp.Compile(".git")
54+
re,err:=regexp.Compile(dotGit)
5155
iferr!=nil {
5256
returnerr
5357
}

‎test_data/test_allow_list_docx_no_git.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
11
[
2+
{
3+
"line":"",
4+
"lineNumber":1,
5+
"offender":"Filename or path offender: ../test_data/test_repos/test_repo_10/.gitignore",
6+
"commit":"",
7+
"repo":"",
8+
"repoURL":"",
9+
"leakURL":"",
10+
"rule":"Block dangerous filetypes",
11+
"commitMessage":"",
12+
"author":"",
13+
"email":"",
14+
"file":"../test_data/test_repos/test_repo_10/.gitignore",
15+
"date":"0001-01-01T00:00:00Z",
16+
"tags":"key, extensions"
17+
},
218
{
319
"line":"",
420
"lineNumber":1,
@@ -14,5 +30,21 @@
1430
"file":"../test_data/test_repos/test_repo_10/bad.zip",
1531
"date":"0001-01-01T00:00:00Z",
1632
"tags":"key, extensions"
33+
},
34+
{
35+
"line":"",
36+
"lineNumber":1,
37+
"offender":"Filename or path offender: ../test_data/test_repos/test_repo_10/gitfile.txt",
38+
"commit":"",
39+
"repo":"",
40+
"repoURL":"",
41+
"leakURL":"",
42+
"rule":"Block dangerous filetypes",
43+
"commitMessage":"",
44+
"author":"",
45+
"email":"",
46+
"file":"../test_data/test_repos/test_repo_10/gitfile.txt",
47+
"date":"0001-01-01T00:00:00Z",
48+
"tags":"key, extensions"
1749
}
1850
]

‎test_data/test_configs/allowlist_docx.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[[rules]]
22
description ="Block dangerous filetypes"
3-
file ='''(.*?)(pdf|doc|docx|zip|xls|tfplan|tfstate|tfvars|vault_pass|vagrant|pyc|key|cache)$'''
3+
file ='''(.*?)(gitfile.txt|gitignore|pdf|doc|docx|zip|xls|tfplan|tfstate|tfvars|vault_pass|vagrant|pyc|key|cache)$'''
44
tags = ["key","extensions"]
55
[rules.allowlist]
66
paths = ['''.docx''']
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
adotgitignorefile
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
a git file

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp