This commit is contained in:
zach rice committed 2019-04-13 13:12:58 -05:00
1 parent 7bd55e33b5
commit c4da547503
6 files changed
+68 -63

No files matched your search

-3
View File
@@ -77,12 +77,9 @@ Application Options:
--owner-path= Path to owner directory (repos discovered) --owner-path= Path to owner directory (repos discovered)
--threads= Maximum number of threads gitleaks spawns --threads= Maximum number of threads gitleaks spawns
--disk Clones repo(s) to disk --disk Clones repo(s) to disk
--single-search= single regular expression to search for
--config= path to gitleaks config --config= path to gitleaks config
--ssh-key= path to ssh key --ssh-key= path to ssh key
--exclude-forks exclude forks for organization/user audits --exclude-forks exclude forks for organization/user audits
-e, --entropy= Include entropy checks during audit. Entropy scale: 0.0(no entropy) - 8.0(max entropy)
--noise-reduction Reduce the number of finds when entropy checks are enabled
--repo-config Load config from target repo. Config file must be ".gitleaks.toml" --repo-config Load config from target repo. Config file must be ".gitleaks.toml"
--branch= Branch to audit --branch= Branch to audit
-l, --log= log level -l, --log= log level
+59 -26
View File
@@ -1,39 +1,72 @@
title = "gitleaks config" title = "sample gitleaks config"
[[regexes]]
description = "AWS" # This is a sample config file for gitleaks. You can configure gitleaks what to search for and what to whitelist.
# The output you are seeing here is the default gitleaks config. If GITLEAKS_CONFIG environment variable
# is set, gitleaks will load configurations from that path. If option --config-path is set, gitleaks will load
# configurations from that path. Gitleaks does not whitelist anything by default.
[[rules]]
description = "AWS Key"
regex = '''AKIA[0-9A-Z]{16}''' regex = '''AKIA[0-9A-Z]{16}'''
[[regexes]] tags = ["key", "AWS"]
description = "RKCS8"
[[rules]]
description = "PKCS8"
regex = '''-----BEGIN PRIVATE KEY-----''' regex = '''-----BEGIN PRIVATE KEY-----'''
[[regexes]] tags = ["key", "PKCS8"]
[[rules]]
description = "RSA" description = "RSA"
regex = '''-----BEGIN RSA PRIVATE KEY-----''' regex = '''-----BEGIN RSA PRIVATE KEY-----'''
[[regexes]] tags = ["key", "RSA"]
description = "Github"
regex = '''(?i)github.*['\"][0-9a-zA-Z]{35,40}['\"]''' [[rules]]
[[regexes]]
description = "SSH" description = "SSH"
regex = '''-----BEGIN OPENSSH PRIVATE KEY-----''' regex = '''-----BEGIN OPENSSH PRIVATE KEY-----'''
[[regexes]] tags = ["key", "SSH"]
description = "Facebook"
regex = '''(?i)facebook.*['\"][0-9a-f]{32}['\"]''' [[rules]]
[[regexes]]
description = "Twitter"
regex = '''(?i)twitter.*['\"][0-9a-zA-Z]{35,44}['\"]'''
[[regexes]]
description = "PGP" description = "PGP"
regex = '''-----BEGIN PGP PRIVATE KEY BLOCK-----''' regex = '''-----BEGIN PGP PRIVATE KEY BLOCK-----'''
[[regexes]] tags = ["key", "PGP"]
description = "Slack token"
regex = '''xox[baprs]-.*''' [[rules]]
[[regexes]] description = "Facebook"
description = "Strip API Key" regex = '''(?i)facebook(.{0,4})?['\"][0-9a-f]{32}['\"]'''
regex = '''(?i)(sk|pk)_(test|live)_[0-9a-zA-Z]{10,32}''' tags = ["key", "Facebook"]
[[rules]]
description = "Twitter"
regex = '''(?i)twitter(.{0,4})?['\"][0-9a-zA-Z]{35,44}['\"]'''
tags = ["key", "Twitter"]
[[rules]]
description = "Github"
regex = '''(?i)github(.{0,4})?['\"][0-9a-zA-Z]{35,40}['\"]'''
tags = ["key", "Github"]
[[rules]]
description = "Slack"
regex = '''xox[baprs]-([0-9a-zA-Z]{10,48})?'''
tags = ["key", "Slack"]
[whitelist] [whitelist]
regexes = [
# "AKIA.*EXAMPLE",
]
files = [ files = [
"(.*?)(jpg|gif|doc|pdf|bin)$" "(.*?)(jpg|gif|doc|pdf|bin)$"
] ]
#commits = [
# "whitelisted-commit1",
# "whitelisted-commit2",
#]
#repos = [
# "whitelisted-repo"
#]
# Additional Examples
# [[rules]]
# description = "Generic Key"
# regex = '''(?i)key(.{0,6})?(:|=|=>|:=)'''
# entropies = ["4.1-4.3"]
# entropyROI = "line"
# tags = ["key"]
Binary file not shown.
-16
View File
@@ -124,22 +124,6 @@ func (config *Config) update(tomlConfig TomlConfig) error {
config.Rules = append(config.Rules, r) config.Rules = append(config.Rules, r)
} }
// // set stand alone rules from opts
// if opts.Entropy != 0.0 {
// ranges, err := getEntropyRanges([]string{fmt.Sprintf("0.0-%s", opts.Entropy)})
// if err != nil {
// log.Fatalf("could not create entropy range for %s", opts.Entropy)
// }
// r := &Rule{
// description: "Entropy ",
// severity: "5",
// tags: []string{"entropy"},
// entropies: ranges,
// entropyROI:
// }
// config.Rules = append(config.Rules, r)
// }
// set whitelists // set whitelists
config.WhiteList.commits = make(map[string]bool) config.WhiteList.commits = make(map[string]bool)
for _, commit := range tomlConfig.Whitelist.Commits { for _, commit := range tomlConfig.Whitelist.Commits {
+7 -16
View File
@@ -4,7 +4,11 @@ const version = "2.0.0"
const defaultGithubURL = "https://api.github.com/" const defaultGithubURL = "https://api.github.com/"
const defaultThreadNum = 1 const defaultThreadNum = 1
// ErrExit used to signal an error during gitleaks execution
const ErrExit = 2 const ErrExit = 2
// LeakExit used to signal leaks present in audit
const LeakExit = 1 const LeakExit = 1
const defaultConfig = ` const defaultConfig = `
@@ -14,14 +18,6 @@ const defaultConfig = `
# configurations from that path. Gitleaks does not whitelist anything by default. # configurations from that path. Gitleaks does not whitelist anything by default.
title = "gitleaks config" title = "gitleaks config"
# add rules to the rule table
# [[rules]]
# description = "Generic Key"
# regex = '''(?i)key(.{0,6})?(:|=|=>|:=)'''
# entropies = ["4.1-4.3"]
# entropyROI = "line"
# tags = ["key"]
[[rules]] [[rules]]
description = "AWS Key" description = "AWS Key"
regex = '''AKIA[0-9A-Z]{16}''' regex = '''AKIA[0-9A-Z]{16}'''
@@ -72,15 +68,10 @@ files = [
"(.*?)(jpg|gif|doc|pdf|bin)$" "(.*?)(jpg|gif|doc|pdf|bin)$"
] ]
#commits = [ #commits = [
# "BADHA5H1", # "whitelisted-commit1",
# "BADHA5H2", # "whitelisted-commit2",
#] #]
#repos = [ #repos = [
# "mygoodrepo" # "whitelisted-repo"
#]
[misc]
#entropy = [
# "3.3-4.30"
# "6.0-8.0
#] #]
` `
+2 -2
View File
@@ -41,9 +41,9 @@ func writeReport(leaks []Leak) error {
} }
defer f.Close() defer f.Close()
w := csv.NewWriter(f) w := csv.NewWriter(f)
w.Write([]string{"repo", "line", "commit", "offender", "reason", "commitMsg", "author", "email", "file", "date"}) w.Write([]string{"repo", "line", "commit", "offender", "rule", "info", "tags", "commitMsg", "author", "email", "file", "date"})
for _, leak := range leaks { for _, leak := range leaks {
w.Write([]string{leak.Repo, leak.Line, leak.Commit, leak.Offender, leak.Rule, leak.Message, leak.Author, leak.Email, leak.File, leak.Date.Format(time.RFC3339)}) w.Write([]string{leak.Repo, leak.Line, leak.Commit, leak.Offender, leak.Rule, leak.Info, leak.Tags, leak.Message, leak.Author, leak.Email, leak.File, leak.Date.Format(time.RFC3339)})
} }
w.Flush() w.Flush()
} else { } else {