mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-28 12:14:22 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3932ed6baf | ||
|
|
981b636920 | ||
|
|
c8e15c731a | ||
|
|
901f932a89 | ||
|
|
c0a9580a65 | ||
|
|
8be91eea5d | ||
|
|
1c6f2252b8 |
No files matched your search
@@ -2,6 +2,7 @@
|
|||||||
<img alt="gitleaks" src="https://raw.githubusercontent.com/zricethezav/gifs/master/gitleakslogo.png" height="70" />
|
<img alt="gitleaks" src="https://raw.githubusercontent.com/zricethezav/gifs/master/gitleakslogo.png" height="70" />
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://travis-ci.org/zricethezav/gitleaks"><img alt="Travis" src="https://img.shields.io/travis/zricethezav/gitleaks/master.svg?style=flat-square"></a>
|
<a href="https://travis-ci.org/zricethezav/gitleaks"><img alt="Travis" src="https://img.shields.io/travis/zricethezav/gitleaks/master.svg?style=flat-square"></a>
|
||||||
|
<a href="https://gitter.im/gitleaks/gitleaks"><img alt="Travis" src="https://badges.gitter.im/gitleaks/gitleaks.svg?style=flat-square"></a>
|
||||||
</p>
|
</p>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
@@ -19,7 +20,7 @@ Gitleaks is a SAST tool for detecting hardcoded secrets like passwords, api keys
|
|||||||
|
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
Written in Go, gitleaks is available in binary form for many popular platforms and OS types from the [releases page](https://github.com/zricethezav/gitleaks/releases). Alternatively, executed via Docker or it can be installed using Go directly.
|
Gitleaks can be installed with Homebrew, Docker, and Go. Gitleaks is also available in binary form for many popular platforms and OS types from the [releases page](https://github.com/zricethezav/gitleaks/releases).
|
||||||
|
|
||||||
##### MacOS
|
##### MacOS
|
||||||
|
|
||||||
@@ -45,6 +46,7 @@ Usage:
|
|||||||
|
|
||||||
Application Options:
|
Application Options:
|
||||||
-v, --verbose Show verbose output from scan
|
-v, --verbose Show verbose output from scan
|
||||||
|
-q, --quiet Sets log level to error and only output leaks, one json object per line
|
||||||
-r, --repo-url= Repository URL
|
-r, --repo-url= Repository URL
|
||||||
-p, --path= Path to directory (repo if contains .git) or file
|
-p, --path= Path to directory (repo if contains .git) or file
|
||||||
-c, --config-path= Path to config
|
-c, --config-path= Path to config
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@ import (
|
|||||||
|
|
||||||
// used for ignoring .git directories when the --no-git flag is set
|
// used for ignoring .git directories when the --no-git flag is set
|
||||||
// related issue: https://github.com/zricethezav/gitleaks/issues/486
|
// related issue: https://github.com/zricethezav/gitleaks/issues/486
|
||||||
const dotGit = `\.git/`
|
const dotGit = `/\.git/`
|
||||||
|
|
||||||
// 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.
|
||||||
|
|||||||
+1
-1
@@ -69,7 +69,7 @@ func ParseOptions() (Options, error) {
|
|||||||
if flagsErr, ok := err.(*flags.Error); ok && flagsErr.Type != flags.ErrHelp {
|
if flagsErr, ok := err.(*flags.Error); ok && flagsErr.Type != flags.ErrHelp {
|
||||||
parser.WriteHelp(os.Stdout)
|
parser.WriteHelp(os.Stdout)
|
||||||
}
|
}
|
||||||
os.Exit(0)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if opts.Version {
|
if opts.Version {
|
||||||
|
|||||||
+12
-2
@@ -73,7 +73,12 @@ func (ngs *NoGitScanner) Scan() (Report, error) {
|
|||||||
for _, rule := range ngs.cfg.Rules {
|
for _, rule := range ngs.cfg.Rules {
|
||||||
if rule.HasFileOrPathLeakOnly(p) {
|
if rule.HasFileOrPathLeakOnly(p) {
|
||||||
leak := NewLeak("", "Filename or path offender: "+p, defaultLineNumber)
|
leak := NewLeak("", "Filename or path offender: "+p, defaultLineNumber)
|
||||||
leak.File = p
|
relPath, err := filepath.Rel(ngs.opts.Path, p)
|
||||||
|
if err != nil {
|
||||||
|
leak.File = p
|
||||||
|
} else {
|
||||||
|
leak.File = relPath
|
||||||
|
}
|
||||||
leak.Rule = rule.Description
|
leak.Rule = rule.Description
|
||||||
leak.Tags = strings.Join(rule.Tags, ", ")
|
leak.Tags = strings.Join(rule.Tags, ", ")
|
||||||
|
|
||||||
@@ -115,7 +120,12 @@ func (ngs *NoGitScanner) Scan() (Report, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
leak := NewLeak(line, offender, defaultLineNumber)
|
leak := NewLeak(line, offender, defaultLineNumber)
|
||||||
leak.File = p
|
relPath, err := filepath.Rel(ngs.opts.Path, p)
|
||||||
|
if err != nil {
|
||||||
|
leak.File = p
|
||||||
|
} else {
|
||||||
|
leak.File = relPath
|
||||||
|
}
|
||||||
leak.LineNumber = lineNumber
|
leak.LineNumber = lineNumber
|
||||||
leak.Rule = rule.Description
|
leak.Rule = rule.Description
|
||||||
leak.Tags = strings.Join(rule.Tags, ", ")
|
leak.Tags = strings.Join(rule.Tags, ", ")
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ func WriteReport(report Report, opts options.Options, cfg config.Config) error {
|
|||||||
logrus.Warn("leaks found: ", len(report.Leaks))
|
logrus.Warn("leaks found: ", len(report.Leaks))
|
||||||
} else {
|
} else {
|
||||||
logrus.Info("No leaks found")
|
logrus.Info("No leaks found")
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if opts.Report == "" {
|
if opts.Report == "" {
|
||||||
|
|||||||
@@ -57,6 +57,28 @@ func (us *UnstagedScanner) Scan() (Report, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if file is allow listed
|
||||||
|
if us.cfg.Allowlist.FileAllowed(filepath.Base(fn)) ||
|
||||||
|
us.cfg.Allowlist.PathAllowed(fn) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// Check individual file path ONLY rules
|
||||||
|
for _, rule := range us.cfg.Rules {
|
||||||
|
if rule.HasFileOrPathLeakOnly(fn) {
|
||||||
|
leak := NewLeak("", "Filename or path offender: "+ fn, defaultLineNumber)
|
||||||
|
leak.Repo = us.repoName
|
||||||
|
leak.File = fn
|
||||||
|
leak.RepoURL = us.opts.RepoURL
|
||||||
|
leak.LeakURL = leak.URL()
|
||||||
|
leak.Rule = rule.Description
|
||||||
|
leak.Tags = strings.Join(rule.Tags, ", ")
|
||||||
|
leak.Log(us.opts)
|
||||||
|
scannerReport.Leaks = append(scannerReport.Leaks, leak)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if _, err := io.Copy(workTreeBuf, workTreeFile); err != nil {
|
if _, err := io.Copy(workTreeBuf, workTreeFile); err != nil {
|
||||||
return scannerReport, err
|
return scannerReport, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,5 +46,37 @@
|
|||||||
"file": "../test_data/test_repos/test_repo_10/gitfile.txt",
|
"file": "../test_data/test_repos/test_repo_10/gitfile.txt",
|
||||||
"date": "0001-01-01T00:00:00Z",
|
"date": "0001-01-01T00:00:00Z",
|
||||||
"tags": "key, extensions"
|
"tags": "key, extensions"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"line": "",
|
||||||
|
"lineNumber": 1,
|
||||||
|
"offender": "Filename or path offender: ../test_data/test_repos/test_repo_10/creds.git",
|
||||||
|
"commit": "",
|
||||||
|
"repo": "",
|
||||||
|
"repoURL": "",
|
||||||
|
"leakURL": "",
|
||||||
|
"rule": "Block dangerous filetypes",
|
||||||
|
"commitMessage": "",
|
||||||
|
"author": "",
|
||||||
|
"email": "",
|
||||||
|
"file": "../test_data/test_repos/test_repo_10/creds.git",
|
||||||
|
"date": "0001-01-01T00:00:00Z",
|
||||||
|
"tags": "key, extensions"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"line": "",
|
||||||
|
"lineNumber": 1,
|
||||||
|
"offender": "Filename or path offender: ../test_data/test_repos/test_repo_10/somedir.git/secret.key",
|
||||||
|
"commit": "",
|
||||||
|
"repo": "",
|
||||||
|
"repoURL": "",
|
||||||
|
"leakURL": "",
|
||||||
|
"rule": "Block dangerous filetypes",
|
||||||
|
"commitMessage": "",
|
||||||
|
"author": "",
|
||||||
|
"email": "",
|
||||||
|
"file": "../test_data/test_repos/test_repo_10/somedir.git/secret.key",
|
||||||
|
"date": "0001-01-01T00:00:00Z",
|
||||||
|
"tags": "key, extensions"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -1,4 +1,20 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"line": "",
|
||||||
|
"lineNumber": 1,
|
||||||
|
"offender": "Filename or path offender: ../test_data/test_repos/test_repo_10/somedir.git/secret.key",
|
||||||
|
"commit": "",
|
||||||
|
"repo": "",
|
||||||
|
"repoURL": "",
|
||||||
|
"leakURL": "",
|
||||||
|
"rule": "Block dangerous filetypes",
|
||||||
|
"commitMessage": "",
|
||||||
|
"author": "",
|
||||||
|
"email": "",
|
||||||
|
"file": "../test_data/test_repos/test_repo_10/somedir.git/secret.key",
|
||||||
|
"date": "0001-01-01T00:00:00Z",
|
||||||
|
"tags": "key, extensions"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"line": "",
|
"line": "",
|
||||||
"lineNumber": 1,
|
"lineNumber": 1,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[[rules]]
|
[[rules]]
|
||||||
description = "Block dangerous filetypes"
|
description = "Block dangerous filetypes"
|
||||||
file = '''(.*?)(gitfile.txt|gitignore|pdf|doc|docx|zip|xls|tfplan|tfstate|tfvars|vault_pass|vagrant|pyc|key|cache)$'''
|
file = '''(.*?)(creds.git|gitfile.txt|gitignore|pdf|doc|docx|zip|xls|tfplan|tfstate|tfvars|vault_pass|vagrant|pyc|key|cache)$'''
|
||||||
tags = ["key", "extensions"]
|
tags = ["key", "extensions"]
|
||||||
[rules.allowlist]
|
[rules.allowlist]
|
||||||
paths = ['''.docx''']
|
paths = ['''.docx''']
|
||||||
|
|||||||
Whitespace-only changes.
@@ -0,0 +1 @@
|
|||||||
|
hah
|
||||||
Reference in new issue
Block a user