mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-28 20:24:22 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2acc34dfdf | ||
|
|
ede68fd95d | ||
|
|
6c60c3dde3 | ||
|
|
ad505754fc | ||
|
|
21d81879e2 | ||
|
|
b5ca2ba614 | ||
|
|
ef4655fcf1 | ||
|
|
01b553a75d | ||
|
|
fae366a404 | ||
|
|
6129b1a15d | ||
|
|
31d03a1146 |
No files matched your search
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
VERSION := `git fetch --tags && git tag | sort -V | tail -1`
|
VERSION := `git fetch --tags && git tag | sort -V | tail -1`
|
||||||
PKG=github.com/zricethezav/gitleaks
|
PKG=github.com/zricethezav/gitleaks
|
||||||
LDFLAGS=-ldflags "-X=github.com/zricethezav/gitleaks/v5/version.Version=$(VERSION)"
|
LDFLAGS=-ldflags "-X=github.com/zricethezav/gitleaks/v6/version.Version=$(VERSION)"
|
||||||
_LDFLAGS="github.com/zricethezav/gitleaks/v5/version.Version=$(VERSION)"
|
_LDFLAGS="github.com/zricethezav/gitleaks/v6/version.Version=$(VERSION)"
|
||||||
COVER=--cover --coverprofile=cover.out
|
COVER=--cover --coverprofile=cover.out
|
||||||
|
|
||||||
test-cover:
|
test-cover:
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ Gamma proactively detects and remediates data leaks across cloud apps. Scan your
|
|||||||
#### Individual Sponsors
|
#### Individual Sponsors
|
||||||
These users are [sponsors](https://github.com/sponsors/zricethezav) of gitleaks:
|
These users are [sponsors](https://github.com/sponsors/zricethezav) of gitleaks:
|
||||||
|
|
||||||
[](https://github.com/adamdecaf) | [](https://github.com/gramidt) |
|
[](https://github.com/adamdecaf) |
|
||||||
---|---|
|
---|
|
||||||
----
|
----
|
||||||
#### Logo Attribution
|
#### Logo Attribution
|
||||||
The Gitleaks logo uses the Git Logo created <a href="https://twitter.com/jasonlong">Jason Long</a> is licensed under the <a href="https://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution 3.0 Unported License</a>.
|
The Gitleaks logo uses the Git Logo created <a href="https://twitter.com/jasonlong">Jason Long</a> is licensed under the <a href="https://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution 3.0 Unported License</a>.
|
||||||
|
|||||||
+87
-72
@@ -6,19 +6,21 @@ import (
|
|||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/v5/options"
|
"github.com/zricethezav/gitleaks/v6/options"
|
||||||
|
|
||||||
"github.com/BurntSushi/toml"
|
"github.com/BurntSushi/toml"
|
||||||
log "github.com/sirupsen/logrus"
|
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
|
||||||
// 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 {
|
||||||
Description string
|
Description string
|
||||||
Regex *regexp.Regexp
|
Regexes []*regexp.Regexp
|
||||||
File *regexp.Regexp
|
Commits []string
|
||||||
Path *regexp.Regexp
|
Files []*regexp.Regexp
|
||||||
|
Paths []*regexp.Regexp
|
||||||
|
Repos []*regexp.Regexp
|
||||||
}
|
}
|
||||||
|
|
||||||
// Entropy represents an entropy range
|
// Entropy represents an entropy range
|
||||||
@@ -34,56 +36,52 @@ type Entropy struct {
|
|||||||
// that match is not allowlisted (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
|
||||||
Regex *regexp.Regexp
|
Regex *regexp.Regexp
|
||||||
FileNameRegex *regexp.Regexp
|
File *regexp.Regexp
|
||||||
FilePathRegex *regexp.Regexp
|
Path *regexp.Regexp
|
||||||
Tags []string
|
ReportGroup int
|
||||||
Allowlist []Allowlist
|
Tags []string
|
||||||
Entropies []Entropy
|
AllowList AllowList
|
||||||
|
Entropies []Entropy
|
||||||
}
|
}
|
||||||
|
|
||||||
// Config is a composite struct of Rules and Allowlists
|
// Config is a composite struct of Rules and Allowlists
|
||||||
// Each Rule contains a description, regular expression, tags, and allowlists if available
|
// Each Rule contains a description, regular expression, tags, and allowlists if available
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Rules []Rule
|
Rules []Rule
|
||||||
Allowlist struct {
|
Allowlist AllowList
|
||||||
Description string
|
}
|
||||||
Commits []string
|
|
||||||
Files []*regexp.Regexp
|
// TomlAllowList is a struct used in the TomlLoader that loads in allowlists from
|
||||||
Paths []*regexp.Regexp
|
// specific rules or globally at the top level config
|
||||||
Repos []*regexp.Regexp
|
type TomlAllowList struct {
|
||||||
}
|
Description string
|
||||||
|
Regexes []string
|
||||||
|
Commits []string
|
||||||
|
Files []string
|
||||||
|
Paths []string
|
||||||
|
Repos []string
|
||||||
}
|
}
|
||||||
|
|
||||||
// TomlLoader gets loaded with the values from a gitleaks toml config
|
// TomlLoader gets loaded with the values from a gitleaks toml config
|
||||||
// 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 {
|
||||||
Allowlist struct {
|
AllowList TomlAllowList
|
||||||
|
Rules []struct {
|
||||||
Description string
|
Description string
|
||||||
Commits []string
|
Regex string
|
||||||
Files []string
|
File string
|
||||||
Paths []string
|
Path string
|
||||||
Repos []string
|
ReportGroup int
|
||||||
}
|
Tags []string
|
||||||
Rules []struct {
|
Entropies []struct {
|
||||||
Description string
|
|
||||||
Regex string
|
|
||||||
FileNameRegex string
|
|
||||||
FilePathRegex string
|
|
||||||
Tags []string
|
|
||||||
Entropies []struct {
|
|
||||||
Min string
|
Min string
|
||||||
Max string
|
Max string
|
||||||
Group string
|
Group string
|
||||||
}
|
}
|
||||||
Allowlist []struct {
|
AllowList TomlAllowList
|
||||||
Description string
|
|
||||||
Regex string
|
|
||||||
File string
|
|
||||||
Path string
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,7 +97,7 @@ func NewConfig(options options.Options) (Config, error) {
|
|||||||
if options.Config != "" {
|
if options.Config != "" {
|
||||||
_, err = toml.DecodeFile(options.Config, &tomlLoader)
|
_, err = toml.DecodeFile(options.Config, &tomlLoader)
|
||||||
// append a allowlist rule for allowlisting the config
|
// append a allowlist rule for allowlisting the config
|
||||||
tomlLoader.Allowlist.Files = append(tomlLoader.Allowlist.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)
|
||||||
}
|
}
|
||||||
@@ -121,7 +119,7 @@ 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
|
// check and make sure the rule is valid
|
||||||
if rule.Regex == "" && rule.FilePathRegex == "" && rule.FileNameRegex == "" && len(rule.Entropies) == 0 {
|
if rule.Regex == "" && rule.Path == "" && rule.File == "" && len(rule.Entropies) == 0 {
|
||||||
log.Warnf("Rule %s does not define any actionable data", rule.Description)
|
log.Warnf("Rule %s does not define any actionable data", rule.Description)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -129,36 +127,43 @@ 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)
|
||||||
}
|
}
|
||||||
fileNameRe, err := regexp.Compile(rule.FileNameRegex)
|
fileNameRe, err := regexp.Compile(rule.File)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cfg, fmt.Errorf("problem loading config: %v", err)
|
return cfg, fmt.Errorf("problem loading config: %v", err)
|
||||||
}
|
}
|
||||||
filePathRe, err := regexp.Compile(rule.FilePathRegex)
|
filePathRe, err := regexp.Compile(rule.Path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cfg, fmt.Errorf("problem loading config: %v", err)
|
return cfg, fmt.Errorf("problem loading config: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// rule specific allowlists
|
// rule specific allowlists
|
||||||
var allowlists []Allowlist
|
var allowList AllowList
|
||||||
for _, wl := range rule.Allowlist {
|
|
||||||
wlRe, err := regexp.Compile(wl.Regex)
|
// rule specific regexes
|
||||||
|
for _, re := range rule.AllowList.Regexes {
|
||||||
|
allowListedRegex, err := regexp.Compile(re)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cfg, fmt.Errorf("problem loading config: %v", err)
|
return cfg, fmt.Errorf("problem loading config: %v", err)
|
||||||
}
|
}
|
||||||
wlFileNameRe, err := regexp.Compile(wl.File)
|
allowList.Regexes = append(allowList.Regexes, allowListedRegex)
|
||||||
|
}
|
||||||
|
|
||||||
|
// rule specific filenames
|
||||||
|
for _, re := range rule.AllowList.Files {
|
||||||
|
allowListedRegex, err := regexp.Compile(re)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cfg, fmt.Errorf("problem loading config: %v", err)
|
return cfg, fmt.Errorf("problem loading config: %v", err)
|
||||||
}
|
}
|
||||||
wlFilePathRe, err := regexp.Compile(wl.Path)
|
allowList.Files = append(allowList.Files, allowListedRegex)
|
||||||
|
}
|
||||||
|
|
||||||
|
// rule specific paths
|
||||||
|
for _, re := range rule.AllowList.Paths {
|
||||||
|
allowListedRegex, err := regexp.Compile(re)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cfg, fmt.Errorf("problem loading config: %v", err)
|
return cfg, fmt.Errorf("problem loading config: %v", err)
|
||||||
}
|
}
|
||||||
allowlists = append(allowlists, Allowlist{
|
allowList.Paths = append(allowList.Paths, allowListedRegex)
|
||||||
Description: wl.Description,
|
|
||||||
File: wlFileNameRe,
|
|
||||||
Path: wlFilePathRe,
|
|
||||||
Regex: wlRe,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var entropies []Entropy
|
var entropies []Entropy
|
||||||
@@ -191,47 +196,57 @@ func (tomlLoader TomlLoader) Parse() (Config, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
r := Rule{
|
r := Rule{
|
||||||
Description: rule.Description,
|
Description: rule.Description,
|
||||||
Regex: re,
|
Regex: re,
|
||||||
FileNameRegex: fileNameRe,
|
File: fileNameRe,
|
||||||
FilePathRegex: filePathRe,
|
Path: filePathRe,
|
||||||
Tags: rule.Tags,
|
ReportGroup: rule.ReportGroup,
|
||||||
Allowlist: allowlists,
|
Tags: rule.Tags,
|
||||||
Entropies: entropies,
|
AllowList: allowList,
|
||||||
|
Entropies: entropies,
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg.Rules = append(cfg.Rules, r)
|
cfg.Rules = append(cfg.Rules, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
// global file name allowlists
|
// global regex allowLists
|
||||||
for _, wlFileName := range tomlLoader.Allowlist.Files {
|
for _, allowListRegex := range tomlLoader.AllowList.Regexes {
|
||||||
re, err := regexp.Compile(wlFileName)
|
re, err := regexp.Compile(allowListRegex)
|
||||||
|
if err != nil {
|
||||||
|
return cfg, fmt.Errorf("problem loading config: %v", err)
|
||||||
|
}
|
||||||
|
cfg.Allowlist.Regexes = append(cfg.Allowlist.Regexes, re)
|
||||||
|
}
|
||||||
|
|
||||||
|
// global file name allowLists
|
||||||
|
for _, allowListFileName := range tomlLoader.AllowList.Files {
|
||||||
|
re, err := regexp.Compile(allowListFileName)
|
||||||
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.Allowlist.Files = append(cfg.Allowlist.Files, re)
|
cfg.Allowlist.Files = append(cfg.Allowlist.Files, re)
|
||||||
}
|
}
|
||||||
|
|
||||||
// global file path allowlists
|
// global file path allowLists
|
||||||
for _, wlFilePath := range tomlLoader.Allowlist.Paths {
|
for _, allowListFilePath := range tomlLoader.AllowList.Paths {
|
||||||
re, err := regexp.Compile(wlFilePath)
|
re, err := regexp.Compile(allowListFilePath)
|
||||||
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.Allowlist.Paths = append(cfg.Allowlist.Paths, re)
|
cfg.Allowlist.Paths = append(cfg.Allowlist.Paths, re)
|
||||||
}
|
}
|
||||||
|
|
||||||
// global repo allowlists
|
// global repo allowLists
|
||||||
for _, wlRepo := range tomlLoader.Allowlist.Repos {
|
for _, allowListRepo := range tomlLoader.AllowList.Repos {
|
||||||
re, err := regexp.Compile(wlRepo)
|
re, err := regexp.Compile(allowListRepo)
|
||||||
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.Allowlist.Repos = append(cfg.Allowlist.Repos, re)
|
cfg.Allowlist.Repos = append(cfg.Allowlist.Repos, re)
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg.Allowlist.Commits = tomlLoader.Allowlist.Commits
|
cfg.Allowlist.Commits = tomlLoader.AllowList.Commits
|
||||||
cfg.Allowlist.Description = tomlLoader.Allowlist.Description
|
cfg.Allowlist.Description = tomlLoader.AllowList.Description
|
||||||
|
|
||||||
return cfg, nil
|
return cfg, nil
|
||||||
}
|
}
|
||||||
+85
-3
@@ -2,10 +2,12 @@ package config
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/v5/options"
|
"github.com/zricethezav/gitleaks/v6/options"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestParse(t *testing.T) {
|
func TestParse(t *testing.T) {
|
||||||
@@ -15,7 +17,7 @@ func TestParse(t *testing.T) {
|
|||||||
wantErr error
|
wantErr error
|
||||||
wantFileRegex *regexp.Regexp
|
wantFileRegex *regexp.Regexp
|
||||||
wantMessages *regexp.Regexp
|
wantMessages *regexp.Regexp
|
||||||
wantAllowlist Allowlist
|
wantAllowlist AllowList
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
description: "default config",
|
description: "default config",
|
||||||
@@ -122,10 +124,90 @@ func TestParse(t *testing.T) {
|
|||||||
_, err := NewConfig(test.opts)
|
_, err := NewConfig(test.opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if test.wantErr == nil {
|
if test.wantErr == nil {
|
||||||
t.Error(err)
|
t.Error(test.description, err)
|
||||||
} else if test.wantErr.Error() != err.Error() {
|
} else if test.wantErr.Error() != err.Error() {
|
||||||
t.Errorf("expected err: %s, got %s", test.wantErr, err)
|
t.Errorf("expected err: %s, got %s", test.wantErr, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TestParseFields will test that fields are properly parsed from a config. As fields are added, then please
|
||||||
|
// add tests here.
|
||||||
|
func TestParseFields(t *testing.T) {
|
||||||
|
tomlConfig := `
|
||||||
|
[[rules]]
|
||||||
|
description = "Some Groups without a reportGroup"
|
||||||
|
regex = '(.)(.)'
|
||||||
|
|
||||||
|
[[rules]]
|
||||||
|
description = "Some Groups"
|
||||||
|
regex = '(.)(.)'
|
||||||
|
reportGroup = 1
|
||||||
|
`
|
||||||
|
configPath, err := writeTestConfig(tomlConfig)
|
||||||
|
defer os.Remove(configPath)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
config, err := NewConfig(options.Options{Config: configPath})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Couldn't parse config: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
expectedRuleFields := []struct {
|
||||||
|
Description string
|
||||||
|
ReportGroup int
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
Description: "Some Groups without a reportGroup",
|
||||||
|
ReportGroup: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Description: "Some Groups",
|
||||||
|
ReportGroup: 1,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(config.Rules) != len(expectedRuleFields) {
|
||||||
|
t.Fatalf("expected %v rules", len(expectedRuleFields))
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, expected := range expectedRuleFields {
|
||||||
|
rule, err := findRuleByDescription(config.Rules, expected.Description)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if rule.ReportGroup != expected.ReportGroup {
|
||||||
|
t.Errorf("expected the rule with description '%v' to have a ReportGroup of %v", expected.Description, expected.ReportGroup)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func findRuleByDescription(rules []Rule, description string) (*Rule, error) {
|
||||||
|
for _, rule := range rules {
|
||||||
|
if rule.Description == description {
|
||||||
|
return &rule, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil, fmt.Errorf("Couldn't find rule with the description: %s", description)
|
||||||
|
}
|
||||||
|
|
||||||
|
func writeTestConfig(toml string) (string, error) {
|
||||||
|
tmpfile, err := ioutil.TempFile("", "testConfig")
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("Couldn't create test config got: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := tmpfile.Write([]byte(toml)); err != nil {
|
||||||
|
return "", fmt.Errorf("Couldn't create test config got: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := tmpfile.Close(); err != nil {
|
||||||
|
return "", fmt.Errorf("Couldn't create test config got: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return tmpfile.Name(), nil
|
||||||
|
}
|
||||||
+21
-29
@@ -129,8 +129,8 @@ 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.allowlist]]
|
[rules.allowlist]
|
||||||
regex = '''(?i)port '''
|
regexes = ['''(?i)port ''']
|
||||||
description = "ignore export "
|
description = "ignore export "
|
||||||
|
|
||||||
|
|
||||||
@@ -139,8 +139,8 @@ 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.allowlist]]
|
[rules.allowlist]
|
||||||
file = '''(?i)bashrc'''
|
files = ['''(?i)bashrc''']
|
||||||
description = "ignore bashrc emails"
|
description = "ignore bashrc emails"
|
||||||
|
|
||||||
|
|
||||||
@@ -149,35 +149,26 @@ 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.allowlist]]
|
[rules.allowlist]
|
||||||
regex = '''xox[baprs]-([0-9a-zA-Z]{10,48})'''
|
description = "ignore slack, mailchimp, aws"
|
||||||
description = "ignore slack"
|
regexes = [
|
||||||
[[rules.allowlist]]
|
'''xox[baprs]-([0-9a-zA-Z]{10,48})''',
|
||||||
description = "MailChimp API key"
|
'''(?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}['"]'''
|
'''(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}'''
|
||||||
[[rules.allowlist]]
|
]
|
||||||
description = "AWS Manager ID"
|
|
||||||
regex = '''(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}'''
|
|
||||||
|
|
||||||
#[[rules]]
|
|
||||||
# description = "s3config"
|
|
||||||
# regex = '''(?i)(dbpasswd|dbuser|dbname|dbhost|api_key|apikey|key|api|password|user|guid|hostname|pw|auth)(.{0,3})?([0-9a-zA-Z-_\/+!{}=]{4,120})'''
|
|
||||||
# fileNameRegex = '''(?i)s3cfg$'''
|
|
||||||
|
|
||||||
[[rules]]
|
[[rules]]
|
||||||
description = "High Entropy"
|
description = "High Entropy"
|
||||||
regex = '''[0-9a-zA-Z-_!{}/=]{4,120}'''
|
regex = '''[0-9a-zA-Z-_!{}/=]{4,120}'''
|
||||||
fileNameRegex = '''(?i)(dump.sql|high-entropy-misc.txt)$'''
|
file = '''(?i)(dump.sql|high-entropy-misc.txt)$'''
|
||||||
tags = ["entropy"]
|
tags = ["entropy"]
|
||||||
[[rules.Entropies]]
|
[[rules.Entropies]]
|
||||||
Min = "4.3"
|
Min = "4.3"
|
||||||
Max = "7.0"
|
Max = "7.0"
|
||||||
[[rules.allowlist]]
|
[rules.allowlist]
|
||||||
description = "ignore ssh key and pems"
|
description = "ignore ssh key and pems"
|
||||||
file = '''(pem|ppk|env)$'''
|
files = ['''(pem|ppk|env)$''']
|
||||||
path = '''(.*)?ssh'''
|
paths = ['''(.*)?ssh''']
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[[rules]]
|
[[rules]]
|
||||||
description = "Potential bash var"
|
description = "Potential bash var"
|
||||||
@@ -195,8 +186,9 @@ title = "gitleaks config"
|
|||||||
|
|
||||||
[[rules]]
|
[[rules]]
|
||||||
description = "Files with keys and credentials"
|
description = "Files with keys and credentials"
|
||||||
fileNameRegex = '''(?i)(id_rsa|passwd|id_rsa.pub|pgpass|pem|key|shadow)'''
|
file = '''(?i)(id_rsa|passwd|id_rsa.pub|pgpass|pem|key|shadow)'''
|
||||||
|
|
||||||
|
# Global allowlist
|
||||||
[allowlist]
|
[allowlist]
|
||||||
description = "image allowlists"
|
description = "image allowlists"
|
||||||
files = ['''(.*?)(jpg|gif|doc|pdf|bin)$''']
|
files = ['''(.*?)(jpg|gif|doc|pdf|bin)$''']
|
||||||
|
|||||||
@@ -8,6 +8,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.allowlist]]
|
[rules.allowlist]
|
||||||
regex = '''AKIAIO5FODNN7EXAMPLE.*'''
|
regexes = ['''AKIAIO5FODNN7EXAMPLE.*''']
|
||||||
description = "ignore example aws key"
|
description = "ignore example aws key"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
module github.com/zricethezav/gitleaks/v5
|
module github.com/zricethezav/gitleaks/v6
|
||||||
|
|
||||||
go 1.14
|
go 1.14
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -6,9 +6,9 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/v5/manager"
|
"github.com/zricethezav/gitleaks/v6/manager"
|
||||||
"github.com/zricethezav/gitleaks/v5/options"
|
"github.com/zricethezav/gitleaks/v6/options"
|
||||||
"github.com/zricethezav/gitleaks/v5/scan"
|
"github.com/zricethezav/gitleaks/v6/scan"
|
||||||
|
|
||||||
"github.com/go-git/go-git/v5"
|
"github.com/go-git/go-git/v5"
|
||||||
"github.com/go-git/go-git/v5/plumbing"
|
"github.com/go-git/go-git/v5/plumbing"
|
||||||
|
|||||||
+7
-3
@@ -4,9 +4,9 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/v5/manager"
|
"github.com/zricethezav/gitleaks/v6/manager"
|
||||||
"github.com/zricethezav/gitleaks/v5/options"
|
"github.com/zricethezav/gitleaks/v6/options"
|
||||||
"github.com/zricethezav/gitleaks/v5/scan"
|
"github.com/zricethezav/gitleaks/v6/scan"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/xanzy/go-gitlab"
|
"github.com/xanzy/go-gitlab"
|
||||||
@@ -93,6 +93,10 @@ func (g *Gitlab) Scan() {
|
|||||||
cloneOpts := g.manager.CloneOptions
|
cloneOpts := g.manager.CloneOptions
|
||||||
cloneOpts.URL = p.HTTPURLToRepo
|
cloneOpts.URL = p.HTTPURLToRepo
|
||||||
err := r.Clone(cloneOpts)
|
err := r.Clone(cloneOpts)
|
||||||
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
// TODO handle clone retry with ssh like github host
|
// TODO handle clone retry with ssh like github host
|
||||||
r.Name = p.Name
|
r.Name = p.Name
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@ package hosts
|
|||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/v5/manager"
|
"github.com/zricethezav/gitleaks/v6/manager"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|||||||
+3
-3
@@ -6,9 +6,9 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/v5/config"
|
"github.com/zricethezav/gitleaks/v6/config"
|
||||||
"github.com/zricethezav/gitleaks/v5/manager"
|
"github.com/zricethezav/gitleaks/v6/manager"
|
||||||
"github.com/zricethezav/gitleaks/v5/options"
|
"github.com/zricethezav/gitleaks/v6/options"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/v5/config"
|
"github.com/zricethezav/gitleaks/v6/config"
|
||||||
"github.com/zricethezav/gitleaks/v5/hosts"
|
"github.com/zricethezav/gitleaks/v6/hosts"
|
||||||
"github.com/zricethezav/gitleaks/v5/manager"
|
"github.com/zricethezav/gitleaks/v6/manager"
|
||||||
"github.com/zricethezav/gitleaks/v5/options"
|
"github.com/zricethezav/gitleaks/v6/options"
|
||||||
"github.com/zricethezav/gitleaks/v5/scan"
|
"github.com/zricethezav/gitleaks/v6/scan"
|
||||||
|
|
||||||
"github.com/hako/durafmt"
|
"github.com/hako/durafmt"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|||||||
+3
-44
@@ -2,7 +2,6 @@ package manager
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/sha1"
|
"crypto/sha1"
|
||||||
"encoding/csv"
|
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
@@ -14,8 +13,8 @@ import (
|
|||||||
"text/tabwriter"
|
"text/tabwriter"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/v5/config"
|
"github.com/zricethezav/gitleaks/v6/config"
|
||||||
"github.com/zricethezav/gitleaks/v5/options"
|
"github.com/zricethezav/gitleaks/v6/options"
|
||||||
|
|
||||||
"github.com/go-git/go-git/v5"
|
"github.com/go-git/go-git/v5"
|
||||||
"github.com/hako/durafmt"
|
"github.com/hako/durafmt"
|
||||||
@@ -252,7 +251,7 @@ func (manager *Manager) DebugOutput() {
|
|||||||
w := tabwriter.NewWriter(os.Stdout, 0, 0, padding, '.', 0)
|
w := tabwriter.NewWriter(os.Stdout, 0, 0, padding, '.', 0)
|
||||||
|
|
||||||
log.Debugf("--------------------------\n")
|
log.Debugf("--------------------------\n")
|
||||||
log.Debugf("| Individual Regex Times |\n")
|
log.Debugf("| Individual Regexes Times |\n")
|
||||||
log.Debugf("--------------------------\n")
|
log.Debugf("--------------------------\n")
|
||||||
for k, v := range manager.metadata.RegexTime {
|
for k, v := range manager.metadata.RegexTime {
|
||||||
_, _ = fmt.Fprintf(w, "%s\t%s\n", k, durafmt.Parse(time.Duration(v)*time.Nanosecond))
|
_, _ = fmt.Fprintf(w, "%s\t%s\n", k, durafmt.Parse(time.Duration(v)*time.Nanosecond))
|
||||||
@@ -261,46 +260,6 @@ func (manager *Manager) DebugOutput() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Report saves gitleaks leaks to a json specified by --report={report.json}
|
|
||||||
func (manager *Manager) Report() error {
|
|
||||||
close(manager.leakChan)
|
|
||||||
close(manager.metadata.timings)
|
|
||||||
|
|
||||||
if log.IsLevelEnabled(log.DebugLevel) {
|
|
||||||
manager.DebugOutput()
|
|
||||||
}
|
|
||||||
|
|
||||||
if manager.Opts.Report != "" {
|
|
||||||
if len(manager.GetLeaks()) == 0 {
|
|
||||||
log.Infof("no leaks found, skipping writing report")
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
file, err := os.Create(manager.Opts.Report)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if manager.Opts.ReportFormat == "json" {
|
|
||||||
encoder := json.NewEncoder(file)
|
|
||||||
encoder.SetIndent("", " ")
|
|
||||||
err = encoder.Encode(manager.leaks)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
w := csv.NewWriter(file)
|
|
||||||
_ = w.Write([]string{"repo", "line", "commit", "offender", "rule", "tags", "commitMsg", "author", "email", "file", "date"})
|
|
||||||
for _, leak := range manager.GetLeaks() {
|
|
||||||
w.Write([]string{leak.Repo, leak.Line, leak.Commit, leak.Offender, leak.Rule, leak.Tags, leak.Message, leak.Author, leak.Email, leak.File, leak.Date.Format(time.RFC3339)})
|
|
||||||
}
|
|
||||||
w.Flush()
|
|
||||||
}
|
|
||||||
_ = file.Close()
|
|
||||||
|
|
||||||
log.Infof("report written to %s", manager.Opts.Report)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (manager *Manager) receiveInterrupt() {
|
func (manager *Manager) receiveInterrupt() {
|
||||||
<-manager.stopChan
|
<-manager.stopChan
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package manager
|
|||||||
import (
|
import (
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/zricethezav/gitleaks/v5/config"
|
"github.com/zricethezav/gitleaks/v6/config"
|
||||||
"github.com/zricethezav/gitleaks/v5/options"
|
"github.com/zricethezav/gitleaks/v6/options"
|
||||||
"io"
|
"io"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -0,0 +1,78 @@
|
|||||||
|
package manager
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/csv"
|
||||||
|
"encoding/json"
|
||||||
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/zricethezav/gitleaks/v6/version"
|
||||||
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Report saves gitleaks leaks to a json specified by --report={report.json}
|
||||||
|
func (manager *Manager) Report() error {
|
||||||
|
close(manager.leakChan)
|
||||||
|
close(manager.metadata.timings)
|
||||||
|
|
||||||
|
if log.IsLevelEnabled(log.DebugLevel) {
|
||||||
|
manager.DebugOutput()
|
||||||
|
}
|
||||||
|
|
||||||
|
if manager.Opts.Report != "" {
|
||||||
|
if len(manager.GetLeaks()) == 0 {
|
||||||
|
log.Infof("no leaks found, skipping writing report")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
file, err := os.Create(manager.Opts.Report)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
switch manager.Opts.ReportFormat {
|
||||||
|
case "json":
|
||||||
|
encoder := json.NewEncoder(file)
|
||||||
|
encoder.SetIndent("", " ")
|
||||||
|
err = encoder.Encode(manager.leaks)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
case "csv":
|
||||||
|
w := csv.NewWriter(file)
|
||||||
|
_ = w.Write([]string{"repo", "line", "commit", "offender", "rule", "tags", "commitMsg", "author", "email", "file", "date"})
|
||||||
|
for _, leak := range manager.GetLeaks() {
|
||||||
|
w.Write([]string{leak.Repo, leak.Line, leak.Commit, leak.Offender, leak.Rule, leak.Tags, leak.Message, leak.Author, leak.Email, leak.File, leak.Date.Format(time.RFC3339)})
|
||||||
|
}
|
||||||
|
w.Flush()
|
||||||
|
case "sarif":
|
||||||
|
s := Sarif{
|
||||||
|
Schema: "https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0-rtm.5.json",
|
||||||
|
Version: "2.1.0",
|
||||||
|
Runs: []Runs{
|
||||||
|
{
|
||||||
|
Tool: Tool{
|
||||||
|
Driver: Driver{
|
||||||
|
Name: "Gitleaks",
|
||||||
|
SemanticVersion: version.Version,
|
||||||
|
Rules: manager.configToRules(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Results: manager.leaksToResults(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
encoder := json.NewEncoder(file)
|
||||||
|
encoder.SetIndent("", " ")
|
||||||
|
err = encoder.Encode(s)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ = file.Close()
|
||||||
|
|
||||||
|
log.Infof("report written to %s", manager.Opts.Report)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,153 @@
|
|||||||
|
package manager
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
//Sarif ...
|
||||||
|
type Sarif struct {
|
||||||
|
Schema string `json:"$schema"`
|
||||||
|
Version string `json:"version"`
|
||||||
|
Runs []Runs `json:"runs"`
|
||||||
|
}
|
||||||
|
|
||||||
|
//ShortDescription ...
|
||||||
|
type ShortDescription struct {
|
||||||
|
Text string `json:"text"`
|
||||||
|
}
|
||||||
|
|
||||||
|
//FullDescription ...
|
||||||
|
type FullDescription struct {
|
||||||
|
Text string `json:"text"`
|
||||||
|
}
|
||||||
|
|
||||||
|
//Rules ...
|
||||||
|
type Rules struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
//Driver ...
|
||||||
|
type Driver struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
SemanticVersion string `json:"semanticVersion"`
|
||||||
|
Rules []Rules `json:"rules"`
|
||||||
|
}
|
||||||
|
|
||||||
|
//Tool ...
|
||||||
|
type Tool struct {
|
||||||
|
Driver Driver `json:"driver"`
|
||||||
|
}
|
||||||
|
|
||||||
|
//Message ...
|
||||||
|
type Message struct {
|
||||||
|
Text string `json:"text"`
|
||||||
|
}
|
||||||
|
|
||||||
|
//ArtifactLocation ...
|
||||||
|
type ArtifactLocation struct {
|
||||||
|
URI string `json:"uri"`
|
||||||
|
}
|
||||||
|
|
||||||
|
//Region ...
|
||||||
|
type Region struct {
|
||||||
|
StartLine int `json:"startLine"`
|
||||||
|
Snippet Snippet `json:"snippet"`
|
||||||
|
}
|
||||||
|
|
||||||
|
//Snippet ...
|
||||||
|
type Snippet struct {
|
||||||
|
Text string `json:"text"`
|
||||||
|
}
|
||||||
|
|
||||||
|
//PhysicalLocation ...
|
||||||
|
type PhysicalLocation struct {
|
||||||
|
ArtifactLocation ArtifactLocation `json:"artifactLocation"`
|
||||||
|
Region Region `json:"region"`
|
||||||
|
}
|
||||||
|
|
||||||
|
//Locations ...
|
||||||
|
type Locations struct {
|
||||||
|
PhysicalLocation PhysicalLocation `json:"physicalLocation"`
|
||||||
|
}
|
||||||
|
|
||||||
|
//Results ...
|
||||||
|
type Results struct {
|
||||||
|
Message Message `json:"message"`
|
||||||
|
Properties ResultProperties `json:"properties"`
|
||||||
|
Locations []Locations `json:"locations"`
|
||||||
|
}
|
||||||
|
|
||||||
|
//ResultProperties ...
|
||||||
|
type ResultProperties struct {
|
||||||
|
Commit string `json:"commit"`
|
||||||
|
Offender string `json:"offender"`
|
||||||
|
Date time.Time `json:"date"`
|
||||||
|
Author string `json:"author"`
|
||||||
|
Email string `json:"email"`
|
||||||
|
CommitMessage string `json:"commitMessage"`
|
||||||
|
Operation string `json:"gitOperation"`
|
||||||
|
Repo string `json:"repo"`
|
||||||
|
}
|
||||||
|
|
||||||
|
//Runs ...
|
||||||
|
type Runs struct {
|
||||||
|
Tool Tool `json:"tool"`
|
||||||
|
Results []Results `json:"results"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (manager *Manager) configToRules() []Rules {
|
||||||
|
var rules []Rules
|
||||||
|
for _, rule := range manager.Config.Rules {
|
||||||
|
rules = append(rules, Rules{
|
||||||
|
ID: rule.Description,
|
||||||
|
Name: rule.Description,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return rules
|
||||||
|
}
|
||||||
|
|
||||||
|
func (manager *Manager) leaksToResults() []Results {
|
||||||
|
var results []Results
|
||||||
|
for _, leak := range manager.leaks {
|
||||||
|
results = append(results, Results{
|
||||||
|
Message: Message{
|
||||||
|
Text: fmt.Sprintf("%s secret detected", leak.Rule),
|
||||||
|
},
|
||||||
|
Properties: ResultProperties{
|
||||||
|
Commit: leak.Commit,
|
||||||
|
Offender: leak.Offender,
|
||||||
|
Date: leak.Date,
|
||||||
|
Author: leak.Author,
|
||||||
|
Email: leak.Email,
|
||||||
|
CommitMessage: leak.Message,
|
||||||
|
Operation: leak.Operation,
|
||||||
|
Repo: leak.Repo,
|
||||||
|
},
|
||||||
|
Locations: leakToLocation(leak),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return results
|
||||||
|
}
|
||||||
|
|
||||||
|
func leakToLocation(leak Leak) []Locations {
|
||||||
|
return []Locations{
|
||||||
|
{
|
||||||
|
PhysicalLocation:
|
||||||
|
PhysicalLocation{
|
||||||
|
ArtifactLocation: ArtifactLocation{
|
||||||
|
URI: leak.File,
|
||||||
|
},
|
||||||
|
Region: Region{
|
||||||
|
StartLine: leak.LineNumber,
|
||||||
|
Snippet: Snippet{
|
||||||
|
Text: leak.Line,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
+35
-30
@@ -7,7 +7,7 @@ import (
|
|||||||
"os/user"
|
"os/user"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/v5/version"
|
"github.com/zricethezav/gitleaks/v6/version"
|
||||||
|
|
||||||
"github.com/go-git/go-git/v5"
|
"github.com/go-git/go-git/v5"
|
||||||
"github.com/go-git/go-git/v5/plumbing/transport/http"
|
"github.com/go-git/go-git/v5/plumbing/transport/http"
|
||||||
@@ -28,35 +28,40 @@ const (
|
|||||||
|
|
||||||
// Options stores values of command line options
|
// Options stores values of command line options
|
||||||
type Options struct {
|
type Options struct {
|
||||||
Verbose bool `short:"v" long:"verbose" description:"Show verbose output from scan"`
|
Verbose bool `short:"v" long:"verbose" description:"Show verbose output from scan"`
|
||||||
Repo string `short:"r" long:"repo" description:"Target repository"`
|
Repo string `short:"r" long:"repo" description:"Target repository"`
|
||||||
Config string `long:"config" description:"config path"`
|
Config string `long:"config" description:"config path"`
|
||||||
Disk bool `long:"disk" description:"Clones repo(s) to disk"`
|
Disk bool `long:"disk" description:"Clones repo(s) to disk"`
|
||||||
Version bool `long:"version" description:"version number"`
|
Version bool `long:"version" description:"version number"`
|
||||||
Username string `long:"username" description:"Username for git repo"`
|
Username string `long:"username" description:"Username for git repo"`
|
||||||
Password string `long:"password" description:"Password for git repo"`
|
Password string `long:"password" description:"Password for git repo"`
|
||||||
AccessToken string `long:"access-token" description:"Access token for git repo"`
|
AccessToken string `long:"access-token" description:"Access token for git repo"`
|
||||||
Commit string `long:"commit" description:"sha of commit to scan or \"latest\" to scan the last commit of the repository"`
|
FilesAtCommit string `long:"files-at-commit" description:"sha of commit to scan all files at commit"`
|
||||||
FilesAtCommit string `long:"files-at-commit" description:"sha of commit to scan all files at commit"`
|
Threads int `long:"threads" description:"Maximum number of threads gitleaks spawns"`
|
||||||
Threads int `long:"threads" description:"Maximum number of threads gitleaks spawns"`
|
SSH string `long:"ssh-key" description:"path to ssh key used for auth"`
|
||||||
SSH string `long:"ssh-key" description:"path to ssh key used for auth"`
|
Uncommited bool `long:"uncommitted" description:"run gitleaks on uncommitted code"`
|
||||||
Uncommited bool `long:"uncommitted" description:"run gitleaks on uncommitted code"`
|
RepoPath string `long:"repo-path" description:"Path to repo"`
|
||||||
RepoPath string `long:"repo-path" description:"Path to repo"`
|
OwnerPath string `long:"owner-path" description:"Path to owner directory (repos discovered)"`
|
||||||
OwnerPath string `long:"owner-path" description:"Path to owner directory (repos discovered)"`
|
Branch string `long:"branch" description:"Branch to scan"`
|
||||||
Branch string `long:"branch" description:"Branch to scan"`
|
Report string `long:"report" description:"path to write json leaks file"`
|
||||||
Report string `long:"report" description:"path to write json leaks file"`
|
ReportFormat string `long:"report-format" default:"json" description:"json, csv, sarif"`
|
||||||
ReportFormat string `long:"report-format" default:"json" description:"json or csv"`
|
Redact bool `long:"redact" description:"redact secrets from log messages and leaks"`
|
||||||
Redact bool `long:"redact" description:"redact secrets from log messages and leaks"`
|
Debug bool `long:"debug" description:"log debug messages"`
|
||||||
Debug bool `long:"debug" description:"log debug messages"`
|
RepoConfig bool `long:"repo-config" description:"Load config from target repo. Config file must be \".gitleaks.toml\" or \"gitleaks.toml\""`
|
||||||
RepoConfig bool `long:"repo-config" description:"Load config from target repo. Config file must be \".gitleaks.toml\" or \"gitleaks.toml\""`
|
PrettyPrint bool `long:"pretty" description:"Pretty print json if leaks are present"`
|
||||||
PrettyPrint bool `long:"pretty" description:"Pretty print json if leaks are present"`
|
|
||||||
CommitFrom string `long:"commit-from" description:"Commit to start scan from"`
|
// Commit Options
|
||||||
CommitTo string `long:"commit-to" description:"Commit to stop scan"`
|
Commit string `long:"commit" description:"sha of commit to scan or \"latest\" to scan the last commit of the repository"`
|
||||||
CommitSince string `long:"commit-since" description:"Scan commits more recent than a specific date. Ex: '2006-01-02' or '2006-01-02T15:04:05-0700' format."`
|
Commits string `long:"commits" description:"comma separated list of a commits to scan"`
|
||||||
CommitUntil string `long:"commit-until" description:"Scan commits older than a specific date. Ex: '2006-01-02' or '2006-01-02T15:04:05-0700' format."`
|
CommitsFile string `long:"commits-file" description:"file of new line separated list of a commits to scan"`
|
||||||
Timeout string `long:"timeout" description:"Time allowed per scan. Ex: 10us, 30s, 1m, 1h10m1s"`
|
CommitFrom string `long:"commit-from" description:"Commit to start scan from"`
|
||||||
Depth int `long:"depth" description:"Number of commits to scan"`
|
CommitTo string `long:"commit-to" description:"Commit to stop scan"`
|
||||||
Deletion bool `long:"include-deletion" description:"Scan for patch deletions in addition to patch additions"`
|
CommitSince string `long:"commit-since" description:"Scan commits more recent than a specific date. Ex: '2006-01-02' or '2006-01-02T15:04:05-0700' format."`
|
||||||
|
CommitUntil string `long:"commit-until" description:"Scan commits older than a specific date. Ex: '2006-01-02' or '2006-01-02T15:04:05-0700' format."`
|
||||||
|
|
||||||
|
Timeout string `long:"timeout" description:"Time allowed per scan. Ex: 10us, 30s, 1m, 1h10m1s"`
|
||||||
|
Depth int `long:"depth" description:"Number of commits to scan"`
|
||||||
|
Deletion bool `long:"include-deletion" description:"Scan for patch deletions in addition to patch additions"`
|
||||||
|
|
||||||
// Hosts
|
// Hosts
|
||||||
Host string `long:"host" description:"git hosting service like gitlab or github. Supported hosts include: Github, Gitlab"`
|
Host string `long:"host" description:"git hosting service like gitlab or github. Supported hosts include: Github, Gitlab"`
|
||||||
|
|||||||
+13
-5
@@ -11,8 +11,8 @@ import (
|
|||||||
"runtime"
|
"runtime"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/v5/config"
|
"github.com/zricethezav/gitleaks/v6/config"
|
||||||
"github.com/zricethezav/gitleaks/v5/manager"
|
"github.com/zricethezav/gitleaks/v6/manager"
|
||||||
|
|
||||||
"github.com/BurntSushi/toml"
|
"github.com/BurntSushi/toml"
|
||||||
"github.com/go-git/go-billy/v5"
|
"github.com/go-git/go-billy/v5"
|
||||||
@@ -77,11 +77,11 @@ func Run(m *manager.Manager) error {
|
|||||||
|
|
||||||
func runHelper(r *Repo) error {
|
func runHelper(r *Repo) error {
|
||||||
// Ignore allowlisted repos
|
// Ignore allowlisted repos
|
||||||
for _, wlRepo := range r.Manager.Config.Allowlist.Repos {
|
for _, allowListedRepo := range r.Manager.Config.Allowlist.Repos {
|
||||||
if RegexMatched(r.Manager.Opts.RepoPath, wlRepo) {
|
if RegexMatched(r.Manager.Opts.RepoPath, allowListedRepo) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if RegexMatched(r.Manager.Opts.Repo, wlRepo) {
|
if RegexMatched(r.Manager.Opts.Repo, allowListedRepo) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -201,6 +201,10 @@ func getLogOptions(repo *Repo) (*git.LogOptions, error) {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
if logOpts.From.IsZero() {
|
if logOpts.From.IsZero() {
|
||||||
return nil, fmt.Errorf("could not find branch %s", repo.Manager.Opts.Branch)
|
return nil, fmt.Errorf("could not find branch %s", repo.Manager.Opts.Branch)
|
||||||
}
|
}
|
||||||
@@ -259,6 +263,10 @@ func (repo *Repo) loadRepoConfig() (config.Config, error) {
|
|||||||
defer f.Close()
|
defer f.Close()
|
||||||
var tomlLoader config.TomlLoader
|
var tomlLoader config.TomlLoader
|
||||||
_, err = toml.DecodeReader(f, &tomlLoader)
|
_, err = toml.DecodeReader(f, &tomlLoader)
|
||||||
|
if err != nil {
|
||||||
|
return config.Config{}, err
|
||||||
|
}
|
||||||
|
|
||||||
return tomlLoader.Parse()
|
return tomlLoader.Parse()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+41
-44
@@ -11,8 +11,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/v5/config"
|
"github.com/zricethezav/gitleaks/v6/config"
|
||||||
"github.com/zricethezav/gitleaks/v5/manager"
|
"github.com/zricethezav/gitleaks/v6/manager"
|
||||||
|
|
||||||
fdiff "github.com/go-git/go-git/v5/plumbing/format/diff"
|
fdiff "github.com/go-git/go-git/v5/plumbing/format/diff"
|
||||||
"github.com/go-git/go-git/v5/plumbing/object"
|
"github.com/go-git/go-git/v5/plumbing/object"
|
||||||
@@ -20,11 +20,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
diffAddPrefix = "+"
|
diffAddPrefix = "+"
|
||||||
diffAddFilePrefix = "+++ b"
|
diffAddFilePrefix = "+++ b"
|
||||||
diffAddFilePrefixSlash = "+++ b/"
|
diffAddFilePrefixSlash = "+++ b/"
|
||||||
diffLineSignature = " @@"
|
diffLineSignature = " @@"
|
||||||
defaultLineNumber = -1
|
diffLineSignaturePrefix = "@@ "
|
||||||
|
defaultLineNumber = -1
|
||||||
)
|
)
|
||||||
|
|
||||||
// CheckRules accepts bundle and checks each rule defined in the config against the bundle's content.
|
// CheckRules accepts bundle and checks each rule defined in the config against the bundle's content.
|
||||||
@@ -58,17 +59,17 @@ func (repo *Repo) CheckRules(bundle *Bundle) {
|
|||||||
start := time.Now()
|
start := time.Now()
|
||||||
|
|
||||||
// For each rule we want to check filename allowlists
|
// For each rule we want to check filename allowlists
|
||||||
if isFileNameWhiteListed(filename, rule.Allowlist) || isFilePathWhiteListed(path, rule.Allowlist) {
|
if isAllowListed(filename, rule.AllowList.Files) || isAllowListed(path, rule.AllowList.Paths) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// If it has fileNameRegex and it doesnt match we continue to next rule
|
// If it has fileNameRegex and it doesnt match we continue to next rule
|
||||||
if ruleContainFileNameRegex(rule) && !RegexMatched(filename, rule.FileNameRegex) {
|
if ruleContainFileRegex(rule) && !RegexMatched(filename, rule.File) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// If it has filePathRegex and it doesnt match we continue to next rule
|
// If it has filePathRegex and it doesnt match we continue to next rule
|
||||||
if ruleContainFilePathRegex(rule) && !RegexMatched(path, rule.FilePathRegex) {
|
if ruleContainPathRegex(rule) && !RegexMatched(path, rule.Path) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,7 +113,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.Allowlist) {
|
if isAllowListed(line, append(rule.AllowList.Regexes, repo.config.Allowlist.Regexes...)) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,6 +121,11 @@ func (repo *Repo) CheckRules(bundle *Bundle) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 0 is a match for the full regex pattern
|
||||||
|
if 0 < rule.ReportGroup && rule.ReportGroup < len(groups) {
|
||||||
|
offender = groups[rule.ReportGroup]
|
||||||
|
}
|
||||||
|
|
||||||
leak := manager.Leak{
|
leak := manager.Leak{
|
||||||
LineNumber: defaultLineNumber,
|
LineNumber: defaultLineNumber,
|
||||||
Line: line,
|
Line: line,
|
||||||
@@ -146,7 +152,6 @@ func (repo *Repo) CheckRules(bundle *Bundle) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO should return filenameRegex if only file rule
|
|
||||||
repo.Manager.RecordTime(manager.RegexTime{
|
repo.Manager.RecordTime(manager.RegexTime{
|
||||||
Time: howLong(start),
|
Time: howLong(start),
|
||||||
Regex: rule.Regex.String(),
|
Regex: rule.Regex.String(),
|
||||||
@@ -239,6 +244,19 @@ func extractAndInjectLineNumber(leak *manager.Leak, bundle *Bundle, repo *Repo)
|
|||||||
leak.LineNumber = potentialLine
|
leak.LineNumber = potentialLine
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
} else if strings.HasPrefix(txt, diffLineSignaturePrefix) && currStartDiffLine != 0 {
|
||||||
|
// This logic is used for when there are multiple leaks of the same offender within the same patch
|
||||||
|
i := strings.Index(txt, diffAddPrefix)
|
||||||
|
pairs := strings.Split(strings.Split(txt[i+1:], diffLineSignature)[0], ",")
|
||||||
|
currStartDiffLine, err = strconv.Atoi(pairs[0])
|
||||||
|
if err != nil {
|
||||||
|
log.Debug(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
currLine = 0
|
||||||
|
if !strings.HasSuffix(txt, diffLineSignature) {
|
||||||
|
currLine = -1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
currLine++
|
currLine++
|
||||||
}
|
}
|
||||||
@@ -339,28 +357,28 @@ func ruleContainRegex(rule config.Rule) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Checks if the given rule has a file name regex
|
// Checks if the given rule has a file name regex
|
||||||
func ruleContainFileNameRegex(rule config.Rule) bool {
|
func ruleContainFileRegex(rule config.Rule) bool {
|
||||||
if rule.FileNameRegex == nil {
|
if rule.File == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if rule.FileNameRegex.String() == "" {
|
if rule.File.String() == "" {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks if the given rule has a file path regex
|
// Checks if the given rule has a file path regex
|
||||||
func ruleContainFilePathRegex(rule config.Rule) bool {
|
func ruleContainPathRegex(rule config.Rule) bool {
|
||||||
if rule.FilePathRegex == nil {
|
if rule.Path == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if rule.FilePathRegex.String() == "" {
|
if rule.Path.String() == "" {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func isCommitWhiteListed(commitHash string, allowlistedCommits []string) bool {
|
func isCommitAllowListed(commitHash string, allowlistedCommits []string) bool {
|
||||||
for _, hash := range allowlistedCommits {
|
for _, hash := range allowlistedCommits {
|
||||||
if commitHash == hash {
|
if commitHash == hash {
|
||||||
return true
|
return true
|
||||||
@@ -369,35 +387,14 @@ func isCommitWhiteListed(commitHash string, allowlistedCommits []string) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func isOffenderWhiteListed(offender string, allowlist []config.Allowlist) bool {
|
func isAllowListed(target string, allowList []*regexp.Regexp) bool {
|
||||||
if len(allowlist) != 0 {
|
if len(allowList) != 0 {
|
||||||
for _, wl := range allowlist {
|
for _, re := range allowList {
|
||||||
if wl.Regex.FindString(offender) != "" {
|
if re.FindString(target) != "" {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
|
||||||
|
|
||||||
func isFileNameWhiteListed(filename string, allowlist []config.Allowlist) bool {
|
|
||||||
if len(allowlist) != 0 {
|
|
||||||
for _, wl := range allowlist {
|
|
||||||
if RegexMatched(filename, wl.File) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func isFilePathWhiteListed(filepath string, allowlist []config.Allowlist) bool {
|
|
||||||
if len(allowlist) != 0 {
|
|
||||||
for _, wl := range allowlist {
|
|
||||||
if RegexMatched(filepath, wl.Path) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
+38
-5
@@ -1,13 +1,16 @@
|
|||||||
package scan
|
package scan
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/v5/manager"
|
"github.com/zricethezav/gitleaks/v6/manager"
|
||||||
|
|
||||||
"github.com/go-git/go-git/v5"
|
"github.com/go-git/go-git/v5"
|
||||||
"github.com/go-git/go-git/v5/plumbing"
|
"github.com/go-git/go-git/v5/plumbing"
|
||||||
@@ -71,11 +74,36 @@ func (repo *Repo) Scan() error {
|
|||||||
|
|
||||||
scanTimeStart := time.Now()
|
scanTimeStart := time.Now()
|
||||||
|
|
||||||
// scan Commit patches OR all files at Commit. See https://github.com/zricethezav/gitleaks/issues/326
|
// See https://github.com/zricethezav/gitleaks/issues/326
|
||||||
|
// Scan commit patches, all files at a commit, or a range of commits
|
||||||
if repo.Manager.Opts.Commit != "" {
|
if repo.Manager.Opts.Commit != "" {
|
||||||
return scanCommit(repo.Manager.Opts.Commit, repo, scanCommitPatches)
|
return scanCommit(repo.Manager.Opts.Commit, repo, scanCommitPatches)
|
||||||
} else if repo.Manager.Opts.FilesAtCommit != "" {
|
} else if repo.Manager.Opts.FilesAtCommit != "" {
|
||||||
return scanCommit(repo.Manager.Opts.FilesAtCommit, repo, scanFilesAtCommit)
|
return scanCommit(repo.Manager.Opts.FilesAtCommit, repo, scanFilesAtCommit)
|
||||||
|
} else if repo.Manager.Opts.Commits != "" {
|
||||||
|
commits := strings.Split(repo.Manager.Opts.Commits, ",")
|
||||||
|
for _, c := range commits {
|
||||||
|
err := scanCommit(c, repo, scanCommitPatches)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
} else if repo.Manager.Opts.CommitsFile != "" {
|
||||||
|
file, err := os.Open(repo.Manager.Opts.CommitsFile)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer file.Close()
|
||||||
|
|
||||||
|
scanner := bufio.NewScanner(file)
|
||||||
|
for scanner.Scan() {
|
||||||
|
err := scanCommit(scanner.Text(), repo, scanCommitPatches)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
logOpts, err := getLogOptions(repo)
|
logOpts, err := getLogOptions(repo)
|
||||||
@@ -96,7 +124,7 @@ func (repo *Repo) Scan() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if Commit is allowlisted
|
// Check if Commit is allowlisted
|
||||||
if isCommitWhiteListed(c.Hash.String(), repo.config.Allowlist.Commits) {
|
if isCommitAllowListed(c.Hash.String(), repo.config.Allowlist.Commits) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,9 +168,10 @@ func (repo *Repo) Scan() error {
|
|||||||
start := time.Now()
|
start := time.Now()
|
||||||
patch, err := parent.Patch(c)
|
patch, err := parent.Patch(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not generate Patch")
|
log.Errorf("could not generate Patch")
|
||||||
}
|
}
|
||||||
repo.Manager.RecordTime(manager.PatchTime(howLong(start)))
|
repo.Manager.RecordTime(manager.PatchTime(howLong(start)))
|
||||||
|
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
semaphore <- true
|
semaphore <- true
|
||||||
go func(c *object.Commit, patch *object.Patch) {
|
go func(c *object.Commit, patch *object.Patch) {
|
||||||
@@ -174,6 +203,9 @@ func (repo *Repo) scanEmpty() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
status, err := wt.Status()
|
status, err := wt.Status()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
for fn := range status {
|
for fn := range status {
|
||||||
workTreeBuf := bytes.NewBuffer(nil)
|
workTreeBuf := bytes.NewBuffer(nil)
|
||||||
workTreeFile, err := wt.Filesystem.Open(fn)
|
workTreeFile, err := wt.Filesystem.Open(fn)
|
||||||
@@ -281,7 +313,8 @@ func (repo *Repo) scanUncommitted() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
diffs := diffmatchpatch.New().DiffMain(prevFileContents, currFileContents, false)
|
dmp := diffmatchpatch.New()
|
||||||
|
diffs := dmp.DiffCleanupSemantic(dmp.DiffMain(prevFileContents, currFileContents, false))
|
||||||
var diffContents string
|
var diffContents string
|
||||||
for _, d := range diffs {
|
for _, d := range diffs {
|
||||||
if d.Type == diffmatchpatch.DiffInsert {
|
if d.Type == diffmatchpatch.DiffInsert {
|
||||||
|
|||||||
+49
-5
@@ -10,9 +10,9 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/v5/config"
|
"github.com/zricethezav/gitleaks/v6/config"
|
||||||
"github.com/zricethezav/gitleaks/v5/manager"
|
"github.com/zricethezav/gitleaks/v6/manager"
|
||||||
"github.com/zricethezav/gitleaks/v5/options"
|
"github.com/zricethezav/gitleaks/v6/options"
|
||||||
|
|
||||||
"github.com/sergi/go-diff/diffmatchpatch"
|
"github.com/sergi/go-diff/diffmatchpatch"
|
||||||
)
|
)
|
||||||
@@ -96,16 +96,36 @@ func TestScan(t *testing.T) {
|
|||||||
wantPath: "../test_data/test_local_repo_two_leaks_commit_to.json",
|
wantPath: "../test_data/test_local_repo_two_leaks_commit_to.json",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "test local repo two leaks range Commit",
|
description: "test local repo two leaks to from Commit",
|
||||||
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_leaks_commit_range.json.got",
|
Report: "../test_data/test_local_repo_two_leaks_commit_to_from.json.got",
|
||||||
ReportFormat: "json",
|
ReportFormat: "json",
|
||||||
CommitFrom: "d8ac0b73aeeb45843319cdc5ce506516eb49bf7a",
|
CommitFrom: "d8ac0b73aeeb45843319cdc5ce506516eb49bf7a",
|
||||||
CommitTo: "51f6dcf6b89b93f4075ba92c400b075631a6cc93",
|
CommitTo: "51f6dcf6b89b93f4075ba92c400b075631a6cc93",
|
||||||
},
|
},
|
||||||
|
wantPath: "../test_data/test_local_repo_two_leaks_commit_to_from.json",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
description: "test local repo two leaks list Commits",
|
||||||
|
opts: options.Options{
|
||||||
|
RepoPath: "../test_data/test_repos/test_repo_2",
|
||||||
|
Report: "../test_data/test_local_repo_two_leaks_commit_range.json.got",
|
||||||
|
ReportFormat: "json",
|
||||||
|
Commits: "d8ac0b73aeeb45843319cdc5ce506516eb49bf7a,996865bb912f3bc45898a370a13aadb315014b55,17471a5fda722a9e423f1a0d3f0d267ea009d41c,51f6dcf6b89b93f4075ba92c400b075631a6cc93,b10b3e2cb320a8c211fda94c4567299d37de7776",
|
||||||
|
},
|
||||||
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 file list commits",
|
||||||
|
opts: options.Options{
|
||||||
|
RepoPath: "../test_data/test_repos/test_repo_2",
|
||||||
|
Report: "../test_data/test_local_repo_two_leaks_file_commit_range.json.got",
|
||||||
|
ReportFormat: "json",
|
||||||
|
CommitsFile: "../test_data/test_options/test_local_repo_commits.txt",
|
||||||
|
},
|
||||||
|
wantPath: "../test_data/test_local_repo_two_leaks_file_commit_range.json",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
description: "test local repo two leaks globally allowlisted",
|
description: "test local repo two leaks globally allowlisted",
|
||||||
opts: options.Options{
|
opts: options.Options{
|
||||||
@@ -124,6 +144,17 @@ func TestScan(t *testing.T) {
|
|||||||
},
|
},
|
||||||
wantEmpty: true,
|
wantEmpty: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
description: "test local repo three leaks dev branch with reportGroup set",
|
||||||
|
opts: options.Options{
|
||||||
|
RepoPath: "../test_data/test_repos/test_repo_3",
|
||||||
|
Report: "../test_data/test_local_repo_three_leaks_with_report_groups.json.got",
|
||||||
|
Config: "../test_data/test_configs/aws_key_with_report_groups.toml",
|
||||||
|
Branch: "dev",
|
||||||
|
ReportFormat: "json",
|
||||||
|
},
|
||||||
|
wantPath: "../test_data/test_local_repo_three_leaks_with_report_groups.json",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
description: "test local repo three leaks dev branch",
|
description: "test local repo three leaks dev branch",
|
||||||
opts: options.Options{
|
opts: options.Options{
|
||||||
@@ -385,6 +416,16 @@ func TestScan(t *testing.T) {
|
|||||||
},
|
},
|
||||||
wantPath: "../test_data/test_local_repo_eight.json",
|
wantPath: "../test_data/test_local_repo_eight.json",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
description: "test local repo nine",
|
||||||
|
opts: options.Options{
|
||||||
|
RepoPath: "../test_data/test_repos/test_repo_9",
|
||||||
|
Report: "../test_data/test_local_repo_nine_aws_leak.json.got",
|
||||||
|
Config: "../test_data/test_configs/large_with_global_allowlist_regex.toml",
|
||||||
|
ReportFormat: "json",
|
||||||
|
},
|
||||||
|
wantPath: "../test_data/test_local_repo_nine_aws_leak.json",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
@@ -412,6 +453,9 @@ func TestScan(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
err = m.Report()
|
err = m.Report()
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
if test.wantEmpty {
|
if test.wantEmpty {
|
||||||
if len(m.GetLeaks()) != 0 {
|
if len(m.GetLeaks()) != 0 {
|
||||||
|
|||||||
@@ -2,13 +2,7 @@
|
|||||||
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.allowlist]]
|
[rules.allowlist]
|
||||||
description = "ignore md files"
|
description = "ignore sample regex md files"
|
||||||
file = '''(.*)?md$'''
|
files = ['''(.*)?md$''']
|
||||||
[[rules.allowlist]]
|
regexes = ['''ignore$''']
|
||||||
description = "ignore this regex"
|
|
||||||
regex = '''ignore$'''
|
|
||||||
[[rules.allowlist]]
|
|
||||||
description = "ignore regex and md files"
|
|
||||||
regex = '''ignore$'''
|
|
||||||
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.allowlist]]
|
[rules.allowlist]
|
||||||
description = "ignore python files"
|
description = "ignore python files"
|
||||||
file = '''(.*)?py$'''
|
files = ['''(.*)?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.allowlist]]
|
[rules.allowlist]
|
||||||
regex = '''AKIAIO5FODNN7EXAMPLE.*'''
|
|
||||||
description = "ignore aws key"
|
description = "ignore aws key"
|
||||||
|
regexes = ['''AKIAIO5FODNN7EXAMPLE.*''']
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
[[rules]]
|
||||||
|
description = "AWS Secret Key"
|
||||||
|
regex = '''(?i)aws(.{0,20})?(?-i)['\"][0-9a-zA-Z\/+]{40}['\"]'''
|
||||||
|
tags = ["key", "AWS"]
|
||||||
|
|
||||||
|
[[rules]]
|
||||||
|
description = "AWS Manager ID"
|
||||||
|
regex = '''AWS secret: ("?)((A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16})("?)'''
|
||||||
|
tags = ["key", "AWS"]
|
||||||
|
reportGroup = 2
|
||||||
@@ -125,19 +125,19 @@ 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.allowlist]]
|
[rules.allowlist]
|
||||||
description = "ignore common jenkins functions"
|
description = "ignore common jenkins functions"
|
||||||
regex = '''allowlistme'''
|
regexes = [
|
||||||
file = '''(.*)?Jenkinsfile$'''
|
'''allowlistme'''
|
||||||
[[rules.allowlist]]
|
]
|
||||||
description = "ignore common jenkins functions2"
|
files = [
|
||||||
regex = '''allowlistme'''
|
'''(.*)?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
|
||||||
[[rules]]
|
[[rules]]
|
||||||
description = "Files with keys and credentials"
|
description = "Files with keys and credentials"
|
||||||
fileRegex = '''(.*?)(pem)'''
|
file = '''(.*?)(pem)'''
|
||||||
|
|
||||||
[allowlist]
|
[allowlist]
|
||||||
description = "File allowlists"
|
description = "File allowlists"
|
||||||
|
|||||||
@@ -0,0 +1,151 @@
|
|||||||
|
title = "gitleaks config"
|
||||||
|
|
||||||
|
[[rules]]
|
||||||
|
description = "AWS Secret Key"
|
||||||
|
regex = '''(?i)aws(.{0,20})?(?-i)['\"][0-9a-zA-Z\/+]{40}['\"]'''
|
||||||
|
tags = ["key", "AWS"]
|
||||||
|
|
||||||
|
[[rules]]
|
||||||
|
description = "AWS MWS key"
|
||||||
|
regex = '''amzn\.mws\.[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'''
|
||||||
|
tags = ["key", "AWS", "MWS"]
|
||||||
|
|
||||||
|
[[rules]]
|
||||||
|
description = "Facebook Secret Key"
|
||||||
|
regex = '''(?i)(facebook|fb)(.{0,20})?(?-i)['\"][0-9a-f]{32}['\"]'''
|
||||||
|
tags = ["key", "Facebook"]
|
||||||
|
|
||||||
|
[[rules]]
|
||||||
|
description = "Facebook Client ID"
|
||||||
|
regex = '''(?i)(facebook|fb)(.{0,20})?['\"][0-9]{13,17}['\"]'''
|
||||||
|
tags = ["key", "Facebook"]
|
||||||
|
|
||||||
|
[[rules]]
|
||||||
|
description = "Twitter Secret Key"
|
||||||
|
regex = '''(?i)twitter(.{0,20})?['\"][0-9a-z]{35,44}['\"]'''
|
||||||
|
tags = ["key", "Twitter"]
|
||||||
|
|
||||||
|
[[rules]]
|
||||||
|
description = "Twitter Client ID"
|
||||||
|
regex = '''(?i)twitter(.{0,20})?['\"][0-9a-z]{18,25}['\"]'''
|
||||||
|
tags = ["client", "Twitter"]
|
||||||
|
|
||||||
|
[[rules]]
|
||||||
|
description = "Github"
|
||||||
|
regex = '''(?i)github(.{0,20})?(?-i)['\"][0-9a-zA-Z]{35,40}['\"]'''
|
||||||
|
tags = ["key", "Github"]
|
||||||
|
|
||||||
|
[[rules]]
|
||||||
|
description = "LinkedIn Client ID"
|
||||||
|
regex = '''(?i)linkedin(.{0,20})?(?-i)['\"][0-9a-z]{12}['\"]'''
|
||||||
|
tags = ["client", "LinkedIn"]
|
||||||
|
|
||||||
|
[[rules]]
|
||||||
|
description = "LinkedIn Secret Key"
|
||||||
|
regex = '''(?i)linkedin(.{0,20})?['\"][0-9a-z]{16}['\"]'''
|
||||||
|
tags = ["secret", "LinkedIn"]
|
||||||
|
|
||||||
|
[[rules]]
|
||||||
|
description = "Slack"
|
||||||
|
regex = '''xox[baprs]-([0-9a-zA-Z]{10,48})?'''
|
||||||
|
tags = ["key", "Slack"]
|
||||||
|
|
||||||
|
[[rules]]
|
||||||
|
description = "EC"
|
||||||
|
regex = '''-----BEGIN EC PRIVATE KEY-----'''
|
||||||
|
tags = ["key", "EC"]
|
||||||
|
|
||||||
|
[[rules]]
|
||||||
|
description = "Generic API key"
|
||||||
|
regex = '''(?i)(api_key|apikey)(.{0,20})?['|"][0-9a-zA-Z]{32,45}['|"]'''
|
||||||
|
tags = ["key", "API", "generic"]
|
||||||
|
|
||||||
|
[[rules]]
|
||||||
|
description = "Generic Secret"
|
||||||
|
regex = '''(?i)secret(.{0,20})?['|"][0-9a-zA-Z]{32,45}['|"]'''
|
||||||
|
tags = ["key", "Secret", "generic"]
|
||||||
|
|
||||||
|
[[rules]]
|
||||||
|
description = "Google API key"
|
||||||
|
regex = '''AIza[0-9A-Za-z\\-_]{35}'''
|
||||||
|
tags = ["key", "Google"]
|
||||||
|
|
||||||
|
|
||||||
|
[[rules]]
|
||||||
|
description = "Heroku API key"
|
||||||
|
regex = '''(?i)heroku(.{0,20})?['"][0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}['"]'''
|
||||||
|
tags = ["key", "Heroku"]
|
||||||
|
|
||||||
|
[[rules]]
|
||||||
|
description = "MailChimp API key"
|
||||||
|
regex = '''(?i)(mailchimp|mc)(.{0,20})?['"][0-9a-f]{32}-us[0-9]{1,2}['"]'''
|
||||||
|
tags = ["key", "Mailchimp"]
|
||||||
|
|
||||||
|
[[rules]]
|
||||||
|
description = "Mailgun API key"
|
||||||
|
regex = '''(?i)(mailgun|mg)(.{0,20})?['"][0-9a-z]{32}['"]'''
|
||||||
|
tags = ["key", "Mailgun"]
|
||||||
|
|
||||||
|
[[rules]]
|
||||||
|
description = "PayPal Braintree access token"
|
||||||
|
regex = '''access_token\$production\$[0-9a-z]{16}\$[0-9a-f]{32}'''
|
||||||
|
tags = ["key", "Paypal"]
|
||||||
|
|
||||||
|
[[rules]]
|
||||||
|
description = "Picatic API key"
|
||||||
|
regex = '''sk_live_[0-9a-z]{32}'''
|
||||||
|
tags = ["key", "Picatic"]
|
||||||
|
|
||||||
|
[[rules]]
|
||||||
|
description = "Slack Webhook"
|
||||||
|
regex = '''https://hooks.slack.com/services/T[a-zA-Z0-9_]{8}/B[a-zA-Z0-9_]{8}/[a-zA-Z0-9_]{24}'''
|
||||||
|
tags = ["key", "slack"]
|
||||||
|
|
||||||
|
[[rules]]
|
||||||
|
description = "Stripe API key"
|
||||||
|
regex = '''(?i)stripe(.{0,20})?['\"][sk|rk]_live_[0-9a-zA-Z]{24}'''
|
||||||
|
tags = ["key", "Stripe"]
|
||||||
|
|
||||||
|
[[rules]]
|
||||||
|
description = "Square access token"
|
||||||
|
regex = '''sq0atp-[0-9A-Za-z\-_]{22}'''
|
||||||
|
tags = ["key", "square"]
|
||||||
|
|
||||||
|
[[rules]]
|
||||||
|
description = "Square OAuth secret"
|
||||||
|
regex = '''sq0csp-[0-9A-Za-z\\-_]{43}'''
|
||||||
|
tags = ["key", "square"]
|
||||||
|
|
||||||
|
[[rules]]
|
||||||
|
description = "Twilio API key"
|
||||||
|
regex = '''(?i)twilio(.{0,20})?['\"][0-9a-f]{32}['\"]'''
|
||||||
|
tags = ["key", "twilio"]
|
||||||
|
|
||||||
|
[[rules]]
|
||||||
|
description = "AWS Manager ID"
|
||||||
|
regex = '''(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}'''
|
||||||
|
tags = ["key", "AWS"]
|
||||||
|
[rules.allowlist]
|
||||||
|
description = "ignore common jenkins functions"
|
||||||
|
regexes = [
|
||||||
|
'''allowlistme'''
|
||||||
|
]
|
||||||
|
files = [
|
||||||
|
'''(.*)?Jenkinsfile$'''
|
||||||
|
]
|
||||||
|
|
||||||
|
[[rules]]
|
||||||
|
description = "Files with keys and credentials"
|
||||||
|
file = '''(.*?)(pem)'''
|
||||||
|
|
||||||
|
# Global allowlist
|
||||||
|
[allowlist]
|
||||||
|
description = "global allowlists"
|
||||||
|
files = [
|
||||||
|
'''(.*?)(jpg|gif)$''',
|
||||||
|
'''(.*?)(doc|pdf|bin)$'''
|
||||||
|
]
|
||||||
|
regexes = [
|
||||||
|
'''(.*?)gitleaks:allow'''
|
||||||
|
]
|
||||||
|
|
||||||
@@ -2,5 +2,5 @@
|
|||||||
[[rules]]
|
[[rules]]
|
||||||
description = "Generic password"
|
description = "Generic password"
|
||||||
regex = '''(?i)(password|token).{0,20}?\s*[:|=]\s*?(?-i)([0-9a-zA-Z\/+]{4,40})'''
|
regex = '''(?i)(password|token).{0,20}?\s*[:|=]\s*?(?-i)([0-9a-zA-Z\/+]{4,40})'''
|
||||||
fileNameRegex = '''.*\.ya?ml'''
|
file = '''.*\.ya?ml'''
|
||||||
tags = ["key", "Yml", "Yaml"]
|
tags = ["key", "Yml", "Yaml"]
|
||||||
@@ -2,5 +2,5 @@
|
|||||||
[[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}'''
|
||||||
filePathRegex = '''config(guration)?'''
|
path = '''config(guration)?'''
|
||||||
tags = ["key", "AWS"]
|
tags = ["key", "AWS"]
|
||||||
@@ -2,6 +2,6 @@
|
|||||||
[[rules]]
|
[[rules]]
|
||||||
description = "Generic password"
|
description = "Generic password"
|
||||||
regex = '''(?i)(password|token).{0,20}?\s*[:|=]\s*?(?-i)([0-9a-zA-Z\/+]{4,40})'''
|
regex = '''(?i)(password|token).{0,20}?\s*[:|=]\s*?(?-i)([0-9a-zA-Z\/+]{4,40})'''
|
||||||
fileNameRegex = '''.*\.properties'''
|
file = '''.*\.properties'''
|
||||||
filePathRegex = '''config(guration)?'''
|
path = '''config(guration)?'''
|
||||||
tags = ["key", "Yml", "Yaml"]
|
tags = ["key", "Yml", "Yaml"]
|
||||||
@@ -178,5 +178,20 @@
|
|||||||
"date": "2020-07-25T14:41:11-04:00",
|
"date": "2020-07-25T14:41:11-04:00",
|
||||||
"tags": "key, AWS",
|
"tags": "key, AWS",
|
||||||
"operation": "addition"
|
"operation": "addition"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE', #gitleaks:allow",
|
||||||
|
"lineNumber": 6,
|
||||||
|
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||||
|
"commit": "8d1fb60d2d80f0590f191ed5ace1e45ef780909a",
|
||||||
|
"repo": "test_repo_9",
|
||||||
|
"rule": "AWS Manager ID",
|
||||||
|
"commitMessage": "gitleaks allow secret\n",
|
||||||
|
"author": "Zach Rice",
|
||||||
|
"email": "zrice@gitlab.com",
|
||||||
|
"file": "server.test.py",
|
||||||
|
"date": "2020-08-12T13:36:20-04:00",
|
||||||
|
"tags": "key, AWS",
|
||||||
|
"operation": "addition"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -178,5 +178,20 @@
|
|||||||
"date": "2020-07-25T14:41:11-04:00",
|
"date": "2020-07-25T14:41:11-04:00",
|
||||||
"tags": "key, AWS",
|
"tags": "key, AWS",
|
||||||
"operation": "addition"
|
"operation": "addition"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE', #gitleaks:allow",
|
||||||
|
"lineNumber": 6,
|
||||||
|
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||||
|
"commit": "8d1fb60d2d80f0590f191ed5ace1e45ef780909a",
|
||||||
|
"repo": "test_repo_9",
|
||||||
|
"rule": "AWS Manager ID",
|
||||||
|
"commitMessage": "gitleaks allow secret\n",
|
||||||
|
"author": "Zach Rice",
|
||||||
|
"email": "zrice@gitlab.com",
|
||||||
|
"file": "server.test.py",
|
||||||
|
"date": "2020-08-12T13:36:20-04:00",
|
||||||
|
"tags": "key, AWS",
|
||||||
|
"operation": "addition"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -88,5 +88,20 @@
|
|||||||
"date": "2020-07-25T14:44:48-04:00",
|
"date": "2020-07-25T14:44:48-04:00",
|
||||||
"tags": "key, AWS",
|
"tags": "key, AWS",
|
||||||
"operation": "addition"
|
"operation": "addition"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE', #gitleaks:allow",
|
||||||
|
"lineNumber": 6,
|
||||||
|
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||||
|
"commit": "8d1fb60d2d80f0590f191ed5ace1e45ef780909a",
|
||||||
|
"repo": "test_repo_9",
|
||||||
|
"rule": "AWS Manager ID",
|
||||||
|
"commitMessage": "gitleaks allow secret\n",
|
||||||
|
"author": "Zach Rice",
|
||||||
|
"email": "zrice@gitlab.com",
|
||||||
|
"file": "server.test.py",
|
||||||
|
"date": "2020-08-12T13:36:20-04:00",
|
||||||
|
"tags": "key, AWS",
|
||||||
|
"operation": "addition"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||||
|
"lineNumber": 5,
|
||||||
|
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||||
|
"commit": "6557c92612d3b35979bd426d429255b3bf9fab74",
|
||||||
|
"repo": "test_repo_9",
|
||||||
|
"rule": "AWS Manager ID",
|
||||||
|
"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": "key, AWS",
|
||||||
|
"operation": "addition"
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"line": "AWS secret: \"AKIALALEMEL33243OLIAE\"",
|
||||||
|
"lineNumber": 6,
|
||||||
|
"offender": "AKIALALEMEL33243OLIA",
|
||||||
|
"commit": "deea550dd6c7acaf0e59432600593533984a2125",
|
||||||
|
"repo": "test_repo_3",
|
||||||
|
"rule": "AWS Manager ID",
|
||||||
|
"commitMessage": "dev branch\n",
|
||||||
|
"author": "zach rice",
|
||||||
|
"email": "zricer@protonmail.com",
|
||||||
|
"file": "secrets.md",
|
||||||
|
"date": "2019-10-25T13:35:03-04:00",
|
||||||
|
"tags": "key, AWS",
|
||||||
|
"operation": "addition"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"",
|
||||||
|
"lineNumber": 5,
|
||||||
|
"offender": "AKIALALEMEL33243OLIA",
|
||||||
|
"commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c",
|
||||||
|
"repo": "test_repo_3",
|
||||||
|
"rule": "AWS Manager ID",
|
||||||
|
"commitMessage": "wait this is actually adding an aws secret\n",
|
||||||
|
"author": "zach rice",
|
||||||
|
"email": "zricer@protonmail.com",
|
||||||
|
"file": "secrets.md",
|
||||||
|
"date": "2019-10-25T13:01:27-04:00",
|
||||||
|
"tags": "key, AWS",
|
||||||
|
"operation": "addition"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"line": "Here's an AWS secret: AKIALALEMEL33243OLIAE",
|
||||||
|
"lineNumber": 3,
|
||||||
|
"offender": "AKIALALEMEL33243OLIA",
|
||||||
|
"commit": "b10b3e2cb320a8c211fda94c4567299d37de7776",
|
||||||
|
"repo": "test_repo_3",
|
||||||
|
"rule": "AWS Manager ID",
|
||||||
|
"commitMessage": "adding aws key\n",
|
||||||
|
"author": "zach rice",
|
||||||
|
"email": "zricer@protonmail.com",
|
||||||
|
"file": "secrets.md",
|
||||||
|
"date": "2019-10-25T12:58:39-04:00",
|
||||||
|
"tags": "key, AWS",
|
||||||
|
"operation": "addition"
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -13,5 +13,20 @@
|
|||||||
"date": "2019-10-25T13:01:27-04:00",
|
"date": "2019-10-25T13:01:27-04:00",
|
||||||
"tags": "key, AWS",
|
"tags": "key, AWS",
|
||||||
"operation": "addition"
|
"operation": "addition"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"line": "Here's an AWS secret: AKIALALEMEL33243OLIAE",
|
||||||
|
"lineNumber": 3,
|
||||||
|
"offender": "AKIALALEMEL33243OLIA",
|
||||||
|
"commit": "b10b3e2cb320a8c211fda94c4567299d37de7776",
|
||||||
|
"repo": "test_repo_2",
|
||||||
|
"rule": "AWS Manager ID",
|
||||||
|
"commitMessage": "adding aws key\n",
|
||||||
|
"author": "zach rice",
|
||||||
|
"email": "zricer@protonmail.com",
|
||||||
|
"file": "secrets.md",
|
||||||
|
"date": "2019-10-25T12:58:39-04:00",
|
||||||
|
"tags": "key, AWS",
|
||||||
|
"operation": "addition"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"",
|
||||||
|
"lineNumber": 5,
|
||||||
|
"offender": "AKIALALEMEL33243OLIA",
|
||||||
|
"commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c",
|
||||||
|
"repo": "test_repo_2",
|
||||||
|
"rule": "AWS Manager ID",
|
||||||
|
"commitMessage": "wait this is actually adding an aws secret\n",
|
||||||
|
"author": "zach rice",
|
||||||
|
"email": "zricer@protonmail.com",
|
||||||
|
"file": "secrets.md",
|
||||||
|
"date": "2019-10-25T13:01:27-04:00",
|
||||||
|
"tags": "key, AWS",
|
||||||
|
"operation": "addition"
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"",
|
||||||
|
"lineNumber": 5,
|
||||||
|
"offender": "AKIALALEMEL33243OLIA",
|
||||||
|
"commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c",
|
||||||
|
"repo": "test_repo_2",
|
||||||
|
"rule": "AWS Manager ID",
|
||||||
|
"commitMessage": "wait this is actually adding an aws secret\n",
|
||||||
|
"author": "zach rice",
|
||||||
|
"email": "zricer@protonmail.com",
|
||||||
|
"file": "secrets.md",
|
||||||
|
"date": "2019-10-25T13:01:27-04:00",
|
||||||
|
"tags": "key, AWS",
|
||||||
|
"operation": "addition"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"line": "Here's an AWS secret: AKIALALEMEL33243OLIAE",
|
||||||
|
"lineNumber": 3,
|
||||||
|
"offender": "AKIALALEMEL33243OLIA",
|
||||||
|
"commit": "b10b3e2cb320a8c211fda94c4567299d37de7776",
|
||||||
|
"repo": "test_repo_2",
|
||||||
|
"rule": "AWS Manager ID",
|
||||||
|
"commitMessage": "adding aws key\n",
|
||||||
|
"author": "zach rice",
|
||||||
|
"email": "zricer@protonmail.com",
|
||||||
|
"file": "secrets.md",
|
||||||
|
"date": "2019-10-25T12:58:39-04:00",
|
||||||
|
"tags": "key, AWS",
|
||||||
|
"operation": "addition"
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
d8ac0b73aeeb45843319cdc5ce506516eb49bf7a
|
||||||
|
996865bb912f3bc45898a370a13aadb315014b55
|
||||||
|
17471a5fda722a9e423f1a0d3f0d267ea009d41c
|
||||||
|
51f6dcf6b89b93f4075ba92c400b075631a6cc93
|
||||||
|
b10b3e2cb320a8c211fda94c4567299d37de7776
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
gitleaks allow secret
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
ref: refs/heads/master
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
[core]
|
||||||
|
repositoryformatversion = 0
|
||||||
|
filemode = true
|
||||||
|
bare = false
|
||||||
|
logallrefupdates = true
|
||||||
|
ignorecase = true
|
||||||
|
precomposeunicode = true
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Unnamed repository; edit this file 'description' to name the repository.
|
||||||
Binary file not shown.
@@ -0,0 +1,6 @@
|
|||||||
|
# git ls-files --others --exclude-from=.git/info/exclude
|
||||||
|
# Lines that start with '#' are comments.
|
||||||
|
# For a project mostly in C, the following would be a good set of
|
||||||
|
# exclude patterns (uncomment them if you want to use them):
|
||||||
|
# *.[oa]
|
||||||
|
# *~
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
0000000000000000000000000000000000000000 6557c92612d3b35979bd426d429255b3bf9fab74 zach rice <zricer@protonmail.com> 1571923767 -0400 commit (initial): commit 1 with secrets
|
||||||
|
6557c92612d3b35979bd426d429255b3bf9fab74 d274003914c707212cbe84e3e466a00013ccb639 zach rice <zricer@protonmail.com> 1571925818 -0400 commit: comment
|
||||||
|
d274003914c707212cbe84e3e466a00013ccb639 8d1fb60d2d80f0590f191ed5ace1e45ef780909a Zach Rice <zrice@gitlab.com> 1597253780 -0400 commit: gitleaks allow secret
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
0000000000000000000000000000000000000000 6557c92612d3b35979bd426d429255b3bf9fab74 zach rice <zricer@protonmail.com> 1571923767 -0400 commit (initial): commit 1 with secrets
|
||||||
|
6557c92612d3b35979bd426d429255b3bf9fab74 d274003914c707212cbe84e3e466a00013ccb639 zach rice <zricer@protonmail.com> 1571925818 -0400 commit: comment
|
||||||
|
d274003914c707212cbe84e3e466a00013ccb639 8d1fb60d2d80f0590f191ed5ace1e45ef780909a Zach Rice <zrice@gitlab.com> 1597253780 -0400 commit: gitleaks allow secret
|
||||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
+2
@@ -0,0 +1,2 @@
|
|||||||
|
x•ŽM
|
||||||
|
Â0F]çseò߀ˆgpén2�Úbk$�žÞzW<x��˲L␍Œ »VE€õ`9X§½ë(ø,Zzé}ÈnˆL,I˜P=©Ê£Ao¢C´I;Ž�6œ¥sbÅ…@ˆ¨-s6)zµ±T¸�p™Xàø©ÛœoS›)¸,'Ð>Eãmìö¸eÕF·wMþõÔ¯*t_�æ¹¼a®ÒÔ¼G*
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
xMŽO‚@Ĺ;ď§č`‘%:XjE ˘<Éş;�¤»°ł~űĚ
|
||||||
|
z§÷`~ďMVęFţ´Ó…P�ŇnÜHZ"�•-xIL”Eca™¶Ú÷>±Ç ‘Cľă¶®«,�¬)TNŔéżČm7
|
||||||
|
]U¨$JŻ%ů“R.Ąw¬ÓBÎś`łÖ‡q|÷űIt␍vÇmôÝy_6ďŮ?¨!ć‹0Šb´ťÔW\>ε9ć …ęr:-†Aň+a}Ć^K§N$
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
xuPMOÃ0åÚüŠGV1lc.LEB`†Ä¸!Miç*a]R5!þ;N‡øââÄö{ÏÏÎ+—ãìôt§³;Ì�z-:¢ƒKzQ«º"hç–ðEcê€à°RKÂÚ\‰zí5\Œ³~À¬™¦/š7Ì~Ú‘‡ªª_h|PMÀÆ�næªXf]Rv�†ž¨ßTVÙh²Ì$ÈmSþÔ„ñÑׂ�D+dUÎþƒæF\âˆ%Z}VJ{²n¨ßPAæ™ä@S"�è[Èôz2›ß=Üß̧w³Éôv~5}¸�IÁ¬HLv,’�nu"C¦F¢_ÅÏ?¼dáD’гª 9¬){üeÆŠ/,Ó$axZòu ƒgm
|
||||||
|
‹(·jÏòc•~Üøé[+Ñ9ÈÞ%.öN"s<æ¸=àVéÅŒâ¯
|
||||||
|
~L–îïbÔãþÂY¥eMª$
|
||||||
BIN
Binary file not shown.
+1
@@ -0,0 +1 @@
|
|||||||
|
x-�±jÃ0„;ç)<¤␍µSJ§B¦@¦¾Aé Û¿lI¤_¸Yú쑃·ãø¾»Þ³ÇûÇÛSƒÉ)|nó’ѶÔYÒäoðe”Ö&†SW©£‹–ÇÞ5ør±:EV“‹Óûf“C�¨¹«ä… ×Ä_�Yý␍.âüZu�¥÷\\œ°°ø½Tz"GdQÐÖ…íW£*)f<—¸=¬ÎâÆ‚ÅD…%Ë£ù¬ò¡û¦ùYÃÿîá›SC
|
||||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
+2
@@ -0,0 +1,2 @@
|
|||||||
|
x��Í
|
||||||
|
1„½êS䨥MÚf+"¾J“XØY‚OïŠ^¼íÀ00‡áéFB\™…‚à=kÄ`±%!9Jë0ÌŽè½�\ã5 ;x%½ÁT4Ãéõ‰érŸÆ:}*ÝAÇþÖ³�HöƳžÛ¾TØ–¡Ô’ºÝ~�…g©7xd�r}l3´Èó.Eë”␍£E•ܸLÙ…�æÇ–T%P\ëÛüÁ~óP7oq,\é
|
||||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
+2
@@ -0,0 +1,2 @@
|
|||||||
|
x-ÍK‚0P×9E[�r§Kïà&0H
|
||||||
|
Ȥ&ƒ…·7~–Ý]õÚ/âq¾\õ±ó!vyrµ«q‹à�Ö´0&‘¹×�&Hʉ”AHÔÏ< dÉÁD_E±e†<Y2l«‡)ÅœD-·_ù.àH¾À6…üÕOň´þ›1|6AUXk¶4�qÕ:Ç;÷xïj2k¹iBŽvÐBü
|
||||||
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1 @@
|
|||||||
|
8d1fb60d2d80f0590f191ed5ace1e45ef780909a
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
# Do not hard code credentials
|
||||||
|
client = boto3.client(
|
||||||
|
's3',
|
||||||
|
# Hard coded strings as credentials, not recommended.
|
||||||
|
aws_access_key_id='AKIAIO5FODNN7EXAMPLE', #gitleaks:allow
|
||||||
|
aws_secret_access_key='ABCDEF+c2L7yXeGvUyrPgYsDnWRRC1AYEXAMPLE'
|
||||||
|
)
|
||||||
|
|
||||||
|
# adding another line
|
||||||
Reference in new issue
Block a user