mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-29 04:34:46 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2acc34dfdf | ||
|
|
ede68fd95d | ||
|
|
6c60c3dde3 | ||
|
|
ad505754fc | ||
|
|
21d81879e2 | ||
|
|
b5ca2ba614 |
No files matched your search
@@ -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>.
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ type Rule struct {
|
|||||||
Regex *regexp.Regexp
|
Regex *regexp.Regexp
|
||||||
File *regexp.Regexp
|
File *regexp.Regexp
|
||||||
Path *regexp.Regexp
|
Path *regexp.Regexp
|
||||||
|
ReportGroup int
|
||||||
Tags []string
|
Tags []string
|
||||||
AllowList AllowList
|
AllowList AllowList
|
||||||
Entropies []Entropy
|
Entropies []Entropy
|
||||||
@@ -73,6 +74,7 @@ type TomlLoader struct {
|
|||||||
Regex string
|
Regex string
|
||||||
File string
|
File string
|
||||||
Path string
|
Path string
|
||||||
|
ReportGroup int
|
||||||
Tags []string
|
Tags []string
|
||||||
Entropies []struct {
|
Entropies []struct {
|
||||||
Min string
|
Min string
|
||||||
@@ -198,6 +200,7 @@ func (tomlLoader TomlLoader) Parse() (Config, error) {
|
|||||||
Regex: re,
|
Regex: re,
|
||||||
File: fileNameRe,
|
File: fileNameRe,
|
||||||
Path: filePathRe,
|
Path: filePathRe,
|
||||||
|
ReportGroup: rule.ReportGroup,
|
||||||
Tags: rule.Tags,
|
Tags: rule.Tags,
|
||||||
AllowList: allowList,
|
AllowList: allowList,
|
||||||
Entropies: entropies,
|
Entropies: entropies,
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package config
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@@ -129,3 +131,83 @@ func TestParse(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
}
|
||||||
+34
-29
@@ -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, csv, sarif"`
|
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"`
|
||||||
|
|||||||
@@ -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()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+24
-5
@@ -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.
|
||||||
@@ -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,
|
||||||
@@ -238,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++
|
||||||
}
|
}
|
||||||
|
|||||||
+32
-1
@@ -1,9 +1,12 @@
|
|||||||
package scan
|
package scan
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -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)
|
||||||
@@ -175,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)
|
||||||
|
|||||||
+36
-2
@@ -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{
|
||||||
@@ -422,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 {
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -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
|
||||||
Reference in new issue
Block a user