Compare commits

...
78 Commits
Author SHA1 Message Date
Daniel Paul SearlesandDaniel Paul Searles 2acc34dfdf Add support for reportGroup (#456)
Why:

* There are times where it would be nice to have a group from the regex
  reported rather than the complete match.

This change addresses the need by:

* Add the reportGroup configuration option for a rule.
* Update scan.CheckRules to return the reportGroup if set.

Co-authored-by: Daniel Paul Searles <dsearles@gitlab.com>
2020-11-03 15:15:48 -05:00
zricethezav ede68fd95d fix off by one 2020-09-02 08:36:19 -04:00
Zachary Rice 6c60c3dde3 Adding some logic to fix line number extractor when there are multipl… (#436)
* Adding some logic to fix line number extractor when there are multiple secrets of the same offender within the same patch

* formatting some consts
2020-09-01 20:48:43 -04:00
Zachary Rice ad505754fc Add commits and commits-file option (#433) 2020-08-31 10:29:04 -04:00
Zachary Rice 21d81879e2 Update README.md 2020-08-27 14:11:11 -04:00
Lars Lehtonen b5ca2ba614 scan: fix dropped errors (#424) 2020-08-20 15:42:42 -04:00
Zachary Rice ef4655fcf1 Sarif (#421)
* init

* more work

* more sarif work

* mergin
2020-08-12 18:07:24 -04:00
Zachary Rice 01b553a75d Update Makefile 2020-08-12 17:51:56 -04:00
Zachary Rice fae366a404 Global allowlist regex (#422)
* work in progress

* Update test configs

* adding test

* golint and change to allowlist

* fix race condition, this mistakenly got committed

* Updating tests and examples

* bump to v6 as this is a breaking change to the config

* More consistent variables
2020-08-12 17:18:25 -04:00
Lars Lehtonen 6129b1a15d hosts: dropped error (#417) 2020-07-31 08:45:47 -04:00
Manuel Jeckelmann 31d03a1146 Clean up 'uncommitted' diff. (#416) 2020-07-28 08:55:33 -04:00
Zachary Rice eabc7b5c12 Fixing merge commit scans and large patch rule checking (#414)
* Fixing merge commit scans and large patch rule checking

* Adding tests for merge request scans
2020-07-25 14:55:59 -04:00
zricethezav 1dc7569f95 removing extra log import... 2020-07-24 14:42:54 -04:00
zricethezav 1797e9c966 Merge branch 'master' of github.com:zricethezav/gitleaks 2020-07-24 14:07:25 -04:00
zricethezav e2eaceb4cd rm bad example config 2020-07-24 14:07:00 -04:00
Zachary Rice c637b129ec Validate config (#412)
* validate config

* fix import fmt

* cleaning
2020-07-24 14:02:48 -04:00
zricethezav 8470e43d7f validate config 2020-07-24 13:54:01 -04:00
Zachary Rice 94f5950d68 Use allowlist (#411) 2020-07-24 11:58:43 -04:00
Zachary Rice fe69a17c9c Change remaining audits to scan (#410) 2020-07-24 11:30:33 -04:00
Zachary Rice 6ca7a11d88 Add line number to report plus some other things (#409)
* Init refactor

* think i got it working

* we got em

* Updating tests

* fixing tests

* Better comments, more test fixing

* Bumping to v5

* Fixing golint messages

* Replacing usage of audit with scan in comments

* bumping go-git

* Updating to v5 in some other spots
2020-07-24 10:49:03 -04:00
Zachary Rice cfbb600fcb Fixing patch direction and making additions the default (#408)
* Fixing patch direction and making additions the default

* adding test
2020-07-22 13:32:46 -04:00
Zachary Rice e36b550851 adding go mod/sum to ignore, adding quotes to aws secret rule (#397)
* adding go mod/sum to ignore, adding quotes to aws secret rule

* lil nicer formatting
2020-06-14 15:41:04 -04:00
zricethezav 2232dc191c removing bad options guard 2020-06-03 08:51:11 -04:00
Zachary Rice bdc688dd53 fix whitelist commits, added test (#390) 2020-05-31 10:25:58 -04:00
Steeve Barbeau e0f6399d5c Audit commits based on date/time parameters (#385)
* time based audit

* fixing SIGSEGV

* adding options for date and time format + tests

* Update repo.go

* Update github.go

* rebase + tests update
2020-05-24 18:03:47 -04:00
Zachary Rice 3e88ac6726 Update README.md 2020-05-20 15:48:53 -04:00
Zeyshi d0088f6c7c Update default.go (#382) 2020-05-14 17:27:35 -04:00
zricethezav 0d7c18cb39 fixing whitelist repo tests 2020-05-09 11:37:08 -04:00
zricethezav d0e98416b9 Merge branch 'master' of github.com:zricethezav/gitleaks 2020-05-09 11:24:06 -04:00
Zachary Rice b7438011b4 Rm generic from default (#379)
* fixing commit latest bug

* remove generic rule from default to reduce false positives
2020-05-09 11:21:17 -04:00
zricethezav 4e59d3bf19 Merge branch 'master' of github.com:zricethezav/gitleaks 2020-05-09 10:54:35 -04:00
Steeve Barbeau e4b26aea4a fixing issue #367 (#368) 2020-05-09 10:49:00 -04:00
Zachary Rice 473d0d55a7 Whitelist repo (#378)
* fixing commit latest bug

* bumping go-git and adding repo whitelist

* adding tests
2020-05-09 10:38:02 -04:00
Zachary Rice 8bd4649b01 Update leaky-repo.toml 2020-05-09 08:53:43 -04:00
zricethezav a69df84325 Merge branch 'master' of github.com:zricethezav/gitleaks 2020-05-09 08:51:58 -04:00
Marlon Pina Tojal 0faebdefea Whitelist files not being parsed (#375)
It seems that there is a typo on the default rules.
2020-05-04 10:56:27 -04:00
Zachary Rice a728e3abf3 Documentation upgrade (#374)
* fixing commit latest bug

* updating readme

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md
2020-04-28 17:43:01 -04:00
zricethezav e87c62fe72 Merge branch 'master' of github.com:zricethezav/gitleaks 2020-04-23 11:23:46 -04:00
Zachary Rice 4801818e3d fixing commit latest bug (#365) 2020-04-05 11:36:37 -04:00
zricethezav b4a0577786 fixing commit latest bug 2020-04-05 11:31:22 -04:00
Zachary Rice 212232f80a Empty repo audit (#364)
* bump to go 1.14 and alpine to 3.11

* audit before commit

* adding test

* rm hooks in test repo
2020-04-05 11:18:33 -04:00
Zachary Rice 11dcb44e41 bump to go 1.14 and alpine to 3.11 (#363) 2020-04-05 09:38:27 -04:00
Prabhu Subramanian af0df6ea2c Added gosec scan (#311) 2020-04-05 09:38:10 -04:00
Zachary Rice 9db91442b3 ignoring config when using custom config (#362) 2020-04-04 14:49:54 -04:00
Zachary Rice 9d76070806 Update README.md 2020-03-25 11:22:32 -04:00
Zachary Rice 2fa580f1bb fix the empty repo org scan error (#358) 2020-03-20 22:44:17 -04:00
Zach Stone c6f15b768e Improve default pattern configuration (#356)
* Add GCP, fix Mailgun format, and loosen format for other keys (don't require quotes)

* Add more match cases to generic credential pattern

* Fix quotation for valid toml

* Update tests
2020-03-20 21:14:30 -04:00
Zachary Rice 779937ca87 Update README.md 2020-03-06 18:59:03 -05:00
Zachary Rice 731856e974 Update README.md 2020-03-06 18:55:24 -05:00
Zachary Rice baf54631c7 Update README.md 2020-03-06 18:43:40 -05:00
zricethezav 3e760d7fed updating help message 2020-03-02 20:24:22 -05:00
Noel Algora 679f00dc9c Scan files at latest commit (#348)
* Inspect files at latest commit

Added option to scan files at latest commit

* Files at latest commit test
2020-03-02 20:22:14 -05:00
Zachary Rice dae5c142d7 Fix host clone auth (#350)
* trying auth fix

* fixing github private user auth and donate msg

* formatting

* go fmt...
2020-02-29 13:30:08 -05:00
Zachary Rice 8e8873286e Update leaky-repo.toml 2020-02-29 13:19:55 -05:00
Zachary Rice 6693cbdde3 Update README.md 2020-02-27 09:29:52 -05:00
Zachary Rice 8b3ce2cb1e forgot to bump in code... (#347) 2020-02-26 20:41:54 -05:00
Zachary Rice 94cae90d1e duplicate leak logic includes the line in hash (#345) 2020-02-26 17:38:16 -05:00
Noel Algora c4b07f5113 Add file regex support (#340)
* Modified Entropy to be able to apply it on regex match or specific capture group

* Config tests

* Small fixes on entropy ranges

* Fix toml configs
Fix tests

* Start adding support for rules with filename regex

Changed how config is parsed
Created new functions to inspect files and content

* File regex working

* Fixing tests and configs

* Implemented different regex for filename and filepath

* Fix comments

* Audit tests

* Config rename vars

* Fix audit tests

* Filename offender

* Indents and code styles

* Indents and code styles

* Removing bad test repo

* Adding test repo 6 for filename and filepath tests

* global whitelist path and fixes

* Fixes on tests and new test for global whitelisting paths

* Removing unused test

* Fix comment
2020-02-26 15:33:14 -05:00
Alexander Curtiss 01d73028f8 Fixed bug where the repo name was removed on a user or org audit. (#344) 2020-02-26 14:42:44 -05:00
Dmitry Ivanov 862f1203ed Minor formatting fix (#330) 2020-02-25 18:24:27 -05:00
Zachary Rice 581e81c16e Update README.md 2020-02-25 17:39:41 -05:00
Zachary Rice 6c166c9530 Update README.md 2020-02-25 17:32:40 -05:00
Zachary Rice 4181ede6cd Update FUNDING.yml 2020-02-25 11:55:18 -05:00
Zachary Rice 10745be661 fixing commit counts (#342)
* fixing commit counts

* fixing commit to test
2020-02-25 10:28:03 -05:00
Noel Algora ee2d73c740 Enhance entropy (#333)
* Modified Entropy to be able to apply it on regex match or specific capture group

* Config tests

* Small fixes on entropy ranges

* Fix toml configs
Fix tests

* Indents and code styles
2020-02-24 13:44:38 -05:00
zricethezav e7fbcf5333 updating readme and comments 2020-02-01 16:48:05 -05:00
Zachary Rice 2810eccc82 Merge pull request #329 from zricethezav/bug/commit-scan
Bug/commit scan
2020-02-01 11:38:02 -05:00
zricethezav baff419091 removing hooks 2020-02-01 11:23:11 -05:00
zricethezav d13e0fdfde adding more tests 2020-02-01 11:18:27 -05:00
zricethezav 5a300c3c64 fixing --commit bug, adding --files-at-commit option 2020-01-30 20:08:01 -05:00
Zachary Rice d8ddb9630a Merge pull request #327 from zricethezav/bug/timeoutcancel
Adding timeout check in context select so we dont log erroneously
2020-01-24 18:16:59 -05:00
zricethezav 1537eeb5fa Adding timeout check in context select so we dont log erroneously 2020-01-24 18:07:16 -05:00
Zachary Rice 1a492537dd Merge pull request #325 from zricethezav/bug/timeoutcancel
defer cancel in audit
2020-01-23 18:52:56 -05:00
zricethezav bd4107b002 ensuring cancel is called after audit is complete so context can be dropped 2020-01-23 18:47:37 -05:00
Zach Rice 7b48cadf6d fixing version loading in makefile 2020-01-22 20:42:14 -05:00
Zachary Rice 6eab8a7a0a Update README.md 2020-01-22 20:00:27 -05:00
Zachary Rice c6d14e5b7d Merge pull request #323 from zricethezav/bug/fix-go-module
fixing modules, adding v3 in path
2020-01-22 18:10:23 -05:00
zricethezav ce95cafd54 fixing modules, adding v3 in path 2020-01-22 10:21:00 -05:00
247 changed files with 3849 additions and 1993 deletions

No files matched your search

+1
View File
@@ -1,3 +1,4 @@
# These are supported funding model platforms
github: [zricethezav]
custom: ["https://www.paypal.me/zricethezav"]
+1
View File
@@ -7,6 +7,7 @@
*.DS_STORE
*.idea
gitleaks
build
# Test binary
*.out
+2 -1
View File
@@ -1,7 +1,8 @@
language: go
go:
- 1.13.x
- 1.14.x
services:
- docker
script:
- make test
- make security-scan
+2 -2
View File
@@ -1,10 +1,10 @@
FROM golang:1.13.4 AS build
FROM golang:1.14.1 AS build
WORKDIR /go/src/github.com/zricethezav/gitleaks
ARG ldflags
COPY . .
RUN GO111MODULE=on CGO_ENABLED=0 go build -o bin/gitleaks -ldflags "-X="${ldflags} *.go
FROM alpine:3.10
FROM alpine:3.11
RUN apk add --no-cache bash git openssh
COPY --from=build /go/src/github.com/zricethezav/gitleaks/bin/* /usr/bin/
ENTRYPOINT ["gitleaks"]
+9 -2
View File
@@ -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/version.Version=$(VERSION)"
_LDFLAGS="github.com/zricethezav/gitleaks/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:
@@ -27,6 +27,10 @@ build:
go mod tidy
go build $(LDFLAGS)
security-scan:
go get github.com/securego/gosec/cmd/gosec
gosec -no-fail ./...
release-builds:
rm -rf build
mkdir build
@@ -43,3 +47,6 @@ deploy:
docker build --build-arg ldflags=$(_LDFLAGS) -f Dockerfile -t zricethezav/gitleaks:latest -t zricethezav/gitleaks:$(VERSION) .
echo "Pushing zricethezav/gitleaks:$(VERSION) and zricethezav/gitleaks:latest"
docker push zricethezav/gitleaks
dockerbuild:
docker build --build-arg ldflags=$(_LDFLAGS) -f Dockerfile -t zricethezav/gitleaks:latest -t zricethezav/gitleaks:$(VERSION) .
+29 -121
View File
@@ -1,131 +1,39 @@
Gitleaks
--------
<p align="left">
<a href="https://travis-ci.com/zricethezav/gitleaks"><img alt="Travis" src="https://travis-ci.com/zricethezav/gitleaks.svg?branch=master"></a>
<p align="center">
<img alt="gitleaks" src="https://raw.githubusercontent.com/zricethezav/gifs/master/gitleakslogo.png" height="70" />
<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>
</p>
</p>
Audit git repos for secrets. Gitleaks provides a way for you to find unencrypted secrets and other unwanted data types in git repositories. As part of its core functionality, it provides:
* Audits for uncommitted changes
* Github and Gitlab support including support for bulk organization and repository owner (user) repository scans, as well as pull/merge request scanning for use in common CI workflows.
* Support for private repository scans, and repositories that require key based authentication
* Output in JSON formats for consumption in other reporting tools and frameworks
* Externalised configuration for environment specific customisation including regex rules
* High performance through the use of src-d's [go-git](https://github.com/src-d/go-git) framework
Gitleaks is a SAST tool for detecting hardcoded secrets like passwords, api keys, and tokens in git repos. Gitleaks aims to be the **easy-to-use, all-in-one solution** for finding secrets, past or present, in your code.
### Features:
- Scans for [commited](https://github.com/zricethezav/gitleaks/wiki/Scanning) secrets
- Scans for [uncommitted](https://github.com/zricethezav/gitleaks/wiki/Scanning#uncommitted-changes-scan) secrets as part of shifting security left
- Available [Github Action](https://github.com/marketplace/actions/gitleaks)
- Gitlab and Github API support which allows scans of whole organizations, users, and pull/merge requests
- [Custom rules](https://github.com/zricethezav/gitleaks/wiki/Configuration) via toml configuration
- High performance using [go-git](https://github.com/go-git/go-git)
- JSON and CSV reporting
- Private repo scans using key or password based authentication
| `repo scan` |
|---|
| <p align="left"><img src="https://raw.githubusercontent.com/zricethezav/gifs/master/repo-scan.gif"></p> | <p align="left"><img src="https://raw.githubusercontent.com/zricethezav/gifs/master/repo-scan.gif"></p> |
| `pre commit scan` |
|---|
| <p align="left"><img src="https://raw.githubusercontent.com/zricethezav/gifs/master/pre-commit-1.gif"></p> |
## Getting Started
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, as per the below;
#### MacOS
```
brew install gitleaks
```
#### Docker
```bash
docker pull zricethezav/gitleaks
```
#### Go
```bash
go get -u github.com/zricethezav/gitleaks
```
## Usage
gitleaks has a wide range of configuration options that can be adjusted at runtime or via a configuration file based on your specific requirements.
```
Usage:
gitleaks [OPTIONS]
Application Options:
-v, --verbose Show verbose output from audit
-r, --repo= Target repository
--config= config path
--disk Clones repo(s) to disk
--version version number
--username= Username for git repo
--password= Password for git repo
--access-token= Access token for git repo
--commit= sha of commit to audit
--threads= Maximum number of threads gitleaks spawns
--ssh-key= path to ssh key used for auth
--uncommitted run gitleaks on uncommitted code
--repo-path= Path to repo
--owner-path= Path to owner directory (repos discovered)
--branch= Branch to audit
--report= path to write json leaks file
--report-format= json or csv (default: json)
--redact redact secrets from log messages and leaks
--debug log debug messages
--repo-config Load config from target repo. Config file must be ".gitleaks.toml" or "gitleaks.toml"
--pretty Pretty print json if leaks are present
--commit-from= Commit to start audit from
--commit-to= Commit to stop audit
--timeout= Time allowed per audit. Ex: 10us, 30s, 1m, 1h10m1s
--depth= Number of commits to audit
--host= git hosting service like gitlab or github. Supported hosts include: Github, Gitlab
--baseurl= Base URL for API requests. Defaults to the public GitLab or GitHub API, but can be set to a domain endpoint to use with a self hosted server.
--org= organization to audit
--user= user to audit
--pr= pull/merge request url
--exclude-forks audit excludes forks
Help Options:
-h, --help Show this help message
```
### Docker usage examples
Run gitleaks against:
###### Public repository
```bash
docker run --rm --name=gitleaks zricethezav/gitleaks -v -r https://github.com/zricethezav/gitleaks.git
```
###### Local repository already cloned into /tmp/
```bash
docker run --rm --name=gitleaks -v /tmp/:/code/ zricethezav/gitleaks -v --repo-path=/code/gitleaks
```
By default repos cloned to memory. Using `--disk` for clone to disk or you can quickly out of memory.
For speed up analyze operation using `--threads` parameter, which set to `ALL - 1` threads at your instance CPU.
## Installation, Documentation and Examples
This project is documented [here](https://github.com/zricethezav/gitleaks/wiki)
## Exit Codes
### Sponsors ❤️
#### Corporate Sponsors
[![gammanet](https://gammanet.com/assets/images/new-design/gamma-logo.png)](https://gammanet.com/?utm_source=gitleaks&utm_medium=homepage&utm_campaign=gitleaks_promotion)
Gitleaks provides consistent exist codes to assist in automation workflows such as CICD platforms and bulk scanning.
Gamma proactively detects and remediates data leaks across cloud apps. Scan your public repos for secret leaks with [Gamma](https://gammanet.com/github-demo?utm_source=gitleaks&utm_medium=homepage&utm_campaign=gitleaks_promotion)
#### Individual Sponsors
These users are [sponsors](https://github.com/sponsors/zricethezav) of gitleaks:
```
0: no leaks
1: leaks present
2: error encountered
```
### Give Thanks
If using gitleaks has made your job easier consider [sponsoring me](https://github.com/sponsors/zricethezav) through github's sponsorship program or donating to one of [Sam](https://www.flickr.com/photos/146541520@N08/albums/72157710121716312)'s favorite places, the Japan House on the University of Illinois at Urbana-Champaign's campus: https://japanhouse.illinois.edu/make-a-gift
[![Adam Shannon](https://github.com/adamdecaf.png?size=50)](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>.
-56
View File
@@ -1,56 +0,0 @@
package audit
import (
"fmt"
"io/ioutil"
"path"
"github.com/zricethezav/gitleaks/manager"
log "github.com/sirupsen/logrus"
)
// Run accepts a manager and begins an audit based on the options/configs set in the manager.
func Run(m *manager.Manager) error {
if m.Opts.OwnerPath != "" {
files, err := ioutil.ReadDir(m.Opts.OwnerPath)
if err != nil {
return err
}
for _, f := range files {
if !f.IsDir() {
continue
}
m.Opts.RepoPath = fmt.Sprintf("%s/%s", m.Opts.OwnerPath, f.Name())
if err := runHelper(NewRepo(m)); err != nil {
log.Warnf("%s is not a git repo, skipping", f.Name())
}
}
return nil
}
return runHelper(NewRepo(m))
}
func runHelper(r *Repo) error {
if r.Manager.Opts.OpenLocal() {
r.Name = path.Base(r.Manager.Opts.RepoPath)
if err := r.Open(); err != nil {
return err
}
// Check if we are checking uncommitted files. This is the default behavior
// for a "$ gitleaks" command with no options set
if r.Manager.Opts.CheckUncommitted() {
if err := r.AuditUncommitted(); err != nil {
return err
}
return nil
}
} else {
if err := r.Clone(nil); err != nil {
return err
}
}
return r.Audit()
}
-403
View File
@@ -1,403 +0,0 @@
package audit
import (
"bytes"
"context"
"crypto/md5"
"fmt"
"io"
"os"
"path"
"path/filepath"
"sync"
"time"
"github.com/zricethezav/gitleaks/config"
"github.com/zricethezav/gitleaks/manager"
"github.com/BurntSushi/toml"
"github.com/sergi/go-diff/diffmatchpatch"
log "github.com/sirupsen/logrus"
"gopkg.in/src-d/go-billy.v4"
"gopkg.in/src-d/go-git.v4"
"gopkg.in/src-d/go-git.v4/plumbing"
"gopkg.in/src-d/go-git.v4/plumbing/object"
"gopkg.in/src-d/go-git.v4/plumbing/storer"
"gopkg.in/src-d/go-git.v4/storage/memory"
)
// Repo wraps a *git.Repository object in addition to a manager object and the name of the repo.
// Commits are inspected from the *git.Repository object. If a commit is found then we send it
// via the manager LeakChan where the manager receives and keeps track of all leaks.
type Repo struct {
*git.Repository
// config is used when the --repo-config option is set.
// This allows users to load up configs specific to their repos.
// Imagine the scenario where you are doing an audit of a large organization
// and you want certain repos to look for specific rules. If those specific repos
// have a gitleaks.toml or .gitleaks.toml config then those configs will be used specifically
// for those repo audits.
config config.Config
// ctx is used to signal timeouts to running goroutines
ctx context.Context
cancel context.CancelFunc
Name string
Manager *manager.Manager
}
// NewRepo initializes and returns a Repo struct.
func NewRepo(m *manager.Manager) *Repo {
return &Repo{
Manager: m,
config: m.Config,
ctx: context.Background(),
}
}
// Clone will clone a repo and return a Repo struct which contains a go-git repo. The clone method
// is determined by the clone options set in Manager.metadata.cloneOptions
func (repo *Repo) Clone(cloneOption *git.CloneOptions) error {
var (
repository *git.Repository
err error
)
if cloneOption == nil {
cloneOption = repo.Manager.CloneOptions
}
log.Infof("cloning... %s", cloneOption.URL)
start := time.Now()
if repo.Manager.CloneDir != "" {
clonePath := fmt.Sprintf("%s/%x", repo.Manager.CloneDir, md5.Sum([]byte(time.Now().String())))
repository, err = git.PlainClone(clonePath, false, cloneOption)
} else {
repository, err = git.Clone(memory.NewStorage(), nil, cloneOption)
}
if err != nil {
return err
}
repo.Name = filepath.Base(repo.Manager.Opts.Repo)
repo.Repository = repository
repo.Manager.RecordTime(manager.CloneTime(howLong(start)))
return nil
}
// AuditUncommitted will do a `git diff` and scan changed files that are being tracked. This is useful functionality
// for a pre-commit hook so you can make sure your code does not have any leaks before committing.
func (repo *Repo) AuditUncommitted() error {
// load up alternative config if possible, if not use manager's config
if repo.Manager.Opts.RepoConfig {
cfg, err := repo.loadRepoConfig()
if err != nil {
return err
}
repo.config = cfg
}
if err := repo.setupTimeout(); err != nil {
return err
}
auditTimeStart := time.Now()
r, err := repo.Head()
if err != nil {
return err
}
c, err := repo.CommitObject(r.Hash())
if err != nil {
return err
}
// Staged change so the commit details do not yet exist. Insert empty defaults.
c.Hash = plumbing.Hash{}
c.Message = "***STAGED CHANGES***"
c.Author.Name = ""
c.Author.Email = ""
c.Author.When = time.Unix(0, 0).UTC()
prevTree, err := c.Tree()
if err != nil {
return err
}
wt, err := repo.Worktree()
if err != nil {
return err
}
status, err := wt.Status()
for fn, state := range status {
var (
prevFileContents string
currFileContents string
filename string
)
if state.Staging != git.Untracked {
if state.Staging == git.Deleted {
// file in staging has been deleted, aka it is not on the filesystem
// so the contents of the file are ""
currFileContents = ""
} else {
workTreeBuf := bytes.NewBuffer(nil)
workTreeFile, err := wt.Filesystem.Open(fn)
if err != nil {
continue
}
if _, err := io.Copy(workTreeBuf, workTreeFile); err != nil {
return err
}
currFileContents = workTreeBuf.String()
filename = workTreeFile.Name()
}
// get files at HEAD state
prevFile, err := prevTree.File(fn)
if err != nil {
prevFileContents = ""
} else {
prevFileContents, err = prevFile.Contents()
if err != nil {
return err
}
if filename == "" {
filename = prevFile.Name
}
}
if fileMatched(filename, repo.config.Whitelist.File) {
log.Debugf("whitelisted file found, skipping audit of file: %s", filename)
} else if fileMatched(filename, repo.config.FileRegex) {
repo.Manager.SendLeaks(manager.Leak{
Line: "N/A",
Offender: filename,
Commit: c.Hash.String(),
Repo: repo.Name,
Rule: "file regex matched" + repo.config.FileRegex.String(),
Message: c.Message,
Author: c.Author.Name,
Email: c.Author.Email,
Date: c.Author.When,
File: filename,
})
} else {
dmp := diffmatchpatch.New()
diffs := dmp.DiffMain(prevFileContents, currFileContents, false)
var diffContents string
for _, d := range diffs {
switch d.Type {
case diffmatchpatch.DiffInsert:
diffContents += fmt.Sprintf("%s\n", d.Text)
case diffmatchpatch.DiffDelete:
diffContents += fmt.Sprintf("%s\n", d.Text)
}
}
InspectString(diffContents, c, repo, filename)
}
}
}
if err != nil {
return err
}
repo.Manager.RecordTime(manager.AuditTime(howLong(auditTimeStart)))
return nil
}
// Audit is responsible for scanning the entire history (default behavior) of a
// git repo. Options that can change the behavior of this function include: --commit, --depth, --branch.
// See options/options.go for an explanation on these options.
func (repo *Repo) Audit() error {
if err := repo.setupTimeout(); err != nil {
return err
}
if repo.Repository == nil {
return fmt.Errorf("%s repo is empty", repo.Name)
}
// load up alternative config if possible, if not use manager's config
if repo.Manager.Opts.RepoConfig {
cfg, err := repo.loadRepoConfig()
if err != nil {
return err
}
repo.config = cfg
}
auditTimeStart := time.Now()
// audit single Commit
if repo.Manager.Opts.Commit != "" {
h := plumbing.NewHash(repo.Manager.Opts.Commit)
c, err := repo.CommitObject(h)
if err != nil {
return err
}
err = inspectCommit(c, repo)
if err != nil {
return err
}
return nil
}
logOpts, err := getLogOptions(repo)
if err != nil {
return err
}
cIter, err := repo.Log(logOpts)
if err != nil {
return err
}
cc := 0
semaphore := make(chan bool, howManyThreads(repo.Manager.Opts.Threads))
wg := sync.WaitGroup{}
err = cIter.ForEach(func(c *object.Commit) error {
if c == nil || c.Hash.String() == repo.Manager.Opts.CommitTo ||
repo.timeoutReached() || repo.depthReached(cc) {
return storer.ErrStop
}
if len(c.ParentHashes) == 0 {
cc++
err = inspectCommit(c, repo)
if err != nil {
return err
}
return nil
}
if isCommitWhiteListed(c.Hash.String(), repo.config.Whitelist.Commits) {
return nil
}
cc++
err = c.Parents().ForEach(func(parent *object.Commit) error {
defer func() {
if err := recover(); err != nil {
// sometimes the patch generation will fail due to a known bug in
// sergi's go-diff: https://github.com/sergi/go-diff/issues/89.
// Once a fix has been merged I will remove this recover.
return
}
}()
if repo.timeoutReached() {
return nil
}
start := time.Now()
patch, err := c.Patch(parent)
if err != nil {
return fmt.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) {
defer func() {
<-semaphore
wg.Done()
}()
inspectPatch(patch, c, repo)
}(c, patch)
return nil
})
return nil
})
wg.Wait()
repo.Manager.RecordTime(manager.AuditTime(howLong(auditTimeStart)))
repo.Manager.IncrementCommits(cc)
return nil
}
// Open opens a local repo either from repo-path or $PWD
func (repo *Repo) Open() error {
if repo.Manager.Opts.RepoPath != "" {
// open git repo from repo path
repository, err := git.PlainOpen(repo.Manager.Opts.RepoPath)
if err != nil {
return err
}
repo.Repository = repository
} else {
// open git repo from PWD
dir, err := os.Getwd()
if err != nil {
return err
}
repository, err := git.PlainOpen(dir)
if err != nil {
return err
}
repo.Repository = repository
repo.Name = path.Base(dir)
}
return nil
}
func (repo *Repo) loadRepoConfig() (config.Config, error) {
wt, err := repo.Repository.Worktree()
if err != nil {
return config.Config{}, err
}
var f billy.File
f, _ = wt.Filesystem.Open(".gitleaks.toml")
if f == nil {
f, err = wt.Filesystem.Open("gitleaks.toml")
if err != nil {
return config.Config{}, fmt.Errorf("problem loading repo config: %v", err)
}
}
defer f.Close()
var tomlLoader config.TomlLoader
_, err = toml.DecodeReader(f, &tomlLoader)
return tomlLoader.Parse()
}
// timeoutReached returns true if the timeout deadline has been met. This function should be used
// at the top of loops and before potentially long running goroutines (like checking inefficient regexes)
func (repo *Repo) timeoutReached() bool {
if repo.ctx.Err() == context.DeadlineExceeded {
return true
}
return false
}
// setupTimeout parses the --timeout option and assigns a context with timeout to the manager
// which will exit early if the timeout has been met.
func (repo *Repo) setupTimeout() error {
if repo.Manager.Opts.Timeout == "" {
return nil
}
timeout, err := time.ParseDuration(repo.Manager.Opts.Timeout)
if err != nil {
return err
}
repo.ctx, repo.cancel = context.WithTimeout(context.Background(), timeout)
go func() {
select {
case <-repo.ctx.Done():
log.Warnf("Timeout deadline exceeded: %s", timeout.String())
}
}()
return nil
}
func (repo *Repo) depthReached(i int) bool {
if repo.Manager.Opts.Depth != 0 && repo.Manager.Opts.Depth == i {
log.Warnf("Exceeded depth limit (%d)", i)
return true
}
return false
}
-394
View File
@@ -1,394 +0,0 @@
package audit
import (
"fmt"
"math"
"regexp"
"runtime"
"strings"
"time"
"github.com/zricethezav/gitleaks/config"
"github.com/zricethezav/gitleaks/manager"
log "github.com/sirupsen/logrus"
"gopkg.in/src-d/go-git.v4"
"gopkg.in/src-d/go-git.v4/plumbing"
fdiff "gopkg.in/src-d/go-git.v4/plumbing/format/diff"
"gopkg.in/src-d/go-git.v4/plumbing/object"
)
// Inspect patch accepts a patch, commit, and repo. If the patches contains files that are
// binary, then gitleaks will skip auditing that file OR if a file is matched on
// whitelisted files set in the configuration. If a global rule for files is defined and a filename
// matches said global rule, then a leak is sent to the manager.
// After that, file chunks are created which are then inspected by InspectString()
func inspectPatch(patch *object.Patch, c *object.Commit, repo *Repo) {
for _, f := range patch.FilePatches() {
if repo.timeoutReached() {
return
}
if f.IsBinary() {
continue
}
if fileMatched(getFileName(f), repo.config.Whitelist.File) {
log.Debugf("whitelisted file found, skipping audit of file: %s", getFileName(f))
continue
}
if fileMatched(getFileName(f), repo.config.FileRegex) {
repo.Manager.SendLeaks(manager.Leak{
Line: "N/A",
Offender: getFileName(f),
Commit: c.Hash.String(),
Repo: repo.Name,
Rule: "file regex matched" + repo.config.FileRegex.String(),
Author: c.Author.Name,
Email: c.Author.Email,
Date: c.Author.When,
File: getFileName(f),
})
}
for _, chunk := range f.Chunks() {
if chunk.Type() == fdiff.Delete || chunk.Type() == fdiff.Add {
InspectString(chunk.Content(), c, repo, getFileName(f))
}
}
}
}
// getFileName accepts a file patch and returns the filename
func getFileName(f fdiff.FilePatch) string {
fn := "???"
from, to := f.Files()
if from != nil {
return from.Path()
} else if to != nil {
return to.Path()
}
return fn
}
// getShannonEntropy https://en.wiktionary.org/wiki/Shannon_entropy
func shannonEntropy(data string) (entropy float64) {
if data == "" {
return 0
}
charCounts := make(map[rune]int)
for _, char := range data {
charCounts[char]++
}
invLength := 1.0 / float64(len(data))
for _, count := range charCounts {
freq := float64(count) * invLength
entropy -= freq * math.Log2(freq)
}
return entropy
}
// aws_access_key_id='AKIAIO5FODNN7EXAMPLE',
// trippedEntropy checks if a given line falls in between entropy ranges supplied
// by a custom gitleaks configuration. Gitleaks do not check entropy by default.
func trippedEntropy(line string, rule config.Rule) bool {
for _, e := range rule.Entropy {
entropy := shannonEntropy(line)
if entropy > e.P1 && entropy < e.P2 {
return true
}
}
return false
}
func ruleContainRegex(rule config.Rule) bool {
if rule.Regex == nil {
return false
}
if rule.Regex.String() == "" {
return false
}
return true
}
// InspectString accepts a string, commit object, repo, and filename. This function iterates over
// all the rules set by the gitleaks config. If the rule contains entropy checks then entropy will be checked first.
// Next, if the rule contains a regular expression then that will be checked.
func InspectString(content string, c *object.Commit, repo *Repo, filename string) {
for _, rule := range repo.config.Rules {
// check entropy
if len(rule.Entropy) != 0 {
// an optimization would be to switch the regex from FindAllIndex to FindString
// since we are iterating on the lines if entropy rules exist...
for _, line := range strings.Split(content, "\n") {
if repo.timeoutReached() {
return
}
entropyTripped := trippedEntropy(line, rule)
if entropyTripped && !ruleContainRegex(rule) {
repo.Manager.SendLeaks(manager.Leak{
Line: line,
Offender: fmt.Sprintf("Entropy range %+v", rule.Entropy),
Commit: c.Hash.String(),
Repo: repo.Name,
Message: c.Message,
Rule: rule.Description,
Author: c.Author.Name,
Email: c.Author.Email,
Date: c.Author.When,
Tags: strings.Join(rule.Tags, ", "),
File: filename,
})
} else if entropyTripped {
if repo.timeoutReached() {
return
}
// entropy has been tripped which means if there is a regex specified in the same
// rule, we need to inspect the line for a regex match. In otherwords, the current rule has
// both entropy and regex set which work in combination. This helps narrow down false positives
// on searches for generic passwords in code.
match := rule.Regex.FindString(line)
// check if any rules are whitelisting this leak
if len(rule.Whitelist) != 0 {
for _, wl := range rule.Whitelist {
if fileMatched(filename, wl.File) {
// if matched, go to next rule
goto NEXTLINE
}
if wl.Regex.FindString(line) != "" {
goto NEXTLINE
}
}
}
if match != "" {
// both the regex and entropy in this rule have been tripped which means this line
// contains a leak
repo.Manager.SendLeaks(manager.Leak{
Line: line,
Offender: match,
Commit: c.Hash.String(),
Message: c.Message,
Repo: repo.Name,
Rule: rule.Description,
Author: c.Author.Name,
Email: c.Author.Email,
Date: c.Author.When,
Tags: strings.Join(rule.Tags, ", "),
File: filename,
})
}
}
NEXTLINE:
}
return
}
if rule.Regex.String() == "" {
continue
}
if repo.timeoutReached() {
return
}
start := time.Now()
locs := rule.Regex.FindAllIndex([]byte(content), -1)
if len(locs) != 0 {
// check if any rules are whitelisting this leak
if len(rule.Whitelist) != 0 {
for _, wl := range rule.Whitelist {
if fileMatched(filename, wl.File) {
// if matched, go to next rule
goto NEXT
}
}
}
for _, loc := range locs {
start := loc[0]
end := loc[1]
for start != 0 && content[start] != '\n' {
start = start - 1
}
if start != 0 {
// skip newline
start = start + 1
}
for end < len(content)-1 && content[end] != '\n' {
end = end + 1
}
offender := content[loc[0]:loc[1]]
line := content[start:end]
if len(rule.Whitelist) != 0 {
for _, wl := range rule.Whitelist {
if wl.Regex.FindString(line) != "" {
goto NEXT
}
}
}
if repo.Manager.Opts.Redact {
line = strings.ReplaceAll(line, offender, "REDACTED")
offender = "REDACTED"
}
repo.Manager.SendLeaks(manager.Leak{
Line: line,
Offender: offender,
Commit: c.Hash.String(),
Message: c.Message,
Repo: repo.Name,
Rule: rule.Description,
Author: c.Author.Name,
Email: c.Author.Email,
Date: c.Author.When,
Tags: strings.Join(rule.Tags, ", "),
File: filename,
})
}
}
repo.Manager.RecordTime(manager.RegexTime{
Time: time.Now().Sub(start).Nanoseconds(),
Regex: rule.Regex.String(),
})
NEXT:
}
}
// inspectCommit accepts a commit object and a repo. This function is only called when the --commit=
// option has been set. That option tells gitleaks to look only at a single commit and check the contents
// of said commit. Similar to inspectPatch(), if the files contained in the commit are a binaries or if they are
// whitelisted then those files will be skipped.
func inspectCommit(c *object.Commit, repo *Repo) error {
fIter, err := c.Files()
if err != nil {
return err
}
err = fIter.ForEach(func(f *object.File) error {
bin, err := f.IsBinary()
if bin || repo.timeoutReached() {
return nil
} else if err != nil {
return err
}
if fileMatched(f, repo.config.Whitelist.File) {
log.Debugf("whitelisted file found, skipping audit of file: %s", f.Name)
return nil
}
if fileMatched(f.Name, repo.config.FileRegex) {
repo.Manager.SendLeaks(manager.Leak{
Line: "N/A",
Offender: f.Name,
Commit: c.Hash.String(),
Repo: repo.Name,
Rule: "file regex matched" + repo.config.FileRegex.String(),
Author: c.Author.Name,
Email: c.Author.Email,
Date: c.Author.When,
File: f.Name,
})
}
content, err := f.Contents()
if err != nil {
return err
}
InspectString(content, c, repo, f.Name)
return nil
})
return err
}
// howManyThreads will return a number 1-GOMAXPROCS which is the number
// of goroutines that will spawn during gitleaks execution
func howManyThreads(threads int) int {
maxThreads := runtime.GOMAXPROCS(0)
if threads == 0 {
return 1
} else if threads > maxThreads {
log.Warnf("%d threads set too high, setting to system max, %d", threads, maxThreads)
return maxThreads
}
return threads
}
func isCommitWhiteListed(commitHash string, whitelistedCommits []string) bool {
for _, hash := range whitelistedCommits {
if commitHash == hash {
return true
}
}
return false
}
func fileMatched(f interface{}, re *regexp.Regexp) bool {
if re == nil {
return false
}
switch f.(type) {
case nil:
return false
case string:
if re.FindString(f.(string)) != "" {
return true
}
return false
case *object.File:
if re.FindString(f.(*object.File).Name) != "" {
return true
}
return false
}
return false
}
// getLogOptions determines what log options are used when iterating through commits.
// It is similar to `git log {branch}`. Default behavior is to log ALL branches so
// gitleaks gets the full git history.
func getLogOptions(repo *Repo) (*git.LogOptions, error) {
var logOpts git.LogOptions
if repo.Manager.Opts.CommitFrom != "" {
logOpts.From = plumbing.NewHash(repo.Manager.Opts.CommitFrom)
}
if repo.Manager.Opts.Branch != "" {
refs, err := repo.Storer.IterReferences()
if err != nil {
return nil, err
}
err = refs.ForEach(func(ref *plumbing.Reference) error {
if ref.Name().IsTag() {
return nil
}
// check heads first
if ref.Name().String() == "refs/heads/"+repo.Manager.Opts.Branch {
logOpts = git.LogOptions{
From: ref.Hash(),
}
return nil
} else if ref.Name().String() == "refs/remotes/origin/"+repo.Manager.Opts.Branch {
logOpts = git.LogOptions{
From: ref.Hash(),
}
return nil
}
return nil
})
if logOpts.From.IsZero() {
return nil, fmt.Errorf("could not find branch %s", repo.Manager.Opts.Branch)
}
return &logOpts, nil
}
if !logOpts.From.IsZero() {
return &logOpts, nil
}
return &git.LogOptions{All: true}, nil
}
// howLong accepts a time.Time object which is subtracted from time.Now() and
// converted to nanoseconds which is returned
func howLong(t time.Time) int64 {
return time.Now().Sub(t).Nanoseconds()
}
+159 -107
View File
@@ -2,82 +2,91 @@ package config
import (
"fmt"
"path"
"regexp"
"strconv"
"strings"
"github.com/zricethezav/gitleaks/options"
"github.com/zricethezav/gitleaks/v6/options"
"github.com/BurntSushi/toml"
log "github.com/sirupsen/logrus"
)
// Whitelist is struct containing items that if encountered will whitelist
// AllowList is struct containing items that if encountered will allowlist
// a commit/line of code that would be considered a leak.
type Whitelist struct {
type AllowList struct {
Description string
Regex *regexp.Regexp
File *regexp.Regexp
Regexes []*regexp.Regexp
Commits []string
Files []*regexp.Regexp
Paths []*regexp.Regexp
Repos []*regexp.Regexp
}
// entropy represents an entropy range
type entropy struct {
P1, P2 float64
// Entropy represents an entropy range
type Entropy struct {
Min float64
Max float64
Group int
}
// Rule is a struct that contains information that is loaded from a gitleaks config.
// This struct is used in the Config struct as an array of Rules and is iterated
// over during an audit. Each rule will be checked. If a regex match is found AND
// that match is not whitelisted (globally or locally), then a leak will be appended
// to the final audit report.
// over during an scan. Each rule will be checked. If a regex match is found AND
// 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
File *regexp.Regexp
Path *regexp.Regexp
ReportGroup int
Tags []string
Whitelist []Whitelist
Entropy []entropy
AllowList AllowList
Entropies []Entropy
}
// Config is a composite struct of Rules and Whitelists
// Each Rule contains a description, regular expression, tags, and whitelists if available
// Config is a composite struct of Rules and Allowlists
// Each Rule contains a description, regular expression, tags, and allowlists if available
type Config struct {
FileRegex *regexp.Regexp
Message *regexp.Regexp
Rules []Rule
Whitelist struct {
Description string
Commits []string
File *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 {
Global struct {
File string
Message string
}
Whitelist struct {
Description string
Commits []string
File string
}
Rules []struct {
AllowList TomlAllowList
Rules []struct {
Description string
Regex string
File string
Path string
ReportGroup int
Tags []string
Entropies []string
Whitelist []struct {
Description string
Regex string
File string
Entropies []struct {
Min string
Max string
Group string
}
AllowList TomlAllowList
}
}
// NewConfig will create a new config struct which contains
// rules on how gitleaks will proceed with its audit.
// rules on how gitleaks will proceed with its scan.
// If no options are passed via cli then NewConfig will return
// a default config which can be seen in config.go
func NewConfig(options options.Options) (Config, error) {
@@ -87,6 +96,8 @@ func NewConfig(options options.Options) (Config, error) {
var err 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))
} else {
_, err = toml.Decode(DefaultConfig, &tomlLoader)
}
@@ -103,98 +114,139 @@ func NewConfig(options options.Options) (Config, error) {
}
// Parse will parse the values set in a TomlLoader and use those values
// to create compiled regular expressions and rules used in audits
// to create compiled regular expressions and rules used in scans
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.Path == "" && rule.File == "" && len(rule.Entropies) == 0 {
log.Warnf("Rule %s does not define any actionable data", rule.Description)
continue
}
re, err := regexp.Compile(rule.Regex)
if err != nil {
return cfg, fmt.Errorf("problem loading config: %v", err)
}
// rule specific whitelists
var whitelists []Whitelist
for _, wl := range rule.Whitelist {
re, err := regexp.Compile(wl.Regex)
if err != nil {
return cfg, fmt.Errorf("problem loading config: %v", err)
}
fileRe, err := regexp.Compile(wl.File)
if err != nil {
return cfg, fmt.Errorf("problem loading config: %v", err)
}
whitelists = append(whitelists, Whitelist{
Description: wl.Description,
File: fileRe,
Regex: re,
})
}
entropies, err := getEntropy(rule.Entropies)
fileNameRe, err := regexp.Compile(rule.File)
if err != nil {
return cfg, err
return cfg, fmt.Errorf("problem loading config: %v", err)
}
filePathRe, err := regexp.Compile(rule.Path)
if err != nil {
return cfg, fmt.Errorf("problem loading config: %v", err)
}
cfg.Rules = append(cfg.Rules, Rule{
// rule specific allowlists
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)
}
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)
}
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)
}
allowList.Paths = append(allowList.Paths, allowListedRegex)
}
var entropies []Entropy
for _, e := range rule.Entropies {
min, err := strconv.ParseFloat(e.Min, 64)
if err != nil {
return cfg, err
}
max, err := strconv.ParseFloat(e.Max, 64)
if err != nil {
return cfg, err
}
if e.Group == "" {
e.Group = "0"
}
group, err := strconv.ParseInt(e.Group, 10, 64)
if err != nil {
return cfg, err
} else if int(group) >= len(re.SubexpNames()) {
return cfg, fmt.Errorf("problem loading config: group cannot be higher than number of groups in regexp")
} else if group < 0 {
return cfg, fmt.Errorf("problem loading config: group cannot be lower than 0")
} else if min > 8.0 || min < 0.0 || max > 8.0 || max < 0.0 {
return cfg, fmt.Errorf("problem loading config: invalid entropy ranges, must be within 0.0-8.0")
} else if min > max {
return cfg, fmt.Errorf("problem loading config: entropy Min value cannot be higher than Max value")
}
entropies = append(entropies, Entropy{Min: min, Max: max, Group: int(group)})
}
r := Rule{
Description: rule.Description,
Regex: re,
File: fileNameRe,
Path: filePathRe,
ReportGroup: rule.ReportGroup,
Tags: rule.Tags,
Whitelist: whitelists,
Entropy: entropies,
})
AllowList: allowList,
Entropies: entropies,
}
cfg.Rules = append(cfg.Rules, r)
}
// global leaks
if tomlLoader.Global.File != "" {
re, err := regexp.Compile(tomlLoader.Global.File)
// 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.FileRegex = re
}
if tomlLoader.Global.Message != "" {
re, err := regexp.Compile(tomlLoader.Global.Message)
if err != nil {
return cfg, fmt.Errorf("problem loading config: %v", err)
}
cfg.Message = re
cfg.Allowlist.Regexes = append(cfg.Allowlist.Regexes, re)
}
// global whitelists
if tomlLoader.Whitelist.File != "" {
re, err := regexp.Compile(tomlLoader.Whitelist.File)
// 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.Whitelist.File = re
cfg.Allowlist.Files = append(cfg.Allowlist.Files, re)
}
cfg.Whitelist.Commits = tomlLoader.Whitelist.Commits
cfg.Whitelist.Description = tomlLoader.Whitelist.Description
// 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 _, 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
return cfg, nil
}
// getEntropy
func getEntropy(entropyStr []string) ([]entropy, error) {
var ranges []entropy
for _, span := range entropyStr {
split := strings.Split(span, "-")
v1, err := strconv.ParseFloat(split[0], 64)
if err != nil {
return nil, err
}
v2, err := strconv.ParseFloat(split[1], 64)
if err != nil {
return nil, err
}
if v1 > v2 {
return nil, fmt.Errorf("entropy range must be ascending")
}
r := entropy{P1: v1, P2: v2}
if r.P1 > 8.0 || r.P1 < 0.0 || r.P2 > 8.0 || r.P2 < 0.0 {
return nil, fmt.Errorf("invalid entropy ranges, must be within 0.0-8.0")
}
ranges = append(ranges, r)
}
return ranges, nil
}
+114 -17
View File
@@ -2,9 +2,12 @@ package config
import (
"fmt"
"github.com/zricethezav/gitleaks/options"
"io/ioutil"
"os"
"regexp"
"testing"
"github.com/zricethezav/gitleaks/v6/options"
)
func TestParse(t *testing.T) {
@@ -14,7 +17,7 @@ func TestParse(t *testing.T) {
wantErr error
wantFileRegex *regexp.Regexp
wantMessages *regexp.Regexp
wantWhitelist Whitelist
wantAllowlist AllowList
}{
{
description: "default config",
@@ -41,9 +44,9 @@ func TestParse(t *testing.T) {
wantErr: fmt.Errorf("problem loading config: error parsing regexp: invalid nested repetition operator: `???`"),
},
{
description: "test bad global whitelist file regex",
description: "test bad global allowlist file regex",
opts: options.Options{
Config: "../test_data/test_configs/bad_aws_key_global_whitelist_file.toml",
Config: "../test_data/test_configs/bad_aws_key_global_allowlist_file.toml",
},
wantErr: fmt.Errorf("problem loading config: error parsing regexp: missing argument to repetition operator: `??`"),
},
@@ -54,13 +57,6 @@ func TestParse(t *testing.T) {
},
wantErr: fmt.Errorf("problem loading config: error parsing regexp: missing argument to repetition operator: `??`"),
},
{
description: "test bad global message regex",
opts: options.Options{
Config: "../test_data/test_configs/bad_aws_key_message_regex.toml",
},
wantErr: fmt.Errorf("problem loading config: error parsing regexp: missing argument to repetition operator: `??`"),
},
{
description: "test successful load big ol thing",
opts: options.Options{
@@ -78,28 +74,49 @@ func TestParse(t *testing.T) {
opts: options.Options{
Config: "../test_data/test_configs/bad_entropy_1.toml",
},
wantErr: fmt.Errorf("entropy range must be ascending"),
wantErr: fmt.Errorf("problem loading config: entropy Min value cannot be higher than Max value"),
},
{
description: "test entropy value p2",
description: "test entropy value max",
opts: options.Options{
Config: "../test_data/test_configs/bad_entropy_2.toml",
},
wantErr: fmt.Errorf("strconv.ParseFloat: parsing \"x\": invalid syntax"),
},
{
description: "test entropy value p1",
description: "test entropy value min",
opts: options.Options{
Config: "../test_data/test_configs/bad_entropy_3.toml",
},
wantErr: fmt.Errorf("strconv.ParseFloat: parsing \"x\": invalid syntax"),
},
{
description: "test entropy value p1",
description: "test entropy value group",
opts: options.Options{
Config: "../test_data/test_configs/bad_entropy_4.toml",
},
wantErr: fmt.Errorf("invalid entropy ranges, must be within 0.0-8.0"),
wantErr: fmt.Errorf("strconv.ParseInt: parsing \"x\": invalid syntax"),
},
{
description: "test entropy value group",
opts: options.Options{
Config: "../test_data/test_configs/bad_entropy_5.toml",
},
wantErr: fmt.Errorf("problem loading config: group cannot be lower than 0"),
},
{
description: "test entropy value group",
opts: options.Options{
Config: "../test_data/test_configs/bad_entropy_6.toml",
},
wantErr: fmt.Errorf("problem loading config: group cannot be higher than number of groups in regexp"),
},
{
description: "test entropy range limits",
opts: options.Options{
Config: "../test_data/test_configs/bad_entropy_7.toml",
},
wantErr: fmt.Errorf("problem loading config: invalid entropy ranges, must be within 0.0-8.0"),
},
}
@@ -107,10 +124,90 @@ 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)
}
}
}
}
// 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
}
+19 -18
View File
@@ -33,27 +33,27 @@ title = "gitleaks config"
[[rules]]
description = "Twitter Secret Key"
regex = '''(?i)twitter(.{0,20})?['\"][0-9a-z]{35,44}['\"]'''
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}['\"]'''
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}['\"]'''
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}['\"]'''
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}['\"]'''
regex = '''(?i)linkedin(.{0,20})?[0-9a-z]{16}'''
tags = ["secret", "LinkedIn"]
[[rules]]
@@ -66,30 +66,29 @@ title = "gitleaks config"
regex = '''-----BEGIN ((EC|PGP|DSA|RSA|OPENSSH) )?PRIVATE KEY( BLOCK)?-----'''
tags = ["key", "AsymmetricPrivateKey"]
[[rules]]
description = "Generic Credential"
regex = '''(?i)(api_key|apikey|secret)(.{0,20})?['|"][0-9a-zA-Z]{16,45}['|"]'''
tags = ["key", "API", "generic"]
[[rules]]
description = "Google API key"
regex = '''AIza[0-9A-Za-z\\-_]{35}'''
tags = ["key", "Google"]
[[rules]]
description = "Google (GCP) Service Account"
regex = '''"type": "service_account"'''
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}['"]'''
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}['"]'''
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}['"]'''
regex = '''((?i)(mailgun|mg)(.{0,20})?)?key-[0-9a-z]{32}'''
tags = ["key", "Mailgun"]
[[rules]]
@@ -114,7 +113,7 @@ title = "gitleaks config"
[[rules]]
description = "Stripe API key"
regex = '''(?i)stripe(.{0,20})?['\"][sk|rk]_live_[0-9a-zA-Z]{24}'''
regex = '''(?i)stripe(.{0,20})?[sr]k_live_[0-9a-zA-Z]{24}'''
tags = ["key", "Stripe"]
[[rules]]
@@ -129,10 +128,12 @@ title = "gitleaks config"
[[rules]]
description = "Twilio API key"
regex = '''(?i)twilio(.{0,20})?['\"][0-9a-f]{32}['\"]'''
regex = '''(?i)twilio(.{0,20})?SK[0-9a-f]{32}'''
tags = ["key", "twilio"]
[whitelist]
description = "Whitelisted files"
file = '''(^\.?gitleaks.toml$|(.*?)(jpg|gif|doc|pdf|bin)$)'''
[allowlist]
description = "Allowlisted files"
files = ['''^\.?gitleaks.toml$''',
'''(.*?)(jpg|gif|doc|pdf|bin)$''',
'''(go.mod|go.sum)$''']
`
+46 -20
View File
@@ -124,46 +124,72 @@ title = "gitleaks config"
[[rules]]
description = "Env Var"
regex = '''(?i)(api_key|apikey|secret|key|api|password|pw|host)=[0-9a-zA-Z-_{}]{4,120}'''
regex = '''(?i)(apikey|secret|key|api|password|pass|pw|host)=[0-9a-zA-Z-_.{}]{4,120}'''
[[rules]]
description = "Port"
regex = '''(?i)port(.{0,4})?[0-9]{1,10}'''
[rules.allowlist]
regexes = ['''(?i)port ''']
description = "ignore export "
[[rules]]
description = "Email"
regex = '''[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}'''
tags = ["email"]
[rules.allowlist]
files = ['''(?i)bashrc''']
description = "ignore bashrc emails"
[[rules]]
description = "Generic Credential"
regex = '''(?i)(dbpasswd|dbuser|dbname|dbhost|api_key|apikey|secret|key|api|password|user|guid|hostname|pw|auth)(.{0,20})?['|"][0-9a-zA-Z-_!{}/=]{4,120}['|"]'''
regex = '''(?i)(dbpasswd|dbuser|dbname|dbhost|api_key|apikey|secret|key|api|password|user|guid|hostname|pw|auth)(.{0,20})?['|"]([0-9a-zA-Z-_\/+!{}/=]{4,120})['|"]'''
tags = ["key", "API", "generic"]
# ignore leaks with specific identifiers like slack and aws
[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}'''
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"
files = ['''(pem|ppk|env)$''']
paths = ['''(.*)?ssh''']
[[rules]]
description = "Potential bash var"
regex='''(?i)(=)([0-9a-zA-Z-_!{}=]{4,120})'''
tags = ["key", "bash", "API", "generic"]
[[rules.Entropies]]
Min = "3.5"
Max = "4.5"
Group = "1"
[[rules]]
description = "WP-Config"
regex='''define(.{0,20})?(DB_CHARSET|NONCE_SALT|LOGGED_IN_SALT|AUTH_SALT|NONCE_KEY|DB_HOST|DB_PASSWORD|AUTH_KEY|SECURE_AUTH_KEY|LOGGED_IN_KEY|DB_NAME|DB_USER)(.{0,20})?['|"].{10,120}['|"]'''
tags = ["key", "API", "generic"]
[[rules]]
description = "Pure Entropy"
regex = '''['|"][0-9a-zA-Z-._{}$\/=]{40,120}['|"]'''
entropies = [
"5.0-5.6"
]
[[rules]]
description = "Entropy plus Generic Credential"
regex = '''(?i)(api_key|apikey|secret|key|api|password|pw)'''
entropies = [
"5.2-5.5"
]
[Global]
description = "Files with keys and credentials"
file = '''(?i)(id_rsa|passwd|id_rsa.pub|pgpass|pem|key|shadow)'''
[whitelist]
description = "image whitelists"
file = '''(.*?)(jpg|gif|doc|pdf|bin)$'''
# Global allowlist
[allowlist]
description = "image allowlists"
files = ['''(.*?)(jpg|gif|doc|pdf|bin)$''']
+7 -5
View File
@@ -1,5 +1,5 @@
# This config contains a single rule which defines a regex and a range of entropy values. If a rule has
# both regex and entropy then that rule uses BOTH the regex and entropy in combination when performing an audit.
# both regex and entropy then that rule uses BOTH the regex and entropy in combination when performing an scan.
# In other words, if a line of code has an entropy value that is within the range of the entropies defined and
# a regex match is found then that line of code contains a leak.
@@ -8,8 +8,10 @@
[[rules]]
description = "entropy and regex"
regex = '''(?i)key(.{0,20})?['|"][0-9a-zA-Z]{16,45}['|"]'''
entropies = [
"4.5-4.7",
"5.5-6.3",
]
tags = ["entropy"]
[[rules.Entropies]]
Min = "4.5"
Max = "5.7"
[[rules.Entropies]]
Min = "5.5"
Max = "6.3"
-10
View File
@@ -1,10 +0,0 @@
# This is a simple gitleaks config that contains one rule which checks for AWS keys and a file check that will trigger
# a leak if a .pem file is found
[[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"]
[Global]
file = '''(.*)?pem$'''
@@ -1,13 +1,13 @@
# This config contains a single rule that checks for AWS keys. However, it also contains a whitelist table
# where you can define one or more whitelists. What this means is that if you have an example AWS key as part of your
# code (in a test for example), then you can whitelist that specific key so gitleaks will not label it as a leak.
# This config contains a single rule that checks for AWS keys. However, it also contains a allowlist table
# where you can define one or more allowlists. What this means is that if you have an example AWS key as part of your
# code (in a test for example), then you can allowlist that specific key so gitleaks will not label it as a leak.
# If this line was present in a git history: `aws_access_key_id='AKIAIO5FODNN7EXAMPLE``, gitleaks would match this line
# with the rule below, but since we have a whitelist against that specific key, it would be ignored.
# with the rule below, but since we have a allowlist against that specific key, it would be ignored.
[[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.whitelist]]
regex = '''AKIAIO5FODNN7EXAMPLE.*'''
description = "ignore example aws key"
[rules.allowlist]
regexes = ['''AKIAIO5FODNN7EXAMPLE.*''']
description = "ignore example aws key"
+6 -6
View File
@@ -1,18 +1,18 @@
module github.com/zricethezav/gitleaks
module github.com/zricethezav/gitleaks/v6
go 1.13
go 1.14
require (
github.com/BurntSushi/toml v0.3.1
github.com/go-git/go-billy/v5 v5.0.0
github.com/go-git/go-git/v5 v5.1.0
github.com/google/go-cmp v0.4.0 // indirect
github.com/google/go-github v17.0.0+incompatible
github.com/google/go-github/v31 v31.0.0
github.com/hako/durafmt v0.0.0-20191009132224-3f39dc1ed9f4
github.com/jessevdk/go-flags v1.4.0
github.com/mattn/go-colorable v0.1.2
github.com/sergi/go-diff v1.0.0
github.com/sergi/go-diff v1.1.0
github.com/sirupsen/logrus v1.4.2
github.com/xanzy/go-gitlab v0.21.0
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
gopkg.in/src-d/go-billy.v4 v4.3.2
gopkg.in/src-d/go-git.v4 v4.13.1
)
+35 -31
View File
@@ -7,7 +7,7 @@ github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -17,18 +17,30 @@ github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 h1:BHsljHzVlRcyQhjr
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0=
github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4=
github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E=
github.com/go-git/go-billy/v5 v5.0.0 h1:7NQHvd9FVid8VL4qVUMm8XifBK+2xCoZ2lSk0agRrHM=
github.com/go-git/go-billy/v5 v5.0.0/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0=
github.com/go-git/go-git-fixtures/v4 v4.0.1 h1:q+IFMfLx200Q3scvt2hN79JsEzy4AmBTp/pqnefH+Bc=
github.com/go-git/go-git-fixtures/v4 v4.0.1/go.mod h1:m+ICp2rF3jDhFgEZ/8yziagdT1C+ZpZcrJjappBCDSw=
github.com/go-git/go-git/v5 v5.1.0 h1:HxJn9g/E7eYvKW3Fm7Jt4ee8LXfPOm/H1cdDu8vEssk=
github.com/go-git/go-git/v5 v5.1.0/go.mod h1:ZKfuPUoY1ZqIG4QG9BDBh3G4gLM5zvPuSJAozQrZuyM=
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-github v17.0.0+incompatible h1:N0LgJ1j65A7kfXrZnUDaYCs/Sf4rEjNlfyDHW9dolSY=
github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
github.com/google/go-github/v31 v31.0.0 h1:JJUxlP9lFK+ziXKimTCprajMApV1ecWD4NB6CCb0plo=
github.com/google/go-github/v31 v31.0.0/go.mod h1:NQPZol8/1sMoWYGN2yaALIBytu17gAWfhbweiEed3pM=
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
github.com/hako/durafmt v0.0.0-20191009132224-3f39dc1ed9f4 h1:60gBOooTSmNtrqNaRvrDbi8VAne0REaek2agjnITKSw=
github.com/hako/durafmt v0.0.0-20191009132224-3f39dc1ed9f4/go.mod h1:5Scbynm8dF1XAPwIwkGPqzkM/shndPm79Jd1003hTjE=
github.com/imdario/mergo v0.3.9 h1:UauaLniWCFHWd+Jp9oCEkTBj8VO/9DKg3PV3VCNMDIg=
github.com/imdario/mergo v0.3.9/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
github.com/jessevdk/go-flags v1.4.0 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGARJA=
@@ -40,32 +52,29 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxv
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU=
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE=
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/pelletier/go-buffruneio v0.2.0/go.mod h1:JkE26KsDizTr40EUHkXVtNPvgGtbSNq5BcowyYOWdKo=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/src-d/gcfg v1.4.0 h1:xXbNR5AlLSA315x2UO+fTSSAXCDf+Ar38/6oyGbDKQ4=
github.com/src-d/gcfg v1.4.0/go.mod h1:p/UMsR43ujA89BJY9duynAwIpvqEujIH/jFlfL7jWoI=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/xanzy/go-gitlab v0.21.0 h1:Ru55sR4TBoDNsAKwCOpzeaGtbiWj7xTksVmzBJbLu6c=
@@ -74,50 +83,45 @@ github.com/xanzy/ssh-agent v0.2.1 h1:TCbipTQL2JiiCprBWx9frJ2eJlCYT00NmctrHxVAr70
github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4=
golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 h1:HuIa8hRrWRSrqYzx1qI49NNxhdi2PrY7gxVSq1JjLDc=
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073 h1:xMPOj6Pz6UipU1wXLkrtqpHbR0AVFnyPEQq/wRWz9lM=
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181108082009-03003ca0c849/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80 h1:Ao/3l156eZf2AW5wK8a7/smtodRU+gha3+BeqJ69lRk=
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200301022130-244492dfa37a h1:GuSPYbZzB5/dcLNCwLQLsg3obCJtX9IJhpXkvY7kzk0=
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190221075227-b4e8571b14e0/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e h1:D5TXcfTk7xF7hvieo4QErS3qqCB4teTffacDWr7CI+0=
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527 h1:uYVVQ9WP/Ds2ROhcaGPeIdVq0RIXVLwsHlnvJ+cT1So=
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190729092621-ff9f1409240a h1:mEQZbbaBjWyLNy0tmZmgEuQAR8XOQ3hL8GYi3J/NG64=
golang.org/x/tools v0.0.0-20190729092621-ff9f1409240a/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/src-d/go-billy.v4 v4.3.2 h1:0SQA1pRztfTFx2miS8sA97XvooFeNOmvUenF4o0EcVg=
gopkg.in/src-d/go-billy.v4 v4.3.2/go.mod h1:nDjArDMp+XMs1aFAESLRjfGSgfvoYN0hDfzEk0GjC98=
gopkg.in/src-d/go-git-fixtures.v3 v3.5.0 h1:ivZFOIltbce2Mo8IjzUHAFoq/IylO9WHhNOAJK+LsJg=
gopkg.in/src-d/go-git-fixtures.v3 v3.5.0/go.mod h1:dLBcvytrw/TYZsNTWCnkNF2DSIlzWYqTe3rJR56Ac7g=
gopkg.in/src-d/go-git.v4 v4.13.1 h1:SRtFyV8Kxc0UP7aCHcijOMQGPxHSmMOPrzulQWolkYE=
gopkg.in/src-d/go-git.v4 v4.13.1/go.mod h1:nx5NYcxdKxq5fpltdHnPa2Exj4Sx0EclMWZQbYDu2z8=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+40 -23
View File
@@ -6,16 +6,17 @@ import (
"strings"
"sync"
"github.com/zricethezav/gitleaks/audit"
"github.com/zricethezav/gitleaks/manager"
"github.com/zricethezav/gitleaks/options"
"github.com/zricethezav/gitleaks/v6/manager"
"github.com/zricethezav/gitleaks/v6/options"
"github.com/zricethezav/gitleaks/v6/scan"
"github.com/google/go-github/github"
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/object"
"github.com/go-git/go-git/v5/plumbing/transport"
"github.com/google/go-github/v31/github"
log "github.com/sirupsen/logrus"
"golang.org/x/oauth2"
"gopkg.in/src-d/go-git.v4"
"gopkg.in/src-d/go-git.v4/plumbing"
"gopkg.in/src-d/go-git.v4/plumbing/object"
)
// Github wraps a github client and manager. This struct implements what the Host interface defines.
@@ -26,7 +27,7 @@ type Github struct {
}
// NewGithubClient accepts a manager struct and returns a Github host pointer which will be used to
// perform a github audit on an organization, user, or PR.
// perform a github scan on an organization, user, or PR.
func NewGithubClient(m *manager.Manager) (*Github, error) {
var err error
ctx := context.Background()
@@ -49,15 +50,18 @@ func NewGithubClient(m *manager.Manager) (*Github, error) {
}, err
}
// Audit will audit a github user or organization's repos.
func (g *Github) Audit() {
// Scan will scan a github user or organization's repos.
func (g *Github) Scan() {
ctx := context.Background()
listOptions := github.ListOptions{
PerPage: 100,
Page: 1,
}
var githubRepos []*github.Repository
var (
githubRepos []*github.Repository
auth transport.AuthMethod
)
for {
var (
@@ -71,6 +75,9 @@ func (g *Github) Audit() {
} else if g.manager.Opts.Organization != "" {
_githubRepos, resp, err = g.client.Repositories.ListByOrg(ctx, g.manager.Opts.Organization,
&github.RepositoryListByOrgOptions{ListOptions: listOptions})
} else {
_githubRepos, resp, err = g.client.Repositories.List(ctx, "",
&github.RepositoryListOptions{ListOptions: listOptions})
}
for _, r := range _githubRepos {
@@ -81,7 +88,6 @@ func (g *Github) Audit() {
githubRepos = append(githubRepos, r)
}
if resp == nil {
break
}
@@ -99,41 +105,48 @@ func (g *Github) Audit() {
}
for _, repo := range githubRepos {
r := audit.NewRepo(g.manager)
r.Name = *repo.Name
r := scan.NewRepo(g.manager)
if g.manager.CloneOptions != nil {
auth = g.manager.CloneOptions.Auth
}
err := r.Clone(&git.CloneOptions{
URL: *repo.CloneURL,
URL: *repo.CloneURL,
Auth: auth,
})
r.Name = *repo.Name
if err != nil {
log.Warn("unable to clone via https and access token, attempting with ssh now")
auth, err := options.SSHAuth(g.manager.Opts)
if err != nil {
log.Warnf("unable to get ssh auth, skipping clone and audit for repo %s: %+v\n", *repo.CloneURL, err)
log.Warnf("unable to get ssh auth, skipping clone and scan for repo %s: %+v\n", *repo.CloneURL, err)
continue
}
err = r.Clone(&git.CloneOptions{
URL: *repo.SSHURL,
Auth: auth,
})
if err != nil {
log.Warnf("err cloning %s, skipping clone and audit: %+v\n", *repo.SSHURL, err)
log.Warnf("err cloning %s, skipping clone and scan: %+v\n", *repo.SSHURL, err)
continue
}
}
if err = r.Audit(); err != nil {
if err = r.Scan(); err != nil {
log.Warn(err)
}
}
}
// AuditPR audits a single github PR
func (g *Github) AuditPR() {
// ScanPR scan a single github PR
func (g *Github) ScanPR() {
ctx := context.Background()
splits := strings.Split(g.manager.Opts.PullRequest, "/")
owner := splits[len(splits)-4]
repoName := splits[len(splits)-3]
prNum, err := strconv.Atoi(splits[len(splits)-1])
repo := audit.NewRepo(g.manager)
repo := scan.NewRepo(g.manager)
repo.Name = repoName
log.Infof("auditing pr %s\n", g.manager.Opts.PullRequest)
log.Infof("scanning pr %s\n", g.manager.Opts.PullRequest)
if err != nil {
return
@@ -162,7 +175,11 @@ func (g *Github) AuditPR() {
if f.Patch == nil {
continue
}
audit.InspectString(*f.Patch, &commitObj, repo, *f.Filename)
repo.CheckRules(&scan.Bundle{
Content: *f.Patch,
FilePath: *f.Filename,
Commit: &commitObj,
})
}
}
page = resp.NextPage
+15 -11
View File
@@ -4,9 +4,9 @@ import (
"context"
"sync"
"github.com/zricethezav/gitleaks/audit"
"github.com/zricethezav/gitleaks/manager"
"github.com/zricethezav/gitleaks/options"
"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"
@@ -21,7 +21,7 @@ type Gitlab struct {
}
// NewGitlabClient accepts a manager struct and returns a Gitlab host pointer which will be used to
// perform a gitlab audit on an group or user.
// perform a gitlab scan on an group or user.
func NewGitlabClient(m *manager.Manager) (*Gitlab, error) {
var err error
@@ -38,8 +38,8 @@ func NewGitlabClient(m *manager.Manager) (*Gitlab, error) {
return gitlabClient, err
}
// Audit will audit a github user or organization's repos.
func (g *Gitlab) Audit() {
// Scan will scan a github user or organization's repos.
func (g *Gitlab) Scan() {
var (
projects []*gitlab.Project
resp *gitlab.Response
@@ -89,20 +89,24 @@ func (g *Gitlab) Audit() {
// iterate of gitlab projects
for _, p := range projects {
r := audit.NewRepo(g.manager)
r := scan.NewRepo(g.manager)
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
if err = r.Audit(); err != nil {
if err = r.Scan(); err != nil {
log.Error(err)
}
}
}
// AuditPR TODO not implemented
func (g *Gitlab) AuditPR() {
log.Error("AuditPR is not implemented in Gitlab host yet...")
// ScanPR TODO not implemented
func (g *Gitlab) ScanPR() {
log.Error("ScanPR is not implemented in Gitlab host yet...")
}
+11 -6
View File
@@ -1,8 +1,9 @@
package hosts
import (
"github.com/zricethezav/gitleaks/manager"
"strings"
"github.com/zricethezav/gitleaks/v6/manager"
)
const (
@@ -13,11 +14,11 @@ const (
// Host is an interface used for defining external git hosting providers like github and gitlab.
// TODO add bitbucket
type Host interface {
Audit()
AuditPR()
Scan()
ScanPR()
}
// Run kicks off a host audit. This function accepts a manager and determines what host it should audit
// Run kicks off a host scan. This function accepts a manager and determines what host it should scan
func Run(m *manager.Manager) error {
var host Host
var err error
@@ -30,10 +31,14 @@ func Run(m *manager.Manager) error {
return nil
}
if err != nil {
return err
}
if m.Opts.PullRequest != "" {
host.AuditPR()
host.ScanPR()
} else {
host.Audit()
host.Scan()
}
return err
}
+4 -3
View File
@@ -3,11 +3,12 @@ package hosts
import (
"flag"
"fmt"
"github.com/zricethezav/gitleaks/config"
"github.com/zricethezav/gitleaks/manager"
"github.com/zricethezav/gitleaks/options"
"os"
"testing"
"github.com/zricethezav/gitleaks/v6/config"
"github.com/zricethezav/gitleaks/v6/manager"
"github.com/zricethezav/gitleaks/v6/options"
)
var (
+14 -14
View File
@@ -5,11 +5,11 @@ import (
"os"
"time"
"github.com/zricethezav/gitleaks/audit"
"github.com/zricethezav/gitleaks/config"
"github.com/zricethezav/gitleaks/hosts"
"github.com/zricethezav/gitleaks/manager"
"github.com/zricethezav/gitleaks/options"
"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"
@@ -53,25 +53,25 @@ func main() {
if m.Opts.CheckUncommitted() {
log.Warnf("%d leaks detected in staged changes", len(leaks))
} else {
log.Warnf("%d leaks detected. %d commits audited in %s", len(leaks),
metadata.Commits, durafmt.Parse(time.Duration(metadata.AuditTime)*time.Nanosecond))
log.Warnf("%d leaks detected. %d commits scanned in %s", len(leaks),
metadata.Commits, durafmt.Parse(time.Duration(metadata.ScanTime)*time.Nanosecond))
}
os.Exit(options.LeaksPresent)
} else {
if m.Opts.CheckUncommitted() {
log.Infof("No leaks detected in staged changes")
} else {
log.Infof("No leaks detected. %d commits audited in %s",
metadata.Commits, durafmt.Parse(time.Duration(metadata.AuditTime)*time.Nanosecond))
log.Infof("No leaks detected. %d commits scanned in %s",
metadata.Commits, durafmt.Parse(time.Duration(metadata.ScanTime)*time.Nanosecond))
}
os.Exit(options.Success)
}
}
// Run begins the program and contains some basic logic on how to continue with the audit. If any external git host
// options are set (like auditing a gitlab or github user) then a specific host client will be created and
// then Audit() and Report() will be called. Otherwise, gitleaks will create a new repo and an audit will proceed.
// If no options or the uncommitted option is set then a pre-commit audit will
// Run begins the program and contains some basic logic on how to continue with the scan. If any external git host
// options are set (like scanning a gitlab or github user) then a specific host client will be created and
// then Scan() and Report() will be called. Otherwise, gitleaks will create a new repo and an scan will proceed.
// If no options or the uncommitted option is set then a pre-commit scan will
// take place -- this is similar to running `git diff` on all the tracked files.
func Run(m *manager.Manager) error {
if m.Opts.Disk {
@@ -87,7 +87,7 @@ func Run(m *manager.Manager) error {
if m.Opts.Host != "" {
err = hosts.Run(m)
} else {
err = audit.Run(m)
err = scan.Run(m)
}
if err != nil {
return err
+24 -58
View File
@@ -2,24 +2,24 @@ package manager
import (
"crypto/sha1"
"encoding/csv"
"encoding/hex"
"encoding/json"
"fmt"
"os"
"os/signal"
"runtime"
"strings"
"sync"
"text/tabwriter"
"time"
"github.com/zricethezav/gitleaks/config"
"github.com/zricethezav/gitleaks/options"
"github.com/zricethezav/gitleaks/v6/config"
"github.com/zricethezav/gitleaks/v6/options"
"github.com/go-git/go-git/v5"
"github.com/hako/durafmt"
"github.com/mattn/go-colorable"
log "github.com/sirupsen/logrus"
"gopkg.in/src-d/go-git.v4"
)
const maxLineLen = 200
@@ -47,6 +47,7 @@ type Manager struct {
// sensitive information as determined by the rules set in a gitleaks config
type Leak struct {
Line string `json:"line"`
LineNumber int `json:"lineNumber"`
Offender string `json:"offender"`
Commit string `json:"commit"`
Repo string `json:"repo"`
@@ -57,13 +58,14 @@ type Leak struct {
File string `json:"file"`
Date time.Time `json:"date"`
Tags string `json:"tags"`
Operation string `json:"operation"`
lookupHash string
}
// AuditTime is a type used to determine total audit time
type AuditTime int64
// ScanTime is a type used to determine total scan time
type ScanTime int64
// PatchTime is a type used to determine total patch time during an audit
// PatchTime is a type used to determine total patch time during an scan
type PatchTime int64
// CloneTime is a type used to determine total clone time
@@ -77,7 +79,7 @@ type RegexTime struct {
Regex string
}
// Metadata is a struct used to communicate metadata about an audit like timings and total commit counts.
// Metadata is a struct used to communicate metadata about an scan like timings and total commit counts.
type Metadata struct {
mux *sync.Mutex
data map[string]interface{}
@@ -86,7 +88,7 @@ type Metadata struct {
RegexTime map[string]int64
Commits int
AuditTime int64
ScanTime int64
patchTime int64
cloneTime int64
}
@@ -146,7 +148,7 @@ func (manager *Manager) GetLeaks() []Leak {
return manager.leaks
}
// SendLeaks accepts a leak and is used by the audit pkg. This is the public function
// SendLeaks accepts a leak and is used by the scan pkg. This is the public function
// that allows other packages to send leaks to the manager.
func (manager *Manager) SendLeaks(l Leak) {
if len(l.Line) > maxLineLen {
@@ -156,8 +158,12 @@ func (manager *Manager) SendLeaks(l Leak) {
l.Offender = l.Offender[0:maxLineLen-1] + "..."
}
h := sha1.New()
h.Write([]byte(l.Commit + l.Offender + l.File))
h.Write([]byte(l.Commit + l.Offender + l.File + l.Line + string(l.LineNumber)))
l.lookupHash = hex.EncodeToString(h.Sum(nil))
if manager.Opts.Redact {
l.Line = strings.ReplaceAll(l.Line, l.Offender, "REDACTED")
l.Offender = "REDACTED"
}
manager.leakWG.Add(1)
manager.leakChan <- l
}
@@ -207,8 +213,8 @@ func (manager *Manager) receiveMetadata() {
switch ti := t.(type) {
case CloneTime:
manager.metadata.cloneTime += int64(ti)
case AuditTime:
manager.metadata.AuditTime += int64(ti)
case ScanTime:
manager.metadata.ScanTime += int64(ti)
case PatchTime:
manager.metadata.patchTime += int64(ti)
case RegexTime:
@@ -218,7 +224,7 @@ func (manager *Manager) receiveMetadata() {
}
}
// IncrementCommits increments total commits during an audit by i.
// IncrementCommits increments total commits during an scan by i.
func (manager *Manager) IncrementCommits(i int) {
manager.metadata.mux.Lock()
manager.metadata.Commits += i
@@ -231,12 +237,12 @@ func (manager *Manager) RecordTime(t interface{}) {
manager.metadata.timings <- t
}
// DebugOutput logs metadata and other messages that occurred during a gitleaks audit
// DebugOutput logs metadata and other messages that occurred during a gitleaks scan
func (manager *Manager) DebugOutput() {
log.Debugf("-------------------------\n")
log.Debugf("| Times and Commit Counts|\n")
log.Debugf("-------------------------\n")
fmt.Println("totalAuditTime: ", durafmt.Parse(time.Duration(manager.metadata.AuditTime)*time.Nanosecond))
fmt.Println("totalScanTime: ", durafmt.Parse(time.Duration(manager.metadata.ScanTime)*time.Nanosecond))
fmt.Println("totalPatchTime: ", durafmt.Parse(time.Duration(manager.metadata.patchTime)*time.Nanosecond))
fmt.Println("totalCloneTime: ", durafmt.Parse(time.Duration(manager.metadata.cloneTime)*time.Nanosecond))
fmt.Println("totalCommits: ", manager.metadata.Commits)
@@ -245,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))
@@ -254,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
@@ -303,6 +269,6 @@ func (manager *Manager) receiveInterrupt() {
log.Error(err)
}
}
log.Info("gitleaks received interrupt, stopping audit")
log.Info("gitleaks received interrupt, stopping scan")
os.Exit(options.ErrorEncountered)
}
+8 -8
View File
@@ -3,8 +3,8 @@ package manager
import (
"crypto/rand"
"fmt"
"github.com/zricethezav/gitleaks/config"
"github.com/zricethezav/gitleaks/options"
"github.com/zricethezav/gitleaks/v6/config"
"github.com/zricethezav/gitleaks/v6/options"
"io"
"testing"
)
@@ -45,14 +45,14 @@ func TestSendReceiveLeaks(t *testing.T) {
func TestSendReceiveMeta(t *testing.T) {
tests := []struct {
auditTime int64
scanTime int64
patchTime int64
cloneTime int64
regexTime int64
iterations int
}{
{
auditTime: 1000,
scanTime: 1000,
patchTime: 1000,
cloneTime: 1000,
regexTime: 1000,
@@ -65,7 +65,7 @@ func TestSendReceiveMeta(t *testing.T) {
m, _ := NewManager(opts, cfg)
for i := 0; i < test.iterations; i++ {
m.RecordTime(AuditTime(test.auditTime))
m.RecordTime(ScanTime(test.scanTime))
m.RecordTime(PatchTime(test.patchTime))
m.RecordTime(CloneTime(test.cloneTime))
m.RecordTime(RegexTime{
@@ -82,9 +82,9 @@ func TestSendReceiveMeta(t *testing.T) {
t.Errorf("clone time mismatch, got %d, wanted %d",
md.cloneTime, test.cloneTime*int64(test.iterations))
}
if md.AuditTime != test.auditTime*int64(test.iterations) {
t.Errorf("audit time mismatch, got %d, wanted %d",
md.AuditTime, test.auditTime*int64(test.iterations))
if md.ScanTime != test.scanTime*int64(test.iterations) {
t.Errorf("scan time mismatch, got %d, wanted %d",
md.ScanTime, test.scanTime*int64(test.iterations))
}
if md.patchTime != test.patchTime*int64(test.iterations) {
t.Errorf("clone time mismatch, got %d, wanted %d",
+78
View File
@@ -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
}
+153
View File
@@ -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,
},
},
},
},
}
}
+44 -33
View File
@@ -7,13 +7,13 @@ import (
"os/user"
"strings"
"github.com/zricethezav/gitleaks/version"
"github.com/zricethezav/gitleaks/v6/version"
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing/transport/http"
"github.com/go-git/go-git/v5/plumbing/transport/ssh"
"github.com/jessevdk/go-flags"
log "github.com/sirupsen/logrus"
"gopkg.in/src-d/go-git.v4"
"gopkg.in/src-d/go-git.v4/plumbing/transport/http"
"gopkg.in/src-d/go-git.v4/plumbing/transport/ssh"
)
// No leaks or early exit due to invalid options
@@ -23,43 +23,53 @@ const (
Success = 0
LeaksPresent = 1
ErrorEncountered = 2
donateMessage = "👋 maintaining gitleaks takes a lot of work so consider sponsoring me or donating a little something\n❤️ https://github.com/sponsors/zricethezav\n💸 https://www.paypal.me/zricethezav\n₿ btc:3GndEzRZa6rJ8ZpkLureUcc5TDHMYfpDxn"
)
// Options stores values of command line options
type Options struct {
Verbose bool `short:"v" long:"verbose" description:"Show verbose output from audit"`
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 audit"`
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 audit"`
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 audit from"`
CommitTo string `long:"commit-to" description:"Commit to stop audit"`
Timeout string `long:"timeout" description:"Time allowed per audit. Ex: 10us, 30s, 1m, 1h10m1s"`
Depth int `long:"depth" description:"Number of commits to audit"`
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"`
BaseURL string `long:"baseurl" description:"Base URL for API requests. Defaults to the public GitLab or GitHub API, but can be set to a domain endpoint to use with a self hosted server."`
Organization string `long:"org" description:"organization to audit"`
User string `long:"user" description:"user to audit"`
Organization string `long:"org" description:"organization to scan"`
User string `long:"user" description:"user to scan"`
PullRequest string `long:"pr" description:"pull/merge request url"`
ExcludeForks bool `long:"exclude-forks" description:"audit excludes forks"`
ExcludeForks bool `long:"exclude-forks" description:"scan excludes forks"`
}
// ParseOptions is responsible for parsing options passed in by cli. An Options struct
@@ -75,6 +85,7 @@ func ParseOptions() (Options, error) {
if flagsErr, ok := err.(*flags.Error); ok && flagsErr.Type != flags.ErrHelp {
parser.WriteHelp(os.Stdout)
}
fmt.Println(donateMessage)
os.Exit(0)
}
@@ -236,7 +247,7 @@ func (opts Options) CheckUncommitted() bool {
}
// GetAccessToken accepts options and returns a string which is the access token to a git host.
// Setting this option or environment var is necessary if performing an audit with any of the git hosting providers
// Setting this option or environment var is necessary if performing an scan with any of the git hosting providers
// in the host pkg. The access token set by cli options takes precedence over env vars.
func GetAccessToken(opts Options) string {
if opts.AccessToken != "" {
+304
View File
@@ -0,0 +1,304 @@
package scan
import (
"context"
"crypto/md5"
"fmt"
"io/ioutil"
"os"
"path"
"path/filepath"
"runtime"
"time"
"github.com/zricethezav/gitleaks/v6/config"
"github.com/zricethezav/gitleaks/v6/manager"
"github.com/BurntSushi/toml"
"github.com/go-git/go-billy/v5"
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/storage/memory"
log "github.com/sirupsen/logrus"
)
// Repo wraps a *git.Repository object in addition to a manager object and the name of the repo.
// Commits are inspected from the *git.Repository object. If a Commit is found then we send it
// via the manager LeakChan where the manager receives and keeps track of all leaks.
type Repo struct {
*git.Repository
// config is used when the --repo-config option is set.
// This allows users to load up configs specific to their repos.
// Imagine the scenario where you are doing an scan of a large organization
// and you want certain repos to look for specific rules. If those specific repos
// have a gitleaks.toml or .gitleaks.toml config then those configs will be used specifically
// for those repo scans.
config config.Config
// ctx is used to signal timeouts to running goroutines
ctx context.Context
cancel context.CancelFunc
Name string
Manager *manager.Manager
}
// NewRepo initializes and returns a Repo struct.
func NewRepo(m *manager.Manager) *Repo {
return &Repo{
Manager: m,
config: m.Config,
ctx: context.Background(),
}
}
// Run accepts a manager and begins an scan based on the options/configs set in the manager.
func Run(m *manager.Manager) error {
if m.Opts.OwnerPath != "" {
files, err := ioutil.ReadDir(m.Opts.OwnerPath)
if err != nil {
return err
}
for _, f := range files {
if !f.IsDir() {
continue
}
m.Opts.RepoPath = fmt.Sprintf("%s/%s", m.Opts.OwnerPath, f.Name())
if err := runHelper(NewRepo(m)); err != nil {
log.Warnf("%s is not a git repo, skipping", f.Name())
}
}
return nil
}
return runHelper(NewRepo(m))
}
func runHelper(r *Repo) error {
// Ignore allowlisted repos
for _, allowListedRepo := range r.Manager.Config.Allowlist.Repos {
if RegexMatched(r.Manager.Opts.RepoPath, allowListedRepo) {
return nil
}
if RegexMatched(r.Manager.Opts.Repo, allowListedRepo) {
return nil
}
}
if r.Manager.Opts.OpenLocal() {
r.Name = path.Base(r.Manager.Opts.RepoPath)
if err := r.Open(); err != nil {
return err
}
// Check if we are checking uncommitted files. This is the default behavior
// for a "$ gitleaks" command with no options set
if r.Manager.Opts.CheckUncommitted() {
if err := r.scanUncommitted(); err != nil {
return err
}
return nil
}
} else {
if err := r.Clone(nil); err != nil {
return err
}
}
return r.Scan()
}
// Clone will clone a repo and return a Repo struct which contains a go-git repo. The clone method
// is determined by the clone options set in Manager.metadata.cloneOptions
func (repo *Repo) Clone(cloneOption *git.CloneOptions) error {
var (
repository *git.Repository
err error
)
if cloneOption == nil {
cloneOption = repo.Manager.CloneOptions
}
log.Infof("cloning... %s", cloneOption.URL)
start := time.Now()
if repo.Manager.CloneDir != "" {
clonePath := fmt.Sprintf("%s/%x", repo.Manager.CloneDir, md5.Sum([]byte(time.Now().String())))
repository, err = git.PlainClone(clonePath, false, cloneOption)
} else {
repository, err = git.Clone(memory.NewStorage(), nil, cloneOption)
}
if err != nil {
return err
}
repo.Name = filepath.Base(repo.Manager.Opts.Repo)
repo.Repository = repository
repo.Manager.RecordTime(manager.CloneTime(howLong(start)))
return nil
}
// howManyThreads will return a number 1-GOMAXPROCS which is the number
// of goroutines that will spawn during gitleaks execution
func howManyThreads(threads int) int {
maxThreads := runtime.GOMAXPROCS(0)
if threads == 0 {
return 1
} else if threads > maxThreads {
log.Warnf("%d threads set too high, setting to system max, %d", threads, maxThreads)
return maxThreads
}
return threads
}
// getLogOptions determines what log options are used when iterating through commits.
// It is similar to `git log {branch}`. Default behavior is to log ALL branches so
// gitleaks gets the full git history.
func getLogOptions(repo *Repo) (*git.LogOptions, error) {
var logOpts git.LogOptions
const dateformat string = "2006-01-02"
const timeformat string = "2006-01-02T15:04:05-0700"
if repo.Manager.Opts.CommitFrom != "" {
logOpts.From = plumbing.NewHash(repo.Manager.Opts.CommitFrom)
}
if repo.Manager.Opts.CommitSince != "" {
if t, err := time.Parse(timeformat, repo.Manager.Opts.CommitSince); err == nil {
logOpts.Since = &t
} else if t, err := time.Parse(dateformat, repo.Manager.Opts.CommitSince); err == nil {
logOpts.Since = &t
} else {
return nil, err
}
}
if repo.Manager.Opts.CommitUntil != "" {
if t, err := time.Parse(timeformat, repo.Manager.Opts.CommitUntil); err == nil {
logOpts.Until = &t
} else if t, err := time.Parse(dateformat, repo.Manager.Opts.CommitUntil); err == nil {
logOpts.Until = &t
} else {
return nil, err
}
}
if repo.Manager.Opts.Branch != "" {
refs, err := repo.Storer.IterReferences()
if err != nil {
return nil, err
}
err = refs.ForEach(func(ref *plumbing.Reference) error {
if ref.Name().IsTag() {
return nil
}
// check heads first
if ref.Name().String() == "refs/heads/"+repo.Manager.Opts.Branch {
logOpts = git.LogOptions{
From: ref.Hash(),
}
return nil
} else if ref.Name().String() == "refs/remotes/origin/"+repo.Manager.Opts.Branch {
logOpts = git.LogOptions{
From: ref.Hash(),
}
return nil
}
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)
}
return &logOpts, nil
}
if !logOpts.From.IsZero() || logOpts.Since != nil || logOpts.Until != nil {
return &logOpts, nil
}
return &git.LogOptions{All: true}, nil
}
// howLong accepts a time.Time object which is subtracted from time.Now() and
// converted to nanoseconds which is returned
func howLong(t time.Time) int64 {
return time.Now().Sub(t).Nanoseconds()
}
// Open opens a local repo either from repo-path or $PWD
func (repo *Repo) Open() error {
if repo.Manager.Opts.RepoPath != "" {
// open git repo from repo path
repository, err := git.PlainOpen(repo.Manager.Opts.RepoPath)
if err != nil {
return err
}
repo.Repository = repository
} else {
// open git repo from PWD
dir, err := os.Getwd()
if err != nil {
return err
}
repository, err := git.PlainOpen(dir)
if err != nil {
return err
}
repo.Repository = repository
repo.Name = path.Base(dir)
}
return nil
}
func (repo *Repo) loadRepoConfig() (config.Config, error) {
wt, err := repo.Repository.Worktree()
if err != nil {
return config.Config{}, err
}
var f billy.File
f, _ = wt.Filesystem.Open(".gitleaks.toml")
if f == nil {
f, err = wt.Filesystem.Open("gitleaks.toml")
if err != nil {
return config.Config{}, fmt.Errorf("problem loading repo config: %v", err)
}
}
defer f.Close()
var tomlLoader config.TomlLoader
_, err = toml.DecodeReader(f, &tomlLoader)
if err != nil {
return config.Config{}, err
}
return tomlLoader.Parse()
}
// timeoutReached returns true if the timeout deadline has been met. This function should be used
// at the top of loops and before potentially long running goroutines (like checking inefficient regexes)
func (repo *Repo) timeoutReached() bool {
if repo.ctx.Err() == context.DeadlineExceeded {
return true
}
return false
}
// setupTimeout parses the --timeout option and assigns a context with timeout to the manager
// which will exit early if the timeout has been met.
func (repo *Repo) setupTimeout() error {
if repo.Manager.Opts.Timeout == "" {
return nil
}
timeout, err := time.ParseDuration(repo.Manager.Opts.Timeout)
if err != nil {
return err
}
repo.ctx, repo.cancel = context.WithTimeout(context.Background(), timeout)
go func() {
select {
case <-repo.ctx.Done():
if repo.timeoutReached() {
log.Warnf("Timeout deadline (%s) exceeded for %s", timeout.String(), repo.Name)
}
}
}()
return nil
}
+400
View File
@@ -0,0 +1,400 @@
package scan
import (
"bufio"
"fmt"
"io"
"math"
"path/filepath"
"regexp"
"strconv"
"strings"
"time"
"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"
log "github.com/sirupsen/logrus"
)
const (
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.
func (repo *Repo) CheckRules(bundle *Bundle) {
filename := filepath.Base(bundle.FilePath)
path := filepath.Dir(bundle.FilePath)
bundle.lineLookup = make(map[string]bool)
// We want to check if there is a allowlist for this file
if len(repo.config.Allowlist.Files) != 0 {
for _, reFileName := range repo.config.Allowlist.Files {
if RegexMatched(filename, reFileName) {
log.Debugf("allowlisted file found, skipping scan of file: %s", filename)
return
}
}
}
// We want to check if there is a allowlist for this path
if len(repo.config.Allowlist.Paths) != 0 {
for _, reFilePath := range repo.config.Allowlist.Paths {
if RegexMatched(path, reFilePath) {
log.Debugf("file in allowlisted path found, skipping scan of file: %s", filename)
return
}
}
}
for _, rule := range repo.config.Rules {
start := time.Now()
// For each rule we want to check filename allowlists
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 ruleContainFileRegex(rule) && !RegexMatched(filename, rule.File) {
continue
}
// If it has filePathRegex and it doesnt match we continue to next rule
if ruleContainPathRegex(rule) && !RegexMatched(path, rule.Path) {
continue
}
// If it doesnt contain a Content regex then it is a filename regex match
if !ruleContainRegex(rule) {
repo.Manager.SendLeaks(manager.Leak{
LineNumber: defaultLineNumber,
Line: "N/A",
Offender: "Filename/path offender: " + filename,
Commit: bundle.Commit.Hash.String(),
Repo: repo.Name,
Message: bundle.Commit.Message,
Rule: rule.Description,
Author: bundle.Commit.Author.Name,
Email: bundle.Commit.Author.Email,
Date: bundle.Commit.Author.When,
Tags: strings.Join(rule.Tags, ", "),
File: filename,
Operation: diffOpToString(bundle.Operation),
})
} else {
//otherwise we check if it matches Content regex
locs := rule.Regex.FindAllIndex([]byte(bundle.Content), -1)
if len(locs) != 0 {
for _, loc := range locs {
start := loc[0]
end := loc[1]
for start != 0 && bundle.Content[start] != '\n' {
start--
}
if bundle.Content[start] == '\n' {
start++
}
for end < len(bundle.Content)-1 && bundle.Content[end] != '\n' {
end++
}
line := bundle.Content[start:end]
offender := bundle.Content[loc[0]:loc[1]]
groups := rule.Regex.FindStringSubmatch(offender)
if isAllowListed(line, append(rule.AllowList.Regexes, repo.config.Allowlist.Regexes...)) {
continue
}
if len(rule.Entropies) != 0 && !trippedEntropy(groups, rule) {
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{
LineNumber: defaultLineNumber,
Line: line,
Offender: offender,
Commit: bundle.Commit.Hash.String(),
Repo: repo.Name,
Message: bundle.Commit.Message,
Rule: rule.Description,
Author: bundle.Commit.Author.Name,
Email: bundle.Commit.Author.Email,
Date: bundle.Commit.Author.When,
Tags: strings.Join(rule.Tags, ", "),
File: bundle.FilePath,
Operation: diffOpToString(bundle.Operation),
}
// only search for line numbers on non-deletions
if bundle.Operation != fdiff.Delete {
extractAndInjectLineNumber(&leak, bundle, repo)
}
repo.Manager.SendLeaks(leak)
}
}
}
repo.Manager.RecordTime(manager.RegexTime{
Time: howLong(start),
Regex: rule.Regex.String(),
})
}
}
// RegexMatched matched an interface to a regular expression. The interface f can
// be a string type or go-git *object.File type.
func RegexMatched(f interface{}, re *regexp.Regexp) bool {
if re == nil {
return false
}
switch f.(type) {
case nil:
return false
case string:
if re.FindString(f.(string)) != "" {
return true
}
return false
case *object.File:
if re.FindString(f.(*object.File).Name) != "" {
return true
}
return false
}
return false
}
// diffOpToString converts a fdiff.Operation to a string
func diffOpToString(operation fdiff.Operation) string {
switch operation {
case fdiff.Add:
return "addition"
case fdiff.Equal:
return "equal"
default:
return "deletion"
}
}
// extractAndInjectLine accepts a leak, bundle, and repo which it uses to do a reverse search in order to extract
// the line number of a historic or present leak. The function is only called when the git operation is an addition
// or none, it does not get called when the git operation is deletion.
func extractAndInjectLineNumber(leak *manager.Leak, bundle *Bundle, repo *Repo) {
var err error
switch bundle.scanType {
case patchScan:
if bundle.Patch == "" {
return
}
// This is needed as some patches generate strings that are larger than
// scanners max size (MaxScanTokenSize = 64 * 1024)
// https://github.com/zricethezav/gitleaks/issues/413
buf := make([]byte, len(bundle.Patch))
scanner := bufio.NewScanner(strings.NewReader(bundle.Patch))
scanner.Buffer(buf, len(bundle.Patch))
scanner.Split(bufio.ScanLines)
currFile := ""
currLine := 0
currStartDiffLine := 0
for scanner.Scan() {
txt := scanner.Text()
if strings.HasPrefix(txt, diffAddFilePrefix) {
currStartDiffLine = 1
currLine = 0
currFile = strings.Split(txt, diffAddFilePrefixSlash)[1]
// next line contains diff line information so lets scan it here
scanner.Scan()
txt := scanner.Text()
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
}
continue
} else if strings.HasPrefix(txt, diffAddPrefix) && strings.Contains(txt, leak.Line) && leak.File == currFile {
potentialLine := currLine + currStartDiffLine
if _, ok := bundle.lineLookup[fmt.Sprintf("%s%d%s", leak.Line, potentialLine, currFile)]; !ok {
bundle.lineLookup[fmt.Sprintf("%s%d%s", leak.Line, potentialLine, currFile)] = true
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++
}
case commitScan:
if bundle.Commit == nil {
return
}
f, err := bundle.Commit.File(bundle.FilePath)
if err != nil {
log.Error(err)
return
}
r, err := f.Reader()
if err != nil {
log.Error(err)
return
}
leak.LineNumber = extractLineHelper(r, bundle, leak)
case uncommittedScan:
wt, err := repo.Worktree()
if err != nil {
log.Error(err)
return
}
f, err := wt.Filesystem.Open(leak.File)
if err != nil {
log.Error(err)
return
}
leak.LineNumber = extractLineHelper(f, bundle, leak)
}
}
// extractLineHelper consolidates code for checking the leak line against the contents of a reader to find the
// line number of the leak.
func extractLineHelper(r io.Reader, bundle *Bundle, leak *manager.Leak) int {
scanner := bufio.NewScanner(r)
lineNumber := 1
for scanner.Scan() {
if leak.Line == scanner.Text() {
if _, ok := bundle.lineLookup[fmt.Sprintf("%s%d%s", leak.Line, lineNumber, bundle.FilePath)]; !ok {
bundle.lineLookup[fmt.Sprintf("%s%d%s", leak.Line, lineNumber, bundle.FilePath)] = true
return lineNumber
}
}
lineNumber++
}
return -1
}
// trippedEntropy checks if a given capture group or offender falls in between entropy ranges
// supplied by a custom gitleaks configuration. Gitleaks do not check entropy by default.
func trippedEntropy(groups []string, rule config.Rule) bool {
for _, e := range rule.Entropies {
if len(groups) > e.Group {
entropy := shannonEntropy(groups[e.Group])
if entropy >= e.Min && entropy <= e.Max {
return true
}
}
}
return false
}
// shannonEntropy calculates the entropy of data using the formula defined here:
// https://en.wiktionary.org/wiki/Shannon_entropy
// Another way to think about what this is doing is calculating the number of bits
// needed to on average encode the data. So, the higher the entropy, the more random the data, the
// more bits needed to encode that data.
func shannonEntropy(data string) (entropy float64) {
if data == "" {
return 0
}
charCounts := make(map[rune]int)
for _, char := range data {
charCounts[char]++
}
invLength := 1.0 / float64(len(data))
for _, count := range charCounts {
freq := float64(count) * invLength
entropy -= freq * math.Log2(freq)
}
return entropy
}
// Checks if the given rule has a regex
func ruleContainRegex(rule config.Rule) bool {
if rule.Regex == nil {
return false
}
if rule.Regex.String() == "" {
return false
}
return true
}
// Checks if the given rule has a file name regex
func ruleContainFileRegex(rule config.Rule) bool {
if rule.File == nil {
return false
}
if rule.File.String() == "" {
return false
}
return true
}
// Checks if the given rule has a file path regex
func ruleContainPathRegex(rule config.Rule) bool {
if rule.Path == nil {
return false
}
if rule.Path.String() == "" {
return false
}
return true
}
func isCommitAllowListed(commitHash string, allowlistedCommits []string) bool {
for _, hash := range allowlistedCommits {
if commitHash == hash {
return true
}
}
return false
}
func isAllowListed(target string, allowList []*regexp.Regexp) bool {
if len(allowList) != 0 {
for _, re := range allowList {
if re.FindString(target) != "" {
return true
}
}
}
return false
}
+493
View File
@@ -0,0 +1,493 @@
package scan
import (
"bufio"
"bytes"
"fmt"
"io"
"os"
"strings"
"sync"
"time"
"github.com/zricethezav/gitleaks/v6/manager"
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing"
fdiff "github.com/go-git/go-git/v5/plumbing/format/diff"
"github.com/go-git/go-git/v5/plumbing/object"
"github.com/go-git/go-git/v5/plumbing/storer"
"github.com/sergi/go-diff/diffmatchpatch"
log "github.com/sirupsen/logrus"
)
// Bundle contains various git information for scans.
type Bundle struct {
Commit *object.Commit
Patch string
Content string
FilePath string
Operation fdiff.Operation
reader io.Reader
lineLookup map[string]bool
scanType int
}
// commitScanner is a function signature for scanning commits. There is some
// redundant work needed by scanning all files at a commit (--files-at-commit=) and scanning
// the patches generated by a commit (--commit=). The function scanCommit wraps that redundant work
// and accepts a commitScanner for the different logic needed between the two cases described above.
type commitScanner func(c *object.Commit, repo *Repo) error
const (
// We need to differentiate between scans as the logic for line searching is different between
// scanning patches, commits, and uncommitted files.
patchScan int = iota + 1
uncommittedScan
commitScan
)
// Scan is responsible for scanning the entire history (default behavior) of a
// git repo. Options that can change the behavior of this function include: --Commit, --depth, --branch.
// See options/options.go for an explanation on these options.
func (repo *Repo) Scan() error {
if err := repo.setupTimeout(); err != nil {
return err
}
if repo.cancel != nil {
defer repo.cancel()
}
if repo.Repository == nil {
return fmt.Errorf("%s repo is empty", repo.Name)
}
// load up alternative config if possible, if not use manager's config
if repo.Manager.Opts.RepoConfig {
cfg, err := repo.loadRepoConfig()
if err != nil {
return err
}
repo.config = cfg
}
scanTimeStart := time.Now()
// 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)
if err != nil {
return err
}
cIter, err := repo.Log(logOpts)
if err != nil {
return err
}
cc := 0
semaphore := make(chan bool, howManyThreads(repo.Manager.Opts.Threads))
wg := sync.WaitGroup{}
err = cIter.ForEach(func(c *object.Commit) error {
if c == nil || repo.timeoutReached() || repo.depthReached(cc) {
return storer.ErrStop
}
// Check if Commit is allowlisted
if isCommitAllowListed(c.Hash.String(), repo.config.Allowlist.Commits) {
return nil
}
// Check if at root
if len(c.ParentHashes) == 0 {
cc++
err = scanFilesAtCommit(c, repo)
if err != nil {
return err
}
return nil
}
// increase Commit counter
cc++
// inspect first parent only as all other parents will be eventually reached
// (they exist as the tip of other branches, etc)
// See https://github.com/zricethezav/gitleaks/issues/413 for details
parent, err := c.Parent(0)
if err != nil {
return err
}
defer func() {
if err := recover(); err != nil {
// sometimes the Patch generation will fail due to a known bug in
// sergi's go-diff: https://github.com/sergi/go-diff/issues/89.
// Once a fix has been merged I will remove this recover.
return
}
}()
if repo.timeoutReached() {
return nil
}
if parent == nil {
// shouldn't reach this point but just in case
return nil
}
start := time.Now()
patch, err := parent.Patch(c)
if err != nil {
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) {
defer func() {
<-semaphore
wg.Done()
}()
scanPatch(patch, c, repo)
}(c, patch)
if c.Hash.String() == repo.Manager.Opts.CommitTo {
return storer.ErrStop
}
return nil
})
wg.Wait()
repo.Manager.RecordTime(manager.ScanTime(howLong(scanTimeStart)))
repo.Manager.IncrementCommits(cc)
return nil
}
// scanEmpty scans an empty repo without any commits. See https://github.com/zricethezav/gitleaks/issues/352
func (repo *Repo) scanEmpty() error {
scanTimeStart := time.Now()
wt, err := repo.Worktree()
if err != nil {
return err
}
status, err := wt.Status()
if err != nil {
return err
}
for fn := range status {
workTreeBuf := bytes.NewBuffer(nil)
workTreeFile, err := wt.Filesystem.Open(fn)
if err != nil {
continue
}
if _, err := io.Copy(workTreeBuf, workTreeFile); err != nil {
return err
}
repo.CheckRules(&Bundle{
Content: workTreeBuf.String(),
FilePath: workTreeFile.Name(),
Commit: emptyCommit(),
scanType: uncommittedScan,
})
}
repo.Manager.RecordTime(manager.ScanTime(howLong(scanTimeStart)))
return nil
}
// scanUncommitted will do a `git diff` and scan changed files that are being tracked. This is useful functionality
// for a pre-Commit hook so you can make sure your code does not have any leaks before committing.
func (repo *Repo) scanUncommitted() error {
// load up alternative config if possible, if not use manager's config
if repo.Manager.Opts.RepoConfig {
cfg, err := repo.loadRepoConfig()
if err != nil {
return err
}
repo.config = cfg
}
if err := repo.setupTimeout(); err != nil {
return err
}
r, err := repo.Head()
if err == plumbing.ErrReferenceNotFound {
// possibly an empty repo, or maybe its not, either way lets scan all the files in the directory
return repo.scanEmpty()
} else if err != nil {
return err
}
scanTimeStart := time.Now()
c, err := repo.CommitObject(r.Hash())
if err != nil {
return err
}
// Staged change so the Commit details do not yet exist. Insert empty defaults.
c.Hash = plumbing.Hash{}
c.Message = "***STAGED CHANGES***"
c.Author.Name = ""
c.Author.Email = ""
c.Author.When = time.Unix(0, 0).UTC()
prevTree, err := c.Tree()
if err != nil {
return err
}
wt, err := repo.Worktree()
if err != nil {
return err
}
status, err := wt.Status()
for fn, state := range status {
var (
prevFileContents string
currFileContents string
filename string
)
if state.Staging != git.Untracked {
if state.Staging == git.Deleted {
// file in staging has been deleted, aka it is not on the filesystem
// so the contents of the file are ""
currFileContents = ""
} else {
workTreeBuf := bytes.NewBuffer(nil)
workTreeFile, err := wt.Filesystem.Open(fn)
if err != nil {
continue
}
if _, err := io.Copy(workTreeBuf, workTreeFile); err != nil {
return err
}
currFileContents = workTreeBuf.String()
filename = workTreeFile.Name()
}
// get files at HEAD state
prevFile, err := prevTree.File(fn)
if err != nil {
prevFileContents = ""
} else {
prevFileContents, err = prevFile.Contents()
if err != nil {
return err
}
if filename == "" {
filename = prevFile.Name
}
}
dmp := diffmatchpatch.New()
diffs := dmp.DiffCleanupSemantic(dmp.DiffMain(prevFileContents, currFileContents, false))
var diffContents string
for _, d := range diffs {
if d.Type == diffmatchpatch.DiffInsert {
diffContents += fmt.Sprintf("%s\n", d.Text)
}
}
repo.CheckRules(&Bundle{
Content: diffContents,
FilePath: filename,
Commit: c,
scanType: uncommittedScan,
})
}
}
if err != nil {
return err
}
repo.Manager.RecordTime(manager.ScanTime(howLong(scanTimeStart)))
return nil
}
// scan accepts a Patch, Commit, and repo. If the patches contains files that are
// binary, then gitleaks will skip scanning that file OR if a file is matched on
// allowlisted files set in the configuration. If a global rule for files is defined and a filename
// matches said global rule, then a leak is sent to the manager.
// After that, file chunks are created which are then inspected by InspectString()
func scanPatch(patch *object.Patch, c *object.Commit, repo *Repo) {
bundle := Bundle{
Commit: c,
Patch: patch.String(),
scanType: patchScan,
}
for _, f := range patch.FilePatches() {
if repo.timeoutReached() {
return
}
if f.IsBinary() {
continue
}
for _, chunk := range f.Chunks() {
if chunk.Type() == fdiff.Add || (repo.Manager.Opts.Deletion && chunk.Type() == fdiff.Delete) {
bundle.Content = chunk.Content()
bundle.Operation = chunk.Type()
// get filepath
from, to := f.Files()
if from != nil {
bundle.FilePath = from.Path()
} else if to != nil {
bundle.FilePath = to.Path()
} else {
bundle.FilePath = "???"
}
repo.CheckRules(&bundle)
}
}
}
}
// scanCommit accepts a Commit hash, repo, and commit scanning function. A new Commit
// object will be created from the hash which will be passed into either scanCommitPatches
// or scanFilesAtCommit depending on the options set.
func scanCommit(commit string, repo *Repo, f commitScanner) error {
if commit == "latest" {
ref, err := repo.Repository.Head()
if err != nil {
return err
}
commit = ref.Hash().String()
}
repo.Manager.IncrementCommits(1)
h := plumbing.NewHash(commit)
c, err := repo.CommitObject(h)
if err != nil {
return err
}
return f(c, repo)
}
// scanCommitPatches accepts a Commit object and a repo. This function is only called when the --Commit=
// option has been set. That option tells gitleaks to look only at a single Commit and check the contents
// of said Commit. Similar to scan(), if the files contained in the Commit are a binaries or if they are
// allowlisted then those files will be skipped.
func scanCommitPatches(c *object.Commit, repo *Repo) error {
if len(c.ParentHashes) == 0 {
err := scanFilesAtCommit(c, repo)
if err != nil {
return err
}
}
return c.Parents().ForEach(func(parent *object.Commit) error {
defer func() {
if err := recover(); err != nil {
// sometimes the Patch generation will fail due to a known bug in
// sergi's go-diff: https://github.com/sergi/go-diff/issues/89.
// Once a fix has been merged I will remove this recover.
return
}
}()
if repo.timeoutReached() {
return nil
}
if parent == nil {
return nil
}
start := time.Now()
patch, err := parent.Patch(c)
if err != nil {
return fmt.Errorf("could not generate Patch")
}
repo.Manager.RecordTime(manager.PatchTime(howLong(start)))
scanPatch(patch, c, repo)
return nil
})
}
// scanFilesAtCommit accepts a Commit object and a repo. This function is only called when the --files-at-Commit=
// option has been set. That option tells gitleaks to look only at ALL the files at a Commit and check the contents
// of said Commit. Similar to scan(), if the files contained in the Commit are a binaries or if they are
// allowlisted then those files will be skipped.
func scanFilesAtCommit(c *object.Commit, repo *Repo) error {
fIter, err := c.Files()
if err != nil {
return err
}
err = fIter.ForEach(func(f *object.File) error {
bin, err := f.IsBinary()
if bin || repo.timeoutReached() {
return nil
} else if err != nil {
return err
}
content, err := f.Contents()
if err != nil {
return err
}
repo.CheckRules(&Bundle{
Content: content,
FilePath: f.Name,
Commit: c,
scanType: commitScan,
Operation: fdiff.Add,
})
return nil
})
return err
}
// depthReached checks if i meets the depth (--depth=) if set
func (repo *Repo) depthReached(i int) bool {
if repo.Manager.Opts.Depth != 0 && repo.Manager.Opts.Depth == i {
log.Warnf("Exceeded depth limit (%d)", i)
return true
}
return false
}
// emptyCommit generates an empty commit used for scanning uncommitted changes
func emptyCommit() *object.Commit {
return &object.Commit{
Hash: plumbing.Hash{},
Message: "***STAGED CHANGES***",
Author: object.Signature{
Name: "",
Email: "",
When: time.Unix(0, 0).UTC(),
},
}
}
+247 -42
View File
@@ -1,4 +1,4 @@
package audit
package scan
import (
"encoding/json"
@@ -10,16 +10,16 @@ import (
"sort"
"testing"
"github.com/zricethezav/gitleaks/config"
"github.com/zricethezav/gitleaks/manager"
"github.com/zricethezav/gitleaks/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"
)
const testRepoBase = "../test_data/test_repos/"
func TestAudit(t *testing.T) {
func TestScan(t *testing.T) {
moveDotGit("dotGit", ".git")
defer moveDotGit(".git", "dotGit")
tests := []struct {
@@ -58,11 +58,11 @@ func TestAudit(t *testing.T) {
emptyRepo: true,
},
{
description: "test local repo one aws leak whitelisted",
description: "test local repo one aws leak allowlisted",
opts: options.Options{
RepoPath: "../test_data/test_repos/test_repo_1",
ReportFormat: "json",
Config: "../test_data/test_configs/aws_key_whitelist_python_files.toml",
Config: "../test_data/test_configs/aws_key_allowlist_python_files.toml",
},
wantEmpty: true,
},
@@ -76,7 +76,7 @@ func TestAudit(t *testing.T) {
wantPath: "../test_data/test_local_repo_two_leaks.json",
},
{
description: "test local repo two leaks from commit",
description: "test local repo two leaks from Commit",
opts: options.Options{
RepoPath: "../test_data/test_repos/test_repo_2",
Report: "../test_data/test_local_repo_two_leaks_commit_from.json.got",
@@ -86,7 +86,7 @@ func TestAudit(t *testing.T) {
wantPath: "../test_data/test_local_repo_two_leaks_commit_from.json",
},
{
description: "test local repo two leaks to commit",
description: "test local repo two leaks to Commit",
opts: options.Options{
RepoPath: "../test_data/test_repos/test_repo_2",
Report: "../test_data/test_local_repo_two_leaks_commit_to.json.got",
@@ -96,34 +96,65 @@ func TestAudit(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 globally whitelisted",
description: "test local repo two leaks file list commits",
opts: options.Options{
RepoPath: "../test_data/test_repos/test_repo_2",
Config: "../test_data/test_configs/aws_key_global_whitelist_file.toml",
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{
RepoPath: "../test_data/test_repos/test_repo_2",
Config: "../test_data/test_configs/aws_key_global_allowlist_file.toml",
ReportFormat: "json",
},
wantEmpty: true,
},
{
description: "test local repo two leaks whitelisted",
description: "test local repo two leaks allowlisted",
opts: options.Options{
RepoPath: "../test_data/test_repos/test_repo_2",
Config: "../test_data/test_configs/aws_key_whitelist_files.toml",
Config: "../test_data/test_configs/aws_key_allowlist_files.toml",
ReportFormat: "json",
},
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",
opts: options.Options{
@@ -145,7 +176,7 @@ func TestAudit(t *testing.T) {
wantEmpty: true,
},
{
description: "test local repo one aws leak single commit",
description: "test local repo one aws leak single Commit",
opts: options.Options{
RepoPath: "../test_data/test_repos/test_repo_1",
Report: "../test_data/test_local_repo_one_aws_leak_commit.json.got",
@@ -174,14 +205,14 @@ func TestAudit(t *testing.T) {
wantPath: "../test_data/test_local_owner_aws_leak.json",
},
{
description: "test entropy",
description: "test owner path allowlist repo",
opts: options.Options{
RepoPath: "../test_data/test_repos/test_repo_1",
Report: "../test_data/test_entropy.json.got",
Config: "../test_data/test_configs/entropy.toml",
OwnerPath: "../test_data/test_repos/",
Report: "../test_data/test_local_owner_aws_leak_allowlist_repo.json.got",
ReportFormat: "json",
Config: "../test_data/test_configs/aws_key_local_owner_allowlist_repo.toml",
},
wantPath: "../test_data/test_entropy.json",
wantPath: "../test_data/test_local_owner_aws_leak_allowlist_repo.json",
},
{
description: "test entropy and regex",
@@ -207,8 +238,8 @@ func TestAudit(t *testing.T) {
description: "test local repo four entropy alternative config",
opts: options.Options{
RepoPath: "../test_data/test_repos/test_repo_1",
Report: "../test_data/test_regex_whitelist.json.got",
Config: "../test_data/test_configs/aws_key_aws_whitelisted.toml",
Report: "../test_data/test_regex_allowlist.json.got",
Config: "../test_data/test_configs/aws_key_aws_allowlisted.toml",
ReportFormat: "json",
},
wantEmpty: true,
@@ -243,6 +274,158 @@ func TestAudit(t *testing.T) {
},
wantPath: "../test_data/test_local_owner_aws_leak_depth_2.json",
},
{
description: "test local repo five files at Commit",
opts: options.Options{
RepoPath: "../test_data/test_repos/test_repo_5",
Report: "../test_data/test_local_repo_five_files_at_commit.json.got",
FilesAtCommit: "a4c9fb737d5552fd96fce5cc7eedb23353ba9ed0",
ReportFormat: "json",
},
wantPath: "../test_data/test_local_repo_five_files_at_commit.json",
},
{
description: "test local repo five files at latest Commit",
opts: options.Options{
RepoPath: "../test_data/test_repos/test_repo_5",
Report: "../test_data/test_local_repo_five_files_at_latest_commit.json.got",
FilesAtCommit: "latest",
ReportFormat: "json",
},
wantPath: "../test_data/test_local_repo_five_files_at_commit.json",
},
{
description: "test local repo five at Commit",
opts: options.Options{
RepoPath: "../test_data/test_repos/test_repo_5",
Report: "../test_data/test_local_repo_five_commit.json.got",
Commit: "a4c9fb737d5552fd96fce5cc7eedb23353ba9ed0",
ReportFormat: "json",
Config: "../test_data/test_configs/generic.toml",
},
wantPath: "../test_data/test_local_repo_five_commit.json",
},
{
description: "test local repo five at latest Commit",
opts: options.Options{
RepoPath: "../test_data/test_repos/test_repo_5",
Report: "../test_data/test_local_repo_five_at_latest_commit.json.got",
Commit: "latest",
ReportFormat: "json",
Config: "../test_data/test_configs/generic.toml",
},
wantPath: "../test_data/test_local_repo_five_at_latest_commit.json",
},
{
description: "test local repo six filename",
opts: options.Options{
RepoPath: "../test_data/test_repos/test_repo_6",
Report: "../test_data/test_local_repo_six_filename.json.got",
Config: "../test_data/test_configs/regex_filename.toml",
ReportFormat: "json",
},
wantPath: "../test_data/test_local_repo_six_filename.json",
},
{
description: "test local repo six filepath",
opts: options.Options{
RepoPath: "../test_data/test_repos/test_repo_6",
Report: "../test_data/test_local_repo_six_filepath.json.got",
Config: "../test_data/test_configs/regex_filepath.toml",
ReportFormat: "json",
},
wantPath: "../test_data/test_local_repo_six_filepath.json",
},
{
description: "test local repo six filename and filepath",
opts: options.Options{
RepoPath: "../test_data/test_repos/test_repo_6",
Report: "../test_data/test_local_repo_six_filepath_filename.json.got",
Config: "../test_data/test_configs/regex_filepath_filename.toml",
ReportFormat: "json",
},
wantPath: "../test_data/test_local_repo_six_filepath_filename.json",
},
{
description: "test local repo six path globally allowlisted",
opts: options.Options{
RepoPath: "../test_data/test_repos/test_repo_6",
Report: "../test_data/test_local_repo_six_path_globally_allowlisted.json.got",
Config: "../test_data/test_configs/aws_key_global_allowlist_path.toml",
ReportFormat: "json",
},
wantPath: "../test_data/test_local_repo_six_path_globally_allowlisted.json",
},
{
description: "test local repo six leaks since date",
opts: options.Options{
RepoPath: "../test_data/test_repos/test_repo_6",
Report: "../test_data/test_local_repo_six_leaks_since_date.json.got",
ReportFormat: "json",
CommitSince: "2019-10-25",
},
wantPath: "../test_data/test_local_repo_six_leaks_since_date.json",
},
{
description: "test local repo two leaks until date",
opts: options.Options{
RepoPath: "../test_data/test_repos/test_repo_6",
Report: "../test_data/test_local_repo_six_leaks_until_date.json.got",
ReportFormat: "json",
CommitUntil: "2019-10-25",
},
wantPath: "../test_data/test_local_repo_six_leaks_until_date.json",
},
{
description: "test local repo four leaks timerange Commit",
opts: options.Options{
RepoPath: "../test_data/test_repos/test_repo_4",
Report: "../test_data/test_local_repo_four_leaks_commit_timerange.json.got",
ReportFormat: "json",
CommitSince: "2019-10-25T13:01:27-0400",
CommitUntil: "2019-10-25T13:12:32-0400",
},
wantPath: "../test_data/test_local_repo_four_leaks_commit_timerange.json",
},
{
description: "test local repo two allowlist Commit config",
opts: options.Options{
RepoPath: "../test_data/test_repos/test_repo_2",
Report: "../test_data/test_local_repo_two_allowlist_commits.json.got",
Config: "../test_data/test_configs/allowlist_commit.toml",
ReportFormat: "json",
},
wantPath: "../test_data/test_local_repo_two_allowlist_commits.json",
},
{
description: "test local repo two deletion",
opts: options.Options{
RepoPath: "../test_data/test_repos/test_repo_2",
Report: "../test_data/test_local_repo_two_leaks_deletion.json.got",
ReportFormat: "json",
Deletion: true,
},
wantPath: "../test_data/test_local_repo_two_leaks_deletion.json",
},
{
description: "test local repo eight (merges)",
opts: options.Options{
RepoPath: "../test_data/test_repos/test_repo_8",
Report: "../test_data/test_local_repo_eight.json.got",
ReportFormat: "json",
},
wantPath: "../test_data/test_local_repo_eight.json",
},
{
description: "test local repo nine",
opts: options.Options{
RepoPath: "../test_data/test_repos/test_repo_9",
Report: "../test_data/test_local_repo_nine_aws_leak.json.got",
Config: "../test_data/test_configs/large_with_global_allowlist_regex.toml",
ReportFormat: "json",
},
wantPath: "../test_data/test_local_repo_nine_aws_leak.json",
},
}
for _, test := range tests {
@@ -270,6 +453,9 @@ func TestAudit(t *testing.T) {
}
err = m.Report()
if err != nil {
t.Error(err)
}
if test.wantEmpty {
if len(m.GetLeaks()) != 0 {
@@ -287,7 +473,7 @@ func TestAudit(t *testing.T) {
}
}
func TestAuditUncommited(t *testing.T) {
func TestScanUncommited(t *testing.T) {
moveDotGit("dotGit", ".git")
defer moveDotGit(".git", "dotGit")
tests := []struct {
@@ -301,7 +487,7 @@ func TestAuditUncommited(t *testing.T) {
addition string
}{
{
description: "test audit local one leak",
description: "test scan local one leak",
opts: options.Options{
RepoPath: "../test_data/test_repos/test_repo_1",
Report: "../test_data/test_local_repo_one_aws_leak_uncommitted.json.got",
@@ -313,7 +499,7 @@ func TestAuditUncommited(t *testing.T) {
addition: " aws_access_key_id='AKIAIO5FODNN7DXAMPLE'\n\n",
},
{
description: "test audit local no leak",
description: "test scan local no leak",
opts: options.Options{
RepoPath: "../test_data/test_repos/test_repo_1",
Uncommited: true,
@@ -323,22 +509,39 @@ func TestAuditUncommited(t *testing.T) {
fileToChange: "server.test.py",
addition: "nothing bad",
},
{
description: "test scan repo with no commits",
opts: options.Options{
RepoPath: "../test_data/test_repos/test_repo_7",
Report: "../test_data/test_local_repo_seven_aws_leak_uncommitted.json.got",
Uncommited: true,
ReportFormat: "json",
},
wantPath: "../test_data/test_local_repo_seven_aws_leak_uncommitted.json",
},
}
for _, test := range tests {
var (
old []byte
err error
)
fmt.Println(test.description)
old, err := ioutil.ReadFile(fmt.Sprintf("%s/%s", test.opts.RepoPath, test.fileToChange))
if err != nil {
t.Error(err)
}
altered, err := os.OpenFile(fmt.Sprintf("%s/%s", test.opts.RepoPath, test.fileToChange),
os.O_WRONLY|os.O_APPEND, 0644)
if err != nil {
t.Error(err)
}
if test.fileToChange != "" {
old, err = ioutil.ReadFile(fmt.Sprintf("%s/%s", test.opts.RepoPath, test.fileToChange))
if err != nil {
t.Error(err)
}
altered, err := os.OpenFile(fmt.Sprintf("%s/%s", test.opts.RepoPath, test.fileToChange),
os.O_WRONLY|os.O_APPEND, 0644)
if err != nil {
t.Error(err)
}
_, err = altered.WriteString(test.addition)
if err != nil {
t.Error(err)
}
_, err = altered.WriteString(test.addition)
if err != nil {
t.Error(err)
}
cfg, err := config.NewConfig(test.opts)
@@ -358,9 +561,11 @@ func TestAuditUncommited(t *testing.T) {
t.Error(err)
}
err = ioutil.WriteFile(fmt.Sprintf("%s/%s", test.opts.RepoPath, test.fileToChange), old, 0)
if err != nil {
t.Error(err)
if test.fileToChange != "" {
err = ioutil.WriteFile(fmt.Sprintf("%s/%s", test.opts.RepoPath, test.fileToChange), old, 0)
if err != nil {
t.Error(err)
}
}
if test.wantEmpty {
@@ -407,7 +612,7 @@ func fileCheck(wantPath, gotPath string) error {
if !reflect.DeepEqual(gotLeaks, wantLeaks) {
dmp := diffmatchpatch.New()
diffs := dmp.DiffMain(string(want), string(got), false)
return fmt.Errorf("does not equal: %s", dmp.DiffPrettyText(diffs))
return fmt.Errorf("%s does not equal %s: %s", wantPath, gotPath, dmp.DiffPrettyText(diffs))
}
if err := os.Remove(gotPath); err != nil {
return err
@@ -0,0 +1,13 @@
[[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"]
[allowlist]
commits = [
"b10b3e2cb320a8c211fda94c4567299d37de7776",
"17471a5fda722a9e423f1a0d3f0d267ea009d41c",
"996865bb912f3bc45898a370a13aadb315014b55"
]
@@ -0,0 +1,8 @@
[[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 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.whitelist]]
[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.whitelist]]
regex = '''AKIAIO5FODNN7EXAMPLE.*'''
[rules.allowlist]
description = "ignore aws key"
regexes = ['''AKIAIO5FODNN7EXAMPLE.*''']
@@ -8,6 +8,7 @@
regex = '''(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}'''
tags = ["key", "AWS"]
[Global]
file = '''(.*)?py$'''
## this is an example of a rule that won't work
[[rules]]
description = "Python files"
fileRegex = "(?i)*.py"
@@ -3,6 +3,8 @@
regex = '''(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}'''
tags = ["key", "AWS"]
[whitelist]
[allowlist]
description = "ignore md files"
file = '''(.*)?md$'''
files = [
'''(.*)?md$'''
]
@@ -0,0 +1,10 @@
[[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"]
[allowlist]
description = "ignore config folders"
paths = [
'''config(uration)?'''
]
@@ -0,0 +1,9 @@
[[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"]
[allowlist]
description = "allowlist repo"
repos = [
'''test_repo_1'''
]
@@ -1,14 +0,0 @@
[[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.whitelist]]
description = "ignore md files"
file = '''(.*)?md$'''
[[rules.whitelist]]
description = "ignore this regex"
regex = '''ignore$'''
[[rules.whitelist]]
description = "ignore regex and md files"
regex = '''ignore$'''
file = '''(.*)?md$'''
@@ -5,9 +5,6 @@
[[rules]]
description = "AWS Manager ID"
regex = '''(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}'''
regex = '''AWS secret: ("?)((A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16})("?)'''
tags = ["key", "AWS"]
[Global]
message = '''?????????????'''
reportGroup = 2
@@ -3,6 +3,6 @@
regex = '''(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}'''
tags = ["key", "AWS"]
[whitelist]
[allowlist]
description = "ignore md files"
file = '''???????'''
files = ['''???????''']
+4 -3
View File
@@ -1,7 +1,8 @@
[[rules]]
description = "entropy"
entropies = [
"4.3-4.1",
]
regex = '''['|"]([0-9a-zA-Z-._{}$\/\+=]{20,120})['|"]'''
tags = ["entropy"]
[[rules.Entropies]]
Min = "4.3"
Max = "4.1"
+4 -3
View File
@@ -1,7 +1,8 @@
[[rules]]
description = "entropy"
entropies = [
"4.3-x",
]
regex = '''['|"]([0-9a-zA-Z-._{}$\/\+=]{20,120})['|"]'''
tags = ["entropy"]
[[rules.Entropies]]
Min = "4.3"
Max = "x"
+4 -3
View File
@@ -1,7 +1,8 @@
[[rules]]
description = "entropy"
entropies = [
"x-4.3",
]
regex = '''['|"]([0-9a-zA-Z-._{}$\/\+=]{20,120})['|"]'''
tags = ["entropy"]
[[rules.Entropies]]
Min = "x"
Max = "4.1"
+5 -3
View File
@@ -1,7 +1,9 @@
[[rules]]
description = "entropy"
entropies = [
"1-8.9",
]
regex = '''['|"]([0-9a-zA-Z-._{}$\/\+=]{20,120})['|"]'''
tags = ["entropy"]
[[rules.Entropies]]
Min = "1.0"
Max = "8"
Group = "x"
@@ -0,0 +1,9 @@
[[rules]]
description = "entropy"
regex = '''['|"]([0-9a-zA-Z-._{}$\/\+=]{20,120})['|"]'''
tags = ["entropy"]
[[rules.Entropies]]
Min = "1.0"
Max = "8.5"
Group = "-2"
@@ -0,0 +1,9 @@
[[rules]]
description = "entropy"
regex = '''['|"]([0-9a-zA-Z-._{}$\/\+=]{20,120})['|"]'''
tags = ["entropy"]
[[rules.Entropies]]
Min = "1.0"
Max = "8.5"
Group = "2"
@@ -0,0 +1,9 @@
[[rules]]
description = "entropy"
regex = '''['|"]([0-9a-zA-Z-._{}$\/\+=]{20,120})['|"]'''
tags = ["entropy"]
[[rules.Entropies]]
Min = "1.0"
Max = "8.5"
Group = "0"
+7 -4
View File
@@ -1,8 +1,11 @@
[[rules]]
description = "entropy"
entropies = [
"4.5-4.7",
"5.5-6.3",
]
regex = '''['|"]([0-9a-zA-Z-._{}$\/\+=]{40,120})['|"]'''
tags = ["entropy"]
[[rules.Entropies]]
Min = "4.5"
Max = "4.7"
[[rules.Entropies]]
Min = "5.5"
Max = "6.3"
+4
View File
@@ -0,0 +1,4 @@
[[rules]]
description = "Generic Credential"
regex = '''(?i)(api_key|apikey|secret|password|pass|pw|key)(.{0,20})?[0-9a-zA-Z]{16,45}'''
tags = ["key", "API", "generic"]
+15 -12
View File
@@ -125,21 +125,24 @@ 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.whitelist]]
[rules.allowlist]
description = "ignore common jenkins functions"
regex = '''whitelistme'''
file = '''(.*)?Jenkinsfile$'''
[[rules.whitelist]]
description = "ignore common jenkins functions2"
regex = '''whitelistme'''
file = '''(.*)?Jenkinsfile$'''
regexes = [
'''allowlistme'''
]
files = [
'''(.*)?Jenkinsfile$'''
]
# Global rules. This instructs gitleaks to ignore all .pem files or if a message with
[Global]
[[rules]]
description = "Files with keys and credentials"
file = '''(.*?)(pem)'''
message = '''somethingbad'''
[whitelist]
description = "image whitelists"
file = '''(.*?)(jpg|gif|doc|pdf|bin)$'''
[allowlist]
description = "File allowlists"
files = [
'''(.*?)(jpg|gif)$''',
'''(.*?)(doc|pdf|bin)$'''
]
@@ -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'''
]
+10 -5
View File
@@ -1,9 +1,14 @@
[[rules]]
description = "entropy and regex"
regex = '''(?i)key(.{0,20})?['|"][0-9a-zA-Z]{16,45}['|"]'''
entropies = [
"4.5-4.7",
"5.5-6.3",
]
regex = '''['|"]([0-9a-zA-Z-._{}$\/\+=]{20,120})['|"]'''
tags = ["entropy"]
[[rules.Entropies]]
Min = "4.5"
Max = "4.7"
Group = "1"
[[rules.Entropies]]
Min = "5.5"
Max = "6.3"
Group = "1"
@@ -0,0 +1,6 @@
[[rules]]
description = "Generic password"
regex = '''(?i)(password|token).{0,20}?\s*[:|=]\s*?(?-i)([0-9a-zA-Z\/+]{4,40})'''
file = '''.*\.ya?ml'''
tags = ["key", "Yml", "Yaml"]
@@ -0,0 +1,6 @@
[[rules]]
description = "AWS Manager ID"
regex = '''(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}'''
path = '''config(guration)?'''
tags = ["key", "AWS"]
@@ -0,0 +1,7 @@
[[rules]]
description = "Generic password"
regex = '''(?i)(password|token).{0,20}?\s*[:|=]\s*?(?-i)([0-9a-zA-Z\/+]{4,40})'''
file = '''.*\.properties'''
path = '''config(guration)?'''
tags = ["key", "Yml", "Yaml"]
+121 -160
View File
@@ -1,6 +1,7 @@
[
{
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
"lineNumber": 5,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "6557c92612d3b35979bd426d429255b3bf9fab74",
"repo": "test_repo_1",
@@ -10,36 +11,12 @@
"email": "zricer@protonmail.com",
"file": "server.test.py",
"date": "2019-10-24T09:29:27-04:00",
"tags": "key, AWS"
},
{
"line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"",
"offender": "AKIALALEMEL33243OLIB",
"commit": "f61cd8587b7ac1d75a89a0c9af870a2f24c60263",
"repo": "test_repo_2",
"rule": "AWS Manager ID",
"commitMessage": "rm secrets again\n",
"author": "zach rice",
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:12:32-04:00",
"tags": "key, AWS"
},
{
"line": " const AWSSECRET = \"99432bfewaf823ec3294e231\"",
"offender": "SECRET = \"99432bfewaf823ec3294e231\"",
"commit": "f61cd8587b7ac1d75a89a0c9af870a2f24c60263",
"repo": "test_repo_2",
"rule": "Generic Credential",
"commitMessage": "rm secrets again\n",
"author": "zach rice",
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:12:32-04:00",
"tags": "key, API, generic"
"tags": "key, AWS",
"operation": "addition"
},
{
"line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"",
"lineNumber": 5,
"offender": "AKIALALEMEL33243OLIB",
"commit": "b2eb34a61c988afd9b4aaa9dd58c8dd7d5f14dba",
"repo": "test_repo_2",
@@ -49,49 +26,12 @@
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:12:08-04:00",
"tags": "key, AWS"
},
{
"line": " const AWSSECRET = \"99432bfewaf823ec3294e231\"",
"offender": "SECRET = \"99432bfewaf823ec3294e231\"",
"commit": "b2eb34a61c988afd9b4aaa9dd58c8dd7d5f14dba",
"repo": "test_repo_2",
"rule": "Generic Credential",
"commitMessage": "adding another one\n",
"author": "zach rice",
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:12:08-04:00",
"tags": "key, API, generic"
},
{
"line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"",
"offender": "AKIALALEMEL33243OLIA",
"commit": "996865bb912f3bc45898a370a13aadb315014b55",
"repo": "test_repo_2",
"rule": "AWS Manager ID",
"commitMessage": "committing pem\n",
"author": "zach rice",
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:07:41-04:00",
"tags": "key, AWS"
},
{
"line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"",
"offender": "secret: \"AKIALALEMEL33243OLIAE\"",
"commit": "996865bb912f3bc45898a370a13aadb315014b55",
"repo": "test_repo_2",
"rule": "Generic Credential",
"commitMessage": "committing pem\n",
"author": "zach rice",
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:07:41-04:00",
"tags": "key, API, generic"
"tags": "key, AWS",
"operation": "addition"
},
{
"line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"",
"lineNumber": 5,
"offender": "AKIALALEMEL33243OLIA",
"commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c",
"repo": "test_repo_2",
@@ -101,23 +41,12 @@
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:01:27-04:00",
"tags": "key, AWS"
"tags": "key, AWS",
"operation": "addition"
},
{
"line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"",
"offender": "secret: \"AKIALALEMEL33243OLIAE\"",
"commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c",
"repo": "test_repo_2",
"rule": "Generic Credential",
"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, API, generic"
},
{
"line": "\nHere's an AWS secret: AKIALALEMEL33243OLIAE",
"line": "Here's an AWS secret: AKIALALEMEL33243OLIAE",
"lineNumber": 3,
"offender": "AKIALALEMEL33243OLIA",
"commit": "b10b3e2cb320a8c211fda94c4567299d37de7776",
"repo": "test_repo_2",
@@ -127,36 +56,12 @@
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T12:58:39-04:00",
"tags": "key, AWS"
},
{
"line": "const AWSKEY = \"AKIALALEMEL33243OLIAE\"",
"offender": "AKIALALEMEL33243OLIA",
"commit": "cd5eb8bef855f73c46b97b4c088badffdc40ebe9",
"repo": "test_repo_3",
"rule": "AWS Manager ID",
"commitMessage": "rm secrets\n",
"author": "zach rice",
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:54:26-04:00",
"tags": "key, AWS"
},
{
"line": "const AWSSECRET = \"99432bfewaf823ec3294e231\"",
"offender": "SECRET = \"99432bfewaf823ec3294e231\"",
"commit": "cd5eb8bef855f73c46b97b4c088badffdc40ebe9",
"repo": "test_repo_3",
"rule": "Generic Credential",
"commitMessage": "rm secrets\n",
"author": "zach rice",
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:54:26-04:00",
"tags": "key, API, generic"
"tags": "key, AWS",
"operation": "addition"
},
{
"line": "const AWSKEY = \"AKIALALEMEL33243OLIAE\"",
"lineNumber": 4,
"offender": "AKIALALEMEL33243OLIA",
"commit": "84ac4e80d4dbf2c968b64e9d4005f5079795bb81",
"repo": "test_repo_3",
@@ -166,49 +71,12 @@
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:54:08-04:00",
"tags": "key, AWS"
},
{
"line": "const AWSSECRET = \"99432bfewaf823ec3294e231\"",
"offender": "SECRET = \"99432bfewaf823ec3294e231\"",
"commit": "84ac4e80d4dbf2c968b64e9d4005f5079795bb81",
"repo": "test_repo_3",
"rule": "Generic Credential",
"commitMessage": "more secrets\n",
"author": "zach rice",
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:54:08-04:00",
"tags": "key, API, generic"
},
{
"line": "AWS secret: \"AKIALALEMEL33243OLIAE\"",
"offender": "AKIALALEMEL33243OLIA",
"commit": "64cfcee9aad1c84581631636bfc54f2050718d1a",
"repo": "test_repo_3",
"rule": "AWS Manager ID",
"commitMessage": "rm secrets\n",
"author": "zach rice",
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:36:22-04:00",
"tags": "key, AWS"
},
{
"line": "AWS secret: \"AKIALALEMEL33243OLIAE\"",
"offender": "secret: \"AKIALALEMEL33243OLIAE\"",
"commit": "64cfcee9aad1c84581631636bfc54f2050718d1a",
"repo": "test_repo_3",
"rule": "Generic Credential",
"commitMessage": "rm secrets\n",
"author": "zach rice",
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:36:22-04:00",
"tags": "key, API, generic"
"tags": "key, AWS",
"operation": "addition"
},
{
"line": "AWS secret: \"AKIALALEMEL33243OLIAE\"",
"lineNumber": 6,
"offender": "AKIALALEMEL33243OLIA",
"commit": "deea550dd6c7acaf0e59432600593533984a2125",
"repo": "test_repo_3",
@@ -218,19 +86,112 @@
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:35:03-04:00",
"tags": "key, AWS"
"tags": "key, AWS",
"operation": "addition"
},
{
"line": "AWS secret: \"AKIALALEMEL33243OLIAE\"",
"offender": "secret: \"AKIALALEMEL33243OLIAE\"",
"commit": "deea550dd6c7acaf0e59432600593533984a2125",
"repo": "test_repo_3",
"rule": "Generic Credential",
"commitMessage": "dev branch\n",
"author": "zach rice",
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPL2'",
"lineNumber": 4,
"offender": "AKIAIO5FODNN7EXAMPL2",
"commit": "ca71fcdeda15f25f0cc661d90e8785c255925c27",
"repo": "test_repo_5",
"rule": "AWS Manager ID",
"commitMessage": "introduce more secrets\n",
"author": "Zach Rice",
"email": "zrice@gitlab.com",
"file": "secrets.py",
"date": "2020-02-01T10:08:04-05:00",
"tags": "key, AWS",
"operation": "addition"
},
{
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPLE'",
"lineNumber": 1,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "1f2a4abc47dabf991e6af6f9770867ce0ac1f360",
"repo": "test_repo_5",
"rule": "AWS Manager ID",
"commitMessage": "introduce secrets\n",
"author": "Zach Rice",
"email": "zrice@gitlab.com",
"file": "secrets.py",
"date": "2020-02-01T10:07:34-05:00",
"tags": "key, AWS",
"operation": "addition"
},
{
"line": "aws_access_key_id=AKIAIO5FODNN7EXAMPLE",
"lineNumber": 3,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "98b6c7cb3fb29a5993c4c95c56a2dc53050b9247",
"repo": "test_repo_6",
"rule": "AWS Manager ID",
"commitMessage": "Adding some secrets in config folder\n\n",
"author": "Noel Algora",
"email": "noealgigu@gmail.com",
"file": "config/application.properties",
"date": "2020-02-24T14:13:15-05:00",
"tags": "key, AWS",
"operation": "addition"
},
{
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
"lineNumber": 6,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "748f11eaf2c38c3cf0ac6a22e44208777e79fa6f",
"repo": "test_repo_8",
"rule": "AWS Manager ID",
"commitMessage": "Merge pull request #1 from zricethezav/additional-secret-branch\n\nUpdate dummy.txt",
"author": "Zachary Rice",
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:35:03-04:00",
"tags": "key, API, generic"
"file": "dummy.txt",
"date": "2020-07-25T14:44:48-04:00",
"tags": "key, AWS",
"operation": "addition"
},
{
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
"lineNumber": 2,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "ce7e8177bbf8a172c06b6a1e370a374d5c19f660",
"repo": "test_repo_8",
"rule": "AWS Manager ID",
"commitMessage": "dummy.txt w/ text",
"author": "Zachary Rice",
"email": "zricer@protonmail.com",
"file": "dummy.txt",
"date": "2020-07-25T14:39:11-04:00",
"tags": "key, AWS",
"operation": "addition"
},
{
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
"lineNumber": 6,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "9267bc86ec1497471cbc6f3308f3527f7ef34b9d",
"repo": "test_repo_8",
"rule": "AWS Manager ID",
"commitMessage": "Update dummy.txt",
"author": "Zachary Rice",
"email": "zricer@protonmail.com",
"file": "dummy.txt",
"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"
}
]
@@ -0,0 +1,197 @@
[
{
"line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"",
"lineNumber": 5,
"offender": "AKIALALEMEL33243OLIB",
"commit": "b2eb34a61c988afd9b4aaa9dd58c8dd7d5f14dba",
"repo": "test_repo_2",
"rule": "AWS Manager ID",
"commitMessage": "adding another one\n",
"author": "zach rice",
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:12:08-04:00",
"tags": "key, AWS",
"operation": "addition"
},
{
"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"
},
{
"line": "const AWSKEY = \"AKIALALEMEL33243OLIAE\"",
"lineNumber": 4,
"offender": "AKIALALEMEL33243OLIA",
"commit": "84ac4e80d4dbf2c968b64e9d4005f5079795bb81",
"repo": "test_repo_3",
"rule": "AWS Manager ID",
"commitMessage": "more secrets\n",
"author": "zach rice",
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:54:08-04:00",
"tags": "key, AWS",
"operation": "addition"
},
{
"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": "aws_access_key_id='AKIAIO5FODNN7EXAMPL2'",
"lineNumber": 4,
"offender": "AKIAIO5FODNN7EXAMPL2",
"commit": "ca71fcdeda15f25f0cc661d90e8785c255925c27",
"repo": "test_repo_5",
"rule": "AWS Manager ID",
"commitMessage": "introduce more secrets\n",
"author": "Zach Rice",
"email": "zrice@gitlab.com",
"file": "secrets.py",
"date": "2020-02-01T10:08:04-05:00",
"tags": "key, AWS",
"operation": "addition"
},
{
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPLE'",
"lineNumber": 1,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "1f2a4abc47dabf991e6af6f9770867ce0ac1f360",
"repo": "test_repo_5",
"rule": "AWS Manager ID",
"commitMessage": "introduce secrets\n",
"author": "Zach Rice",
"email": "zrice@gitlab.com",
"file": "secrets.py",
"date": "2020-02-01T10:07:34-05:00",
"tags": "key, AWS",
"operation": "addition"
},
{
"line": "aws_access_key_id=AKIAIO5FODNN7EXAMPLE",
"lineNumber": 3,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "98b6c7cb3fb29a5993c4c95c56a2dc53050b9247",
"repo": "test_repo_6",
"rule": "AWS Manager ID",
"commitMessage": "Adding some secrets in config folder\n\n",
"author": "Noel Algora",
"email": "noealgigu@gmail.com",
"file": "config/application.properties",
"date": "2020-02-24T14:13:15-05:00",
"tags": "key, AWS",
"operation": "addition"
},
{
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
"lineNumber": 5,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "6557c92612d3b35979bd426d429255b3bf9fab74",
"repo": "test_repo_6",
"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"
},
{
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
"lineNumber": 6,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "748f11eaf2c38c3cf0ac6a22e44208777e79fa6f",
"repo": "test_repo_8",
"rule": "AWS Manager ID",
"commitMessage": "Merge pull request #1 from zricethezav/additional-secret-branch\n\nUpdate dummy.txt",
"author": "Zachary Rice",
"email": "zricer@protonmail.com",
"file": "dummy.txt",
"date": "2020-07-25T14:44:48-04:00",
"tags": "key, AWS",
"operation": "addition"
},
{
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
"lineNumber": 2,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "ce7e8177bbf8a172c06b6a1e370a374d5c19f660",
"repo": "test_repo_8",
"rule": "AWS Manager ID",
"commitMessage": "dummy.txt w/ text",
"author": "Zachary Rice",
"email": "zricer@protonmail.com",
"file": "dummy.txt",
"date": "2020-07-25T14:39:11-04:00",
"tags": "key, AWS",
"operation": "addition"
},
{
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
"lineNumber": 6,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "9267bc86ec1497471cbc6f3308f3527f7ef34b9d",
"repo": "test_repo_8",
"rule": "AWS Manager ID",
"commitMessage": "Update dummy.txt",
"author": "Zachary Rice",
"email": "zricer@protonmail.com",
"file": "dummy.txt",
"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"
}
]
@@ -1,6 +1,7 @@
[
{
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
"lineNumber": 5,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "6557c92612d3b35979bd426d429255b3bf9fab74",
"repo": "test_repo_1",
@@ -10,36 +11,12 @@
"email": "zricer@protonmail.com",
"file": "server.test.py",
"date": "2019-10-24T09:29:27-04:00",
"tags": "key, AWS"
},
{
"line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"",
"offender": "AKIALALEMEL33243OLIB",
"commit": "f61cd8587b7ac1d75a89a0c9af870a2f24c60263",
"repo": "test_repo_2",
"rule": "AWS Manager ID",
"commitMessage": "rm secrets again\n",
"author": "zach rice",
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:12:32-04:00",
"tags": "key, AWS"
},
{
"line": " const AWSSECRET = \"99432bfewaf823ec3294e231\"",
"offender": "SECRET = \"99432bfewaf823ec3294e231\"",
"commit": "f61cd8587b7ac1d75a89a0c9af870a2f24c60263",
"repo": "test_repo_2",
"rule": "Generic Credential",
"commitMessage": "rm secrets again\n",
"author": "zach rice",
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:12:32-04:00",
"tags": "key, API, generic"
"tags": "key, AWS",
"operation": "addition"
},
{
"line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"",
"lineNumber": 5,
"offender": "AKIALALEMEL33243OLIB",
"commit": "b2eb34a61c988afd9b4aaa9dd58c8dd7d5f14dba",
"repo": "test_repo_2",
@@ -49,49 +26,12 @@
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:12:08-04:00",
"tags": "key, AWS"
},
{
"line": " const AWSSECRET = \"99432bfewaf823ec3294e231\"",
"offender": "SECRET = \"99432bfewaf823ec3294e231\"",
"commit": "b2eb34a61c988afd9b4aaa9dd58c8dd7d5f14dba",
"repo": "test_repo_2",
"rule": "Generic Credential",
"commitMessage": "adding another one\n",
"author": "zach rice",
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:12:08-04:00",
"tags": "key, API, generic"
},
{
"line": "const AWSKEY = \"AKIALALEMEL33243OLIAE\"",
"offender": "AKIALALEMEL33243OLIA",
"commit": "cd5eb8bef855f73c46b97b4c088badffdc40ebe9",
"repo": "test_repo_3",
"rule": "AWS Manager ID",
"commitMessage": "rm secrets\n",
"author": "zach rice",
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:54:26-04:00",
"tags": "key, AWS"
},
{
"line": "const AWSSECRET = \"99432bfewaf823ec3294e231\"",
"offender": "SECRET = \"99432bfewaf823ec3294e231\"",
"commit": "cd5eb8bef855f73c46b97b4c088badffdc40ebe9",
"repo": "test_repo_3",
"rule": "Generic Credential",
"commitMessage": "rm secrets\n",
"author": "zach rice",
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:54:26-04:00",
"tags": "key, API, generic"
"tags": "key, AWS",
"operation": "addition"
},
{
"line": "const AWSKEY = \"AKIALALEMEL33243OLIAE\"",
"lineNumber": 4,
"offender": "AKIALALEMEL33243OLIA",
"commit": "84ac4e80d4dbf2c968b64e9d4005f5079795bb81",
"repo": "test_repo_3",
@@ -101,19 +41,67 @@
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:54:08-04:00",
"tags": "key, AWS"
"tags": "key, AWS",
"operation": "addition"
},
{
"line": "const AWSSECRET = \"99432bfewaf823ec3294e231\"",
"offender": "SECRET = \"99432bfewaf823ec3294e231\"",
"commit": "84ac4e80d4dbf2c968b64e9d4005f5079795bb81",
"repo": "test_repo_3",
"rule": "Generic Credential",
"commitMessage": "more secrets\n",
"author": "zach rice",
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPL2'",
"lineNumber": 4,
"offender": "AKIAIO5FODNN7EXAMPL2",
"commit": "ca71fcdeda15f25f0cc661d90e8785c255925c27",
"repo": "test_repo_5",
"rule": "AWS Manager ID",
"commitMessage": "introduce more secrets\n",
"author": "Zach Rice",
"email": "zrice@gitlab.com",
"file": "secrets.py",
"date": "2020-02-01T10:08:04-05:00",
"tags": "key, AWS",
"operation": "addition"
},
{
"line": "aws_access_key_id=AKIAIO5FODNN7EXAMPLE",
"lineNumber": 3,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "98b6c7cb3fb29a5993c4c95c56a2dc53050b9247",
"repo": "test_repo_6",
"rule": "AWS Manager ID",
"commitMessage": "Adding some secrets in config folder\n\n",
"author": "Noel Algora",
"email": "noealgigu@gmail.com",
"file": "config/application.properties",
"date": "2020-02-24T14:13:15-05:00",
"tags": "key, AWS",
"operation": "addition"
},
{
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
"lineNumber": 6,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "748f11eaf2c38c3cf0ac6a22e44208777e79fa6f",
"repo": "test_repo_8",
"rule": "AWS Manager ID",
"commitMessage": "Merge pull request #1 from zricethezav/additional-secret-branch\n\nUpdate dummy.txt",
"author": "Zachary Rice",
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:54:08-04:00",
"tags": "key, API, generic"
"file": "dummy.txt",
"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"
}
]
+47
View File
@@ -0,0 +1,47 @@
[
{
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
"lineNumber": 6,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "748f11eaf2c38c3cf0ac6a22e44208777e79fa6f",
"repo": "test_repo_8",
"rule": "AWS Manager ID",
"commitMessage": "Merge pull request #1 from zricethezav/additional-secret-branch\n\nUpdate dummy.txt",
"author": "Zachary Rice",
"email": "zricer@protonmail.com",
"file": "dummy.txt",
"date": "2020-07-25T14:44:48-04:00",
"tags": "key, AWS",
"operation": "addition"
},
{
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
"lineNumber": 2,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "ce7e8177bbf8a172c06b6a1e370a374d5c19f660",
"repo": "test_repo_8",
"rule": "AWS Manager ID",
"commitMessage": "dummy.txt w/ text",
"author": "Zachary Rice",
"email": "zricer@protonmail.com",
"file": "dummy.txt",
"date": "2020-07-25T14:39:11-04:00",
"tags": "key, AWS",
"operation": "addition"
},
{
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
"lineNumber": 6,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "9267bc86ec1497471cbc6f3308f3527f7ef34b9d",
"repo": "test_repo_8",
"rule": "AWS Manager ID",
"commitMessage": "Update dummy.txt",
"author": "Zachary Rice",
"email": "zricer@protonmail.com",
"file": "dummy.txt",
"date": "2020-07-25T14:41:11-04:00",
"tags": "key, AWS",
"operation": "addition"
}
]
@@ -0,0 +1,17 @@
[
{
"line": "more_secrets = '99432bfewaf823ec3294e231'",
"lineNumber": 7,
"offender": "secrets = '99432bfewaf823ec3294e231",
"commit": "a4c9fb737d5552fd96fce5cc7eedb23353ba9ed0",
"repo": "test_repo_5",
"rule": "Generic Credential",
"commitMessage": "even more secrets\n",
"author": "Zach Rice",
"email": "zrice@gitlab.com",
"file": "secrets.py",
"date": "2020-02-01T10:30:22-05:00",
"tags": "key, API, generic",
"operation": "addition"
}
]
@@ -0,0 +1,17 @@
[
{
"line": "more_secrets = '99432bfewaf823ec3294e231'",
"lineNumber": 7,
"offender": "secrets = '99432bfewaf823ec3294e231",
"commit": "a4c9fb737d5552fd96fce5cc7eedb23353ba9ed0",
"repo": "test_repo_5",
"rule": "Generic Credential",
"commitMessage": "even more secrets\n",
"author": "Zach Rice",
"email": "zrice@gitlab.com",
"file": "secrets.py",
"date": "2020-02-01T10:30:22-05:00",
"tags": "key, API, generic",
"operation": "addition"
}
]
@@ -0,0 +1,32 @@
[
{
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPLE'",
"lineNumber": 1,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "a4c9fb737d5552fd96fce5cc7eedb23353ba9ed0",
"repo": "test_repo_5",
"rule": "AWS Manager ID",
"commitMessage": "even more secrets\n",
"author": "Zach Rice",
"email": "zrice@gitlab.com",
"file": "secrets.py",
"date": "2020-02-01T10:30:22-05:00",
"tags": "key, AWS",
"operation": "addition"
},
{
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPL2'",
"lineNumber": 4,
"offender": "AKIAIO5FODNN7EXAMPL2",
"commit": "a4c9fb737d5552fd96fce5cc7eedb23353ba9ed0",
"repo": "test_repo_5",
"rule": "AWS Manager ID",
"commitMessage": "even more secrets\n",
"author": "Zach Rice",
"email": "zrice@gitlab.com",
"file": "secrets.py",
"date": "2020-02-01T10:30:22-05:00",
"tags": "key, AWS",
"operation": "addition"
}
]
@@ -0,0 +1,32 @@
[
{
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPLE'",
"lineNumber": 1,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "a4c9fb737d5552fd96fce5cc7eedb23353ba9ed0",
"repo": "test_repo_5",
"rule": "AWS Manager ID",
"commitMessage": "even more secrets\n",
"author": "Zach Rice",
"email": "zrice@gitlab.com",
"file": "secrets.py",
"date": "2020-02-01T10:30:22-05:00",
"tags": "key, AWS",
"operation": "addition"
},
{
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPL2'",
"lineNumber": 4,
"offender": "AKIAIO5FODNN7EXAMPL2",
"commit": "a4c9fb737d5552fd96fce5cc7eedb23353ba9ed0",
"repo": "test_repo_5",
"rule": "AWS Manager ID",
"commitMessage": "even more secrets\n",
"author": "Zach Rice",
"email": "zrice@gitlab.com",
"file": "secrets.py",
"date": "2020-02-01T10:30:22-05:00",
"tags": "key, AWS",
"operation": "addition"
}
]
@@ -1,28 +1,32 @@
[
{
"line": " Just moments after the Cessna's inquiry, a Twin Beech piped up on frequency, in a rather superior tone, asking for his ground speed. \"I have you at one hundred and twenty-five knots of ground spe...",
"offender": "Entropy range [{P1:4.5 P2:4.7}]",
"commit": "d8ac0b73aeeb45843319cdc5ce506516eb49bf7a",
"line": "const AWSSECRET = \"99432bfewaf823ec3294e231\"",
"lineNumber": 5,
"offender": "\"99432bfewaf823ec3294e231\"",
"commit": "84ac4e80d4dbf2c968b64e9d4005f5079795bb81",
"repo": "test_repo_4",
"rule": "entropy",
"commitMessage": "removing secret.pem\n",
"commitMessage": "more secrets\n",
"author": "zach rice",
"email": "zricer@protonmail.com",
"file": "secret.pem",
"date": "2019-10-25T13:08:39-04:00",
"tags": "entropy"
"file": "secrets.md",
"date": "2019-10-25T13:54:08-04:00",
"tags": "entropy",
"operation": "addition"
},
{
"line": " Just moments after the Cessna's inquiry, a Twin Beech piped up on frequency, in a rather superior tone, asking for his ground speed. \"I have you at one hundred and twenty-five knots of ground spe...",
"offender": "Entropy range [{P1:4.5 P2:4.7}]",
"commit": "996865bb912f3bc45898a370a13aadb315014b55",
"line": " const AWSSECRET = \"99432bfewaf823ec3294e231\"",
"lineNumber": 6,
"offender": "\"99432bfewaf823ec3294e231\"",
"commit": "b2eb34a61c988afd9b4aaa9dd58c8dd7d5f14dba",
"repo": "test_repo_4",
"rule": "entropy",
"commitMessage": "committing pem\n",
"commitMessage": "adding another one\n",
"author": "zach rice",
"email": "zricer@protonmail.com",
"file": "secret.pem",
"date": "2019-10-25T13:07:41-04:00",
"tags": "entropy"
"file": "secrets.md",
"date": "2019-10-25T13:12:08-04:00",
"tags": "entropy",
"operation": "addition"
}
]
@@ -0,0 +1,32 @@
[
{
"line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"",
"lineNumber": 5,
"offender": "AKIALALEMEL33243OLIB",
"commit": "b2eb34a61c988afd9b4aaa9dd58c8dd7d5f14dba",
"repo": "test_repo_4",
"rule": "AWS Manager ID",
"commitMessage": "adding another one\n",
"author": "zach rice",
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:12:08-04:00",
"tags": "key, AWS",
"operation": "addition"
},
{
"line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"",
"lineNumber": 5,
"offender": "AKIALALEMEL33243OLIA",
"commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c",
"repo": "test_repo_4",
"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"
}
]
@@ -1,15 +1,17 @@
[
{
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
"lineNumber": 5,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "6557c92612d3b35979bd426d429255b3bf9fab74",
"repo": "test_repo_1",
"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"
"tags": "key, AWS",
"operation": "addition"
}
]
+3 -1
View File
@@ -1,6 +1,7 @@
[
{
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
"lineNumber": 5,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "6557c92612d3b35979bd426d429255b3bf9fab74",
"repo": "test_repo_1",
@@ -10,6 +11,7 @@
"email": "zricer@protonmail.com",
"file": "server.test.py",
"date": "2019-10-24T09:29:27-04:00",
"tags": "key, AWS"
"tags": "key, AWS",
"operation": "addition"
}
]
@@ -1,32 +1,7 @@
[
{
"line": "N/A",
"offender": "server.test.py",
"commit": "d274003914c707212cbe84e3e466a00013ccb639",
"repo": "test_repo_1",
"rule": "file regex matched(.*)?py$",
"commitMessage": "",
"author": "zach rice",
"email": "zricer@protonmail.com",
"file": "server.test.py",
"date": "2019-10-24T10:03:38-04:00",
"tags": ""
},
{
"line": "N/A",
"offender": "server.test.py",
"commit": "6557c92612d3b35979bd426d429255b3bf9fab74",
"repo": "test_repo_1",
"rule": "file regex matched(.*)?py$",
"commitMessage": "",
"author": "zach rice",
"email": "zricer@protonmail.com",
"file": "server.test.py",
"date": "2019-10-24T09:29:27-04:00",
"tags": ""
},
{
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
"lineNumber": 5,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "6557c92612d3b35979bd426d429255b3bf9fab74",
"repo": "test_repo_1",
@@ -36,6 +11,7 @@
"email": "zricer@protonmail.com",
"file": "server.test.py",
"date": "2019-10-24T09:29:27-04:00",
"tags": "key, AWS"
"tags": "key, AWS",
"operation": "addition"
}
]
@@ -1,6 +1,7 @@
[
{
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
"lineNumber": 5,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "6557c92612d3b35979bd426d429255b3bf9fab74",
"repo": "test_repo_1",
@@ -10,6 +11,7 @@
"email": "zricer@protonmail.com",
"file": "server.test.py",
"date": "2019-10-24T09:29:27-04:00",
"tags": "key, AWS"
"tags": "key, AWS",
"operation": "addition"
}
]
@@ -1,6 +1,7 @@
[
{
"line": " aws_access_key_id='AKIAIO5FODNN7DXAMPLE'",
"lineNumber": 10,
"offender": "AKIAIO5FODNN7DXAMPLE",
"commit": "0000000000000000000000000000000000000000",
"repo": "test_repo_1",
@@ -10,6 +11,7 @@
"email": "",
"file": "server.test.py",
"date": "1970-01-01T00:00:00Z",
"tags": "key, AWS"
"tags": "key, AWS",
"operation": "equal"
}
]
@@ -0,0 +1,17 @@
[
{
"line": "AKIAIO5FODNN7EXAMPLE",
"lineNumber": 5,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "0000000000000000000000000000000000000000",
"repo": "test_repo_7",
"rule": "AWS Manager ID",
"commitMessage": "***STAGED CHANGES***",
"author": "",
"email": "",
"file": "file",
"date": "1970-01-01T00:00:00Z",
"tags": "key, AWS",
"operation": "equal"
}
]
+44
View File
@@ -0,0 +1,44 @@
[
{
"line": "api_token: exampleSecretPassword",
"lineNumber": 3,
"offender": "token: exampleSecretPassword",
"commit": "e7bf376f855ae9bc6e3bb27b5f9d65c57eba799d",
"repo": "test_repo_6",
"rule": "Generic password",
"commitMessage": "More secrets\n\n",
"author": "Noel Algora",
"email": "noealgigu@gmail.com",
"file": "config/config.yaml",
"date": "2020-02-19T04:08:26-05:00",
"tags": "key, Yml, Yaml"
},
{
"line": "db_password_token: exampleSecretPassword",
"lineNumber": 3,
"offender": "password_token: exampleSecretPassword",
"commit": "e7bf376f855ae9bc6e3bb27b5f9d65c57eba799d",
"repo": "test_repo_6",
"rule": "Generic password",
"commitMessage": "More secrets\n\n",
"author": "Noel Algora",
"email": "noealgigu@gmail.com",
"file": "config/config.yaml",
"date": "2020-02-19T04:08:26-05:00",
"tags": "key, Yml, Yaml"
},
{
"line": "aws_access_key_id=AKIAIO5FODNN7EXAMPLE",
"lineNumber": 1,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "95cf0237f8cdfc0686a29df08260d8635f46c9b0",
"repo": "test_repo_6",
"rule": "AWS Manager ID",
"commitMessage": "AWS Key in properties\n\n",
"author": "Noel Algora",
"email": "noealgigu@gmail.com",
"file": "config/application.properties",
"date": "2020-02-19T04:04:15-05:00",
"tags": "key, AWS"
}
]
@@ -0,0 +1,32 @@
[
{
"line": "api_token: exampleSecretPassword",
"lineNumber": 2,
"offender": "token: exampleSecretPassword",
"commit": "98b6c7cb3fb29a5993c4c95c56a2dc53050b9247",
"repo": "test_repo_6",
"rule": "Generic password",
"commitMessage": "Adding some secrets in config folder\n\n",
"author": "Noel Algora",
"email": "noealgigu@gmail.com",
"file": "application.yaml",
"date": "2020-02-24T14:13:15-05:00",
"tags": "key, Yml, Yaml",
"operation": "addition"
},
{
"line": "db_password: verySecretProductionPassword",
"lineNumber": 3,
"offender": "password: verySecretProductionPassword",
"commit": "98b6c7cb3fb29a5993c4c95c56a2dc53050b9247",
"repo": "test_repo_6",
"rule": "Generic password",
"commitMessage": "Adding some secrets in config folder\n\n",
"author": "Noel Algora",
"email": "noealgigu@gmail.com",
"file": "application.yaml",
"date": "2020-02-24T14:13:15-05:00",
"tags": "key, Yml, Yaml",
"operation": "addition"
}
]
@@ -0,0 +1,17 @@
[
{
"line": "aws_access_key_id=AKIAIO5FODNN7EXAMPLE",
"lineNumber": 3,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "98b6c7cb3fb29a5993c4c95c56a2dc53050b9247",
"repo": "test_repo_6",
"rule": "AWS Manager ID",
"commitMessage": "Adding some secrets in config folder\n\n",
"author": "Noel Algora",
"email": "noealgigu@gmail.com",
"file": "config/application.properties",
"date": "2020-02-24T14:13:15-05:00",
"tags": "key, AWS",
"operation": "addition"
}
]
@@ -0,0 +1,17 @@
[
{
"line": "apiToken=d41d8cd98f00b204e9800998ecf8427e",
"lineNumber": 2,
"offender": "Token=d41d8cd98f00b204e9800998ecf8427e",
"commit": "98b6c7cb3fb29a5993c4c95c56a2dc53050b9247",
"repo": "test_repo_6",
"rule": "Generic password",
"commitMessage": "Adding some secrets in config folder\n\n",
"author": "Noel Algora",
"email": "noealgigu@gmail.com",
"file": "config/application.properties",
"date": "2020-02-24T14:13:15-05:00",
"tags": "key, Yml, Yaml",
"operation": "addition"
}
]
@@ -0,0 +1,17 @@
[
{
"line": "aws_access_key_id=AKIAIO5FODNN7EXAMPLE",
"lineNumber": 3,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "98b6c7cb3fb29a5993c4c95c56a2dc53050b9247",
"repo": "test_repo_6",
"rule": "AWS Manager ID",
"commitMessage": "Adding some secrets in config folder\n\n",
"author": "Noel Algora",
"email": "noealgigu@gmail.com",
"file": "config/application.properties",
"date": "2020-02-24T14:13:15-05: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_6",
"rule": "AWS Manager ID",
"commitMessage": "commit 1 with secrets\n",
"author": "zach rice",
"email": "zricer@protonmail.com",
"file": "server.test.py",
"date": "2019-10-24T09:29:27-04:00",
"tags": "key, AWS",
"operation": "addition"
}
]
@@ -0,0 +1,17 @@
[
{
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
"lineNumber": 5,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "6557c92612d3b35979bd426d429255b3bf9fab74",
"repo": "test_repo_6",
"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 -44
View File
@@ -1,19 +1,7 @@
[
{
"line": "AWS secret: \"AKIALALEMEL33243OLIAE\"",
"offender": "AKIALALEMEL33243OLIA",
"commit": "64cfcee9aad1c84581631636bfc54f2050718d1a",
"repo": "test_repo_3",
"rule": "AWS Manager ID",
"commitMessage": "rm secrets\n",
"author": "zach rice",
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:36:22-04:00",
"tags": "key, AWS"
},
{
"line": "AWS secret: \"AKIALALEMEL33243OLIAE\"",
"lineNumber": 6,
"offender": "AKIALALEMEL33243OLIA",
"commit": "deea550dd6c7acaf0e59432600593533984a2125",
"repo": "test_repo_3",
@@ -23,23 +11,12 @@
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:35:03-04:00",
"tags": "key, AWS"
},
{
"line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"",
"offender": "AKIALALEMEL33243OLIB",
"commit": "f61cd8587b7ac1d75a89a0c9af870a2f24c60263",
"repo": "test_repo_3",
"rule": "AWS Manager ID",
"commitMessage": "rm secrets again\n",
"author": "zach rice",
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:12:32-04:00",
"tags": "key, AWS"
"tags": "key, AWS",
"operation": "addition"
},
{
"line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"",
"lineNumber": 5,
"offender": "AKIALALEMEL33243OLIB",
"commit": "b2eb34a61c988afd9b4aaa9dd58c8dd7d5f14dba",
"repo": "test_repo_3",
@@ -49,23 +26,12 @@
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:12:08-04:00",
"tags": "key, AWS"
},
{
"line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"",
"offender": "AKIALALEMEL33243OLIA",
"commit": "996865bb912f3bc45898a370a13aadb315014b55",
"repo": "test_repo_3",
"rule": "AWS Manager ID",
"commitMessage": "committing pem\n",
"author": "zach rice",
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:07:41-04:00",
"tags": "key, AWS"
"tags": "key, AWS",
"operation": "addition"
},
{
"line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"",
"lineNumber": 5,
"offender": "AKIALALEMEL33243OLIA",
"commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c",
"repo": "test_repo_3",
@@ -75,10 +41,12 @@
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:01:27-04:00",
"tags": "key, AWS"
"tags": "key, AWS",
"operation": "addition"
},
{
"line": "\nHere's an AWS secret: AKIALALEMEL33243OLIAE",
"line": "Here's an AWS secret: AKIALALEMEL33243OLIAE",
"lineNumber": 3,
"offender": "AKIALALEMEL33243OLIA",
"commit": "b10b3e2cb320a8c211fda94c4567299d37de7776",
"repo": "test_repo_3",
@@ -88,6 +56,7 @@
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T12:58:39-04:00",
"tags": "key, AWS"
"tags": "key, AWS",
"operation": "addition"
}
]
@@ -0,0 +1,47 @@
[
{
"line": "AWS secret: \"AKIALALEMEL33243OLIAE\"",
"lineNumber": 6,
"offender": "AKIALALEMEL33243OLIA",
"commit": "deea550dd6c7acaf0e59432600593533984a2125",
"repo": "test_repo_3",
"rule": "AWS Manager ID",
"commitMessage": "dev branch\n",
"author": "zach rice",
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:35:03-04:00",
"tags": "key, AWS",
"operation": "addition"
},
{
"line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"",
"lineNumber": 5,
"offender": "AKIALALEMEL33243OLIA",
"commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c",
"repo": "test_repo_3",
"rule": "AWS Manager ID",
"commitMessage": "wait this is actually adding an aws secret\n",
"author": "zach rice",
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:01:27-04:00",
"tags": "key, AWS",
"operation": "addition"
},
{
"line": "Here's an AWS secret: AKIALALEMEL33243OLIAE",
"lineNumber": 3,
"offender": "AKIALALEMEL33243OLIA",
"commit": "b10b3e2cb320a8c211fda94c4567299d37de7776",
"repo": "test_repo_3",
"rule": "AWS Manager ID",
"commitMessage": "adding aws key\n",
"author": "zach rice",
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T12:58:39-04:00",
"tags": "key, AWS",
"operation": "addition"
}
]
@@ -0,0 +1,17 @@
[
{
"line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"",
"lineNumber": 5,
"offender": "AKIALALEMEL33243OLIB",
"commit": "b2eb34a61c988afd9b4aaa9dd58c8dd7d5f14dba",
"repo": "test_repo_2",
"rule": "AWS Manager ID",
"commitMessage": "adding another one\n",
"author": "zach rice",
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:12:08-04:00",
"tags": "key, AWS",
"operation": "addition"
}
]
+10 -82
View File
@@ -1,32 +1,7 @@
[
{
"line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"",
"offender": "AKIALALEMEL33243OLIB",
"commit": "f61cd8587b7ac1d75a89a0c9af870a2f24c60263",
"repo": "test_repo_2",
"rule": "AWS Manager ID",
"commitMessage": "rm secrets again\n",
"author": "zach rice",
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:12:32-04:00",
"tags": "key, AWS"
},
{
"line": " const AWSSECRET = \"99432bfewaf823ec3294e231\"",
"offender": "SECRET = \"99432bfewaf823ec3294e231\"",
"commit": "f61cd8587b7ac1d75a89a0c9af870a2f24c60263",
"repo": "test_repo_2",
"rule": "Generic Credential",
"commitMessage": "rm secrets again\n",
"author": "zach rice",
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:12:32-04:00",
"tags": "key, API, generic"
},
{
"line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"",
"lineNumber": 5,
"offender": "AKIALALEMEL33243OLIB",
"commit": "b2eb34a61c988afd9b4aaa9dd58c8dd7d5f14dba",
"repo": "test_repo_2",
@@ -36,49 +11,12 @@
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:12:08-04:00",
"tags": "key, AWS"
},
{
"line": " const AWSSECRET = \"99432bfewaf823ec3294e231\"",
"offender": "SECRET = \"99432bfewaf823ec3294e231\"",
"commit": "b2eb34a61c988afd9b4aaa9dd58c8dd7d5f14dba",
"repo": "test_repo_2",
"rule": "Generic Credential",
"commitMessage": "adding another one\n",
"author": "zach rice",
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:12:08-04:00",
"tags": "key, API, generic"
},
{
"line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"",
"offender": "AKIALALEMEL33243OLIA",
"commit": "996865bb912f3bc45898a370a13aadb315014b55",
"repo": "test_repo_2",
"rule": "AWS Manager ID",
"commitMessage": "committing pem\n",
"author": "zach rice",
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:07:41-04:00",
"tags": "key, AWS"
},
{
"line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"",
"offender": "secret: \"AKIALALEMEL33243OLIAE\"",
"commit": "996865bb912f3bc45898a370a13aadb315014b55",
"repo": "test_repo_2",
"rule": "Generic Credential",
"commitMessage": "committing pem\n",
"author": "zach rice",
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:07:41-04:00",
"tags": "key, API, generic"
"tags": "key, AWS",
"operation": "addition"
},
{
"line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"",
"lineNumber": 5,
"offender": "AKIALALEMEL33243OLIA",
"commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c",
"repo": "test_repo_2",
@@ -88,23 +26,12 @@
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:01:27-04:00",
"tags": "key, AWS"
"tags": "key, AWS",
"operation": "addition"
},
{
"line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"",
"offender": "secret: \"AKIALALEMEL33243OLIAE\"",
"commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c",
"repo": "test_repo_2",
"rule": "Generic Credential",
"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, API, generic"
},
{
"line": "\nHere's an AWS secret: AKIALALEMEL33243OLIAE",
"line": "Here's an AWS secret: AKIALALEMEL33243OLIAE",
"lineNumber": 3,
"offender": "AKIALALEMEL33243OLIA",
"commit": "b10b3e2cb320a8c211fda94c4567299d37de7776",
"repo": "test_repo_2",
@@ -114,6 +41,7 @@
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T12:58:39-04:00",
"tags": "key, AWS"
"tags": "key, AWS",
"operation": "addition"
}
]
@@ -1,32 +1,7 @@
[
{
"line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"",
"offender": "AKIALALEMEL33243OLIA",
"commit": "996865bb912f3bc45898a370a13aadb315014b55",
"repo": "test_repo_2",
"rule": "AWS Manager ID",
"commitMessage": "committing pem\n",
"author": "zach rice",
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:07:41-04:00",
"tags": "key, AWS"
},
{
"line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"",
"offender": "secret: \"AKIALALEMEL33243OLIAE\"",
"commit": "996865bb912f3bc45898a370a13aadb315014b55",
"repo": "test_repo_2",
"rule": "Generic Credential",
"commitMessage": "committing pem\n",
"author": "zach rice",
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:07:41-04:00",
"tags": "key, API, generic"
},
{
"line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"",
"lineNumber": 5,
"offender": "AKIALALEMEL33243OLIA",
"commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c",
"repo": "test_repo_2",
@@ -36,23 +11,12 @@
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:01:27-04:00",
"tags": "key, AWS"
"tags": "key, AWS",
"operation": "addition"
},
{
"line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"",
"offender": "secret: \"AKIALALEMEL33243OLIAE\"",
"commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c",
"repo": "test_repo_2",
"rule": "Generic Credential",
"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, API, generic"
},
{
"line": "\nHere's an AWS secret: AKIALALEMEL33243OLIAE",
"line": "Here's an AWS secret: AKIALALEMEL33243OLIAE",
"lineNumber": 3,
"offender": "AKIALALEMEL33243OLIA",
"commit": "b10b3e2cb320a8c211fda94c4567299d37de7776",
"repo": "test_repo_2",
@@ -62,6 +26,7 @@
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T12:58:39-04:00",
"tags": "key, AWS"
"tags": "key, AWS",
"operation": "addition"
}
]
@@ -1,32 +1,7 @@
[
{
"line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"",
"offender": "AKIALALEMEL33243OLIA",
"commit": "996865bb912f3bc45898a370a13aadb315014b55",
"repo": "test_repo_2",
"rule": "AWS Manager ID",
"commitMessage": "committing pem\n",
"author": "zach rice",
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:07:41-04:00",
"tags": "key, AWS"
},
{
"line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"",
"offender": "secret: \"AKIALALEMEL33243OLIAE\"",
"commit": "996865bb912f3bc45898a370a13aadb315014b55",
"repo": "test_repo_2",
"rule": "Generic Credential",
"commitMessage": "committing pem\n",
"author": "zach rice",
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:07:41-04:00",
"tags": "key, API, generic"
},
{
"line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"",
"lineNumber": 5,
"offender": "AKIALALEMEL33243OLIA",
"commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c",
"repo": "test_repo_2",
@@ -36,19 +11,22 @@
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:01:27-04:00",
"tags": "key, AWS"
"tags": "key, AWS",
"operation": "addition"
},
{
"line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"",
"offender": "secret: \"AKIALALEMEL33243OLIAE\"",
"commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c",
"line": "Here's an AWS secret: AKIALALEMEL33243OLIAE",
"lineNumber": 3,
"offender": "AKIALALEMEL33243OLIA",
"commit": "b10b3e2cb320a8c211fda94c4567299d37de7776",
"repo": "test_repo_2",
"rule": "Generic Credential",
"commitMessage": "wait this is actually adding an aws secret\n",
"rule": "AWS Manager ID",
"commitMessage": "adding aws key\n",
"author": "zach rice",
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:01:27-04:00",
"tags": "key, API, generic"
"date": "2019-10-25T12:58:39-04:00",
"tags": "key, AWS",
"operation": "addition"
}
]
@@ -1,32 +1,7 @@
[
{
"line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"",
"offender": "AKIALALEMEL33243OLIB",
"commit": "f61cd8587b7ac1d75a89a0c9af870a2f24c60263",
"repo": "test_repo_2",
"rule": "AWS Manager ID",
"commitMessage": "rm secrets again\n",
"author": "zach rice",
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:12:32-04:00",
"tags": "key, AWS"
},
{
"line": " const AWSSECRET = \"99432bfewaf823ec3294e231\"",
"offender": "SECRET = \"99432bfewaf823ec3294e231\"",
"commit": "f61cd8587b7ac1d75a89a0c9af870a2f24c60263",
"repo": "test_repo_2",
"rule": "Generic Credential",
"commitMessage": "rm secrets again\n",
"author": "zach rice",
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:12:32-04:00",
"tags": "key, API, generic"
},
{
"line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"",
"lineNumber": 5,
"offender": "AKIALALEMEL33243OLIB",
"commit": "b2eb34a61c988afd9b4aaa9dd58c8dd7d5f14dba",
"repo": "test_repo_2",
@@ -36,19 +11,7 @@
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:12:08-04:00",
"tags": "key, AWS"
},
{
"line": " const AWSSECRET = \"99432bfewaf823ec3294e231\"",
"offender": "SECRET = \"99432bfewaf823ec3294e231\"",
"commit": "b2eb34a61c988afd9b4aaa9dd58c8dd7d5f14dba",
"repo": "test_repo_2",
"rule": "Generic Credential",
"commitMessage": "adding another one\n",
"author": "zach rice",
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:12:08-04:00",
"tags": "key, API, generic"
"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,92 @@
[
{
"line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"",
"lineNumber": -1,
"offender": "AKIALALEMEL33243OLIB",
"commit": "f61cd8587b7ac1d75a89a0c9af870a2f24c60263",
"repo": "test_repo_2",
"rule": "AWS Manager ID",
"commitMessage": "rm secrets again\n",
"author": "zach rice",
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:12:32-04:00",
"tags": "key, AWS",
"operation": "deletion"
},
{
"line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"",
"lineNumber": 5,
"offender": "AKIALALEMEL33243OLIB",
"commit": "b2eb34a61c988afd9b4aaa9dd58c8dd7d5f14dba",
"repo": "test_repo_2",
"rule": "AWS Manager ID",
"commitMessage": "adding another one\n",
"author": "zach rice",
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:12:08-04:00",
"tags": "key, AWS",
"operation": "addition"
},
{
"line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"",
"lineNumber": -1,
"offender": "AKIALALEMEL33243OLIA",
"commit": "996865bb912f3bc45898a370a13aadb315014b55",
"repo": "test_repo_2",
"rule": "AWS Manager ID",
"commitMessage": "committing pem\n",
"author": "zach rice",
"email": "zricer@protonmail.com",
"file": "secrets.md",
"date": "2019-10-25T13:07:41-04:00",
"tags": "key, AWS",
"operation": "deletion"
},
{
"line": "Here's an AWS secret: AKIALALEMEL33243OLIAE",
"lineNumber": -1,
"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": "deletion"
},
{
"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,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
+5 -3
View File
@@ -1,7 +1,8 @@
[
{
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
"offender": "key_id='AKIAIO5FODNN7EXAMPLE'",
"line": " aws_secret_access_key='ABCDEF+c2L7yXeGvUyrPgYsDnWRRC1AYEXAMPLE'",
"lineNumber": 6,
"offender": "'ABCDEF+c2L7yXeGvUyrPgYsDnWRRC1AYEXAMPLE'",
"commit": "6557c92612d3b35979bd426d429255b3bf9fab74",
"repo": "test_repo_1",
"rule": "entropy and regex",
@@ -10,6 +11,7 @@
"email": "zricer@protonmail.com",
"file": "server.test.py",
"date": "2019-10-24T09:29:27-04:00",
"tags": "entropy"
"tags": "entropy",
"operation": "addition"
}
]
@@ -1,6 +1,8 @@
[[rules]]
description = "entropy"
entropies = [
"4.5-4.7",
]
regex = '''['|"]([0-9a-zA-Z-._{}$\/\+=]{20,120})['|"]'''
tags = ["entropy"]
[[rules.Entropies]]
Min = "3.3"
Max = "3.5"
Group = "1"
@@ -0,0 +1 @@
even more secrets
@@ -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]
# *~
Loaded 100 of 247 files, more files were not shown because too many files have changed in this diff. Show more