Use allowlist (#411)

This commit is contained in:
Zachary Rice authored and GitHub committed 2020-07-24 11:58:43 -04:00
1 parent fe69a17c9c
commit 94f5950d68
21 files changed
+111 -111

No files matched your search

+27 -27
View File
@@ -11,9 +11,9 @@ import (
"github.com/BurntSushi/toml" "github.com/BurntSushi/toml"
) )
// Whitelist is struct containing items that if encountered will whitelist // 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 Whitelist struct { type Allowlist struct {
Description string Description string
Regex *regexp.Regexp Regex *regexp.Regexp
File *regexp.Regexp File *regexp.Regexp
@@ -30,7 +30,7 @@ type Entropy struct {
// Rule is a struct that contains information that is loaded from a gitleaks config. // Rule is a struct that contains information that is loaded from a gitleaks config.
// This struct is used in the Config struct as an array of Rules and is iterated // This struct is used in the Config struct as an array of Rules and is iterated
// over during an scan. Each rule will be checked. If a regex match is found AND // over during an scan. Each rule will be checked. If a regex match is found AND
// that match is not whitelisted (globally or locally), then a leak will be appended // that match is not allowlisted (globally or locally), then a leak will be appended
// to the final scan report. // to the final scan report.
type Rule struct { type Rule struct {
Description string Description string
@@ -38,15 +38,15 @@ type Rule struct {
FileNameRegex *regexp.Regexp FileNameRegex *regexp.Regexp
FilePathRegex *regexp.Regexp FilePathRegex *regexp.Regexp
Tags []string Tags []string
Whitelist []Whitelist Allowlist []Allowlist
Entropies []Entropy Entropies []Entropy
} }
// Config is a composite struct of Rules and Whitelists // Config is a composite struct of Rules and Allowlists
// Each Rule contains a description, regular expression, tags, and whitelists if available // Each Rule contains a description, regular expression, tags, and allowlists if available
type Config struct { type Config struct {
Rules []Rule Rules []Rule
Whitelist struct { Allowlist struct {
Description string Description string
Commits []string Commits []string
Files []*regexp.Regexp Files []*regexp.Regexp
@@ -59,7 +59,7 @@ type Config struct {
// see the config in config/defaults.go for an example. TomlLoader is used // see the config in config/defaults.go for an example. TomlLoader is used
// to generate Config values (compiling regexes, etc). // to generate Config values (compiling regexes, etc).
type TomlLoader struct { type TomlLoader struct {
Whitelist struct { Allowlist struct {
Description string Description string
Commits []string Commits []string
Files []string Files []string
@@ -77,7 +77,7 @@ type TomlLoader struct {
Max string Max string
Group string Group string
} }
Whitelist []struct { Allowlist []struct {
Description string Description string
Regex string Regex string
File string File string
@@ -97,8 +97,8 @@ func NewConfig(options options.Options) (Config, error) {
var err error var err error
if options.Config != "" { if options.Config != "" {
_, err = toml.DecodeFile(options.Config, &tomlLoader) _, err = toml.DecodeFile(options.Config, &tomlLoader)
// append a whitelist rule for whitelisting the config // append a allowlist rule for allowlisting the config
tomlLoader.Whitelist.Files = append(tomlLoader.Whitelist.Files, path.Base(options.Config)) tomlLoader.Allowlist.Files = append(tomlLoader.Allowlist.Files, path.Base(options.Config))
} else { } else {
_, err = toml.Decode(DefaultConfig, &tomlLoader) _, err = toml.Decode(DefaultConfig, &tomlLoader)
} }
@@ -132,9 +132,9 @@ func (tomlLoader TomlLoader) Parse() (Config, error) {
return cfg, fmt.Errorf("problem loading config: %v", err) return cfg, fmt.Errorf("problem loading config: %v", err)
} }
// rule specific whitelists // rule specific allowlists
var whitelists []Whitelist var allowlists []Allowlist
for _, wl := range rule.Whitelist { for _, wl := range rule.Allowlist {
wlRe, err := regexp.Compile(wl.Regex) wlRe, err := regexp.Compile(wl.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)
@@ -147,7 +147,7 @@ func (tomlLoader TomlLoader) Parse() (Config, error) {
if err != nil { if err != nil {
return cfg, fmt.Errorf("problem loading config: %v", err) return cfg, fmt.Errorf("problem loading config: %v", err)
} }
whitelists = append(whitelists, Whitelist{ allowlists = append(allowlists, Allowlist{
Description: wl.Description, Description: wl.Description,
File: wlFileNameRe, File: wlFileNameRe,
Path: wlFilePathRe, Path: wlFilePathRe,
@@ -190,40 +190,40 @@ func (tomlLoader TomlLoader) Parse() (Config, error) {
FileNameRegex: fileNameRe, FileNameRegex: fileNameRe,
FilePathRegex: filePathRe, FilePathRegex: filePathRe,
Tags: rule.Tags, Tags: rule.Tags,
Whitelist: whitelists, Allowlist: allowlists,
Entropies: entropies, Entropies: entropies,
}) })
} }
// global file name whitelists // global file name allowlists
for _, wlFileName := range tomlLoader.Whitelist.Files { for _, wlFileName := range tomlLoader.Allowlist.Files {
re, err := regexp.Compile(wlFileName) re, err := regexp.Compile(wlFileName)
if err != nil { if err != nil {
return cfg, fmt.Errorf("problem loading config: %v", err) return cfg, fmt.Errorf("problem loading config: %v", err)
} }
cfg.Whitelist.Files = append(cfg.Whitelist.Files, re) cfg.Allowlist.Files = append(cfg.Allowlist.Files, re)
} }
// global file path whitelists // global file path allowlists
for _, wlFilePath := range tomlLoader.Whitelist.Paths { for _, wlFilePath := range tomlLoader.Allowlist.Paths {
re, err := regexp.Compile(wlFilePath) re, err := regexp.Compile(wlFilePath)
if err != nil { if err != nil {
return cfg, fmt.Errorf("problem loading config: %v", err) return cfg, fmt.Errorf("problem loading config: %v", err)
} }
cfg.Whitelist.Paths = append(cfg.Whitelist.Paths, re) cfg.Allowlist.Paths = append(cfg.Allowlist.Paths, re)
} }
// global repo whitelists // global repo allowlists
for _, wlRepo := range tomlLoader.Whitelist.Repos { for _, wlRepo := range tomlLoader.Allowlist.Repos {
re, err := regexp.Compile(wlRepo) re, err := regexp.Compile(wlRepo)
if err != nil { if err != nil {
return cfg, fmt.Errorf("problem loading config: %v", err) return cfg, fmt.Errorf("problem loading config: %v", err)
} }
cfg.Whitelist.Repos = append(cfg.Whitelist.Repos, re) cfg.Allowlist.Repos = append(cfg.Allowlist.Repos, re)
} }
cfg.Whitelist.Commits = tomlLoader.Whitelist.Commits cfg.Allowlist.Commits = tomlLoader.Allowlist.Commits
cfg.Whitelist.Description = tomlLoader.Whitelist.Description cfg.Allowlist.Description = tomlLoader.Allowlist.Description
return cfg, nil return cfg, nil
} }
+3 -3
View File
@@ -15,7 +15,7 @@ func TestParse(t *testing.T) {
wantErr error wantErr error
wantFileRegex *regexp.Regexp wantFileRegex *regexp.Regexp
wantMessages *regexp.Regexp wantMessages *regexp.Regexp
wantWhitelist Whitelist wantAllowlist Allowlist
}{ }{
{ {
description: "default config", description: "default config",
@@ -42,9 +42,9 @@ func TestParse(t *testing.T) {
wantErr: fmt.Errorf("problem loading config: error parsing regexp: invalid nested repetition operator: `???`"), wantErr: fmt.Errorf("problem loading config: error parsing regexp: invalid nested repetition operator: `???`"),
}, },
{ {
description: "test bad global whitelist file regex", description: "test bad global allowlist file regex",
opts: options.Options{ opts: options.Options{
Config: "../test_data/test_configs/bad_aws_key_global_whitelist_file.toml", Config: "../test_data/test_configs/bad_aws_key_global_allowlist_file.toml",
}, },
wantErr: fmt.Errorf("problem loading config: error parsing regexp: missing argument to repetition operator: `??`"), wantErr: fmt.Errorf("problem loading config: error parsing regexp: missing argument to repetition operator: `??`"),
}, },
+2 -2
View File
@@ -131,8 +131,8 @@ title = "gitleaks config"
regex = '''(?i)twilio(.{0,20})?SK[0-9a-f]{32}''' regex = '''(?i)twilio(.{0,20})?SK[0-9a-f]{32}'''
tags = ["key", "twilio"] tags = ["key", "twilio"]
[whitelist] [allowlist]
description = "Whitelisted files" description = "Allowlisted files"
files = ['''^\.?gitleaks.toml$''', files = ['''^\.?gitleaks.toml$''',
'''(.*?)(jpg|gif|doc|pdf|bin)$''', '''(.*?)(jpg|gif|doc|pdf|bin)$''',
'''(go.mod|go.sum)$'''] '''(go.mod|go.sum)$''']
+8 -8
View File
@@ -129,7 +129,7 @@ title = "gitleaks config"
[[rules]] [[rules]]
description = "Port" description = "Port"
regex = '''(?i)port(.{0,4})?[0-9]{1,10}''' regex = '''(?i)port(.{0,4})?[0-9]{1,10}'''
[[rules.whitelist]] [[rules.allowlist]]
regex = '''(?i)port ''' regex = '''(?i)port '''
description = "ignore export " description = "ignore export "
@@ -139,7 +139,7 @@ title = "gitleaks config"
description = "Email" description = "Email"
regex = '''[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}''' regex = '''[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}'''
tags = ["email"] tags = ["email"]
[[rules.whitelist]] [[rules.allowlist]]
file = '''(?i)bashrc''' file = '''(?i)bashrc'''
description = "ignore bashrc emails" description = "ignore bashrc emails"
@@ -149,13 +149,13 @@ title = "gitleaks config"
regex = '''(?i)(dbpasswd|dbuser|dbname|dbhost|api_key|apikey|secret|key|api|password|user|guid|hostname|pw|auth)(.{0,20})?['|"]([0-9a-zA-Z-_\/+!{}/=]{4,120})['|"]''' regex = '''(?i)(dbpasswd|dbuser|dbname|dbhost|api_key|apikey|secret|key|api|password|user|guid|hostname|pw|auth)(.{0,20})?['|"]([0-9a-zA-Z-_\/+!{}/=]{4,120})['|"]'''
tags = ["key", "API", "generic"] tags = ["key", "API", "generic"]
# ignore leaks with specific identifiers like slack and aws # ignore leaks with specific identifiers like slack and aws
[[rules.whitelist]] [[rules.allowlist]]
regex = '''xox[baprs]-([0-9a-zA-Z]{10,48})''' regex = '''xox[baprs]-([0-9a-zA-Z]{10,48})'''
description = "ignore slack" description = "ignore slack"
[[rules.whitelist]] [[rules.allowlist]]
description = "MailChimp API key" description = "MailChimp API key"
regex = '''(?i)(.{0,20})?['"][0-9a-f]{32}-us[0-9]{1,2}['"]''' regex = '''(?i)(.{0,20})?['"][0-9a-f]{32}-us[0-9]{1,2}['"]'''
[[rules.whitelist]] [[rules.allowlist]]
description = "AWS Manager ID" description = "AWS Manager ID"
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}'''
@@ -172,7 +172,7 @@ title = "gitleaks config"
[[rules.Entropies]] [[rules.Entropies]]
Min = "4.3" Min = "4.3"
Max = "7.0" Max = "7.0"
[[rules.whitelist]] [[rules.allowlist]]
description = "ignore ssh key and pems" description = "ignore ssh key and pems"
file = '''(pem|ppk|env)$''' file = '''(pem|ppk|env)$'''
path = '''(.*)?ssh''' path = '''(.*)?ssh'''
@@ -197,7 +197,7 @@ title = "gitleaks config"
description = "Files with keys and credentials" description = "Files with keys and credentials"
fileNameRegex = '''(?i)(id_rsa|passwd|id_rsa.pub|pgpass|pem|key|shadow)''' fileNameRegex = '''(?i)(id_rsa|passwd|id_rsa.pub|pgpass|pem|key|shadow)'''
[whitelist] [allowlist]
description = "image whitelists" description = "image allowlists"
files = ['''(.*?)(jpg|gif|doc|pdf|bin)$'''] files = ['''(.*?)(jpg|gif|doc|pdf|bin)$''']
@@ -1,13 +1,13 @@
# This config contains a single rule that checks for AWS keys. However, it also contains a whitelist table # This config contains a single rule that checks for AWS keys. However, it also contains a allowlist table
# where you can define one or more whitelists. What this means is that if you have an example AWS key as part of your # where you can define one or more allowlists. What this means is that if you have an example AWS key as part of your
# code (in a test for example), then you can whitelist that specific key so gitleaks will not label it as a leak. # code (in a test for example), then you can allowlist that specific key so gitleaks will not label it as a leak.
# If this line was present in a git history: `aws_access_key_id='AKIAIO5FODNN7EXAMPLE``, gitleaks would match this line # If this line was present in a git history: `aws_access_key_id='AKIAIO5FODNN7EXAMPLE``, gitleaks would match this line
# with the rule below, but since we have a whitelist against that specific key, it would be ignored. # with the rule below, but since we have a allowlist against that specific key, it would be ignored.
[[rules]] [[rules]]
description = "AWS Manager ID" description = "AWS Manager ID"
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"]
[[rules.whitelist]] [[rules.allowlist]]
regex = '''AKIAIO5FODNN7EXAMPLE.*''' regex = '''AKIAIO5FODNN7EXAMPLE.*'''
description = "ignore example aws key" description = "ignore example aws key"
+2 -2
View File
@@ -76,8 +76,8 @@ func Run(m *manager.Manager) error {
} }
func runHelper(r *Repo) error { func runHelper(r *Repo) error {
// Ignore whitelisted repos // Ignore allowlisted repos
for _, wlRepo := range r.Manager.Config.Whitelist.Repos { for _, wlRepo := range r.Manager.Config.Allowlist.Repos {
if RegexMatched(r.Manager.Opts.RepoPath, wlRepo) { if RegexMatched(r.Manager.Opts.RepoPath, wlRepo) {
return nil return nil
} }
+22 -22
View File
@@ -34,21 +34,21 @@ func (repo *Repo) CheckRules(bundle *Bundle) {
bundle.lineLookup = make(map[string]bool) bundle.lineLookup = make(map[string]bool)
// We want to check if there is a whitelist for this file // We want to check if there is a allowlist for this file
if len(repo.config.Whitelist.Files) != 0 { if len(repo.config.Allowlist.Files) != 0 {
for _, reFileName := range repo.config.Whitelist.Files { for _, reFileName := range repo.config.Allowlist.Files {
if RegexMatched(filename, reFileName) { if RegexMatched(filename, reFileName) {
log.Debugf("whitelisted file found, skipping scan of file: %s", filename) log.Debugf("allowlisted file found, skipping scan of file: %s", filename)
return return
} }
} }
} }
// We want to check if there is a whitelist for this path // We want to check if there is a allowlist for this path
if len(repo.config.Whitelist.Paths) != 0 { if len(repo.config.Allowlist.Paths) != 0 {
for _, reFilePath := range repo.config.Whitelist.Paths { for _, reFilePath := range repo.config.Allowlist.Paths {
if RegexMatched(path, reFilePath) { if RegexMatched(path, reFilePath) {
log.Debugf("file in whitelisted path found, skipping scan of file: %s", filename) log.Debugf("file in allowlisted path found, skipping scan of file: %s", filename)
return return
} }
} }
@@ -57,8 +57,8 @@ func (repo *Repo) CheckRules(bundle *Bundle) {
for _, rule := range repo.config.Rules { for _, rule := range repo.config.Rules {
start := time.Now() start := time.Now()
// For each rule we want to check filename whitelists // For each rule we want to check filename allowlists
if isFileNameWhiteListed(filename, rule.Whitelist) || isFilePathWhiteListed(path, rule.Whitelist) { if isFileNameWhiteListed(filename, rule.Allowlist) || isFilePathWhiteListed(path, rule.Allowlist) {
continue continue
} }
@@ -112,7 +112,7 @@ func (repo *Repo) CheckRules(bundle *Bundle) {
offender := bundle.Content[loc[0]:loc[1]] offender := bundle.Content[loc[0]:loc[1]]
groups := rule.Regex.FindStringSubmatch(offender) groups := rule.Regex.FindStringSubmatch(offender)
if isOffenderWhiteListed(offender, rule.Whitelist) { if isOffenderWhiteListed(offender, rule.Allowlist) {
continue continue
} }
@@ -352,8 +352,8 @@ func ruleContainFilePathRegex(rule config.Rule) bool {
return true return true
} }
func isCommitWhiteListed(commitHash string, whitelistedCommits []string) bool { func isCommitWhiteListed(commitHash string, allowlistedCommits []string) bool {
for _, hash := range whitelistedCommits { for _, hash := range allowlistedCommits {
if commitHash == hash { if commitHash == hash {
return true return true
} }
@@ -361,9 +361,9 @@ func isCommitWhiteListed(commitHash string, whitelistedCommits []string) bool {
return false return false
} }
func isOffenderWhiteListed(offender string, whitelist []config.Whitelist) bool { func isOffenderWhiteListed(offender string, allowlist []config.Allowlist) bool {
if len(whitelist) != 0 { if len(allowlist) != 0 {
for _, wl := range whitelist { for _, wl := range allowlist {
if wl.Regex.FindString(offender) != "" { if wl.Regex.FindString(offender) != "" {
return true return true
} }
@@ -372,9 +372,9 @@ func isOffenderWhiteListed(offender string, whitelist []config.Whitelist) bool {
return false return false
} }
func isFileNameWhiteListed(filename string, whitelist []config.Whitelist) bool { func isFileNameWhiteListed(filename string, allowlist []config.Allowlist) bool {
if len(whitelist) != 0 { if len(allowlist) != 0 {
for _, wl := range whitelist { for _, wl := range allowlist {
if RegexMatched(filename, wl.File) { if RegexMatched(filename, wl.File) {
return true return true
} }
@@ -383,9 +383,9 @@ func isFileNameWhiteListed(filename string, whitelist []config.Whitelist) bool {
return false return false
} }
func isFilePathWhiteListed(filepath string, whitelist []config.Whitelist) bool { func isFilePathWhiteListed(filepath string, allowlist []config.Allowlist) bool {
if len(whitelist) != 0 { if len(allowlist) != 0 {
for _, wl := range whitelist { for _, wl := range allowlist {
if RegexMatched(filepath, wl.Path) { if RegexMatched(filepath, wl.Path) {
return true return true
} }
+5 -5
View File
@@ -95,8 +95,8 @@ func (repo *Repo) Scan() error {
return storer.ErrStop return storer.ErrStop
} }
// Check if Commit is whitelisted // Check if Commit is allowlisted
if isCommitWhiteListed(c.Hash.String(), repo.config.Whitelist.Commits) { if isCommitWhiteListed(c.Hash.String(), repo.config.Allowlist.Commits) {
return nil return nil
} }
@@ -301,7 +301,7 @@ func (repo *Repo) scanUncommitted() error {
// scan accepts a Patch, Commit, and repo. If the patches contains files that are // scan accepts a Patch, Commit, and repo. If the patches contains files that are
// binary, then gitleaks will skip scanning that file OR if a file is matched on // binary, then gitleaks will skip scanning that file OR if a file is matched on
// whitelisted files set in the configuration. If a global rule for files is defined and a filename // allowlisted files set in the configuration. If a global rule for files is defined and a filename
// matches said global rule, then a leak is sent to the manager. // matches said global rule, then a leak is sent to the manager.
// After that, file chunks are created which are then inspected by InspectString() // After that, file chunks are created which are then inspected by InspectString()
func scanPatch(patch *object.Patch, c *object.Commit, repo *Repo) { func scanPatch(patch *object.Patch, c *object.Commit, repo *Repo) {
@@ -360,7 +360,7 @@ func scanCommit(commit string, repo *Repo, f commitScanner) error {
// scanCommitPatches accepts a Commit object and a repo. This function is only called when the --Commit= // scanCommitPatches accepts a Commit object and a repo. This function is only called when the --Commit=
// option has been set. That option tells gitleaks to look only at a single Commit and check the contents // option has been set. That option tells gitleaks to look only at a single Commit and check the contents
// of said Commit. Similar to scan(), if the files contained in the Commit are a binaries or if they are // of said Commit. Similar to scan(), if the files contained in the Commit are a binaries or if they are
// whitelisted then those files will be skipped. // allowlisted then those files will be skipped.
func scanCommitPatches(c *object.Commit, repo *Repo) error { func scanCommitPatches(c *object.Commit, repo *Repo) error {
if len(c.ParentHashes) == 0 { if len(c.ParentHashes) == 0 {
err := scanFilesAtCommit(c, repo) err := scanFilesAtCommit(c, repo)
@@ -400,7 +400,7 @@ func scanCommitPatches(c *object.Commit, repo *Repo) error {
// scanFilesAtCommit accepts a Commit object and a repo. This function is only called when the --files-at-Commit= // scanFilesAtCommit accepts a Commit object and a repo. This function is only called when the --files-at-Commit=
// option has been set. That option tells gitleaks to look only at ALL the files at a Commit and check the contents // option has been set. That option tells gitleaks to look only at ALL the files at a Commit and check the contents
// of said Commit. Similar to scan(), if the files contained in the Commit are a binaries or if they are // of said Commit. Similar to scan(), if the files contained in the Commit are a binaries or if they are
// whitelisted then those files will be skipped. // allowlisted then those files will be skipped.
func scanFilesAtCommit(c *object.Commit, repo *Repo) error { func scanFilesAtCommit(c *object.Commit, repo *Repo) error {
fIter, err := c.Files() fIter, err := c.Files()
if err != nil { if err != nil {
+20 -20
View File
@@ -58,11 +58,11 @@ func TestScan(t *testing.T) {
emptyRepo: true, emptyRepo: true,
}, },
{ {
description: "test local repo one aws leak whitelisted", description: "test local repo one aws leak allowlisted",
opts: options.Options{ opts: options.Options{
RepoPath: "../test_data/test_repos/test_repo_1", RepoPath: "../test_data/test_repos/test_repo_1",
ReportFormat: "json", ReportFormat: "json",
Config: "../test_data/test_configs/aws_key_whitelist_python_files.toml", Config: "../test_data/test_configs/aws_key_allowlist_python_files.toml",
}, },
wantEmpty: true, wantEmpty: true,
}, },
@@ -107,19 +107,19 @@ func TestScan(t *testing.T) {
wantPath: "../test_data/test_local_repo_two_leaks_commit_range.json", wantPath: "../test_data/test_local_repo_two_leaks_commit_range.json",
}, },
{ {
description: "test local repo two leaks globally whitelisted", description: "test local repo two leaks globally allowlisted",
opts: options.Options{ opts: options.Options{
RepoPath: "../test_data/test_repos/test_repo_2", RepoPath: "../test_data/test_repos/test_repo_2",
Config: "../test_data/test_configs/aws_key_global_whitelist_file.toml", Config: "../test_data/test_configs/aws_key_global_allowlist_file.toml",
ReportFormat: "json", ReportFormat: "json",
}, },
wantEmpty: true, wantEmpty: true,
}, },
{ {
description: "test local repo two leaks whitelisted", description: "test local repo two leaks allowlisted",
opts: options.Options{ opts: options.Options{
RepoPath: "../test_data/test_repos/test_repo_2", RepoPath: "../test_data/test_repos/test_repo_2",
Config: "../test_data/test_configs/aws_key_whitelist_files.toml", Config: "../test_data/test_configs/aws_key_allowlist_files.toml",
ReportFormat: "json", ReportFormat: "json",
}, },
wantEmpty: true, wantEmpty: true,
@@ -174,14 +174,14 @@ func TestScan(t *testing.T) {
wantPath: "../test_data/test_local_owner_aws_leak.json", wantPath: "../test_data/test_local_owner_aws_leak.json",
}, },
{ {
description: "test owner path whitelist repo", description: "test owner path allowlist repo",
opts: options.Options{ opts: options.Options{
OwnerPath: "../test_data/test_repos/", OwnerPath: "../test_data/test_repos/",
Report: "../test_data/test_local_owner_aws_leak_whitelist_repo.json.got", Report: "../test_data/test_local_owner_aws_leak_allowlist_repo.json.got",
ReportFormat: "json", ReportFormat: "json",
Config: "../test_data/test_configs/aws_key_local_owner_whitelist_repo.toml", Config: "../test_data/test_configs/aws_key_local_owner_allowlist_repo.toml",
}, },
wantPath: "../test_data/test_local_owner_aws_leak_whitelist_repo.json", wantPath: "../test_data/test_local_owner_aws_leak_allowlist_repo.json",
}, },
{ {
description: "test entropy and regex", description: "test entropy and regex",
@@ -207,8 +207,8 @@ func TestScan(t *testing.T) {
description: "test local repo four entropy alternative config", description: "test local repo four entropy alternative config",
opts: options.Options{ opts: options.Options{
RepoPath: "../test_data/test_repos/test_repo_1", RepoPath: "../test_data/test_repos/test_repo_1",
Report: "../test_data/test_regex_whitelist.json.got", Report: "../test_data/test_regex_allowlist.json.got",
Config: "../test_data/test_configs/aws_key_aws_whitelisted.toml", Config: "../test_data/test_configs/aws_key_aws_allowlisted.toml",
ReportFormat: "json", ReportFormat: "json",
}, },
wantEmpty: true, wantEmpty: true,
@@ -316,14 +316,14 @@ func TestScan(t *testing.T) {
wantPath: "../test_data/test_local_repo_six_filepath_filename.json", wantPath: "../test_data/test_local_repo_six_filepath_filename.json",
}, },
{ {
description: "test local repo six path globally whitelisted", description: "test local repo six path globally allowlisted",
opts: options.Options{ opts: options.Options{
RepoPath: "../test_data/test_repos/test_repo_6", RepoPath: "../test_data/test_repos/test_repo_6",
Report: "../test_data/test_local_repo_six_path_globally_whitelisted.json.got", Report: "../test_data/test_local_repo_six_path_globally_allowlisted.json.got",
Config: "../test_data/test_configs/aws_key_global_whitelist_path.toml", Config: "../test_data/test_configs/aws_key_global_allowlist_path.toml",
ReportFormat: "json", ReportFormat: "json",
}, },
wantPath: "../test_data/test_local_repo_six_path_globally_whitelisted.json", wantPath: "../test_data/test_local_repo_six_path_globally_allowlisted.json",
}, },
{ {
description: "test local repo six leaks since date", description: "test local repo six leaks since date",
@@ -357,14 +357,14 @@ func TestScan(t *testing.T) {
wantPath: "../test_data/test_local_repo_four_leaks_commit_timerange.json", wantPath: "../test_data/test_local_repo_four_leaks_commit_timerange.json",
}, },
{ {
description: "test local repo two whitelist Commit config", description: "test local repo two allowlist Commit config",
opts: options.Options{ opts: options.Options{
RepoPath: "../test_data/test_repos/test_repo_2", RepoPath: "../test_data/test_repos/test_repo_2",
Report: "../test_data/test_local_repo_two_whitelist_commits.json.got", Report: "../test_data/test_local_repo_two_allowlist_commits.json.got",
Config: "../test_data/test_configs/whitelist_commit.toml", Config: "../test_data/test_configs/allowlist_commit.toml",
ReportFormat: "json", ReportFormat: "json",
}, },
wantPath: "../test_data/test_local_repo_two_whitelist_commits.json", wantPath: "../test_data/test_local_repo_two_allowlist_commits.json",
}, },
{ {
description: "test local repo two deletion", description: "test local repo two deletion",
@@ -4,7 +4,7 @@
tags = ["key", "AWS"] tags = ["key", "AWS"]
[whitelist] [allowlist]
commits = [ commits = [
"b10b3e2cb320a8c211fda94c4567299d37de7776", "b10b3e2cb320a8c211fda94c4567299d37de7776",
"17471a5fda722a9e423f1a0d3f0d267ea009d41c", "17471a5fda722a9e423f1a0d3f0d267ea009d41c",
@@ -2,13 +2,13 @@
description = "AWS Manager ID" description = "AWS Manager ID"
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"]
[[rules.whitelist]] [[rules.allowlist]]
description = "ignore md files" description = "ignore md files"
file = '''(.*)?md$''' file = '''(.*)?md$'''
[[rules.whitelist]] [[rules.allowlist]]
description = "ignore this regex" description = "ignore this regex"
regex = '''ignore$''' regex = '''ignore$'''
[[rules.whitelist]] [[rules.allowlist]]
description = "ignore regex and md files" description = "ignore regex and md files"
regex = '''ignore$''' regex = '''ignore$'''
file = '''(.*)?md$''' file = '''(.*)?md$'''
@@ -2,6 +2,6 @@
description = "AWS Manager ID" description = "AWS Manager ID"
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"]
[[rules.whitelist]] [[rules.allowlist]]
description = "ignore python files" description = "ignore python files"
file = '''(.*)?py$''' file = '''(.*)?py$'''
@@ -2,6 +2,6 @@
description = "AWS Manager ID" description = "AWS Manager ID"
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"]
[[rules.whitelist]] [[rules.allowlist]]
regex = '''AKIAIO5FODNN7EXAMPLE.*''' regex = '''AKIAIO5FODNN7EXAMPLE.*'''
description = "ignore aws key" description = "ignore aws key"
@@ -3,7 +3,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"]
[whitelist] [allowlist]
description = "ignore md files" description = "ignore md files"
files = [ files = [
'''(.*)?md$''' '''(.*)?md$'''
@@ -3,7 +3,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"]
[whitelist] [allowlist]
description = "ignore config folders" description = "ignore config folders"
paths = [ paths = [
'''config(uration)?''' '''config(uration)?'''
@@ -2,8 +2,8 @@
description = "AWS Manager ID" description = "AWS Manager ID"
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"]
[whitelist] [allowlist]
description = "whitelist repo" description = "allowlist repo"
repos = [ repos = [
'''test_repo_1''' '''test_repo_1'''
] ]
@@ -3,6 +3,6 @@
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"]
[whitelist] [allowlist]
description = "ignore md files" description = "ignore md files"
files = ['''???????'''] files = ['''???????''']
+6 -6
View File
@@ -125,13 +125,13 @@ title = "gitleaks config"
description = "AWS Manager ID" description = "AWS Manager ID"
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"]
[[rules.whitelist]] [[rules.allowlist]]
description = "ignore common jenkins functions" description = "ignore common jenkins functions"
regex = '''whitelistme''' regex = '''allowlistme'''
file = '''(.*)?Jenkinsfile$''' file = '''(.*)?Jenkinsfile$'''
[[rules.whitelist]] [[rules.allowlist]]
description = "ignore common jenkins functions2" description = "ignore common jenkins functions2"
regex = '''whitelistme''' regex = '''allowlistme'''
file = '''(.*)?Jenkinsfile$''' file = '''(.*)?Jenkinsfile$'''
# Global rules. This instructs gitleaks to ignore all .pem files or if a message with # Global rules. This instructs gitleaks to ignore all .pem files or if a message with
@@ -139,8 +139,8 @@ title = "gitleaks config"
description = "Files with keys and credentials" description = "Files with keys and credentials"
fileRegex = '''(.*?)(pem)''' fileRegex = '''(.*?)(pem)'''
[whitelist] [allowlist]
description = "File whitelists" description = "File allowlists"
files = [ files = [
'''(.*?)(jpg|gif)$''', '''(.*?)(jpg|gif)$''',
'''(.*?)(doc|pdf|bin)$''' '''(.*?)(doc|pdf|bin)$'''