mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-28 20:24:22 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4024faceab | ||
|
|
1afa931248 | ||
|
|
2474c39311 | ||
|
|
f6460a7365 | ||
|
|
b47e00858e | ||
|
|
b200a13c8d | ||
|
|
e6fabdbb31 | ||
|
|
cdd654eab7 | ||
|
|
2f07b96333 | ||
|
|
62e74b2b18 | ||
|
|
e75693b131 | ||
|
|
3cd14d4696 | ||
|
|
d29cc9892c | ||
|
|
d996882f4e | ||
|
|
17b6aa856d | ||
|
|
c21a9cf121 | ||
|
|
d3c4342c15 | ||
|
|
b4c2f8e69c | ||
|
|
a0f72a4e35 | ||
|
|
24844002de | ||
|
|
593edeae21 | ||
|
|
6df770d261 | ||
|
|
4f0c9dcede | ||
|
|
52425a8ca9 | ||
|
|
454acebe5a | ||
|
|
6fcf91e934 | ||
|
|
f89b8f2b29 | ||
|
|
648a7ba577 | ||
|
|
7c5594c39d | ||
|
|
274e8212a6 | ||
|
|
36c6ddaf86 | ||
|
|
15ed72bc09 | ||
|
|
ace8de93a9 | ||
|
|
45a4c0a284 | ||
|
|
c5e1e8abc0 | ||
|
|
ef38b69c39 | ||
|
|
ac6bde9996 | ||
|
|
23568cc0ba | ||
|
|
e61c2cfae7 | ||
|
|
38e0b11995 | ||
|
|
31903d1a80 | ||
|
|
3655284b57 | ||
|
|
db79a96118 | ||
|
|
5152e1fc63 | ||
|
|
c04e137b28 | ||
|
|
9b3342fbff | ||
|
|
d9a060a12d | ||
|
|
77f2fdd09a | ||
|
|
dba1ef6104 | ||
|
|
725da55905 | ||
|
|
cfac551ab8 | ||
|
|
c559fdbf04 | ||
|
|
e2ac47cd06 | ||
|
|
8ef16d9efb | ||
|
|
b6f726654e | ||
|
|
8cbb84c50f | ||
|
|
f3eac0c958 | ||
|
|
3211cfbbb1 |
No files matched your search
@@ -0,0 +1,29 @@
|
|||||||
|
---
|
||||||
|
name: Bug report
|
||||||
|
about: Create a report to help us improve
|
||||||
|
title: ''
|
||||||
|
labels: bug
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Describe the bug**
|
||||||
|
A clear and concise description of what the bug is.
|
||||||
|
|
||||||
|
**To Reproduce**
|
||||||
|
Steps to reproduce the behavior:
|
||||||
|
|
||||||
|
**Expected behavior**
|
||||||
|
A clear and concise description of what you expected to happen.
|
||||||
|
|
||||||
|
**Screenshots**
|
||||||
|
If applicable, add screenshots to help explain your problem.
|
||||||
|
|
||||||
|
**Basic Info (please complete the following information):**
|
||||||
|
- OS:
|
||||||
|
- Gitleaks Version:
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context about the problem here.
|
||||||
|
|
||||||
|
cc @zricethezav
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
---
|
||||||
|
name: Feature request
|
||||||
|
about: Suggest an idea for this project
|
||||||
|
title: ''
|
||||||
|
labels: enhancement
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Is your feature request related to a problem? Please describe.**
|
||||||
|
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||||
|
|
||||||
|
**Describe the solution you'd like**
|
||||||
|
A clear and concise description of what you want to happen.
|
||||||
|
|
||||||
|
**Describe alternatives you've considered**
|
||||||
|
A clear and concise description of any alternative solutions or features you've considered.
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context or screenshots about the feature request here.
|
||||||
|
|
||||||
|
cc @zricethezav
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
### Description:
|
||||||
|
Explain the purpose of the PR.
|
||||||
|
|
||||||
|
### Checklist:
|
||||||
|
|
||||||
|
* [ ] Does your PR pass tests?
|
||||||
|
* [ ] Have you written new tests for your changes?
|
||||||
|
* [ ] Have you lint your code locally prior to submission?
|
||||||
+2
-3
@@ -1,8 +1,7 @@
|
|||||||
sudo: required
|
|
||||||
language: go
|
language: go
|
||||||
go:
|
go:
|
||||||
- 1.13
|
- 1.13.x
|
||||||
services:
|
services:
|
||||||
- docker
|
- docker
|
||||||
script:
|
script:
|
||||||
- env GO111MODULE=on make test
|
- make test
|
||||||
+4
-4
@@ -1,9 +1,10 @@
|
|||||||
FROM golang:1.13.0 AS build
|
FROM golang:1.13.4 AS build
|
||||||
WORKDIR /go/src/github.com/zricethezav/gitleaks
|
WORKDIR /go/src/github.com/zricethezav/gitleaks
|
||||||
|
ARG ldflags
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN GO111MODULE=on CGO_ENABLED=0 go build -o bin/gitleaks *.go
|
RUN GO111MODULE=on CGO_ENABLED=0 go build -o bin/gitleaks -ldflags "-X="${ldflags} *.go
|
||||||
|
|
||||||
FROM alpine:3.7
|
FROM alpine:3.10
|
||||||
RUN apk add --no-cache bash git openssh
|
RUN apk add --no-cache bash git openssh
|
||||||
COPY --from=build /go/src/github.com/zricethezav/gitleaks/bin/* /usr/bin/
|
COPY --from=build /go/src/github.com/zricethezav/gitleaks/bin/* /usr/bin/
|
||||||
ENTRYPOINT ["gitleaks"]
|
ENTRYPOINT ["gitleaks"]
|
||||||
@@ -14,4 +15,3 @@ ENTRYPOINT ["gitleaks"]
|
|||||||
# docker run --rm --name=gitleaks gitleaks --repo=https://github.com/zricethezav/gitleaks
|
# docker run --rm --name=gitleaks gitleaks --repo=https://github.com/zricethezav/gitleaks
|
||||||
|
|
||||||
# This will check for secrets in https://github.com/zricethezav/gitleaks
|
# This will check for secrets in https://github.com/zricethezav/gitleaks
|
||||||
|
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2019 Zachary Rice
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
VERSION := `git fetch --tags && git tag | sort -V | tail -1`
|
VERSION := `git fetch --tags && git tag | sort -V | tail -1`
|
||||||
PKG=github.com/zricethezav/gitleaks
|
PKG=github.com/zricethezav/gitleaks
|
||||||
LDFLAGS=-ldflags "-X=github.com/zricethezav/gitleaks/version.Version=$(VERSION)"
|
LDFLAGS=-ldflags "-X=github.com/zricethezav/gitleaks/version.Version=$(VERSION)"
|
||||||
|
_LDFLAGS="github.com/zricethezav/gitleaks/version.Version=$(VERSION)"
|
||||||
COVER=--cover --coverprofile=cover.out
|
COVER=--cover --coverprofile=cover.out
|
||||||
|
|
||||||
test-cover:
|
test-cover:
|
||||||
@@ -12,6 +13,7 @@ test-cover:
|
|||||||
test:
|
test:
|
||||||
go get golang.org/x/lint/golint
|
go get golang.org/x/lint/golint
|
||||||
go fmt ./...
|
go fmt ./...
|
||||||
|
go vet ./...
|
||||||
golint ./...
|
golint ./...
|
||||||
go test ./... --race $(PKG) -v
|
go test ./... --race $(PKG) -v
|
||||||
|
|
||||||
@@ -21,22 +23,23 @@ test-integration:
|
|||||||
build:
|
build:
|
||||||
go fmt ./...
|
go fmt ./...
|
||||||
golint ./...
|
golint ./...
|
||||||
|
go vet ./...
|
||||||
go mod tidy
|
go mod tidy
|
||||||
go build $(LDFLAGS)
|
go build $(LDFLAGS)
|
||||||
|
|
||||||
release-builds:
|
release-builds:
|
||||||
rm -rf build
|
rm -rf build
|
||||||
mkdir build
|
mkdir build
|
||||||
env GOOS="windows" GOARCH="amd64" go build -o "build/gitleaks-windows-amd64.exe"
|
env GOOS="windows" GOARCH="amd64" go build -o "build/gitleaks-windows-amd64.exe" $(LDFLAGS)
|
||||||
env GOOS="windows" GOARCH="386" go build -o "build/gitleaks-windows-386.exe"
|
env GOOS="windows" GOARCH="386" go build -o "build/gitleaks-windows-386.exe" $(LDFLAGS)
|
||||||
env GOOS="linux" GOARCH="amd64" go build -o "build/gitleaks-linux-amd64"
|
env GOOS="linux" GOARCH="amd64" go build -o "build/gitleaks-linux-amd64" $(LDFLAGS)
|
||||||
env GOOS="linux" GOARCH="arm" go build -o "build/gitleaks-linux-arm"
|
env GOOS="linux" GOARCH="arm" go build -o "build/gitleaks-linux-arm" $(LDFLAGS)
|
||||||
env GOOS="linux" GOARCH="mips" go build -o "build/gitleaks-linux-mips"
|
env GOOS="linux" GOARCH="mips" go build -o "build/gitleaks-linux-mips" $(LDFLAGS)
|
||||||
env GOOS="linux" GOARCH="mips" go build -o "build/gitleaks-linux-mips"
|
env GOOS="linux" GOARCH="mips" go build -o "build/gitleaks-linux-mips" $(LDFLAGS)
|
||||||
env GOOS="darwin" GOARCH="amd64" go build -o "build/gitleaks-darwin-amd64"
|
env GOOS="darwin" GOARCH="amd64" go build -o "build/gitleaks-darwin-amd64" $(LDFLAGS)
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
@echo "$(DOCKER_PASSWORD)" | docker login -u "$(DOCKER_USERNAME)" --password-stdin
|
@echo "$(DOCKER_PASSWORD)" | docker login -u "$(DOCKER_USERNAME)" --password-stdin
|
||||||
docker build -f Dockerfile -t $(REPO):$(TAG) .
|
docker build --build-arg ldflags=$(_LDFLAGS) -f Dockerfile -t zricethezav/gitleaks:latest -t zricethezav/gitleaks:$(VERSION) .
|
||||||
echo "Pushing $(REPO):$(COMMIT) $(REPO):$(TAG)"
|
echo "Pushing zricethezav/gitleaks:$(VERSION) and zricethezav/gitleaks:latest"
|
||||||
docker push $(REPO)
|
docker push zricethezav/gitleaks
|
||||||
@@ -2,10 +2,10 @@ Gitleaks
|
|||||||
--------
|
--------
|
||||||
|
|
||||||
<p align="left">
|
<p align="left">
|
||||||
<a href="https://travis-ci.org/zricethezav/gitleaks"><img alt="Travis" src="https://img.shields.io/travis/zricethezav/gitleaks/master.svg?style=flat-square"></a>
|
<a href="https://travis-ci.com/zricethezav/gitleaks"><img alt="Travis" src="https://travis-ci.com/zricethezav/gitleaks.svg?branch=master"></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 it's core functionality, it provides:
|
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
|
* 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.
|
* 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.
|
||||||
@@ -55,34 +55,42 @@ Usage:
|
|||||||
gitleaks [OPTIONS]
|
gitleaks [OPTIONS]
|
||||||
|
|
||||||
Application Options:
|
Application Options:
|
||||||
-v, --verbose Show verbose output from audit
|
-v, --verbose Show verbose output from audit
|
||||||
-r, --repo= Target repository
|
-r, --repo= Target repository
|
||||||
--config= config path
|
--config= config path
|
||||||
--disk Clones repo(s) to disk
|
--disk Clones repo(s) to disk
|
||||||
--version version number
|
--version version number
|
||||||
--timeout= Timeout (s)
|
--username= Username for git repo
|
||||||
--username= Username for git repo
|
--password= Password for git repo
|
||||||
--password= Password for git repo
|
--access-token= Access token for git repo
|
||||||
--access-token= Access token for git repo
|
--commit= sha of commit to audit
|
||||||
--commit= sha of commit to audit
|
--threads= Maximum number of threads gitleaks spawns
|
||||||
--threads= Maximum number of threads gitleaks spawns
|
--ssh-key= path to ssh key used for auth
|
||||||
--ssh-key= path to ssh key used for auth
|
--uncommitted run gitleaks on uncommitted code
|
||||||
--uncommitted run gitleaks on uncommitted code
|
--repo-path= Path to repo
|
||||||
--repo-path= Path to repo
|
--owner-path= Path to owner directory (repos discovered)
|
||||||
--owner-path= Path to owner directory (repos discovered)
|
--branch= Branch to audit
|
||||||
--branch= Branch to audit
|
--report= path to write json leaks file
|
||||||
--report= path to write json leaks file
|
--report-format= json or csv (default: json)
|
||||||
--redact redact secrets from log messages and leaks
|
--redact redact secrets from log messages and leaks
|
||||||
--debug log debug messages
|
--debug log debug messages
|
||||||
--repo-config Load config from target repo. Config file must be ".gitleaks.toml" or "gitleaks.toml"
|
--repo-config Load config from target repo. Config file must be ".gitleaks.toml" or "gitleaks.toml"
|
||||||
--pretty Pretty print json if leaks are present
|
--pretty Pretty print json if leaks are present
|
||||||
--host= git hosting service like gitlab or github. Supported hosts include: Github, Gitlab
|
--commit-from= Commit to start audit from
|
||||||
--org= organization to audit
|
--commit-to= Commit to stop audit
|
||||||
--user= user to audit
|
--timeout= Time allowed per audit. Ex: 10us, 30s, 1m, 1h10m1s
|
||||||
--pr= pull/merge request url
|
--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:
|
Help Options:
|
||||||
-h, --help Show this help message
|
-h, --help Show this help message
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Docker usage examples
|
### Docker usage examples
|
||||||
@@ -119,5 +127,5 @@ Gitleaks provides consistent exist codes to assist in automation workflows such
|
|||||||
|
|
||||||
### Give Thanks
|
### Give Thanks
|
||||||
|
|
||||||
If using gitleaks has made you job easier consider 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
|
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
|
||||||
|
|
||||||
+5
-4
@@ -2,11 +2,12 @@ package audit
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"github.com/zricethezav/gitleaks/manager"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
|
||||||
"path"
|
"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.
|
// Run accepts a manager and begins an audit based on the options/configs set in the manager.
|
||||||
@@ -39,7 +40,7 @@ func runHelper(r *Repo) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if we are checking uncommitted files. This is the default behavior
|
// Check if we are checking uncommitted files. This is the default behavior
|
||||||
// for a "$gitleaks" command with no options set
|
// for a "$ gitleaks" command with no options set
|
||||||
if r.Manager.Opts.CheckUncommitted() {
|
if r.Manager.Opts.CheckUncommitted() {
|
||||||
if err := r.AuditUncommitted(); err != nil {
|
if err := r.AuditUncommitted(); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
+152
-52
@@ -1,16 +1,20 @@
|
|||||||
package audit
|
package audit
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/sergi/go-diff/diffmatchpatch"
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
"reflect"
|
||||||
|
"runtime"
|
||||||
|
"sort"
|
||||||
|
"testing"
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/config"
|
"github.com/zricethezav/gitleaks/config"
|
||||||
"github.com/zricethezav/gitleaks/manager"
|
"github.com/zricethezav/gitleaks/manager"
|
||||||
"github.com/zricethezav/gitleaks/options"
|
"github.com/zricethezav/gitleaks/options"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"github.com/sergi/go-diff/diffmatchpatch"
|
||||||
"runtime"
|
|
||||||
"strings"
|
|
||||||
"testing"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const testRepoBase = "../test_data/test_repos/"
|
const testRepoBase = "../test_data/test_repos/"
|
||||||
@@ -29,139 +33,216 @@ func TestAudit(t *testing.T) {
|
|||||||
{
|
{
|
||||||
description: "test local repo one aws leak",
|
description: "test local repo one aws leak",
|
||||||
opts: options.Options{
|
opts: options.Options{
|
||||||
RepoPath: "../test_data/test_repos/test_repo_1",
|
RepoPath: "../test_data/test_repos/test_repo_1",
|
||||||
Report: "../test_data/test_local_repo_one_aws_leak.json.got",
|
Report: "../test_data/test_local_repo_one_aws_leak.json.got",
|
||||||
|
ReportFormat: "json",
|
||||||
},
|
},
|
||||||
wantPath: "../test_data/test_local_repo_one_aws_leak.json",
|
wantPath: "../test_data/test_local_repo_one_aws_leak.json",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "test local repo one aws leak threaded",
|
description: "test local repo one aws leak threaded",
|
||||||
opts: options.Options{
|
opts: options.Options{
|
||||||
Threads: runtime.GOMAXPROCS(0),
|
Threads: runtime.GOMAXPROCS(0),
|
||||||
RepoPath: "../test_data/test_repos/test_repo_1",
|
RepoPath: "../test_data/test_repos/test_repo_1",
|
||||||
Report: "../test_data/test_local_repo_one_aws_leak.json.got",
|
Report: "../test_data/test_local_repo_one_aws_leak.json.got",
|
||||||
|
ReportFormat: "json",
|
||||||
},
|
},
|
||||||
wantPath: "../test_data/test_local_repo_one_aws_leak.json",
|
wantPath: "../test_data/test_local_repo_one_aws_leak.json",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "test non existent repo",
|
description: "test non existent repo",
|
||||||
opts: options.Options{
|
opts: options.Options{
|
||||||
RepoPath: "../test_data/test_repos/no_repo_here",
|
RepoPath: "../test_data/test_repos/no_repo_here",
|
||||||
|
ReportFormat: "json",
|
||||||
},
|
},
|
||||||
emptyRepo: true,
|
emptyRepo: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "test local repo one aws leak whitelisted",
|
description: "test local repo one aws leak whitelisted",
|
||||||
opts: options.Options{
|
opts: options.Options{
|
||||||
RepoPath: "../test_data/test_repos/test_repo_1",
|
RepoPath: "../test_data/test_repos/test_repo_1",
|
||||||
Config: "../test_data/test_configs/aws_key_whitelist_python_files.toml",
|
ReportFormat: "json",
|
||||||
|
Config: "../test_data/test_configs/aws_key_whitelist_python_files.toml",
|
||||||
},
|
},
|
||||||
wantEmpty: true,
|
wantEmpty: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "test local repo two leaks",
|
description: "test local repo two leaks",
|
||||||
opts: options.Options{
|
opts: options.Options{
|
||||||
RepoPath: "../test_data/test_repos/test_repo_2",
|
RepoPath: "../test_data/test_repos/test_repo_2",
|
||||||
Report: "../test_data/test_local_repo_two_leaks.json.got",
|
Report: "../test_data/test_local_repo_two_leaks.json.got",
|
||||||
|
ReportFormat: "json",
|
||||||
},
|
},
|
||||||
wantPath: "../test_data/test_local_repo_two_leaks.json",
|
wantPath: "../test_data/test_local_repo_two_leaks.json",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
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",
|
||||||
|
ReportFormat: "json",
|
||||||
|
CommitFrom: "996865bb912f3bc45898a370a13aadb315014b55",
|
||||||
|
},
|
||||||
|
wantPath: "../test_data/test_local_repo_two_leaks_commit_from.json",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
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",
|
||||||
|
ReportFormat: "json",
|
||||||
|
CommitTo: "996865bb912f3bc45898a370a13aadb315014b55",
|
||||||
|
},
|
||||||
|
wantPath: "../test_data/test_local_repo_two_leaks_commit_to.json",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
description: "test local repo two leaks range commit",
|
||||||
|
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",
|
||||||
|
CommitFrom: "d8ac0b73aeeb45843319cdc5ce506516eb49bf7a",
|
||||||
|
CommitTo: "51f6dcf6b89b93f4075ba92c400b075631a6cc93",
|
||||||
|
},
|
||||||
|
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 globally whitelisted",
|
||||||
opts: options.Options{
|
opts: options.Options{
|
||||||
RepoPath: "../test_data/test_repos/test_repo_2",
|
RepoPath: "../test_data/test_repos/test_repo_2",
|
||||||
Config: "../test_data/test_configs/aws_key_global_whitelist_file.toml",
|
Config: "../test_data/test_configs/aws_key_global_whitelist_file.toml",
|
||||||
|
ReportFormat: "json",
|
||||||
},
|
},
|
||||||
wantEmpty: true,
|
wantEmpty: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "test local repo two leaks whitelisted",
|
description: "test local repo two leaks whitelisted",
|
||||||
opts: options.Options{
|
opts: options.Options{
|
||||||
RepoPath: "../test_data/test_repos/test_repo_2",
|
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_whitelist_files.toml",
|
||||||
|
ReportFormat: "json",
|
||||||
},
|
},
|
||||||
wantEmpty: true,
|
wantEmpty: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "test local repo three leaks dev branch",
|
description: "test local repo three leaks dev branch",
|
||||||
opts: options.Options{
|
opts: options.Options{
|
||||||
RepoPath: "../test_data/test_repos/test_repo_3",
|
RepoPath: "../test_data/test_repos/test_repo_3",
|
||||||
Report: "../test_data/test_local_repo_three_leaks.json.got",
|
Report: "../test_data/test_local_repo_three_leaks.json.got",
|
||||||
Config: "../test_data/test_configs/aws_key.toml",
|
Config: "../test_data/test_configs/aws_key.toml",
|
||||||
Branch: "dev",
|
Branch: "dev",
|
||||||
|
ReportFormat: "json",
|
||||||
},
|
},
|
||||||
wantPath: "../test_data/test_local_repo_three_leaks.json",
|
wantPath: "../test_data/test_local_repo_three_leaks.json",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "test local repo branch does not exist",
|
description: "test local repo branch does not exist",
|
||||||
opts: options.Options{
|
opts: options.Options{
|
||||||
RepoPath: "../test_data/test_repos/test_repo_3",
|
RepoPath: "../test_data/test_repos/test_repo_3",
|
||||||
Branch: "nobranch",
|
Branch: "nobranch",
|
||||||
|
ReportFormat: "json",
|
||||||
},
|
},
|
||||||
wantEmpty: true,
|
wantEmpty: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "test local repo one aws leak single commit",
|
description: "test local repo one aws leak single commit",
|
||||||
opts: options.Options{
|
opts: options.Options{
|
||||||
RepoPath: "../test_data/test_repos/test_repo_1",
|
RepoPath: "../test_data/test_repos/test_repo_1",
|
||||||
Report: "../test_data/test_local_repo_one_aws_leak_commit.json.got",
|
Report: "../test_data/test_local_repo_one_aws_leak_commit.json.got",
|
||||||
Commit: "6557c92612d3b35979bd426d429255b3bf9fab74",
|
Commit: "6557c92612d3b35979bd426d429255b3bf9fab74",
|
||||||
|
ReportFormat: "json",
|
||||||
},
|
},
|
||||||
wantPath: "../test_data/test_local_repo_one_aws_leak_commit.json",
|
wantPath: "../test_data/test_local_repo_one_aws_leak_commit.json",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "test local repo one aws leak AND leak on python files",
|
description: "test local repo one aws leak AND leak on python files",
|
||||||
opts: options.Options{
|
opts: options.Options{
|
||||||
RepoPath: "../test_data/test_repos/test_repo_1",
|
RepoPath: "../test_data/test_repos/test_repo_1",
|
||||||
Report: "../test_data/test_local_repo_one_aws_leak_and_file_leak.json.got",
|
Report: "../test_data/test_local_repo_one_aws_leak_and_file_leak.json.got",
|
||||||
Config: "../test_data/test_configs/aws_key_file_regex.toml",
|
Config: "../test_data/test_configs/aws_key_file_regex.toml",
|
||||||
|
ReportFormat: "json",
|
||||||
},
|
},
|
||||||
wantPath: "../test_data/test_local_repo_one_aws_leak_and_file_leak.json",
|
wantPath: "../test_data/test_local_repo_one_aws_leak_and_file_leak.json",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "test owner path",
|
description: "test owner path",
|
||||||
opts: options.Options{
|
opts: options.Options{
|
||||||
OwnerPath: "../test_data/test_repos/",
|
OwnerPath: "../test_data/test_repos/",
|
||||||
Report: "../test_data/test_local_owner_aws_leak.json.got",
|
Report: "../test_data/test_local_owner_aws_leak.json.got",
|
||||||
|
ReportFormat: "json",
|
||||||
},
|
},
|
||||||
wantPath: "../test_data/test_local_owner_aws_leak.json",
|
wantPath: "../test_data/test_local_owner_aws_leak.json",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "test entropy",
|
description: "test entropy",
|
||||||
opts: options.Options{
|
opts: options.Options{
|
||||||
RepoPath: "../test_data/test_repos/test_repo_1",
|
RepoPath: "../test_data/test_repos/test_repo_1",
|
||||||
Report: "../test_data/test_entropy.json.got",
|
Report: "../test_data/test_entropy.json.got",
|
||||||
Config: "../test_data/test_configs/entropy.toml",
|
Config: "../test_data/test_configs/entropy.toml",
|
||||||
|
ReportFormat: "json",
|
||||||
},
|
},
|
||||||
wantPath: "../test_data/test_entropy.json",
|
wantPath: "../test_data/test_entropy.json",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "test entropy and regex",
|
description: "test entropy and regex",
|
||||||
opts: options.Options{
|
opts: options.Options{
|
||||||
RepoPath: "../test_data/test_repos/test_repo_1",
|
RepoPath: "../test_data/test_repos/test_repo_1",
|
||||||
Report: "../test_data/test_regex_entropy.json.got",
|
Report: "../test_data/test_regex_entropy.json.got",
|
||||||
Config: "../test_data/test_configs/regex_entropy.toml",
|
Config: "../test_data/test_configs/regex_entropy.toml",
|
||||||
|
ReportFormat: "json",
|
||||||
},
|
},
|
||||||
wantPath: "../test_data/test_regex_entropy.json",
|
wantPath: "../test_data/test_regex_entropy.json",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "test local repo four entropy alternative config",
|
description: "test local repo four entropy alternative config",
|
||||||
opts: options.Options{
|
opts: options.Options{
|
||||||
RepoPath: "../test_data/test_repos/test_repo_4",
|
RepoPath: "../test_data/test_repos/test_repo_4",
|
||||||
Report: "../test_data/test_local_repo_four_alt_config_entropy.json.got",
|
Report: "../test_data/test_local_repo_four_alt_config_entropy.json.got",
|
||||||
RepoConfig: true,
|
RepoConfig: true,
|
||||||
|
ReportFormat: "json",
|
||||||
},
|
},
|
||||||
wantPath: "../test_data/test_local_repo_four_alt_config_entropy.json",
|
wantPath: "../test_data/test_local_repo_four_alt_config_entropy.json",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "test local repo four entropy alternative config",
|
description: "test local repo four entropy alternative config",
|
||||||
opts: options.Options{
|
opts: options.Options{
|
||||||
RepoPath: "../test_data/test_repos/test_repo_1",
|
RepoPath: "../test_data/test_repos/test_repo_1",
|
||||||
Report: "../test_data/test_regex_whitelist.json.got",
|
Report: "../test_data/test_regex_whitelist.json.got",
|
||||||
Config: "../test_data/test_configs/aws_key_aws_whitelisted.toml",
|
Config: "../test_data/test_configs/aws_key_aws_whitelisted.toml",
|
||||||
|
ReportFormat: "json",
|
||||||
},
|
},
|
||||||
wantEmpty: true,
|
wantEmpty: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
description: "test local repo one aws leak timeout",
|
||||||
|
opts: options.Options{
|
||||||
|
RepoPath: "../test_data/test_repos/test_repo_1",
|
||||||
|
Report: "../test_data/test_local_repo_one_aws_leak.json.got",
|
||||||
|
ReportFormat: "json",
|
||||||
|
Timeout: "10ns",
|
||||||
|
},
|
||||||
|
wantEmpty: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
description: "test local repo one aws leak long timeout",
|
||||||
|
opts: options.Options{
|
||||||
|
RepoPath: "../test_data/test_repos/test_repo_1",
|
||||||
|
Report: "../test_data/test_local_repo_one_aws_leak.json.got",
|
||||||
|
ReportFormat: "json",
|
||||||
|
Timeout: "2m",
|
||||||
|
},
|
||||||
|
wantPath: "../test_data/test_local_repo_one_aws_leak.json",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
description: "test owner path depth=2",
|
||||||
|
opts: options.Options{
|
||||||
|
OwnerPath: "../test_data/test_repos/",
|
||||||
|
Report: "../test_data/test_local_owner_aws_leak_depth_2.json.got",
|
||||||
|
ReportFormat: "json",
|
||||||
|
Depth: 2,
|
||||||
|
},
|
||||||
|
wantPath: "../test_data/test_local_owner_aws_leak_depth_2.json",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
@@ -222,9 +303,10 @@ func TestAuditUncommited(t *testing.T) {
|
|||||||
{
|
{
|
||||||
description: "test audit local one leak",
|
description: "test audit local one leak",
|
||||||
opts: options.Options{
|
opts: options.Options{
|
||||||
RepoPath: "../test_data/test_repos/test_repo_1",
|
RepoPath: "../test_data/test_repos/test_repo_1",
|
||||||
Report: "../test_data/test_local_repo_one_aws_leak_uncommitted.json.got",
|
Report: "../test_data/test_local_repo_one_aws_leak_uncommitted.json.got",
|
||||||
Uncommited: true,
|
Uncommited: true,
|
||||||
|
ReportFormat: "json",
|
||||||
},
|
},
|
||||||
wantPath: "../test_data/test_local_repo_one_aws_leak_uncommitted.json",
|
wantPath: "../test_data/test_local_repo_one_aws_leak_uncommitted.json",
|
||||||
fileToChange: "server.test.py",
|
fileToChange: "server.test.py",
|
||||||
@@ -233,8 +315,9 @@ func TestAuditUncommited(t *testing.T) {
|
|||||||
{
|
{
|
||||||
description: "test audit local no leak",
|
description: "test audit local no leak",
|
||||||
opts: options.Options{
|
opts: options.Options{
|
||||||
RepoPath: "../test_data/test_repos/test_repo_1",
|
RepoPath: "../test_data/test_repos/test_repo_1",
|
||||||
Uncommited: true,
|
Uncommited: true,
|
||||||
|
ReportFormat: "json",
|
||||||
},
|
},
|
||||||
wantEmpty: true,
|
wantEmpty: true,
|
||||||
fileToChange: "server.test.py",
|
fileToChange: "server.test.py",
|
||||||
@@ -294,6 +377,10 @@ func TestAuditUncommited(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func fileCheck(wantPath, gotPath string) error {
|
func fileCheck(wantPath, gotPath string) error {
|
||||||
|
var (
|
||||||
|
gotLeaks []manager.Leak
|
||||||
|
wantLeaks []manager.Leak
|
||||||
|
)
|
||||||
want, err := ioutil.ReadFile(wantPath)
|
want, err := ioutil.ReadFile(wantPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -304,7 +391,20 @@ func fileCheck(wantPath, gotPath string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.Trim(string(want), "\n") != strings.Trim(string(got), "\n") {
|
err = json.Unmarshal(got, &gotLeaks)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal(want, &wantLeaks)
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
sort.Slice(gotLeaks, func(i, j int) bool { return (gotLeaks)[i].Commit < (gotLeaks)[j].Commit })
|
||||||
|
sort.Slice(wantLeaks, func(i, j int) bool { return (wantLeaks)[i].Commit < (wantLeaks)[j].Commit })
|
||||||
|
|
||||||
|
if !reflect.DeepEqual(gotLeaks, wantLeaks) {
|
||||||
dmp := diffmatchpatch.New()
|
dmp := diffmatchpatch.New()
|
||||||
diffs := dmp.DiffMain(string(want), string(got), false)
|
diffs := dmp.DiffMain(string(want), string(got), false)
|
||||||
return fmt.Errorf("does not equal: %s", dmp.DiffPrettyText(diffs))
|
return fmt.Errorf("does not equal: %s", dmp.DiffPrettyText(diffs))
|
||||||
|
|||||||
+121
-23
@@ -2,25 +2,28 @@ package audit
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"context"
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/BurntSushi/toml"
|
|
||||||
"github.com/sergi/go-diff/diffmatchpatch"
|
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"github.com/zricethezav/gitleaks/config"
|
|
||||||
"github.com/zricethezav/gitleaks/manager"
|
|
||||||
"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"
|
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"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.
|
// Repo wraps a *git.Repository object in addition to a manager object and the name of the repo.
|
||||||
@@ -37,6 +40,10 @@ type Repo struct {
|
|||||||
// for those repo audits.
|
// for those repo audits.
|
||||||
config config.Config
|
config config.Config
|
||||||
|
|
||||||
|
// ctx is used to signal timeouts to running goroutines
|
||||||
|
ctx context.Context
|
||||||
|
cancel context.CancelFunc
|
||||||
|
|
||||||
Name string
|
Name string
|
||||||
Manager *manager.Manager
|
Manager *manager.Manager
|
||||||
}
|
}
|
||||||
@@ -46,6 +53,7 @@ func NewRepo(m *manager.Manager) *Repo {
|
|||||||
return &Repo{
|
return &Repo{
|
||||||
Manager: m,
|
Manager: m,
|
||||||
config: m.Config,
|
config: m.Config,
|
||||||
|
ctx: context.Background(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,6 +90,19 @@ func (repo *Repo) Clone(cloneOption *git.CloneOptions) error {
|
|||||||
// AuditUncommitted will do a `git diff` and scan changed files that are being tracked. This is useful functionality
|
// 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.
|
// for a pre-commit hook so you can make sure your code does not have any leaks before committing.
|
||||||
func (repo *Repo) AuditUncommitted() error {
|
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()
|
auditTimeStart := time.Now()
|
||||||
|
|
||||||
r, err := repo.Head()
|
r, err := repo.Head()
|
||||||
@@ -93,6 +114,12 @@ func (repo *Repo) AuditUncommitted() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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()
|
prevTree, err := c.Tree()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -144,18 +171,35 @@ func (repo *Repo) AuditUncommitted() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dmp := diffmatchpatch.New()
|
if fileMatched(filename, repo.config.Whitelist.File) {
|
||||||
diffs := dmp.DiffMain(prevFileContents, currFileContents, false)
|
log.Debugf("whitelisted file found, skipping audit of file: %s", filename)
|
||||||
var diffContents string
|
} else if fileMatched(filename, repo.config.FileRegex) {
|
||||||
for _, d := range diffs {
|
repo.Manager.SendLeaks(manager.Leak{
|
||||||
switch d.Type {
|
Line: "N/A",
|
||||||
case diffmatchpatch.DiffInsert:
|
Offender: filename,
|
||||||
diffContents += fmt.Sprintf("%s\n", d.Text)
|
Commit: c.Hash.String(),
|
||||||
case diffmatchpatch.DiffDelete:
|
Repo: repo.Name,
|
||||||
diffContents += fmt.Sprintf("%s\n", d.Text)
|
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)
|
||||||
}
|
}
|
||||||
InspectString(diffContents, c, repo, filename)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,6 +214,10 @@ func (repo *Repo) AuditUncommitted() error {
|
|||||||
// git repo. Options that can change the behavior of this function include: --commit, --depth, --branch.
|
// 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.
|
// See options/options.go for an explanation on these options.
|
||||||
func (repo *Repo) Audit() error {
|
func (repo *Repo) Audit() error {
|
||||||
|
if err := repo.setupTimeout(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
if repo.Repository == nil {
|
if repo.Repository == nil {
|
||||||
return fmt.Errorf("%s repo is empty", repo.Name)
|
return fmt.Errorf("%s repo is empty", repo.Name)
|
||||||
}
|
}
|
||||||
@@ -209,12 +257,12 @@ func (repo *Repo) Audit() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
//checker := make(map[string]bool)
|
|
||||||
cc := 0
|
cc := 0
|
||||||
semaphore := make(chan bool, howManyThreads(repo.Manager.Opts.Threads))
|
semaphore := make(chan bool, howManyThreads(repo.Manager.Opts.Threads))
|
||||||
wg := sync.WaitGroup{}
|
wg := sync.WaitGroup{}
|
||||||
err = cIter.ForEach(func(c *object.Commit) error {
|
err = cIter.ForEach(func(c *object.Commit) error {
|
||||||
if c == nil {
|
if c == nil || c.Hash.String() == repo.Manager.Opts.CommitTo ||
|
||||||
|
repo.timeoutReached() || repo.depthReached(cc) {
|
||||||
return storer.ErrStop
|
return storer.ErrStop
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,6 +281,17 @@ func (repo *Repo) Audit() error {
|
|||||||
|
|
||||||
cc++
|
cc++
|
||||||
err = c.Parents().ForEach(func(parent *object.Commit) error {
|
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()
|
start := time.Now()
|
||||||
patch, err := c.Patch(parent)
|
patch, err := c.Patch(parent)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -303,3 +362,42 @@ func (repo *Repo) loadRepoConfig() (config.Config, error) {
|
|||||||
_, err = toml.DecodeReader(f, &tomlLoader)
|
_, err = toml.DecodeReader(f, &tomlLoader)
|
||||||
return tomlLoader.Parse()
|
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
|
||||||
|
}
|
||||||
+47
-21
@@ -2,30 +2,32 @@ package audit
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"github.com/zricethezav/gitleaks/config"
|
|
||||||
"github.com/zricethezav/gitleaks/manager"
|
|
||||||
"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"
|
|
||||||
"math"
|
"math"
|
||||||
"path"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
|
||||||
|
|
||||||
const maxLineLen = 200
|
"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
|
// 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
|
// 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
|
// whitelisted files set in the configuration. If a global rule for files is defined and a filename
|
||||||
// matches said global rule, then a laek is sent to the manager.
|
// matches said global rule, then a leak is sent to the manager.
|
||||||
// After that, file chunks are created which are then inspected by InspectString()
|
// After that, file chunks are created which are then inspected by InspectString()
|
||||||
func inspectPatch(patch *object.Patch, c *object.Commit, repo *Repo) {
|
func inspectPatch(patch *object.Patch, c *object.Commit, repo *Repo) {
|
||||||
for _, f := range patch.FilePatches() {
|
for _, f := range patch.FilePatches() {
|
||||||
|
if repo.timeoutReached() {
|
||||||
|
return
|
||||||
|
}
|
||||||
if f.IsBinary() {
|
if f.IsBinary() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -59,9 +61,9 @@ func getFileName(f fdiff.FilePatch) string {
|
|||||||
fn := "???"
|
fn := "???"
|
||||||
from, to := f.Files()
|
from, to := f.Files()
|
||||||
if from != nil {
|
if from != nil {
|
||||||
return path.Base(from.Path())
|
return from.Path()
|
||||||
} else if to != nil {
|
} else if to != nil {
|
||||||
return path.Base(to.Path())
|
return to.Path()
|
||||||
}
|
}
|
||||||
|
|
||||||
return fn
|
return fn
|
||||||
@@ -120,14 +122,13 @@ func InspectString(content string, c *object.Commit, repo *Repo, filename string
|
|||||||
// an optimization would be to switch the regex from FindAllIndex to FindString
|
// an optimization would be to switch the regex from FindAllIndex to FindString
|
||||||
// since we are iterating on the lines if entropy rules exist...
|
// since we are iterating on the lines if entropy rules exist...
|
||||||
for _, line := range strings.Split(content, "\n") {
|
for _, line := range strings.Split(content, "\n") {
|
||||||
|
if repo.timeoutReached() {
|
||||||
|
return
|
||||||
|
}
|
||||||
entropyTripped := trippedEntropy(line, rule)
|
entropyTripped := trippedEntropy(line, rule)
|
||||||
if entropyTripped && !ruleContainRegex(rule) {
|
if entropyTripped && !ruleContainRegex(rule) {
|
||||||
_line := line
|
|
||||||
if len(_line) > maxLineLen {
|
|
||||||
_line = line[0 : maxLineLen-1]
|
|
||||||
}
|
|
||||||
repo.Manager.SendLeaks(manager.Leak{
|
repo.Manager.SendLeaks(manager.Leak{
|
||||||
Line: _line,
|
Line: line,
|
||||||
Offender: fmt.Sprintf("Entropy range %+v", rule.Entropy),
|
Offender: fmt.Sprintf("Entropy range %+v", rule.Entropy),
|
||||||
Commit: c.Hash.String(),
|
Commit: c.Hash.String(),
|
||||||
Repo: repo.Name,
|
Repo: repo.Name,
|
||||||
@@ -140,6 +141,9 @@ func InspectString(content string, c *object.Commit, repo *Repo, filename string
|
|||||||
File: filename,
|
File: filename,
|
||||||
})
|
})
|
||||||
} else if entropyTripped {
|
} else if entropyTripped {
|
||||||
|
if repo.timeoutReached() {
|
||||||
|
return
|
||||||
|
}
|
||||||
// entropy has been tripped which means if there is a regex specified in the same
|
// 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
|
// 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
|
// both entropy and regex set which work in combination. This helps narrow down false positives
|
||||||
@@ -184,6 +188,9 @@ func InspectString(content string, c *object.Commit, repo *Repo, filename string
|
|||||||
if rule.Regex.String() == "" {
|
if rule.Regex.String() == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if repo.timeoutReached() {
|
||||||
|
return
|
||||||
|
}
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
locs := rule.Regex.FindAllIndex([]byte(content), -1)
|
locs := rule.Regex.FindAllIndex([]byte(content), -1)
|
||||||
if len(locs) != 0 {
|
if len(locs) != 0 {
|
||||||
@@ -225,7 +232,6 @@ func InspectString(content string, c *object.Commit, repo *Repo, filename string
|
|||||||
line = strings.ReplaceAll(line, offender, "REDACTED")
|
line = strings.ReplaceAll(line, offender, "REDACTED")
|
||||||
offender = "REDACTED"
|
offender = "REDACTED"
|
||||||
}
|
}
|
||||||
|
|
||||||
repo.Manager.SendLeaks(manager.Leak{
|
repo.Manager.SendLeaks(manager.Leak{
|
||||||
Line: line,
|
Line: line,
|
||||||
Offender: offender,
|
Offender: offender,
|
||||||
@@ -261,7 +267,7 @@ func inspectCommit(c *object.Commit, repo *Repo) error {
|
|||||||
|
|
||||||
err = fIter.ForEach(func(f *object.File) error {
|
err = fIter.ForEach(func(f *object.File) error {
|
||||||
bin, err := f.IsBinary()
|
bin, err := f.IsBinary()
|
||||||
if bin {
|
if bin || repo.timeoutReached() {
|
||||||
return nil
|
return nil
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -270,6 +276,20 @@ func inspectCommit(c *object.Commit, repo *Repo) error {
|
|||||||
log.Debugf("whitelisted file found, skipping audit of file: %s", f.Name)
|
log.Debugf("whitelisted file found, skipping audit of file: %s", f.Name)
|
||||||
return nil
|
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()
|
content, err := f.Contents()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -329,8 +349,11 @@ func fileMatched(f interface{}, re *regexp.Regexp) bool {
|
|||||||
// It is similar to `git log {branch}`. Default behavior is to log ALL branches so
|
// It is similar to `git log {branch}`. Default behavior is to log ALL branches so
|
||||||
// gitleaks gets the full git history.
|
// gitleaks gets the full git history.
|
||||||
func getLogOptions(repo *Repo) (*git.LogOptions, error) {
|
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 != "" {
|
if repo.Manager.Opts.Branch != "" {
|
||||||
var logOpts git.LogOptions
|
|
||||||
refs, err := repo.Storer.IterReferences()
|
refs, err := repo.Storer.IterReferences()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -358,6 +381,9 @@ func getLogOptions(repo *Repo) (*git.LogOptions, error) {
|
|||||||
}
|
}
|
||||||
return &logOpts, nil
|
return &logOpts, nil
|
||||||
}
|
}
|
||||||
|
if !logOpts.From.IsZero() {
|
||||||
|
return &logOpts, nil
|
||||||
|
}
|
||||||
return &git.LogOptions{All: true}, nil
|
return &git.LogOptions{All: true}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-2
@@ -2,11 +2,13 @@ package config
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/BurntSushi/toml"
|
|
||||||
"github.com/zricethezav/gitleaks/options"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/zricethezav/gitleaks/options"
|
||||||
|
|
||||||
|
"github.com/BurntSushi/toml"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Whitelist is struct containing items that if encountered will whitelist
|
// Whitelist is struct containing items that if encountered will whitelist
|
||||||
|
|||||||
+10
-6
@@ -62,16 +62,15 @@ title = "gitleaks config"
|
|||||||
tags = ["key", "Slack"]
|
tags = ["key", "Slack"]
|
||||||
|
|
||||||
[[rules]]
|
[[rules]]
|
||||||
description = "EC"
|
description = "Asymmetric Private Key"
|
||||||
regex = '''-----BEGIN EC PRIVATE KEY-----'''
|
regex = '''-----BEGIN ((EC|PGP|DSA|RSA|OPENSSH) )?PRIVATE KEY( BLOCK)?-----'''
|
||||||
tags = ["key", "EC"]
|
tags = ["key", "AsymmetricPrivateKey"]
|
||||||
|
|
||||||
[[rules]]
|
[[rules]]
|
||||||
description = "Generic Credential"
|
description = "Generic Credential"
|
||||||
regex = '''(?i)(api_key|apikey|secret)(.{0,20})?['|"][0-9a-zA-Z]{16,45}['|"]'''
|
regex = '''(?i)(api_key|apikey|secret)(.{0,20})?['|"][0-9a-zA-Z]{16,45}['|"]'''
|
||||||
tags = ["key", "API", "generic"]
|
tags = ["key", "API", "generic"]
|
||||||
|
|
||||||
|
|
||||||
[[rules]]
|
[[rules]]
|
||||||
description = "Google API key"
|
description = "Google API key"
|
||||||
regex = '''AIza[0-9A-Za-z\\-_]{35}'''
|
regex = '''AIza[0-9A-Za-z\\-_]{35}'''
|
||||||
@@ -103,6 +102,11 @@ title = "gitleaks config"
|
|||||||
regex = '''sk_live_[0-9a-z]{32}'''
|
regex = '''sk_live_[0-9a-z]{32}'''
|
||||||
tags = ["key", "Picatic"]
|
tags = ["key", "Picatic"]
|
||||||
|
|
||||||
|
[[rules]]
|
||||||
|
description = "SendGrid API Key"
|
||||||
|
regex = '''SG\.[\w_]{16,32}\.[\w_]{16,64}'''
|
||||||
|
tags = ["key", "SendGrid"]
|
||||||
|
|
||||||
[[rules]]
|
[[rules]]
|
||||||
description = "Slack Webhook"
|
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}'''
|
regex = '''https://hooks.slack.com/services/T[a-zA-Z0-9_]{8}/B[a-zA-Z0-9_]{8}/[a-zA-Z0-9_]{24}'''
|
||||||
@@ -129,6 +133,6 @@ title = "gitleaks config"
|
|||||||
tags = ["key", "twilio"]
|
tags = ["key", "twilio"]
|
||||||
|
|
||||||
[whitelist]
|
[whitelist]
|
||||||
description = "image whitelists"
|
description = "Whitelisted files"
|
||||||
file = '''(.*?)(jpg|gif|doc|pdf|bin)$'''
|
file = '''(^\.?gitleaks.toml$|(.*?)(jpg|gif|doc|pdf|bin)$)'''
|
||||||
`
|
`
|
||||||
@@ -0,0 +1,169 @@
|
|||||||
|
title = "gitleaks config"
|
||||||
|
|
||||||
|
[[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]]
|
||||||
|
description = "AWS cred file info"
|
||||||
|
regex = '''(?i)(aws_access_key_id|aws_secret_access_key)(.{0,20})?=.[0-9a-zA-Z\/+]{20,40}'''
|
||||||
|
tags = ["AWS"]
|
||||||
|
|
||||||
|
[[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 = "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 = "Env Var"
|
||||||
|
regex = '''(?i)(api_key|apikey|secret|key|api|password|pw|host)=[0-9a-zA-Z-_{}]{4,120}'''
|
||||||
|
|
||||||
|
[[rules]]
|
||||||
|
description = "Port"
|
||||||
|
regex = '''(?i)port(.{0,4})?[0-9]{1,10}'''
|
||||||
|
|
||||||
|
[[rules]]
|
||||||
|
description = "Email"
|
||||||
|
regex = '''[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}'''
|
||||||
|
tags = ["email"]
|
||||||
|
|
||||||
|
[[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}['|"]'''
|
||||||
|
tags = ["key", "API", "generic"]
|
||||||
|
|
||||||
|
[[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]
|
||||||
|
file = '''(?i)(id_rsa|passwd|id_rsa.pub|pgpass|pem|key|shadow)'''
|
||||||
|
|
||||||
|
[whitelist]
|
||||||
|
description = "image whitelists"
|
||||||
|
file = '''(.*?)(jpg|gif|doc|pdf|bin)$'''
|
||||||
|
|
||||||
@@ -1,9 +1,10 @@
|
|||||||
module github.com/zricethezav/gitleaks
|
module github.com/zricethezav/gitleaks
|
||||||
|
|
||||||
go 1.12
|
go 1.13
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/BurntSushi/toml v0.3.1
|
github.com/BurntSushi/toml v0.3.1
|
||||||
|
github.com/google/go-cmp v0.4.0 // indirect
|
||||||
github.com/google/go-github v17.0.0+incompatible
|
github.com/google/go-github v17.0.0+incompatible
|
||||||
github.com/hako/durafmt v0.0.0-20191009132224-3f39dc1ed9f4
|
github.com/hako/durafmt v0.0.0-20191009132224-3f39dc1ed9f4
|
||||||
github.com/jessevdk/go-flags v1.4.0
|
github.com/jessevdk/go-flags v1.4.0
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ 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.2.0/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 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=
|
||||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
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 h1:N0LgJ1j65A7kfXrZnUDaYCs/Sf4rEjNlfyDHW9dolSY=
|
||||||
github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
|
github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
|
||||||
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
|
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
|
||||||
@@ -101,6 +103,8 @@ 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-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 h1:mEQZbbaBjWyLNy0tmZmgEuQAR8XOQ3hL8GYi3J/NG64=
|
||||||
golang.org/x/tools v0.0.0-20190729092621-ff9f1409240a/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI=
|
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.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
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 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508=
|
||||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||||
|
|||||||
+32
-12
@@ -2,39 +2,51 @@ package hosts
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/google/go-github/github"
|
"strconv"
|
||||||
log "github.com/sirupsen/logrus"
|
"strings"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/audit"
|
"github.com/zricethezav/gitleaks/audit"
|
||||||
"github.com/zricethezav/gitleaks/manager"
|
"github.com/zricethezav/gitleaks/manager"
|
||||||
"github.com/zricethezav/gitleaks/options"
|
"github.com/zricethezav/gitleaks/options"
|
||||||
|
|
||||||
|
"github.com/google/go-github/github"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
"golang.org/x/oauth2"
|
"golang.org/x/oauth2"
|
||||||
"gopkg.in/src-d/go-git.v4"
|
"gopkg.in/src-d/go-git.v4"
|
||||||
"gopkg.in/src-d/go-git.v4/plumbing"
|
"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/object"
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
"sync"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Github wraps a github client and manager. This struct implements what the Host interface defines.
|
// Github wraps a github client and manager. This struct implements what the Host interface defines.
|
||||||
type Github struct {
|
type Github struct {
|
||||||
client *github.Client
|
client *github.Client
|
||||||
manager manager.Manager
|
manager *manager.Manager
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewGithubClient accepts a manager struct and returns a Github host pointer which will be used to
|
// 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 audit on an organization, user, or PR.
|
||||||
func NewGithubClient(m manager.Manager) *Github {
|
func NewGithubClient(m *manager.Manager) (*Github, error) {
|
||||||
|
var err error
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
token := oauth2.StaticTokenSource(
|
token := oauth2.StaticTokenSource(
|
||||||
&oauth2.Token{AccessToken: options.GetAccessToken(m.Opts)},
|
&oauth2.Token{AccessToken: options.GetAccessToken(m.Opts)},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var githubClient *github.Client
|
||||||
|
httpClient := oauth2.NewClient(ctx, token)
|
||||||
|
|
||||||
|
if m.Opts.BaseURL == "" {
|
||||||
|
githubClient = github.NewClient(httpClient)
|
||||||
|
} else {
|
||||||
|
githubClient, err = github.NewEnterpriseClient(m.Opts.BaseURL, m.Opts.BaseURL, httpClient)
|
||||||
|
}
|
||||||
|
|
||||||
return &Github{
|
return &Github{
|
||||||
manager: m,
|
manager: m,
|
||||||
client: github.NewClient(oauth2.NewClient(ctx, token)),
|
client: githubClient,
|
||||||
}
|
}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Audit will audit a github user or organization's repos.
|
// Audit will audit a github user or organization's repos.
|
||||||
@@ -60,7 +72,15 @@ func (g *Github) Audit() {
|
|||||||
_githubRepos, resp, err = g.client.Repositories.ListByOrg(ctx, g.manager.Opts.Organization,
|
_githubRepos, resp, err = g.client.Repositories.ListByOrg(ctx, g.manager.Opts.Organization,
|
||||||
&github.RepositoryListByOrgOptions{ListOptions: listOptions})
|
&github.RepositoryListByOrgOptions{ListOptions: listOptions})
|
||||||
}
|
}
|
||||||
githubRepos = append(githubRepos, _githubRepos...)
|
|
||||||
|
for _, r := range _githubRepos {
|
||||||
|
if g.manager.Opts.ExcludeForks && r.GetFork() {
|
||||||
|
log.Debugf("excluding forked repo: %s", *r.Name)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
githubRepos = append(githubRepos, r)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if resp == nil {
|
if resp == nil {
|
||||||
break
|
break
|
||||||
@@ -79,7 +99,7 @@ func (g *Github) Audit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, repo := range githubRepos {
|
for _, repo := range githubRepos {
|
||||||
r := audit.NewRepo(&g.manager)
|
r := audit.NewRepo(g.manager)
|
||||||
r.Name = *repo.Name
|
r.Name = *repo.Name
|
||||||
err := r.Clone(&git.CloneOptions{
|
err := r.Clone(&git.CloneOptions{
|
||||||
URL: *repo.CloneURL,
|
URL: *repo.CloneURL,
|
||||||
@@ -111,7 +131,7 @@ func (g *Github) AuditPR() {
|
|||||||
owner := splits[len(splits)-4]
|
owner := splits[len(splits)-4]
|
||||||
repoName := splits[len(splits)-3]
|
repoName := splits[len(splits)-3]
|
||||||
prNum, err := strconv.Atoi(splits[len(splits)-1])
|
prNum, err := strconv.Atoi(splits[len(splits)-1])
|
||||||
repo := audit.NewRepo(&g.manager)
|
repo := audit.NewRepo(g.manager)
|
||||||
repo.Name = repoName
|
repo.Name = repoName
|
||||||
log.Infof("auditing pr %s\n", g.manager.Opts.PullRequest)
|
log.Infof("auditing pr %s\n", g.manager.Opts.PullRequest)
|
||||||
|
|
||||||
|
|||||||
+27
-10
@@ -2,30 +2,40 @@ package hosts
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
log "github.com/sirupsen/logrus"
|
"sync"
|
||||||
"github.com/xanzy/go-gitlab"
|
|
||||||
"github.com/zricethezav/gitleaks/audit"
|
"github.com/zricethezav/gitleaks/audit"
|
||||||
"github.com/zricethezav/gitleaks/manager"
|
"github.com/zricethezav/gitleaks/manager"
|
||||||
"github.com/zricethezav/gitleaks/options"
|
"github.com/zricethezav/gitleaks/options"
|
||||||
"sync"
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
"github.com/xanzy/go-gitlab"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Gitlab wraps a gitlab client and manager. This struct implements what the Host interface defines.
|
// Gitlab wraps a gitlab client and manager. This struct implements what the Host interface defines.
|
||||||
type Gitlab struct {
|
type Gitlab struct {
|
||||||
client *gitlab.Client
|
client *gitlab.Client
|
||||||
manager manager.Manager
|
manager *manager.Manager
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewGitlabClient accepts a manager struct and returns a Gitlab host pointer which will be used to
|
// 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 audit on an group or user.
|
||||||
func NewGitlabClient(m manager.Manager) *Gitlab {
|
func NewGitlabClient(m *manager.Manager) (*Gitlab, error) {
|
||||||
return &Gitlab{
|
var err error
|
||||||
|
|
||||||
|
gitlabClient := &Gitlab{
|
||||||
manager: m,
|
manager: m,
|
||||||
ctx: context.Background(),
|
ctx: context.Background(),
|
||||||
client: gitlab.NewClient(nil, options.GetAccessToken(m.Opts)),
|
client: gitlab.NewClient(nil, options.GetAccessToken(m.Opts)),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if m.Opts.BaseURL != "" {
|
||||||
|
err = gitlabClient.client.SetBaseURL(m.Opts.BaseURL)
|
||||||
|
}
|
||||||
|
|
||||||
|
return gitlabClient, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Audit will audit a github user or organization's repos.
|
// Audit will audit a github user or organization's repos.
|
||||||
@@ -47,19 +57,26 @@ func (g *Gitlab) Audit() {
|
|||||||
glOpts := &gitlab.ListProjectsOptions{
|
glOpts := &gitlab.ListProjectsOptions{
|
||||||
ListOptions: listOpts,
|
ListOptions: listOpts,
|
||||||
}
|
}
|
||||||
projects, resp, err = g.client.Projects.ListUserProjects(g.manager.Opts.User, glOpts)
|
_projects, resp, err = g.client.Projects.ListUserProjects(g.manager.Opts.User, glOpts)
|
||||||
|
|
||||||
} else if g.manager.Opts.Organization != "" {
|
} else if g.manager.Opts.Organization != "" {
|
||||||
glOpts := &gitlab.ListGroupProjectsOptions{
|
glOpts := &gitlab.ListGroupProjectsOptions{
|
||||||
ListOptions: listOpts,
|
ListOptions: listOpts,
|
||||||
}
|
}
|
||||||
projects, resp, err = g.client.Groups.ListGroupProjects(g.manager.Opts.Organization, glOpts)
|
_projects, resp, err = g.client.Groups.ListGroupProjects(g.manager.Opts.Organization, glOpts)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
projects = append(projects, _projects...)
|
for _, p := range _projects {
|
||||||
|
if g.manager.Opts.ExcludeForks && p.ForkedFromProject != nil {
|
||||||
|
log.Debugf("excluding forked repo: %s", p.Name)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
projects = append(projects, p)
|
||||||
|
}
|
||||||
|
|
||||||
if resp == nil {
|
if resp == nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -72,7 +89,7 @@ func (g *Gitlab) Audit() {
|
|||||||
|
|
||||||
// iterate of gitlab projects
|
// iterate of gitlab projects
|
||||||
for _, p := range projects {
|
for _, p := range projects {
|
||||||
r := audit.NewRepo(&g.manager)
|
r := audit.NewRepo(g.manager)
|
||||||
cloneOpts := g.manager.CloneOptions
|
cloneOpts := g.manager.CloneOptions
|
||||||
cloneOpts.URL = p.HTTPURLToRepo
|
cloneOpts.URL = p.HTTPURLToRepo
|
||||||
err := r.Clone(cloneOpts)
|
err := r.Clone(cloneOpts)
|
||||||
|
|||||||
+4
-3
@@ -20,11 +20,12 @@ type Host interface {
|
|||||||
// Run kicks off a host audit. This function accepts a manager and determines what host it should audit
|
// Run kicks off a host audit. This function accepts a manager and determines what host it should audit
|
||||||
func Run(m *manager.Manager) error {
|
func Run(m *manager.Manager) error {
|
||||||
var host Host
|
var host Host
|
||||||
|
var err error
|
||||||
switch getHost(m.Opts.Host) {
|
switch getHost(m.Opts.Host) {
|
||||||
case _github:
|
case _github:
|
||||||
host = NewGithubClient(*m)
|
host, err = NewGithubClient(m)
|
||||||
case _gitlab:
|
case _gitlab:
|
||||||
host = NewGitlabClient(*m)
|
host, err = NewGitlabClient(m)
|
||||||
default:
|
default:
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -34,7 +35,7 @@ func Run(m *manager.Manager) error {
|
|||||||
} else {
|
} else {
|
||||||
host.Audit()
|
host.Audit()
|
||||||
}
|
}
|
||||||
return nil
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func getHost(host string) int {
|
func getHost(host string) int {
|
||||||
|
|||||||
@@ -1,16 +1,18 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/hako/durafmt"
|
"io/ioutil"
|
||||||
log "github.com/sirupsen/logrus"
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/audit"
|
"github.com/zricethezav/gitleaks/audit"
|
||||||
"github.com/zricethezav/gitleaks/config"
|
"github.com/zricethezav/gitleaks/config"
|
||||||
"github.com/zricethezav/gitleaks/hosts"
|
"github.com/zricethezav/gitleaks/hosts"
|
||||||
"github.com/zricethezav/gitleaks/manager"
|
"github.com/zricethezav/gitleaks/manager"
|
||||||
"github.com/zricethezav/gitleaks/options"
|
"github.com/zricethezav/gitleaks/options"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"github.com/hako/durafmt"
|
||||||
"time"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|||||||
+105
-66
@@ -1,22 +1,29 @@
|
|||||||
package manager
|
package manager
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/sha1"
|
||||||
|
"encoding/csv"
|
||||||
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/hako/durafmt"
|
|
||||||
"github.com/mattn/go-colorable"
|
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"github.com/zricethezav/gitleaks/config"
|
|
||||||
"github.com/zricethezav/gitleaks/options"
|
|
||||||
"gopkg.in/src-d/go-git.v4"
|
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"runtime"
|
"runtime"
|
||||||
"sync"
|
"sync"
|
||||||
"text/tabwriter"
|
"text/tabwriter"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/zricethezav/gitleaks/config"
|
||||||
|
"github.com/zricethezav/gitleaks/options"
|
||||||
|
|
||||||
|
"github.com/hako/durafmt"
|
||||||
|
"github.com/mattn/go-colorable"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
"gopkg.in/src-d/go-git.v4"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const maxLineLen = 200
|
||||||
|
|
||||||
// Manager is a struct containing options and configs as well CloneOptions and CloneDir.
|
// Manager is a struct containing options and configs as well CloneOptions and CloneDir.
|
||||||
// This struct is passed into each NewRepo so we are not passing around the manager in func params.
|
// This struct is passed into each NewRepo so we are not passing around the manager in func params.
|
||||||
type Manager struct {
|
type Manager struct {
|
||||||
@@ -26,9 +33,10 @@ type Manager struct {
|
|||||||
CloneOptions *git.CloneOptions
|
CloneOptions *git.CloneOptions
|
||||||
CloneDir string
|
CloneDir string
|
||||||
|
|
||||||
leaks []Leak
|
leaks []Leak
|
||||||
leakChan chan Leak
|
leakChan chan Leak
|
||||||
leakWG *sync.WaitGroup
|
leakWG *sync.WaitGroup
|
||||||
|
leakCache map[string]bool
|
||||||
|
|
||||||
stopChan chan os.Signal
|
stopChan chan os.Signal
|
||||||
metadata Metadata
|
metadata Metadata
|
||||||
@@ -38,17 +46,18 @@ type Manager struct {
|
|||||||
// Leak is a struct that contains information about some line of code that contains
|
// Leak is a struct that contains information about some line of code that contains
|
||||||
// sensitive information as determined by the rules set in a gitleaks config
|
// sensitive information as determined by the rules set in a gitleaks config
|
||||||
type Leak struct {
|
type Leak struct {
|
||||||
Line string `json:"line"`
|
Line string `json:"line"`
|
||||||
Offender string `json:"offender"`
|
Offender string `json:"offender"`
|
||||||
Commit string `json:"commit"`
|
Commit string `json:"commit"`
|
||||||
Repo string `json:"repo"`
|
Repo string `json:"repo"`
|
||||||
Rule string `json:"rule"`
|
Rule string `json:"rule"`
|
||||||
Message string `json:"commitMessage"`
|
Message string `json:"commitMessage"`
|
||||||
Author string `json:"author"`
|
Author string `json:"author"`
|
||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
||||||
File string `json:"file"`
|
File string `json:"file"`
|
||||||
Date time.Time `json:"date"`
|
Date time.Time `json:"date"`
|
||||||
Tags string `json:"tags"`
|
Tags string `json:"tags"`
|
||||||
|
lookupHash string
|
||||||
}
|
}
|
||||||
|
|
||||||
// AuditTime is a type used to determine total audit time
|
// AuditTime is a type used to determine total audit time
|
||||||
@@ -70,7 +79,7 @@ type RegexTime struct {
|
|||||||
|
|
||||||
// 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 audit like timings and total commit counts.
|
||||||
type Metadata struct {
|
type Metadata struct {
|
||||||
mux sync.Mutex
|
mux *sync.Mutex
|
||||||
data map[string]interface{}
|
data map[string]interface{}
|
||||||
|
|
||||||
timings chan interface{}
|
timings chan interface{}
|
||||||
@@ -94,6 +103,42 @@ func init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewManager accepts options and returns a manager struct. The manager is a container for gitleaks configurations,
|
||||||
|
// options and channel receivers.
|
||||||
|
func NewManager(opts options.Options, cfg config.Config) (*Manager, error) {
|
||||||
|
cloneOpts, err := opts.CloneOptions()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
m := &Manager{
|
||||||
|
Opts: opts,
|
||||||
|
Config: cfg,
|
||||||
|
CloneOptions: cloneOpts,
|
||||||
|
|
||||||
|
stopChan: make(chan os.Signal, 1),
|
||||||
|
leakChan: make(chan Leak),
|
||||||
|
leakWG: &sync.WaitGroup{},
|
||||||
|
leakCache: make(map[string]bool),
|
||||||
|
metaWG: &sync.WaitGroup{},
|
||||||
|
metadata: Metadata{
|
||||||
|
RegexTime: make(map[string]int64),
|
||||||
|
timings: make(chan interface{}),
|
||||||
|
data: make(map[string]interface{}),
|
||||||
|
mux: new(sync.Mutex),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
signal.Notify(m.stopChan, os.Interrupt)
|
||||||
|
|
||||||
|
// start receiving leaks and metadata
|
||||||
|
go m.receiveLeaks()
|
||||||
|
go m.receiveMetadata()
|
||||||
|
go m.receiveInterrupt()
|
||||||
|
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
|
|
||||||
// GetLeaks returns all available leaks
|
// GetLeaks returns all available leaks
|
||||||
func (manager *Manager) GetLeaks() []Leak {
|
func (manager *Manager) GetLeaks() []Leak {
|
||||||
// need to wait for any straggling leaks
|
// need to wait for any straggling leaks
|
||||||
@@ -104,15 +149,36 @@ func (manager *Manager) GetLeaks() []Leak {
|
|||||||
// 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 audit pkg. This is the public function
|
||||||
// that allows other packages to send leaks to the manager.
|
// that allows other packages to send leaks to the manager.
|
||||||
func (manager *Manager) SendLeaks(l Leak) {
|
func (manager *Manager) SendLeaks(l Leak) {
|
||||||
|
if len(l.Line) > maxLineLen {
|
||||||
|
l.Line = l.Line[0:maxLineLen-1] + "..."
|
||||||
|
}
|
||||||
|
if len(l.Offender) > maxLineLen {
|
||||||
|
l.Offender = l.Offender[0:maxLineLen-1] + "..."
|
||||||
|
}
|
||||||
|
h := sha1.New()
|
||||||
|
h.Write([]byte(l.Commit + l.Offender + l.File))
|
||||||
|
l.lookupHash = hex.EncodeToString(h.Sum(nil))
|
||||||
manager.leakWG.Add(1)
|
manager.leakWG.Add(1)
|
||||||
manager.leakChan <- l
|
manager.leakChan <- l
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (manager *Manager) alreadySeen(leak Leak) bool {
|
||||||
|
if _, ok := manager.leakCache[leak.lookupHash]; ok {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
manager.leakCache[leak.lookupHash] = true
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// receiveLeaks listens to leakChan for incoming leaks. If any are received, they are appended to the
|
// receiveLeaks listens to leakChan for incoming leaks. If any are received, they are appended to the
|
||||||
// manager's leaks for future reporting. If the -v/--verbose option is set the leaks will marshaled into
|
// manager's leaks for future reporting. If the -v/--verbose option is set the leaks will marshaled into
|
||||||
// json and printed out.
|
// json and printed out.
|
||||||
func (manager *Manager) receiveLeaks() {
|
func (manager *Manager) receiveLeaks() {
|
||||||
for leak := range manager.leakChan {
|
for leak := range manager.leakChan {
|
||||||
|
if manager.alreadySeen(leak) {
|
||||||
|
manager.leakWG.Done()
|
||||||
|
continue
|
||||||
|
}
|
||||||
manager.leaks = append(manager.leaks, leak)
|
manager.leaks = append(manager.leaks, leak)
|
||||||
if manager.Opts.Verbose {
|
if manager.Opts.Verbose {
|
||||||
var b []byte
|
var b []byte
|
||||||
@@ -165,40 +231,6 @@ func (manager *Manager) RecordTime(t interface{}) {
|
|||||||
manager.metadata.timings <- t
|
manager.metadata.timings <- t
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewManager accepts options and returns a manager struct. The manager is a container for gitleaks configurations,
|
|
||||||
// options and channel receivers.
|
|
||||||
func NewManager(opts options.Options, cfg config.Config) (*Manager, error) {
|
|
||||||
cloneOpts, err := opts.CloneOptions()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
m := &Manager{
|
|
||||||
Opts: opts,
|
|
||||||
Config: cfg,
|
|
||||||
CloneOptions: cloneOpts,
|
|
||||||
|
|
||||||
stopChan: make(chan os.Signal, 1),
|
|
||||||
leakChan: make(chan Leak),
|
|
||||||
leakWG: &sync.WaitGroup{},
|
|
||||||
metaWG: &sync.WaitGroup{},
|
|
||||||
metadata: Metadata{
|
|
||||||
RegexTime: make(map[string]int64),
|
|
||||||
timings: make(chan interface{}),
|
|
||||||
data: make(map[string]interface{}),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
signal.Notify(m.stopChan, os.Interrupt)
|
|
||||||
|
|
||||||
// start receiving leaks and metadata
|
|
||||||
go m.receiveLeaks()
|
|
||||||
go m.receiveMetadata()
|
|
||||||
go m.receiveInterrupt()
|
|
||||||
|
|
||||||
return m, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// DebugOutput logs metadata and other messages that occurred during a gitleaks audit
|
// DebugOutput logs metadata and other messages that occurred during a gitleaks audit
|
||||||
func (manager *Manager) DebugOutput() {
|
func (manager *Manager) DebugOutput() {
|
||||||
log.Debugf("-------------------------\n")
|
log.Debugf("-------------------------\n")
|
||||||
@@ -216,9 +248,9 @@ func (manager *Manager) DebugOutput() {
|
|||||||
log.Debugf("| Individual Regex Times |\n")
|
log.Debugf("| Individual Regex Times |\n")
|
||||||
log.Debugf("--------------------------\n")
|
log.Debugf("--------------------------\n")
|
||||||
for k, v := range manager.metadata.RegexTime {
|
for k, v := range manager.metadata.RegexTime {
|
||||||
fmt.Fprintf(w, "%s\t%s\n", k, durafmt.Parse(time.Duration(v)*time.Nanosecond))
|
_, _ = fmt.Fprintf(w, "%s\t%s\n", k, durafmt.Parse(time.Duration(v)*time.Nanosecond))
|
||||||
}
|
}
|
||||||
w.Flush()
|
_ = w.Flush()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,16 +273,23 @@ func (manager *Manager) Report() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
encoder := json.NewEncoder(file)
|
if manager.Opts.ReportFormat == "json" {
|
||||||
encoder.SetIndent("", " ")
|
encoder := json.NewEncoder(file)
|
||||||
err = encoder.Encode(manager.leaks)
|
encoder.SetIndent("", " ")
|
||||||
if err != nil {
|
err = encoder.Encode(manager.leaks)
|
||||||
return err
|
if err != nil {
|
||||||
}
|
return err
|
||||||
err = file.Close()
|
}
|
||||||
if err != nil {
|
} else {
|
||||||
return err
|
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)
|
log.Infof("report written to %s", manager.Opts.Report)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
+19
-1
@@ -1,8 +1,11 @@
|
|||||||
package manager
|
package manager
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/rand"
|
||||||
|
"fmt"
|
||||||
"github.com/zricethezav/gitleaks/config"
|
"github.com/zricethezav/gitleaks/config"
|
||||||
"github.com/zricethezav/gitleaks/options"
|
"github.com/zricethezav/gitleaks/options"
|
||||||
|
"io"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -28,7 +31,10 @@ func TestSendReceiveLeaks(t *testing.T) {
|
|||||||
m, _ := NewManager(opts, cfg)
|
m, _ := NewManager(opts, cfg)
|
||||||
|
|
||||||
for i := 0; i < test.leaksToAdd; i++ {
|
for i := 0; i < test.leaksToAdd; i++ {
|
||||||
m.SendLeaks(Leak{})
|
// we are testing the sync of sending/receiving leaks so we need
|
||||||
|
// the hash generation in sendLeaks to be unique for each iteration
|
||||||
|
// so I'm just setting the offender string as a uuid
|
||||||
|
m.SendLeaks(Leak{Offender: newUUID()})
|
||||||
}
|
}
|
||||||
got := m.GetLeaks()
|
got := m.GetLeaks()
|
||||||
if len(got) != test.leaksToAdd {
|
if len(got) != test.leaksToAdd {
|
||||||
@@ -86,3 +92,15 @@ func TestSendReceiveMeta(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// newUUID generates a random UUID according to RFC 4122
|
||||||
|
// Ripped from https://play.golang.org/p/4FkNSiUDMg
|
||||||
|
func newUUID() string {
|
||||||
|
uuid := make([]byte, 16)
|
||||||
|
io.ReadFull(rand.Reader, uuid)
|
||||||
|
// variant bits; see section 4.1.1
|
||||||
|
uuid[8] = uuid[8]&^0xc0 | 0x80
|
||||||
|
// version 4 (pseudo-random); see section 4.1.3
|
||||||
|
uuid[6] = uuid[6]&^0xf0 | 0x40
|
||||||
|
return fmt.Sprintf("%x-%x-%x-%x-%x", uuid[0:4], uuid[4:6], uuid[6:8], uuid[8:10], uuid[10:])
|
||||||
|
}
|
||||||
+41
-29
@@ -2,16 +2,18 @@ package options
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/jessevdk/go-flags"
|
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"github.com/zricethezav/gitleaks/version"
|
|
||||||
"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"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"os/user"
|
"os/user"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/zricethezav/gitleaks/version"
|
||||||
|
|
||||||
|
"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
|
// No leaks or early exit due to invalid options
|
||||||
@@ -25,33 +27,39 @@ const (
|
|||||||
|
|
||||||
// Options stores values of command line options
|
// Options stores values of command line options
|
||||||
type Options struct {
|
type Options struct {
|
||||||
Verbose bool `short:"v" long:"verbose" description:"Show verbose output from audit"`
|
Verbose bool `short:"v" long:"verbose" description:"Show verbose output from audit"`
|
||||||
Repo string `short:"r" long:"repo" description:"Target repository"`
|
Repo string `short:"r" long:"repo" description:"Target repository"`
|
||||||
Config string `long:"config" description:"config path"`
|
Config string `long:"config" description:"config path"`
|
||||||
Disk bool `long:"disk" description:"Clones repo(s) to disk"`
|
Disk bool `long:"disk" description:"Clones repo(s) to disk"`
|
||||||
Version bool `long:"version" description:"version number"`
|
Version bool `long:"version" description:"version number"`
|
||||||
Timeout int `long:"timeout" description:"Timeout (s)"`
|
Username string `long:"username" description:"Username for git repo"`
|
||||||
Username string `long:"username" description:"Username for git repo"`
|
Password string `long:"password" description:"Password for git repo"`
|
||||||
Password string `long:"password" description:"Password for git repo"`
|
AccessToken string `long:"access-token" description:"Access token for git repo"`
|
||||||
AccessToken string `long:"access-token" description:"Access token for git repo"`
|
Commit string `long:"commit" description:"sha of commit to audit"`
|
||||||
Commit string `long:"commit" description:"sha of commit to audit"`
|
Threads int `long:"threads" description:"Maximum number of threads gitleaks spawns"`
|
||||||
Threads int `long:"threads" description:"Maximum number of threads gitleaks spawns"`
|
SSH string `long:"ssh-key" description:"path to ssh key used for auth"`
|
||||||
SSH string `long:"ssh-key" description:"path to ssh key used for auth"`
|
Uncommited bool `long:"uncommitted" description:"run gitleaks on uncommitted code"`
|
||||||
Uncommited bool `long:"uncommitted" description:"run gitleaks on uncommitted code"`
|
RepoPath string `long:"repo-path" description:"Path to repo"`
|
||||||
RepoPath string `long:"repo-path" description:"Path to repo"`
|
OwnerPath string `long:"owner-path" description:"Path to owner directory (repos discovered)"`
|
||||||
OwnerPath string `long:"owner-path" description:"Path to owner directory (repos discovered)"`
|
Branch string `long:"branch" description:"Branch to audit"`
|
||||||
Branch string `long:"branch" description:"Branch to audit"`
|
Report string `long:"report" description:"path to write json leaks file"`
|
||||||
Report string `long:"report" description:"path to write json leaks file"`
|
ReportFormat string `long:"report-format" default:"json" description:"json or csv"`
|
||||||
Redact bool `long:"redact" description:"redact secrets from log messages and leaks"`
|
Redact bool `long:"redact" description:"redact secrets from log messages and leaks"`
|
||||||
Debug bool `long:"debug" description:"log debug messages"`
|
Debug bool `long:"debug" description:"log debug messages"`
|
||||||
RepoConfig bool `long:"repo-config" description:"Load config from target repo. Config file must be \".gitleaks.toml\" or \"gitleaks.toml\""`
|
RepoConfig bool `long:"repo-config" description:"Load config from target repo. Config file must be \".gitleaks.toml\" or \"gitleaks.toml\""`
|
||||||
PrettyPrint bool `long:"pretty" description:"Pretty print json if leaks are present"`
|
PrettyPrint bool `long:"pretty" description:"Pretty print json if leaks are present"`
|
||||||
|
CommitFrom string `long:"commit-from" description:"Commit to start 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"`
|
||||||
|
|
||||||
// Hosts
|
// Hosts
|
||||||
Host string `long:"host" description:"git hosting service like gitlab or github. Supported hosts include: Github, Gitlab"`
|
Host string `long:"host" description:"git hosting service like gitlab or github. Supported hosts include: Github, Gitlab"`
|
||||||
|
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"`
|
Organization string `long:"org" description:"organization to audit"`
|
||||||
User string `long:"user" description:"user to audit"` //work
|
User string `long:"user" description:"user to audit"`
|
||||||
PullRequest string `long:"pr" description:"pull/merge request url"`
|
PullRequest string `long:"pr" description:"pull/merge request url"`
|
||||||
|
ExcludeForks bool `long:"exclude-forks" description:"audit excludes forks"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParseOptions is responsible for parsing options passed in by cli. An Options struct
|
// ParseOptions is responsible for parsing options passed in by cli. An Options struct
|
||||||
@@ -71,7 +79,11 @@ func ParseOptions() (Options, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if opts.Version {
|
if opts.Version {
|
||||||
fmt.Printf("%s\n", version.Version)
|
if version.Version == "" {
|
||||||
|
fmt.Println("Gitleaks uses LDFLAGS to pull most recent version. Build with 'make build' for version")
|
||||||
|
} else {
|
||||||
|
fmt.Printf("%s\n", version.Version)
|
||||||
|
}
|
||||||
os.Exit(Success)
|
os.Exit(Success)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -116,19 +116,6 @@
|
|||||||
"date": "2019-10-25T13:01:27-04:00",
|
"date": "2019-10-25T13:01:27-04:00",
|
||||||
"tags": "key, API, generic"
|
"tags": "key, API, generic"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"line": "Here's an AWS secret: AKIALALEMEL33243OLIAE",
|
|
||||||
"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"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"line": "\nHere's an AWS secret: AKIALALEMEL33243OLIAE",
|
"line": "\nHere's an AWS secret: AKIALALEMEL33243OLIAE",
|
||||||
"offender": "AKIALALEMEL33243OLIA",
|
"offender": "AKIALALEMEL33243OLIA",
|
||||||
@@ -245,369 +232,5 @@
|
|||||||
"file": "secrets.md",
|
"file": "secrets.md",
|
||||||
"date": "2019-10-25T13:35:03-04:00",
|
"date": "2019-10-25T13:35:03-04:00",
|
||||||
"tags": "key, API, generic"
|
"tags": "key, API, generic"
|
||||||
},
|
|
||||||
{
|
|
||||||
"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"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"line": " const AWSSECRET = \"99432bfewaf823ec3294e231\"",
|
|
||||||
"offender": "SECRET = \"99432bfewaf823ec3294e231\"",
|
|
||||||
"commit": "f61cd8587b7ac1d75a89a0c9af870a2f24c60263",
|
|
||||||
"repo": "test_repo_3",
|
|
||||||
"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\"",
|
|
||||||
"offender": "AKIALALEMEL33243OLIB",
|
|
||||||
"commit": "b2eb34a61c988afd9b4aaa9dd58c8dd7d5f14dba",
|
|
||||||
"repo": "test_repo_3",
|
|
||||||
"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"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"line": " const AWSSECRET = \"99432bfewaf823ec3294e231\"",
|
|
||||||
"offender": "SECRET = \"99432bfewaf823ec3294e231\"",
|
|
||||||
"commit": "b2eb34a61c988afd9b4aaa9dd58c8dd7d5f14dba",
|
|
||||||
"repo": "test_repo_3",
|
|
||||||
"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_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"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"",
|
|
||||||
"offender": "secret: \"AKIALALEMEL33243OLIAE\"",
|
|
||||||
"commit": "996865bb912f3bc45898a370a13aadb315014b55",
|
|
||||||
"repo": "test_repo_3",
|
|
||||||
"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\"",
|
|
||||||
"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"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"",
|
|
||||||
"offender": "secret: \"AKIALALEMEL33243OLIAE\"",
|
|
||||||
"commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c",
|
|
||||||
"repo": "test_repo_3",
|
|
||||||
"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": "Here's an AWS secret: AKIALALEMEL33243OLIAE",
|
|
||||||
"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"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"line": "\nHere's an AWS secret: AKIALALEMEL33243OLIAE",
|
|
||||||
"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"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"line": "const AWSKEY = \"AKIALALEMEL33243OLIAE\"",
|
|
||||||
"offender": "AKIALALEMEL33243OLIA",
|
|
||||||
"commit": "cd5eb8bef855f73c46b97b4c088badffdc40ebe9",
|
|
||||||
"repo": "test_repo_4",
|
|
||||||
"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_4",
|
|
||||||
"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"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"line": "const AWSKEY = \"AKIALALEMEL33243OLIAE\"",
|
|
||||||
"offender": "AKIALALEMEL33243OLIA",
|
|
||||||
"commit": "84ac4e80d4dbf2c968b64e9d4005f5079795bb81",
|
|
||||||
"repo": "test_repo_4",
|
|
||||||
"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"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"line": "const AWSSECRET = \"99432bfewaf823ec3294e231\"",
|
|
||||||
"offender": "SECRET = \"99432bfewaf823ec3294e231\"",
|
|
||||||
"commit": "84ac4e80d4dbf2c968b64e9d4005f5079795bb81",
|
|
||||||
"repo": "test_repo_4",
|
|
||||||
"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_4",
|
|
||||||
"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_4",
|
|
||||||
"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"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"line": "AWS secret: \"AKIALALEMEL33243OLIAE\"",
|
|
||||||
"offender": "AKIALALEMEL33243OLIA",
|
|
||||||
"commit": "deea550dd6c7acaf0e59432600593533984a2125",
|
|
||||||
"repo": "test_repo_4",
|
|
||||||
"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"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"line": "AWS secret: \"AKIALALEMEL33243OLIAE\"",
|
|
||||||
"offender": "secret: \"AKIALALEMEL33243OLIAE\"",
|
|
||||||
"commit": "deea550dd6c7acaf0e59432600593533984a2125",
|
|
||||||
"repo": "test_repo_4",
|
|
||||||
"rule": "Generic Credential",
|
|
||||||
"commitMessage": "dev branch\n",
|
|
||||||
"author": "zach rice",
|
|
||||||
"email": "zricer@protonmail.com",
|
|
||||||
"file": "secrets.md",
|
|
||||||
"date": "2019-10-25T13:35:03-04:00",
|
|
||||||
"tags": "key, API, generic"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"",
|
|
||||||
"offender": "AKIALALEMEL33243OLIB",
|
|
||||||
"commit": "f61cd8587b7ac1d75a89a0c9af870a2f24c60263",
|
|
||||||
"repo": "test_repo_4",
|
|
||||||
"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_4",
|
|
||||||
"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\"",
|
|
||||||
"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"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"line": " const AWSSECRET = \"99432bfewaf823ec3294e231\"",
|
|
||||||
"offender": "SECRET = \"99432bfewaf823ec3294e231\"",
|
|
||||||
"commit": "b2eb34a61c988afd9b4aaa9dd58c8dd7d5f14dba",
|
|
||||||
"repo": "test_repo_4",
|
|
||||||
"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_4",
|
|
||||||
"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_4",
|
|
||||||
"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\"",
|
|
||||||
"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"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"",
|
|
||||||
"offender": "secret: \"AKIALALEMEL33243OLIAE\"",
|
|
||||||
"commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c",
|
|
||||||
"repo": "test_repo_4",
|
|
||||||
"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": "Here's an AWS secret: AKIALALEMEL33243OLIAE",
|
|
||||||
"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"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"line": "\nHere's an AWS secret: AKIALALEMEL33243OLIAE",
|
|
||||||
"offender": "AKIALALEMEL33243OLIA",
|
|
||||||
"commit": "b10b3e2cb320a8c211fda94c4567299d37de7776",
|
|
||||||
"repo": "test_repo_4",
|
|
||||||
"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"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||||
|
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||||
|
"commit": "6557c92612d3b35979bd426d429255b3bf9fab74",
|
||||||
|
"repo": "test_repo_1",
|
||||||
|
"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"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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\"",
|
||||||
|
"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"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"line": "const AWSKEY = \"AKIALALEMEL33243OLIAE\"",
|
||||||
|
"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"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"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",
|
"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}]",
|
"offender": "Entropy range [{P1:4.5 P2:4.7}]",
|
||||||
"commit": "d8ac0b73aeeb45843319cdc5ce506516eb49bf7a",
|
"commit": "d8ac0b73aeeb45843319cdc5ce506516eb49bf7a",
|
||||||
"repo": "test_repo_4",
|
"repo": "test_repo_4",
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
"tags": "entropy"
|
"tags": "entropy"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"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",
|
"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}]",
|
"offender": "Entropy range [{P1:4.5 P2:4.7}]",
|
||||||
"commit": "996865bb912f3bc45898a370a13aadb315014b55",
|
"commit": "996865bb912f3bc45898a370a13aadb315014b55",
|
||||||
"repo": "test_repo_4",
|
"repo": "test_repo_4",
|
||||||
|
|||||||
@@ -12,6 +12,19 @@
|
|||||||
"date": "2019-10-24T10:03:38-04:00",
|
"date": "2019-10-24T10:03:38-04:00",
|
||||||
"tags": ""
|
"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',",
|
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||||
|
|||||||
@@ -2,14 +2,14 @@
|
|||||||
{
|
{
|
||||||
"line": " aws_access_key_id='AKIAIO5FODNN7DXAMPLE'",
|
"line": " aws_access_key_id='AKIAIO5FODNN7DXAMPLE'",
|
||||||
"offender": "AKIAIO5FODNN7DXAMPLE",
|
"offender": "AKIAIO5FODNN7DXAMPLE",
|
||||||
"commit": "d274003914c707212cbe84e3e466a00013ccb639",
|
"commit": "0000000000000000000000000000000000000000",
|
||||||
"repo": "test_repo_1",
|
"repo": "test_repo_1",
|
||||||
"rule": "AWS Manager ID",
|
"rule": "AWS Manager ID",
|
||||||
"commitMessage": "comment\n",
|
"commitMessage": "***STAGED CHANGES***",
|
||||||
"author": "zach rice",
|
"author": "",
|
||||||
"email": "zricer@protonmail.com",
|
"email": "",
|
||||||
"file": "server.test.py",
|
"file": "server.test.py",
|
||||||
"date": "2019-10-24T10:03:38-04:00",
|
"date": "1970-01-01T00:00:00Z",
|
||||||
"tags": "key, AWS"
|
"tags": "key, AWS"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -77,19 +77,6 @@
|
|||||||
"date": "2019-10-25T13:01:27-04:00",
|
"date": "2019-10-25T13:01:27-04:00",
|
||||||
"tags": "key, AWS"
|
"tags": "key, AWS"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"line": "Here's an AWS secret: AKIALALEMEL33243OLIAE",
|
|
||||||
"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"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"line": "\nHere's an AWS secret: AKIALALEMEL33243OLIAE",
|
"line": "\nHere's an AWS secret: AKIALALEMEL33243OLIAE",
|
||||||
"offender": "AKIALALEMEL33243OLIA",
|
"offender": "AKIALALEMEL33243OLIA",
|
||||||
|
|||||||
@@ -103,19 +103,6 @@
|
|||||||
"date": "2019-10-25T13:01:27-04:00",
|
"date": "2019-10-25T13:01:27-04:00",
|
||||||
"tags": "key, API, generic"
|
"tags": "key, API, generic"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"line": "Here's an AWS secret: AKIALALEMEL33243OLIAE",
|
|
||||||
"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"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"line": "\nHere's an AWS secret: AKIALALEMEL33243OLIAE",
|
"line": "\nHere's an AWS secret: AKIALALEMEL33243OLIAE",
|
||||||
"offender": "AKIALALEMEL33243OLIA",
|
"offender": "AKIALALEMEL33243OLIA",
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"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\"",
|
||||||
|
"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"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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",
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"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\"",
|
||||||
|
"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"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"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\"",
|
||||||
|
"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"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
]
|
||||||
Reference in new issue
Block a user