mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-27 03:34:22 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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`
|
||||
PKG=github.com/zricethezav/gitleaks
|
||||
LDFLAGS=-ldflags "-X=github.com/zricethezav/gitleaks/v5/version.Version=$(VERSION)"
|
||||
_LDFLAGS="github.com/zricethezav/gitleaks/v5/version.Version=$(VERSION)"
|
||||
LDFLAGS=-ldflags "-X=github.com/zricethezav/gitleaks/v6/version.Version=$(VERSION)"
|
||||
_LDFLAGS="github.com/zricethezav/gitleaks/v6/version.Version=$(VERSION)"
|
||||
COVER=--cover --coverprofile=cover.out
|
||||
|
||||
test-cover:
|
||||
|
||||
@@ -31,8 +31,8 @@ Gamma proactively detects and remediates data leaks across cloud apps. Scan your
|
||||
#### Individual Sponsors
|
||||
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
|
||||
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>.
|
||||
|
||||
+84
-72
@@ -6,19 +6,21 @@ import (
|
||||
"regexp"
|
||||
"strconv"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v5/options"
|
||||
"github.com/zricethezav/gitleaks/v6/options"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// Allowlist is struct containing items that if encountered will allowlist
|
||||
// AllowList is struct containing items that if encountered will allowlist
|
||||
// a commit/line of code that would be considered a leak.
|
||||
type Allowlist struct {
|
||||
type AllowList struct {
|
||||
Description string
|
||||
Regex *regexp.Regexp
|
||||
File *regexp.Regexp
|
||||
Path *regexp.Regexp
|
||||
Regexes []*regexp.Regexp
|
||||
Commits []string
|
||||
Files []*regexp.Regexp
|
||||
Paths []*regexp.Regexp
|
||||
Repos []*regexp.Regexp
|
||||
}
|
||||
|
||||
// Entropy represents an entropy range
|
||||
@@ -34,56 +36,50 @@ type Entropy struct {
|
||||
// that match is not allowlisted (globally or locally), then a leak will be appended
|
||||
// to the final scan report.
|
||||
type Rule struct {
|
||||
Description string
|
||||
Regex *regexp.Regexp
|
||||
FileNameRegex *regexp.Regexp
|
||||
FilePathRegex *regexp.Regexp
|
||||
Tags []string
|
||||
Allowlist []Allowlist
|
||||
Entropies []Entropy
|
||||
Description string
|
||||
Regex *regexp.Regexp
|
||||
File *regexp.Regexp
|
||||
Path *regexp.Regexp
|
||||
Tags []string
|
||||
AllowList AllowList
|
||||
Entropies []Entropy
|
||||
}
|
||||
|
||||
// Config is a composite struct of Rules and Allowlists
|
||||
// Each Rule contains a description, regular expression, tags, and allowlists if available
|
||||
type Config struct {
|
||||
Rules []Rule
|
||||
Allowlist struct {
|
||||
Description string
|
||||
Commits []string
|
||||
Files []*regexp.Regexp
|
||||
Paths []*regexp.Regexp
|
||||
Repos []*regexp.Regexp
|
||||
}
|
||||
Allowlist AllowList
|
||||
}
|
||||
|
||||
// TomlAllowList is a struct used in the TomlLoader that loads in allowlists from
|
||||
// specific rules or globally at the top level config
|
||||
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
|
||||
// see the config in config/defaults.go for an example. TomlLoader is used
|
||||
// to generate Config values (compiling regexes, etc).
|
||||
type TomlLoader struct {
|
||||
Allowlist struct {
|
||||
AllowList TomlAllowList
|
||||
Rules []struct {
|
||||
Description string
|
||||
Commits []string
|
||||
Files []string
|
||||
Paths []string
|
||||
Repos []string
|
||||
}
|
||||
Rules []struct {
|
||||
Description string
|
||||
Regex string
|
||||
FileNameRegex string
|
||||
FilePathRegex string
|
||||
Tags []string
|
||||
Entropies []struct {
|
||||
Regex string
|
||||
File string
|
||||
Path string
|
||||
Tags []string
|
||||
Entropies []struct {
|
||||
Min string
|
||||
Max string
|
||||
Group string
|
||||
}
|
||||
Allowlist []struct {
|
||||
Description string
|
||||
Regex string
|
||||
File string
|
||||
Path string
|
||||
}
|
||||
AllowList TomlAllowList
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +95,7 @@ func NewConfig(options options.Options) (Config, error) {
|
||||
if options.Config != "" {
|
||||
_, err = toml.DecodeFile(options.Config, &tomlLoader)
|
||||
// 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 {
|
||||
_, err = toml.Decode(DefaultConfig, &tomlLoader)
|
||||
}
|
||||
@@ -121,7 +117,7 @@ func (tomlLoader TomlLoader) Parse() (Config, error) {
|
||||
var cfg Config
|
||||
for _, rule := range tomlLoader.Rules {
|
||||
// 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)
|
||||
continue
|
||||
}
|
||||
@@ -129,36 +125,43 @@ func (tomlLoader TomlLoader) Parse() (Config, error) {
|
||||
if err != nil {
|
||||
return cfg, fmt.Errorf("problem loading config: %v", err)
|
||||
}
|
||||
fileNameRe, err := regexp.Compile(rule.FileNameRegex)
|
||||
fileNameRe, err := regexp.Compile(rule.File)
|
||||
if err != nil {
|
||||
return cfg, fmt.Errorf("problem loading config: %v", err)
|
||||
}
|
||||
filePathRe, err := regexp.Compile(rule.FilePathRegex)
|
||||
filePathRe, err := regexp.Compile(rule.Path)
|
||||
if err != nil {
|
||||
return cfg, fmt.Errorf("problem loading config: %v", err)
|
||||
}
|
||||
|
||||
// rule specific allowlists
|
||||
var allowlists []Allowlist
|
||||
for _, wl := range rule.Allowlist {
|
||||
wlRe, err := regexp.Compile(wl.Regex)
|
||||
var allowList AllowList
|
||||
|
||||
// rule specific regexes
|
||||
for _, re := range rule.AllowList.Regexes {
|
||||
allowListedRegex, err := regexp.Compile(re)
|
||||
if err != nil {
|
||||
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 {
|
||||
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 {
|
||||
return cfg, fmt.Errorf("problem loading config: %v", err)
|
||||
}
|
||||
allowlists = append(allowlists, Allowlist{
|
||||
Description: wl.Description,
|
||||
File: wlFileNameRe,
|
||||
Path: wlFilePathRe,
|
||||
Regex: wlRe,
|
||||
})
|
||||
allowList.Paths = append(allowList.Paths, allowListedRegex)
|
||||
}
|
||||
|
||||
var entropies []Entropy
|
||||
@@ -191,47 +194,56 @@ func (tomlLoader TomlLoader) Parse() (Config, error) {
|
||||
}
|
||||
|
||||
r := Rule{
|
||||
Description: rule.Description,
|
||||
Regex: re,
|
||||
FileNameRegex: fileNameRe,
|
||||
FilePathRegex: filePathRe,
|
||||
Tags: rule.Tags,
|
||||
Allowlist: allowlists,
|
||||
Entropies: entropies,
|
||||
Description: rule.Description,
|
||||
Regex: re,
|
||||
File: fileNameRe,
|
||||
Path: filePathRe,
|
||||
Tags: rule.Tags,
|
||||
AllowList: allowList,
|
||||
Entropies: entropies,
|
||||
}
|
||||
|
||||
cfg.Rules = append(cfg.Rules, r)
|
||||
}
|
||||
|
||||
// global file name allowlists
|
||||
for _, wlFileName := range tomlLoader.Allowlist.Files {
|
||||
re, err := regexp.Compile(wlFileName)
|
||||
// global regex allowLists
|
||||
for _, allowListRegex := range tomlLoader.AllowList.Regexes {
|
||||
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 {
|
||||
return cfg, fmt.Errorf("problem loading config: %v", err)
|
||||
}
|
||||
cfg.Allowlist.Files = append(cfg.Allowlist.Files, re)
|
||||
}
|
||||
|
||||
// global file path allowlists
|
||||
for _, wlFilePath := range tomlLoader.Allowlist.Paths {
|
||||
re, err := regexp.Compile(wlFilePath)
|
||||
// global file path allowLists
|
||||
for _, allowListFilePath := range tomlLoader.AllowList.Paths {
|
||||
re, err := regexp.Compile(allowListFilePath)
|
||||
if err != nil {
|
||||
return cfg, fmt.Errorf("problem loading config: %v", err)
|
||||
}
|
||||
cfg.Allowlist.Paths = append(cfg.Allowlist.Paths, re)
|
||||
}
|
||||
|
||||
// global repo allowlists
|
||||
for _, wlRepo := range tomlLoader.Allowlist.Repos {
|
||||
re, err := regexp.Compile(wlRepo)
|
||||
// global repo allowLists
|
||||
for _, allowListRepo := range tomlLoader.AllowList.Repos {
|
||||
re, err := regexp.Compile(allowListRepo)
|
||||
if err != nil {
|
||||
return cfg, fmt.Errorf("problem loading config: %v", err)
|
||||
}
|
||||
cfg.Allowlist.Repos = append(cfg.Allowlist.Repos, re)
|
||||
}
|
||||
|
||||
cfg.Allowlist.Commits = tomlLoader.Allowlist.Commits
|
||||
cfg.Allowlist.Description = tomlLoader.Allowlist.Description
|
||||
cfg.Allowlist.Commits = tomlLoader.AllowList.Commits
|
||||
cfg.Allowlist.Description = tomlLoader.AllowList.Description
|
||||
|
||||
return cfg, nil
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"regexp"
|
||||
"testing"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v5/options"
|
||||
"github.com/zricethezav/gitleaks/v6/options"
|
||||
)
|
||||
|
||||
func TestParse(t *testing.T) {
|
||||
@@ -15,7 +15,7 @@ func TestParse(t *testing.T) {
|
||||
wantErr error
|
||||
wantFileRegex *regexp.Regexp
|
||||
wantMessages *regexp.Regexp
|
||||
wantAllowlist Allowlist
|
||||
wantAllowlist AllowList
|
||||
}{
|
||||
{
|
||||
description: "default config",
|
||||
@@ -122,7 +122,7 @@ func TestParse(t *testing.T) {
|
||||
_, err := NewConfig(test.opts)
|
||||
if err != nil {
|
||||
if test.wantErr == nil {
|
||||
t.Error(err)
|
||||
t.Error(test.description, err)
|
||||
} else if test.wantErr.Error() != err.Error() {
|
||||
t.Errorf("expected err: %s, got %s", test.wantErr, err)
|
||||
}
|
||||
|
||||
+21
-29
@@ -129,8 +129,8 @@ title = "gitleaks config"
|
||||
[[rules]]
|
||||
description = "Port"
|
||||
regex = '''(?i)port(.{0,4})?[0-9]{1,10}'''
|
||||
[[rules.allowlist]]
|
||||
regex = '''(?i)port '''
|
||||
[rules.allowlist]
|
||||
regexes = ['''(?i)port ''']
|
||||
description = "ignore export "
|
||||
|
||||
|
||||
@@ -139,8 +139,8 @@ title = "gitleaks config"
|
||||
description = "Email"
|
||||
regex = '''[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}'''
|
||||
tags = ["email"]
|
||||
[[rules.allowlist]]
|
||||
file = '''(?i)bashrc'''
|
||||
[rules.allowlist]
|
||||
files = ['''(?i)bashrc''']
|
||||
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})['|"]'''
|
||||
tags = ["key", "API", "generic"]
|
||||
# ignore leaks with specific identifiers like slack and aws
|
||||
[[rules.allowlist]]
|
||||
regex = '''xox[baprs]-([0-9a-zA-Z]{10,48})'''
|
||||
description = "ignore slack"
|
||||
[[rules.allowlist]]
|
||||
description = "MailChimp API key"
|
||||
regex = '''(?i)(.{0,20})?['"][0-9a-f]{32}-us[0-9]{1,2}['"]'''
|
||||
[[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.allowlist]
|
||||
description = "ignore slack, mailchimp, aws"
|
||||
regexes = [
|
||||
'''xox[baprs]-([0-9a-zA-Z]{10,48})''',
|
||||
'''(?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]]
|
||||
description = "High Entropy"
|
||||
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"]
|
||||
[[rules.Entropies]]
|
||||
Min = "4.3"
|
||||
Max = "7.0"
|
||||
[[rules.allowlist]]
|
||||
description = "ignore ssh key and pems"
|
||||
file = '''(pem|ppk|env)$'''
|
||||
path = '''(.*)?ssh'''
|
||||
|
||||
|
||||
[[rules.Entropies]]
|
||||
Min = "4.3"
|
||||
Max = "7.0"
|
||||
[rules.allowlist]
|
||||
description = "ignore ssh key and pems"
|
||||
files = ['''(pem|ppk|env)$''']
|
||||
paths = ['''(.*)?ssh''']
|
||||
|
||||
[[rules]]
|
||||
description = "Potential bash var"
|
||||
@@ -195,8 +186,9 @@ title = "gitleaks config"
|
||||
|
||||
[[rules]]
|
||||
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]
|
||||
description = "image allowlists"
|
||||
files = ['''(.*?)(jpg|gif|doc|pdf|bin)$''']
|
||||
|
||||
@@ -8,6 +8,6 @@
|
||||
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]]
|
||||
regex = '''AKIAIO5FODNN7EXAMPLE.*'''
|
||||
description = "ignore example aws key"
|
||||
[rules.allowlist]
|
||||
regexes = ['''AKIAIO5FODNN7EXAMPLE.*''']
|
||||
description = "ignore example aws key"
|
||||
@@ -1,4 +1,4 @@
|
||||
module github.com/zricethezav/gitleaks/v5
|
||||
module github.com/zricethezav/gitleaks/v6
|
||||
|
||||
go 1.14
|
||||
|
||||
|
||||
+3
-3
@@ -6,9 +6,9 @@ import (
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v5/manager"
|
||||
"github.com/zricethezav/gitleaks/v5/options"
|
||||
"github.com/zricethezav/gitleaks/v5/scan"
|
||||
"github.com/zricethezav/gitleaks/v6/manager"
|
||||
"github.com/zricethezav/gitleaks/v6/options"
|
||||
"github.com/zricethezav/gitleaks/v6/scan"
|
||||
|
||||
"github.com/go-git/go-git/v5"
|
||||
"github.com/go-git/go-git/v5/plumbing"
|
||||
|
||||
+7
-3
@@ -4,9 +4,9 @@ import (
|
||||
"context"
|
||||
"sync"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v5/manager"
|
||||
"github.com/zricethezav/gitleaks/v5/options"
|
||||
"github.com/zricethezav/gitleaks/v5/scan"
|
||||
"github.com/zricethezav/gitleaks/v6/manager"
|
||||
"github.com/zricethezav/gitleaks/v6/options"
|
||||
"github.com/zricethezav/gitleaks/v6/scan"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/xanzy/go-gitlab"
|
||||
@@ -93,6 +93,10 @@ func (g *Gitlab) Scan() {
|
||||
cloneOpts := g.manager.CloneOptions
|
||||
cloneOpts.URL = p.HTTPURLToRepo
|
||||
err := r.Clone(cloneOpts)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
continue
|
||||
}
|
||||
// TODO handle clone retry with ssh like github host
|
||||
r.Name = p.Name
|
||||
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ package hosts
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v5/manager"
|
||||
"github.com/zricethezav/gitleaks/v6/manager"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
+3
-3
@@ -6,9 +6,9 @@ import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v5/config"
|
||||
"github.com/zricethezav/gitleaks/v5/manager"
|
||||
"github.com/zricethezav/gitleaks/v5/options"
|
||||
"github.com/zricethezav/gitleaks/v6/config"
|
||||
"github.com/zricethezav/gitleaks/v6/manager"
|
||||
"github.com/zricethezav/gitleaks/v6/options"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -5,11 +5,11 @@ import (
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v5/config"
|
||||
"github.com/zricethezav/gitleaks/v5/hosts"
|
||||
"github.com/zricethezav/gitleaks/v5/manager"
|
||||
"github.com/zricethezav/gitleaks/v5/options"
|
||||
"github.com/zricethezav/gitleaks/v5/scan"
|
||||
"github.com/zricethezav/gitleaks/v6/config"
|
||||
"github.com/zricethezav/gitleaks/v6/hosts"
|
||||
"github.com/zricethezav/gitleaks/v6/manager"
|
||||
"github.com/zricethezav/gitleaks/v6/options"
|
||||
"github.com/zricethezav/gitleaks/v6/scan"
|
||||
|
||||
"github.com/hako/durafmt"
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
+3
-44
@@ -2,7 +2,6 @@ package manager
|
||||
|
||||
import (
|
||||
"crypto/sha1"
|
||||
"encoding/csv"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
@@ -14,8 +13,8 @@ import (
|
||||
"text/tabwriter"
|
||||
"time"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v5/config"
|
||||
"github.com/zricethezav/gitleaks/v5/options"
|
||||
"github.com/zricethezav/gitleaks/v6/config"
|
||||
"github.com/zricethezav/gitleaks/v6/options"
|
||||
|
||||
"github.com/go-git/go-git/v5"
|
||||
"github.com/hako/durafmt"
|
||||
@@ -252,7 +251,7 @@ func (manager *Manager) DebugOutput() {
|
||||
w := tabwriter.NewWriter(os.Stdout, 0, 0, padding, '.', 0)
|
||||
|
||||
log.Debugf("--------------------------\n")
|
||||
log.Debugf("| Individual Regex Times |\n")
|
||||
log.Debugf("| Individual Regexes Times |\n")
|
||||
log.Debugf("--------------------------\n")
|
||||
for k, v := range manager.metadata.RegexTime {
|
||||
_, _ = 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() {
|
||||
<-manager.stopChan
|
||||
|
||||
@@ -3,8 +3,8 @@ package manager
|
||||
import (
|
||||
"crypto/rand"
|
||||
"fmt"
|
||||
"github.com/zricethezav/gitleaks/v5/config"
|
||||
"github.com/zricethezav/gitleaks/v5/options"
|
||||
"github.com/zricethezav/gitleaks/v6/config"
|
||||
"github.com/zricethezav/gitleaks/v6/options"
|
||||
"io"
|
||||
"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"
|
||||
"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/plumbing/transport/http"
|
||||
@@ -28,35 +28,40 @@ const (
|
||||
|
||||
// Options stores values of command line options
|
||||
type Options struct {
|
||||
Verbose bool `short:"v" long:"verbose" description:"Show verbose output from scan"`
|
||||
Repo string `short:"r" long:"repo" description:"Target repository"`
|
||||
Config string `long:"config" description:"config path"`
|
||||
Disk bool `long:"disk" description:"Clones repo(s) to disk"`
|
||||
Version bool `long:"version" description:"version number"`
|
||||
Username string `long:"username" description:"Username for git repo"`
|
||||
Password string `long:"password" description:"Password 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"`
|
||||
Threads int `long:"threads" description:"Maximum number of threads gitleaks spawns"`
|
||||
SSH string `long:"ssh-key" description:"path to ssh key used for auth"`
|
||||
Uncommited bool `long:"uncommitted" description:"run gitleaks on uncommitted code"`
|
||||
RepoPath string `long:"repo-path" description:"Path to repo"`
|
||||
OwnerPath string `long:"owner-path" description:"Path to owner directory (repos discovered)"`
|
||||
Branch string `long:"branch" description:"Branch to scan"`
|
||||
Report string `long:"report" description:"path to write json leaks file"`
|
||||
ReportFormat string `long:"report-format" default:"json" description:"json or csv"`
|
||||
Redact bool `long:"redact" description:"redact secrets from log messages and leaks"`
|
||||
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\""`
|
||||
PrettyPrint bool `long:"pretty" description:"Pretty print json if leaks are present"`
|
||||
CommitFrom string `long:"commit-from" description:"Commit to start scan from"`
|
||||
CommitTo string `long:"commit-to" description:"Commit to stop scan"`
|
||||
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"`
|
||||
Verbose bool `short:"v" long:"verbose" description:"Show verbose output from scan"`
|
||||
Repo string `short:"r" long:"repo" description:"Target repository"`
|
||||
Config string `long:"config" description:"config path"`
|
||||
Disk bool `long:"disk" description:"Clones repo(s) to disk"`
|
||||
Version bool `long:"version" description:"version number"`
|
||||
Username string `long:"username" description:"Username for git repo"`
|
||||
Password string `long:"password" description:"Password for git repo"`
|
||||
AccessToken string `long:"access-token" description:"Access token for git repo"`
|
||||
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"`
|
||||
SSH string `long:"ssh-key" description:"path to ssh key used for auth"`
|
||||
Uncommited bool `long:"uncommitted" description:"run gitleaks on uncommitted code"`
|
||||
RepoPath string `long:"repo-path" description:"Path to repo"`
|
||||
OwnerPath string `long:"owner-path" description:"Path to owner directory (repos discovered)"`
|
||||
Branch string `long:"branch" description:"Branch to scan"`
|
||||
Report string `long:"report" description:"path to write json leaks file"`
|
||||
ReportFormat string `long:"report-format" default:"json" description:"json, csv, sarif"`
|
||||
Redact bool `long:"redact" description:"redact secrets from log messages and leaks"`
|
||||
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\""`
|
||||
PrettyPrint bool `long:"pretty" description:"Pretty print json if leaks are present"`
|
||||
|
||||
// Commit Options
|
||||
Commit string `long:"commit" description:"sha of commit to scan or \"latest\" to scan the last commit of the repository"`
|
||||
Commits string `long:"commits" description:"comma separated list of a commits to scan"`
|
||||
CommitsFile string `long:"commits-file" description:"file of new line separated list of a commits to scan"`
|
||||
CommitFrom string `long:"commit-from" description:"Commit to start scan from"`
|
||||
CommitTo string `long:"commit-to" description:"Commit to stop scan"`
|
||||
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
|
||||
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"
|
||||
"time"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v5/config"
|
||||
"github.com/zricethezav/gitleaks/v5/manager"
|
||||
"github.com/zricethezav/gitleaks/v6/config"
|
||||
"github.com/zricethezav/gitleaks/v6/manager"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
"github.com/go-git/go-billy/v5"
|
||||
@@ -77,11 +77,11 @@ func Run(m *manager.Manager) error {
|
||||
|
||||
func runHelper(r *Repo) error {
|
||||
// Ignore allowlisted repos
|
||||
for _, wlRepo := range r.Manager.Config.Allowlist.Repos {
|
||||
if RegexMatched(r.Manager.Opts.RepoPath, wlRepo) {
|
||||
for _, allowListedRepo := range r.Manager.Config.Allowlist.Repos {
|
||||
if RegexMatched(r.Manager.Opts.RepoPath, allowListedRepo) {
|
||||
return nil
|
||||
}
|
||||
if RegexMatched(r.Manager.Opts.Repo, wlRepo) {
|
||||
if RegexMatched(r.Manager.Opts.Repo, allowListedRepo) {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@@ -201,6 +201,10 @@ func getLogOptions(repo *Repo) (*git.LogOptions, error) {
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if logOpts.From.IsZero() {
|
||||
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()
|
||||
var tomlLoader config.TomlLoader
|
||||
_, err = toml.DecodeReader(f, &tomlLoader)
|
||||
if err != nil {
|
||||
return config.Config{}, err
|
||||
}
|
||||
|
||||
return tomlLoader.Parse()
|
||||
}
|
||||
|
||||
|
||||
+36
-44
@@ -11,8 +11,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v5/config"
|
||||
"github.com/zricethezav/gitleaks/v5/manager"
|
||||
"github.com/zricethezav/gitleaks/v6/config"
|
||||
"github.com/zricethezav/gitleaks/v6/manager"
|
||||
|
||||
fdiff "github.com/go-git/go-git/v5/plumbing/format/diff"
|
||||
"github.com/go-git/go-git/v5/plumbing/object"
|
||||
@@ -20,11 +20,12 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
diffAddPrefix = "+"
|
||||
diffAddFilePrefix = "+++ b"
|
||||
diffAddFilePrefixSlash = "+++ b/"
|
||||
diffLineSignature = " @@"
|
||||
defaultLineNumber = -1
|
||||
diffAddPrefix = "+"
|
||||
diffAddFilePrefix = "+++ b"
|
||||
diffAddFilePrefixSlash = "+++ b/"
|
||||
diffLineSignature = " @@"
|
||||
diffLineSignaturePrefix = "@@ "
|
||||
defaultLineNumber = -1
|
||||
)
|
||||
|
||||
// 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()
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
@@ -112,7 +113,7 @@ func (repo *Repo) CheckRules(bundle *Bundle) {
|
||||
offender := bundle.Content[loc[0]:loc[1]]
|
||||
groups := rule.Regex.FindStringSubmatch(offender)
|
||||
|
||||
if isOffenderWhiteListed(offender, rule.Allowlist) {
|
||||
if isAllowListed(line, append(rule.AllowList.Regexes, repo.config.Allowlist.Regexes...)) {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -146,7 +147,6 @@ func (repo *Repo) CheckRules(bundle *Bundle) {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO should return filenameRegex if only file rule
|
||||
repo.Manager.RecordTime(manager.RegexTime{
|
||||
Time: howLong(start),
|
||||
Regex: rule.Regex.String(),
|
||||
@@ -239,6 +239,19 @@ func extractAndInjectLineNumber(leak *manager.Leak, bundle *Bundle, repo *Repo)
|
||||
leak.LineNumber = potentialLine
|
||||
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++
|
||||
}
|
||||
@@ -339,28 +352,28 @@ func ruleContainRegex(rule config.Rule) bool {
|
||||
}
|
||||
|
||||
// Checks if the given rule has a file name regex
|
||||
func ruleContainFileNameRegex(rule config.Rule) bool {
|
||||
if rule.FileNameRegex == nil {
|
||||
func ruleContainFileRegex(rule config.Rule) bool {
|
||||
if rule.File == nil {
|
||||
return false
|
||||
}
|
||||
if rule.FileNameRegex.String() == "" {
|
||||
if rule.File.String() == "" {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// Checks if the given rule has a file path regex
|
||||
func ruleContainFilePathRegex(rule config.Rule) bool {
|
||||
if rule.FilePathRegex == nil {
|
||||
func ruleContainPathRegex(rule config.Rule) bool {
|
||||
if rule.Path == nil {
|
||||
return false
|
||||
}
|
||||
if rule.FilePathRegex.String() == "" {
|
||||
if rule.Path.String() == "" {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func isCommitWhiteListed(commitHash string, allowlistedCommits []string) bool {
|
||||
func isCommitAllowListed(commitHash string, allowlistedCommits []string) bool {
|
||||
for _, hash := range allowlistedCommits {
|
||||
if commitHash == hash {
|
||||
return true
|
||||
@@ -369,35 +382,14 @@ func isCommitWhiteListed(commitHash string, allowlistedCommits []string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func isOffenderWhiteListed(offender string, allowlist []config.Allowlist) bool {
|
||||
if len(allowlist) != 0 {
|
||||
for _, wl := range allowlist {
|
||||
if wl.Regex.FindString(offender) != "" {
|
||||
func isAllowListed(target string, allowList []*regexp.Regexp) bool {
|
||||
if len(allowList) != 0 {
|
||||
for _, re := range allowList {
|
||||
if re.FindString(target) != "" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
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
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
"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/plumbing"
|
||||
@@ -71,11 +74,36 @@ func (repo *Repo) Scan() error {
|
||||
|
||||
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 != "" {
|
||||
return scanCommit(repo.Manager.Opts.Commit, repo, scanCommitPatches)
|
||||
} else if repo.Manager.Opts.FilesAtCommit != "" {
|
||||
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)
|
||||
@@ -96,7 +124,7 @@ func (repo *Repo) Scan() error {
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
@@ -140,9 +168,10 @@ func (repo *Repo) Scan() error {
|
||||
start := time.Now()
|
||||
patch, err := parent.Patch(c)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not generate Patch")
|
||||
log.Errorf("could not generate Patch")
|
||||
}
|
||||
repo.Manager.RecordTime(manager.PatchTime(howLong(start)))
|
||||
|
||||
wg.Add(1)
|
||||
semaphore <- true
|
||||
go func(c *object.Commit, patch *object.Patch) {
|
||||
@@ -174,6 +203,9 @@ func (repo *Repo) scanEmpty() error {
|
||||
}
|
||||
|
||||
status, err := wt.Status()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for fn := range status {
|
||||
workTreeBuf := bytes.NewBuffer(nil)
|
||||
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
|
||||
for _, d := range diffs {
|
||||
if d.Type == diffmatchpatch.DiffInsert {
|
||||
|
||||
+38
-5
@@ -10,9 +10,9 @@ import (
|
||||
"sort"
|
||||
"testing"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v5/config"
|
||||
"github.com/zricethezav/gitleaks/v5/manager"
|
||||
"github.com/zricethezav/gitleaks/v5/options"
|
||||
"github.com/zricethezav/gitleaks/v6/config"
|
||||
"github.com/zricethezav/gitleaks/v6/manager"
|
||||
"github.com/zricethezav/gitleaks/v6/options"
|
||||
|
||||
"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",
|
||||
},
|
||||
{
|
||||
description: "test local repo two leaks range Commit",
|
||||
description: "test local repo two leaks to from Commit",
|
||||
opts: options.Options{
|
||||
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",
|
||||
CommitFrom: "d8ac0b73aeeb45843319cdc5ce506516eb49bf7a",
|
||||
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",
|
||||
},
|
||||
{
|
||||
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",
|
||||
opts: options.Options{
|
||||
@@ -385,6 +405,16 @@ func TestScan(t *testing.T) {
|
||||
},
|
||||
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 {
|
||||
@@ -412,6 +442,9 @@ func TestScan(t *testing.T) {
|
||||
}
|
||||
|
||||
err = m.Report()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if test.wantEmpty {
|
||||
if len(m.GetLeaks()) != 0 {
|
||||
|
||||
@@ -2,13 +2,7 @@
|
||||
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 md files"
|
||||
file = '''(.*)?md$'''
|
||||
[[rules.allowlist]]
|
||||
description = "ignore this regex"
|
||||
regex = '''ignore$'''
|
||||
[[rules.allowlist]]
|
||||
description = "ignore regex and md files"
|
||||
regex = '''ignore$'''
|
||||
file = '''(.*)?md$'''
|
||||
[rules.allowlist]
|
||||
description = "ignore sample regex md files"
|
||||
files = ['''(.*)?md$''']
|
||||
regexes = ['''ignore$''']
|
||||
@@ -2,6 +2,6 @@
|
||||
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]]
|
||||
[rules.allowlist]
|
||||
description = "ignore python files"
|
||||
file = '''(.*)?py$'''
|
||||
files = ['''(.*)?py$''']
|
||||
@@ -2,6 +2,6 @@
|
||||
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]]
|
||||
regex = '''AKIAIO5FODNN7EXAMPLE.*'''
|
||||
[rules.allowlist]
|
||||
description = "ignore aws key"
|
||||
regexes = ['''AKIAIO5FODNN7EXAMPLE.*''']
|
||||
@@ -125,19 +125,19 @@ title = "gitleaks config"
|
||||
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]]
|
||||
[rules.allowlist]
|
||||
description = "ignore common jenkins functions"
|
||||
regex = '''allowlistme'''
|
||||
file = '''(.*)?Jenkinsfile$'''
|
||||
[[rules.allowlist]]
|
||||
description = "ignore common jenkins functions2"
|
||||
regex = '''allowlistme'''
|
||||
file = '''(.*)?Jenkinsfile$'''
|
||||
regexes = [
|
||||
'''allowlistme'''
|
||||
]
|
||||
files = [
|
||||
'''(.*)?Jenkinsfile$'''
|
||||
]
|
||||
|
||||
# Global rules. This instructs gitleaks to ignore all .pem files or if a message with
|
||||
[[rules]]
|
||||
description = "Files with keys and credentials"
|
||||
fileRegex = '''(.*?)(pem)'''
|
||||
file = '''(.*?)(pem)'''
|
||||
|
||||
[allowlist]
|
||||
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]]
|
||||
description = "Generic password"
|
||||
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"]
|
||||
@@ -2,5 +2,5 @@
|
||||
[[rules]]
|
||||
description = "AWS Manager ID"
|
||||
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"]
|
||||
@@ -2,6 +2,6 @@
|
||||
[[rules]]
|
||||
description = "Generic password"
|
||||
regex = '''(?i)(password|token).{0,20}?\s*[:|=]\s*?(?-i)([0-9a-zA-Z\/+]{4,40})'''
|
||||
fileNameRegex = '''.*\.properties'''
|
||||
filePathRegex = '''config(guration)?'''
|
||||
file = '''.*\.properties'''
|
||||
path = '''config(guration)?'''
|
||||
tags = ["key", "Yml", "Yaml"]
|
||||
@@ -178,5 +178,20 @@
|
||||
"date": "2020-07-25T14:41:11-04:00",
|
||||
"tags": "key, AWS",
|
||||
"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",
|
||||
"tags": "key, AWS",
|
||||
"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",
|
||||
"tags": "key, AWS",
|
||||
"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"
|
||||
}
|
||||
]
|
||||
@@ -13,5 +13,20 @@
|
||||
"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,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