mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-12-01 13:34:23 +01:00
1 parent
94f5950d68
commit
c637b129ec
5 files changed
+8
-34
No files matched your search
@@ -9,6 +9,7 @@ import (
|
|||||||
"github.com/zricethezav/gitleaks/v5/options"
|
"github.com/zricethezav/gitleaks/v5/options"
|
||||||
|
|
||||||
"github.com/BurntSushi/toml"
|
"github.com/BurntSushi/toml"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Allowlist is struct containing items that if encountered will allowlist
|
// Allowlist is struct containing items that if encountered will allowlist
|
||||||
@@ -119,6 +120,11 @@ func NewConfig(options options.Options) (Config, error) {
|
|||||||
func (tomlLoader TomlLoader) Parse() (Config, error) {
|
func (tomlLoader TomlLoader) Parse() (Config, error) {
|
||||||
var cfg Config
|
var cfg Config
|
||||||
for _, rule := range tomlLoader.Rules {
|
for _, rule := range tomlLoader.Rules {
|
||||||
|
// check and make sure the rule is valid
|
||||||
|
if rule.Regex == "" && rule.FilePathRegex == "" && rule.FileNameRegex == "" && len(rule.Entropies) == 0 {
|
||||||
|
log.Warnf("Rule %s does not define any actionable data", rule.Description)
|
||||||
|
continue
|
||||||
|
}
|
||||||
re, err := regexp.Compile(rule.Regex)
|
re, err := regexp.Compile(rule.Regex)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cfg, fmt.Errorf("problem loading config: %v", err)
|
return cfg, fmt.Errorf("problem loading config: %v", err)
|
||||||
|
|||||||
@@ -23,8 +23,6 @@ github.com/go-git/go-billy/v5 v5.0.0 h1:7NQHvd9FVid8VL4qVUMm8XifBK+2xCoZ2lSk0agR
|
|||||||
github.com/go-git/go-billy/v5 v5.0.0/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0=
|
github.com/go-git/go-billy/v5 v5.0.0/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0=
|
||||||
github.com/go-git/go-git-fixtures/v4 v4.0.1 h1:q+IFMfLx200Q3scvt2hN79JsEzy4AmBTp/pqnefH+Bc=
|
github.com/go-git/go-git-fixtures/v4 v4.0.1 h1:q+IFMfLx200Q3scvt2hN79JsEzy4AmBTp/pqnefH+Bc=
|
||||||
github.com/go-git/go-git-fixtures/v4 v4.0.1/go.mod h1:m+ICp2rF3jDhFgEZ/8yziagdT1C+ZpZcrJjappBCDSw=
|
github.com/go-git/go-git-fixtures/v4 v4.0.1/go.mod h1:m+ICp2rF3jDhFgEZ/8yziagdT1C+ZpZcrJjappBCDSw=
|
||||||
github.com/go-git/go-git/v5 v5.0.0 h1:k5RWPm4iJwYtfWoxIJy4wJX9ON7ihPeZZYC1fLYDnpg=
|
|
||||||
github.com/go-git/go-git/v5 v5.0.0/go.mod h1:oYD8y9kWsGINPFJoLdaScGCN6dlKg23blmClfZwtUVA=
|
|
||||||
github.com/go-git/go-git/v5 v5.1.0 h1:HxJn9g/E7eYvKW3Fm7Jt4ee8LXfPOm/H1cdDu8vEssk=
|
github.com/go-git/go-git/v5 v5.1.0 h1:HxJn9g/E7eYvKW3Fm7Jt4ee8LXfPOm/H1cdDu8vEssk=
|
||||||
github.com/go-git/go-git/v5 v5.1.0/go.mod h1:ZKfuPUoY1ZqIG4QG9BDBh3G4gLM5zvPuSJAozQrZuyM=
|
github.com/go-git/go-git/v5 v5.1.0/go.mod h1:ZKfuPUoY1ZqIG4QG9BDBh3G4gLM5zvPuSJAozQrZuyM=
|
||||||
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
|
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
|
||||||
|
|||||||
@@ -393,4 +393,3 @@ func isFilePathWhiteListed(filepath string, allowlist []config.Allowlist) bool {
|
|||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -8,6 +8,7 @@
|
|||||||
regex = '''(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}'''
|
regex = '''(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}'''
|
||||||
tags = ["key", "AWS"]
|
tags = ["key", "AWS"]
|
||||||
|
|
||||||
|
## this is an example of a rule that won't work
|
||||||
[[rules]]
|
[[rules]]
|
||||||
description = "Python files"
|
description = "Python files"
|
||||||
fileRegex = '''(.*)?py$'''
|
fileRegex = "(?i)*.py"
|
||||||
@@ -1,19 +1,4 @@
|
|||||||
[
|
[
|
||||||
{
|
|
||||||
"line": "N/A",
|
|
||||||
"lineNumber": -1,
|
|
||||||
"offender": "Filename/path offender: server.test.py",
|
|
||||||
"commit": "d274003914c707212cbe84e3e466a00013ccb639",
|
|
||||||
"repo": "test_repo_1",
|
|
||||||
"rule": "Python files",
|
|
||||||
"commitMessage": "comment\n",
|
|
||||||
"author": "zach rice",
|
|
||||||
"email": "zricer@protonmail.com",
|
|
||||||
"file": "server.test.py",
|
|
||||||
"date": "2019-10-24T10:03:38-04:00",
|
|
||||||
"tags": "",
|
|
||||||
"operation": "addition"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||||
"lineNumber": 5,
|
"lineNumber": 5,
|
||||||
@@ -28,20 +13,5 @@
|
|||||||
"date": "2019-10-24T09:29:27-04:00",
|
"date": "2019-10-24T09:29:27-04:00",
|
||||||
"tags": "key, AWS",
|
"tags": "key, AWS",
|
||||||
"operation": "addition"
|
"operation": "addition"
|
||||||
},
|
|
||||||
{
|
|
||||||
"line": "N/A",
|
|
||||||
"lineNumber": -1,
|
|
||||||
"offender": "Filename/path offender: server.test.py",
|
|
||||||
"commit": "6557c92612d3b35979bd426d429255b3bf9fab74",
|
|
||||||
"repo": "test_repo_1",
|
|
||||||
"rule": "Python files",
|
|
||||||
"commitMessage": "commit 1 with secrets\n",
|
|
||||||
"author": "zach rice",
|
|
||||||
"email": "zricer@protonmail.com",
|
|
||||||
"file": "server.test.py",
|
|
||||||
"date": "2019-10-24T09:29:27-04:00",
|
|
||||||
"tags": "",
|
|
||||||
"operation": "addition"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
Reference in new issue
Block a user