mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-26 19:30:55 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7b48cadf6d | ||
|
|
6eab8a7a0a | ||
|
|
c6d14e5b7d | ||
|
|
ce95cafd54 | ||
|
|
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 | ||
|
|
c6934f5eab | ||
|
|
f8c054b879 | ||
|
|
ad2a64c82b | ||
|
|
9e0028fe73 | ||
|
|
dfbd01a980 | ||
|
|
86737955de | ||
|
|
7f0b027486 | ||
|
|
4d04ea079f | ||
|
|
6e1c41b536 | ||
|
|
275232f8c8 | ||
|
|
c8f9560aa3 | ||
|
|
315ee56024 | ||
|
|
e446ba0738 | ||
|
|
2ccd40677d | ||
|
|
41ef2a8cd2 | ||
|
|
d8acd1354f | ||
|
|
e28cfd1ad5 | ||
|
|
e5f5e64cdb | ||
|
|
b55d88dc15 | ||
|
|
f3360cbf66 | ||
|
|
065b621604 | ||
|
|
fd87df475c | ||
|
|
c7b6792956 | ||
|
|
1f2d11003d | ||
|
|
6432f11a6b | ||
|
|
7d53fb5951 | ||
|
|
b9aa3ef97d | ||
|
|
c271497ecb | ||
|
|
e05c4645ac | ||
|
|
63d8e6e21b | ||
|
|
5bd59b0d8c | ||
|
|
464e152783 | ||
|
|
91406b0c4c | ||
|
|
04e81270cb | ||
|
|
69c6695765 | ||
|
|
9e0e050f92 | ||
|
|
b2efcf36c8 | ||
|
|
ba39abfb19 | ||
|
|
f47e1f71ee | ||
|
|
6d980b4eab | ||
|
|
ca18e8e2f6 | ||
|
|
ec436d7b33 | ||
|
|
38a511f6ba | ||
|
|
15ac1ffdd1 | ||
|
|
eb977ba237 | ||
|
|
9a6b1c3bbb | ||
|
|
95443e742c | ||
|
|
0c94db2d6b | ||
|
|
9808551eed | ||
|
|
b6fe5b08d3 | ||
|
|
5309811a09 | ||
|
|
3b6c198715 | ||
|
|
57bfa41b33 | ||
|
|
474266c0b5 | ||
|
|
c891470344 | ||
|
|
e6004da801 | ||
|
|
e18b1a884a | ||
|
|
faeb0914b2 | ||
|
|
d6578df998 | ||
|
|
f010513d17 | ||
|
|
d4be9602e3 | ||
|
|
7676690697 | ||
|
|
f4b9b6d0b3 | ||
|
|
7a3d155675 | ||
|
|
68b6388ef7 | ||
|
|
547e9768ec | ||
|
|
8608cf5b48 | ||
|
|
a08ddedb88 | ||
|
|
398366a615 | ||
|
|
7dfa3f2b48 | ||
|
|
2e7325ce03 | ||
|
|
cb74386ef0 | ||
|
|
87d6c588a6 | ||
|
|
df8a2d35a8 | ||
|
|
c4da547503 | ||
|
|
7bd55e33b5 | ||
|
|
256ace38d7 | ||
|
|
4c20d5d85c | ||
|
|
ac43c67a47 | ||
|
|
d2d68a7e44 | ||
|
|
27aee19a35 | ||
|
|
2a6bd1636f | ||
|
|
7b82e29e7e | ||
|
|
4fd2f06a0d | ||
|
|
8016dffe18 | ||
|
|
10004da36f | ||
|
|
633e06a7c7 | ||
|
|
660350c9b1 | ||
|
|
9122aa6cf4 | ||
|
|
56c89866a2 | ||
|
|
f9be4e543a | ||
|
|
042b82e2af | ||
|
|
9176896742 | ||
|
|
4ea0c66bec | ||
|
|
ae4542abf0 | ||
|
|
ac14d347de | ||
|
|
c2143c5843 | ||
|
|
e79ffc6ae8 | ||
|
|
a56c2341cf | ||
|
|
1c14586cde | ||
|
|
2b995fda44 | ||
|
|
5d68b48af3 | ||
|
|
f90a00b564 | ||
|
|
4bc7c13310 | ||
|
|
771055fd59 | ||
|
|
75c70bf804 | ||
|
|
c5f34a6704 | ||
|
|
463871a307 | ||
|
|
fa1080d066 | ||
|
|
52cfad1d08 | ||
|
|
9e294f5910 | ||
|
|
9f8326de56 | ||
|
|
79c3f99165 | ||
|
|
d4925443c8 | ||
|
|
fa27d32bfe | ||
|
|
230a52e3e3 | ||
|
|
15dedda59a | ||
|
|
3b45fb91e3 | ||
|
|
f378319395 | ||
|
|
98173b3aa6 | ||
|
|
36340c8f2f | ||
|
|
77b6d90a16 | ||
|
|
6b3bd46fa8 | ||
|
|
8485f88158 | ||
|
|
d2baa9e675 | ||
|
|
7fa9c802f5 | ||
|
|
8f1bc74e26 | ||
|
|
8de38be418 | ||
|
|
ec1ebd4686 | ||
|
|
81ddfbed88 | ||
|
|
63814f1eaf | ||
|
|
38a36add57 | ||
|
|
9e39927ac6 | ||
|
|
0ba9dda0f0 | ||
|
|
a24f9a2c92 | ||
|
|
f57158a893 | ||
|
|
1e3bf42464 | ||
|
|
9d6a75fbab | ||
|
|
6fa52ae7cc | ||
|
|
bb9c459a1a | ||
|
|
432c76a9d9 | ||
|
|
1cdf315bfa | ||
|
|
777601a0ea | ||
|
|
35d170018e | ||
|
|
af2e99ef45 | ||
|
|
734befb555 | ||
|
|
64c8d618a2 | ||
|
|
92bb4ea6fc | ||
|
|
98b025da72 | ||
|
|
af7717412f | ||
|
|
68c2a18f6f | ||
|
|
ea49078ffd | ||
|
|
b902d7310a | ||
|
|
3591560b34 | ||
|
|
949029ca89 | ||
|
|
cde0894711 | ||
|
|
342e9f80db | ||
|
|
96b0f4aab7 | ||
|
|
3af6a546ac | ||
|
|
6e086c4297 | ||
|
|
db08fc0564 | ||
|
|
dbb6d4cc5f | ||
|
|
d0f44da4c2 | ||
|
|
cb6b01cc5d | ||
|
|
392d79b9e2 | ||
|
|
f8e609d4bf | ||
|
|
573bf46fd1 | ||
|
|
d65592bbcc | ||
|
|
169a137e7f | ||
|
|
bd61f2d2f7 | ||
|
|
793bbc793f | ||
|
|
4aa7be2dbf | ||
|
|
35531233d9 | ||
|
|
54949bd62a | ||
|
|
e95a8a7158 | ||
|
|
de0a70a835 | ||
|
|
9f8feca926 | ||
|
|
c50187559b | ||
|
|
c2cf6327c2 | ||
|
|
1ea773ddfb | ||
|
|
79a8983bac | ||
|
|
7d5ed837a4 | ||
|
|
60267523e9 | ||
|
|
8153da6e9c | ||
|
|
5f6fb388ec | ||
|
|
ba49396755 | ||
|
|
40240cb5ee | ||
|
|
bba926693e | ||
|
|
9103834503 | ||
|
|
7e3c740592 | ||
|
|
35a59746df | ||
|
|
23b5ce3264 | ||
|
|
03c53d2978 | ||
|
|
695449d73d | ||
|
|
6bad1e7194 | ||
|
|
77dec1461b | ||
|
|
14d77f59d4 | ||
|
|
afb598cf15 | ||
|
|
b4c6fe92e0 | ||
|
|
f50577be1c | ||
|
|
c358ae9310 | ||
|
|
9554258d02 | ||
|
|
95ee2cc30e | ||
|
|
79a35f0c27 | ||
|
|
7a021cda9e | ||
|
|
447f7a04cb | ||
|
|
e5b62cbc7c | ||
|
|
6739a34f74 | ||
|
|
e502bf29de | ||
|
|
51b504bf99 | ||
|
|
107d582e7b | ||
|
|
ea42ed406f | ||
|
|
c869812875 | ||
|
|
4f7ce9c195 | ||
|
|
847687a637 | ||
|
|
94389137e8 | ||
|
|
98e6ba9378 | ||
|
|
e288db29a8 | ||
|
|
98aeee9b1d | ||
|
|
45a2aa8495 | ||
|
|
4b350987a1 | ||
|
|
3b2b754fe5 | ||
|
|
64e7afea98 | ||
|
|
16765c19cf | ||
|
|
87d916fc24 | ||
|
|
21b59fab5d | ||
|
|
9272e1e556 | ||
|
|
0a51dabb17 | ||
|
|
8c1cee4e00 | ||
|
|
4d5315e2ca | ||
|
|
88cc9bb363 | ||
|
|
80e41ee14c | ||
|
|
23489f3f18 | ||
|
|
a998ddc9d4 | ||
|
|
833963c1c1 | ||
|
|
4b11f87f80 | ||
|
|
923dcf0311 | ||
|
|
8896cf66cd | ||
|
|
df133ccaf8 | ||
|
|
23cd693d71 | ||
|
|
524d81fde9 | ||
|
|
d387f528c4 | ||
|
|
dcda26578b | ||
|
|
28639d3a49 | ||
|
|
19e23c9cbe | ||
|
|
160015b872 | ||
|
|
abdf2c47f0 | ||
|
|
8536f16ceb | ||
|
|
6862c13bf7 | ||
|
|
9939c638ec | ||
|
|
ed3a512b4b | ||
|
|
7c988c927d | ||
|
|
bde9af44ea | ||
|
|
eee4d05642 | ||
|
|
9144594d77 | ||
|
|
1cb15242fd | ||
|
|
08498600d1 | ||
|
|
88c0c7779b | ||
|
|
67454d109e | ||
|
|
ce603c73b4 | ||
|
|
55218fc8f8 | ||
|
|
5d81c650e8 | ||
|
|
0726209172 | ||
|
|
bfec8aca51 | ||
|
|
a9b30edb06 | ||
|
|
cc6d698e63 | ||
|
|
2ba97d0fa3 | ||
|
|
d299b5aa7f | ||
|
|
0a209b60a5 | ||
|
|
fe8c6271f2 | ||
|
|
42fb085684 | ||
|
|
3faec00bf9 | ||
|
|
93669f1ee8 | ||
|
|
fad98cbde2 | ||
|
|
8eb28cbb4c | ||
|
|
9dc9a8e62a | ||
|
|
e6caef0d94 | ||
|
|
5e289ed0cc | ||
|
|
d99588fe19 | ||
|
|
a7ccb7a9d1 | ||
|
|
f32abb921d | ||
|
|
e8851c1f99 | ||
|
|
f3a8359ac0 | ||
|
|
829e8fed8c | ||
|
|
c7e3605bff | ||
|
|
c1774b1596 | ||
|
|
35710a7428 | ||
|
|
c7ba4d8bbf | ||
|
|
5585e10933 | ||
|
|
23d5bf0b51 | ||
|
|
b1c7a84fae | ||
|
|
60801b336a | ||
|
|
851ea3df3c | ||
|
|
d482577e47 | ||
|
|
94e7a25b5b | ||
|
|
45d94fa013 | ||
|
|
b4e69ecd37 | ||
|
|
1c2820b4f1 | ||
|
|
215c3f6623 | ||
|
|
39b162cadf | ||
|
|
e0c717c3a3 | ||
|
|
ebb9be999f | ||
|
|
5fbb15be62 | ||
|
|
8922546a00 | ||
|
|
38b7fc3cfb | ||
|
|
8a76e0af27 | ||
|
|
1f80d14f3f | ||
|
|
91eb014f17 | ||
|
|
6122092224 | ||
|
|
55102bd461 | ||
|
|
9927c0bd4b | ||
|
|
ba6f0c4d88 | ||
|
|
a52abe0b31 | ||
|
|
b1ae2a02fe | ||
|
|
f7fca41beb | ||
|
|
a257e9ed2e | ||
|
|
c51944c4d2 | ||
|
|
8e59bf766a | ||
|
|
fa498287b9 | ||
|
|
c77421d077 | ||
|
|
fe977ea857 | ||
|
|
ccef3680d5 | ||
|
|
2c80ad5ea9 | ||
|
|
f5ae1ae88b | ||
|
|
f653ab71c2 | ||
|
|
aec926df5e | ||
|
|
7bbf07e7e6 | ||
|
|
9f3ae4efa0 | ||
|
|
2fd1d44e0a | ||
|
|
e2060e9cd3 | ||
|
|
ce44961e6e | ||
|
|
078b951a43 | ||
|
|
b6b3e768dc | ||
|
|
2fadf219d9 | ||
|
|
ae71ce6ea0 | ||
|
|
041c11d9fc | ||
|
|
c019a9d80d | ||
|
|
0ed0489c2d | ||
|
|
2d27ce7cdf | ||
|
|
032c616f63 | ||
|
|
36c31bf181 | ||
|
|
d85c8d8abd | ||
|
|
39c9cb617c | ||
|
|
648ae701bf | ||
|
|
9dd624affa | ||
|
|
17efe94f95 | ||
|
|
25736d115f | ||
|
|
0d75136c1c | ||
|
|
7919e15a65 | ||
|
|
faca0e14d9 | ||
|
|
59f1f02480 | ||
|
|
c8880ed911 | ||
|
|
095279d60c | ||
|
|
91c39935e4 | ||
|
|
d972792aa1 | ||
|
|
9d544f474a | ||
|
|
01c54e55e7 | ||
|
|
4b21bbef2e | ||
|
|
9e87d94ce7 | ||
|
|
93380ad86a | ||
|
|
a63f5059f2 |
No files matched your search
@@ -0,0 +1,3 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: [zricethezav]
|
||||
@@ -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?
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
# Binaries for programs and plugins
|
||||
*.exe
|
||||
*.exe~
|
||||
*.dll
|
||||
*.so
|
||||
*.dylib
|
||||
*.DS_STORE
|
||||
*.idea
|
||||
gitleaks
|
||||
build
|
||||
|
||||
# Test binary
|
||||
*.out
|
||||
+5
-5
@@ -1,7 +1,7 @@
|
||||
language: go
|
||||
go:
|
||||
- 1.9
|
||||
|
||||
go:
|
||||
- 1.13.x
|
||||
services:
|
||||
- docker
|
||||
script:
|
||||
- go test -v
|
||||
|
||||
- make test
|
||||
@@ -1,26 +0,0 @@
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
0.2.0
|
||||
-----
|
||||
Version 0.2.0 of Gitleaks is the first version update since this got relatively popular. Based on the issues raised it seems that folks want better support for integration into their pipelines. I hear ya. This is what this update tries to provide. So... what are the changes?
|
||||
|
||||
* Additionally regex checking
|
||||
* $HOME/.gitleaks/ directory for clones and reports
|
||||
* Clone into temp dir option
|
||||
* Persistent repos for Orgs and Users (no more re-cloning)
|
||||
* Pagination for Org/User list... no more partial repo lists
|
||||
* Since commit option
|
||||
* Updated README
|
||||
* Multi-staged Docker build
|
||||
* Travis CI
|
||||
|
||||
|
||||
0.1.0
|
||||
-----
|
||||
|
||||
Version 0.1.0 of Gitleaks demonstrates:
|
||||
|
||||
* full git history search
|
||||
* regex/entropy checks
|
||||
* report generation
|
||||
+9
-21
@@ -1,29 +1,17 @@
|
||||
FROM golang:1.10.0 AS build
|
||||
|
||||
ENV PROJECT /go/src/github.com/zricethezav/gitleaks
|
||||
|
||||
RUN mkdir -p $PROJECT
|
||||
|
||||
WORKDIR ${PROJECT}
|
||||
|
||||
RUN git clone https://github.com/zricethezav/gitleaks.git . \
|
||||
&& CGO_ENABLED=0 go build -o bin/gitleaks *.go
|
||||
|
||||
FROM alpine:3.7
|
||||
|
||||
ENV PROJECT /go/src/github.com/zricethezav/gitleaks
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN apk update && apk upgrade && apk add --no-cache bash git openssh
|
||||
|
||||
COPY --from=build $PROJECT/bin/* /usr/bin/
|
||||
FROM golang:1.13.4 AS build
|
||||
WORKDIR /go/src/github.com/zricethezav/gitleaks
|
||||
ARG ldflags
|
||||
COPY . .
|
||||
RUN GO111MODULE=on CGO_ENABLED=0 go build -o bin/gitleaks -ldflags "-X="${ldflags} *.go
|
||||
|
||||
FROM alpine:3.10
|
||||
RUN apk add --no-cache bash git openssh
|
||||
COPY --from=build /go/src/github.com/zricethezav/gitleaks/bin/* /usr/bin/
|
||||
ENTRYPOINT ["gitleaks"]
|
||||
|
||||
# How to use me :
|
||||
|
||||
# docker build -t gitleaks .
|
||||
# docker run --rm --name=gitleaks gitleaks 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
|
||||
Generated
-65
@@ -1,65 +0,0 @@
|
||||
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
|
||||
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/golang/protobuf"
|
||||
packages = ["proto"]
|
||||
revision = "925541529c1fa6821df4e44ce2723319eb2be768"
|
||||
version = "v1.0.0"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/google/go-github"
|
||||
packages = ["github"]
|
||||
revision = "e48060a28fac52d0f1cb758bc8b87c07bac4a87d"
|
||||
version = "v15.0.0"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/google/go-querystring"
|
||||
packages = ["query"]
|
||||
revision = "53e6ce116135b80d037921a7fdd5138cf32d7a8a"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/mitchellh/go-homedir"
|
||||
packages = ["."]
|
||||
revision = "b8bc1bf767474819792c23f32d8286a45736f1c6"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "golang.org/x/net"
|
||||
packages = [
|
||||
"context",
|
||||
"context/ctxhttp"
|
||||
]
|
||||
revision = "cbe0f9307d0156177f9dd5dc85da1a31abc5f2fb"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "golang.org/x/oauth2"
|
||||
packages = [
|
||||
".",
|
||||
"internal"
|
||||
]
|
||||
revision = "543e37812f10c46c622c9575afd7ad22f22a12ba"
|
||||
|
||||
[[projects]]
|
||||
name = "google.golang.org/appengine"
|
||||
packages = [
|
||||
"internal",
|
||||
"internal/base",
|
||||
"internal/datastore",
|
||||
"internal/log",
|
||||
"internal/remote_api",
|
||||
"internal/urlfetch",
|
||||
"urlfetch"
|
||||
]
|
||||
revision = "150dc57a1b433e64154302bdc40b6bb8aefa313a"
|
||||
version = "v1.0.0"
|
||||
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
inputs-digest = "7333248555a2c0448201b30ce445c31106919113c141e5b6436580e21151d851"
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
||||
-42
@@ -1,42 +0,0 @@
|
||||
# Gopkg.toml example
|
||||
#
|
||||
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html
|
||||
# for detailed Gopkg.toml documentation.
|
||||
#
|
||||
# required = ["github.com/user/thing/cmd/thing"]
|
||||
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
|
||||
#
|
||||
# [[constraint]]
|
||||
# name = "github.com/user/project"
|
||||
# version = "1.0.0"
|
||||
#
|
||||
# [[constraint]]
|
||||
# name = "github.com/user/project2"
|
||||
# branch = "dev"
|
||||
# source = "github.com/myfork/project2"
|
||||
#
|
||||
# [[override]]
|
||||
# name = "github.com/x/y"
|
||||
# version = "2.4.0"
|
||||
#
|
||||
# [prune]
|
||||
# non-go = false
|
||||
# go-tests = true
|
||||
# unused-packages = true
|
||||
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/google/go-github"
|
||||
version = "15.0.0"
|
||||
|
||||
[[constraint]]
|
||||
branch = "master"
|
||||
name = "github.com/mitchellh/go-homedir"
|
||||
|
||||
[[constraint]]
|
||||
branch = "master"
|
||||
name = "golang.org/x/oauth2"
|
||||
|
||||
[prune]
|
||||
go-tests = true
|
||||
unused-packages = true
|
||||
@@ -1,674 +1,21 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
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.
|
||||
@@ -0,0 +1,45 @@
|
||||
.PHONY: test test-cover build release-builds
|
||||
|
||||
VERSION := `git fetch --tags && git tag | sort -V | tail -1`
|
||||
PKG=github.com/zricethezav/gitleaks
|
||||
LDFLAGS=-ldflags "-X=github.com/zricethezav/gitleaks/v3/version.Version=$(VERSION)"
|
||||
_LDFLAGS="github.com/zricethezav/gitleaks/v3/version.Version=$(VERSION)"
|
||||
COVER=--cover --coverprofile=cover.out
|
||||
|
||||
test-cover:
|
||||
go test ./... --race $(COVER) $(PKG) -v
|
||||
go tool cover -html=cover.out
|
||||
|
||||
test:
|
||||
go get golang.org/x/lint/golint
|
||||
go fmt ./...
|
||||
go vet ./...
|
||||
golint ./...
|
||||
go test ./... --race $(PKG) -v
|
||||
|
||||
test-integration:
|
||||
go test github.com/zricethezav/gitleaks/hosts -v -integration
|
||||
|
||||
build:
|
||||
go fmt ./...
|
||||
golint ./...
|
||||
go vet ./...
|
||||
go mod tidy
|
||||
go build $(LDFLAGS)
|
||||
|
||||
release-builds:
|
||||
rm -rf build
|
||||
mkdir build
|
||||
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" $(LDFLAGS)
|
||||
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" $(LDFLAGS)
|
||||
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" $(LDFLAGS)
|
||||
env GOOS="darwin" GOARCH="amd64" go build -o "build/gitleaks-darwin-amd64" $(LDFLAGS)
|
||||
|
||||
deploy:
|
||||
@echo "$(DOCKER_PASSWORD)" | docker login -u "$(DOCKER_USERNAME)" --password-stdin
|
||||
docker build --build-arg ldflags=$(_LDFLAGS) -f Dockerfile -t zricethezav/gitleaks:latest -t zricethezav/gitleaks:$(VERSION) .
|
||||
echo "Pushing zricethezav/gitleaks:$(VERSION) and zricethezav/gitleaks:latest"
|
||||
docker push zricethezav/gitleaks
|
||||
@@ -1,112 +1,131 @@
|
||||
# GitLeaks
|
||||
Gitleaks
|
||||
--------
|
||||
|
||||
<p align="left">
|
||||
<a href="https://travis-ci.com/zricethezav/gitleaks"><img alt="Travis" src="https://travis-ci.com/zricethezav/gitleaks.svg?branch=master"></a>
|
||||
</p>
|
||||
|
||||
Audit git repos for secrets. Gitleaks provides a way for you to find unencrypted secrets and other unwanted data types in git repositories. As part of its core functionality, it provides:
|
||||
|
||||
* Audits for uncommitted changes
|
||||
* Github and Gitlab support including support for bulk organization and repository owner (user) repository scans, as well as pull/merge request scanning for use in common CI workflows.
|
||||
* Support for private repository scans, and repositories that require key based authentication
|
||||
* Output in JSON formats for consumption in other reporting tools and frameworks
|
||||
* Externalised configuration for environment specific customisation including regex rules
|
||||
* High performance through the use of src-d's [go-git](https://github.com/src-d/go-git) framework
|
||||
|
||||
|
||||
[](https://travis-ci.org/zricethezav/gitleaks)
|
||||
|
||||
## Check git repos for secrets and keys
|
||||
| `repo scan` |
|
||||
|---|
|
||||
| <p align="left"><img src="https://raw.githubusercontent.com/zricethezav/gifs/master/repo-scan.gif"></p> | <p align="left"><img src="https://raw.githubusercontent.com/zricethezav/gifs/master/repo-scan.gif"></p> |
|
||||
|
||||
#### Installing
|
||||
| `pre commit scan` |
|
||||
|---|
|
||||
| <p align="left"><img src="https://raw.githubusercontent.com/zricethezav/gifs/master/pre-commit-1.gif"></p> |
|
||||
|
||||
## Getting Started
|
||||
|
||||
Written in Go, gitleaks is available in binary form for many popular platforms and OS types from the [releases page](https://github.com/zricethezav/gitleaks/releases). Alternatively, executed via Docker or it can be installed using Go directly, as per the below;
|
||||
|
||||
#### MacOS
|
||||
|
||||
```
|
||||
brew install gitleaks
|
||||
```
|
||||
|
||||
#### Docker
|
||||
|
||||
```bash
|
||||
go get -u github.com/zricethezav/gitleaks
|
||||
docker pull zricethezav/gitleaks
|
||||
```
|
||||
|
||||
#### Usage and Explanation
|
||||
#### Go
|
||||
Ensure `GO111MODULE=on` is set as an env var
|
||||
```bash
|
||||
go get github.com/zricethezav/gitleaks/v3@latest
|
||||
```
|
||||
|
||||

|
||||
## Usage
|
||||
|
||||
gitleaks has a wide range of configuration options that can be adjusted at runtime or via a configuration file based on your specific requirements.
|
||||
|
||||
```
|
||||
Usage:
|
||||
gitleaks [OPTIONS]
|
||||
|
||||
Application Options:
|
||||
-v, --verbose Show verbose output from audit
|
||||
-r, --repo= Target repository
|
||||
--config= config path
|
||||
--disk Clones repo(s) to disk
|
||||
--version version number
|
||||
--username= Username for git repo
|
||||
--password= Password for git repo
|
||||
--access-token= Access token for git repo
|
||||
--commit= sha of commit to audit
|
||||
--threads= Maximum number of threads gitleaks spawns
|
||||
--ssh-key= path to ssh key used for auth
|
||||
--uncommitted run gitleaks on uncommitted code
|
||||
--repo-path= Path to repo
|
||||
--owner-path= Path to owner directory (repos discovered)
|
||||
--branch= Branch to audit
|
||||
--report= path to write json leaks file
|
||||
--report-format= json or csv (default: json)
|
||||
--redact redact secrets from log messages and leaks
|
||||
--debug log debug messages
|
||||
--repo-config Load config from target repo. Config file must be ".gitleaks.toml" or "gitleaks.toml"
|
||||
--pretty Pretty print json if leaks are present
|
||||
--commit-from= Commit to start audit from
|
||||
--commit-to= Commit to stop audit
|
||||
--timeout= Time allowed per audit. Ex: 10us, 30s, 1m, 1h10m1s
|
||||
--depth= Number of commits to audit
|
||||
|
||||
--host= git hosting service like gitlab or github. Supported hosts include: Github, Gitlab
|
||||
--baseurl= Base URL for API requests. Defaults to the public GitLab or GitHub API, but can be set to a domain endpoint to use with a self hosted server.
|
||||
--org= organization to audit
|
||||
--user= user to audit
|
||||
--pr= pull/merge request url
|
||||
--exclude-forks audit excludes forks
|
||||
|
||||
Help Options:
|
||||
-h, --help Show this help message
|
||||
|
||||
```
|
||||
|
||||
### Docker usage examples
|
||||
|
||||
Run gitleaks against:
|
||||
|
||||
###### Public repository
|
||||
|
||||
```bash
|
||||
./gitleaks {git url}
|
||||
docker run --rm --name=gitleaks zricethezav/gitleaks -v -r https://github.com/zricethezav/gitleaks.git
|
||||
```
|
||||
|
||||
Gitleaks will clone the target `<git url>` to `$HOME/.gitleaks/clones/<repo name>` and run a regex check against all diffs of all commits on all remotes in topological order. If any leaks are found gitleaks will output the leak in json, Ex:
|
||||
```
|
||||
{
|
||||
"line": "-const AWS_KEY = \"AKIALALEMEL33243OLIAE\"",
|
||||
"commit": "eaeffdc65b4c73ccb67e75d96bd8743be2c85973",
|
||||
"string": "AKIALALEMEL33243OLIA",
|
||||
"reason": "AWS",
|
||||
"commitMsg": "remove fake key",
|
||||
"time": "2018-02-04 19:43:28 -0600",
|
||||
"author": "Zachary Rice",
|
||||
"file": "main.go",
|
||||
"repoURL": "https://github.com/zricethezav/gronit"
|
||||
}
|
||||
```
|
||||
Gitleaks will not re-clone repos unless the temporary flag is set (see Options section), instead gitleaks will `fetch` all new changes before the scan. This works for users and organization repos as well. Regex's for the scan are defined in `main.go`, feel free to open a PR and contribute if you have additional regex you want included. Work largely based on [https://people.eecs.berkeley.edu/~rohanpadhye/files/key_leaks-msr15.pdf](https://people.eecs.berkeley.edu/~rohanpadhye/files/key_leaks-msr15.pdf) and regexes from https://github.com/dxa4481/truffleHog and https://github.com/anshumanbh/git-all-secrets.
|
||||
###### Local repository already cloned into /tmp/
|
||||
|
||||
#### Example with Report
|
||||
```bash
|
||||
gitleaks --json https://github.com/zricethezav/gronit
|
||||
```
|
||||
This will run gitleaks on one of my projects, gronit and create the following structure in `$HOME/.gitleaks`:
|
||||
```
|
||||
.
|
||||
├── clones
|
||||
│ └── zricethezav
|
||||
│ └── gronit
|
||||
│ ├── README.md
|
||||
│ ├── main.go
|
||||
│ ├── options.go
|
||||
│ ├── server.go
|
||||
│ └── utils.go
|
||||
└── report
|
||||
└── zricethezav
|
||||
└── gronit_leaks.json
|
||||
```
|
||||
The clones directory contains the repo owner (me) and any repos gitleaks has scanned. Next time we run gitleaks on gronit again we will `fetch` gronit rather than `clone`. Reports are written out to `$HOME/.gitleaks/report/<owner>/<repo>_leaks.json`
|
||||
|
||||
#### Options
|
||||
```
|
||||
usage: gitleaks [options] <url>
|
||||
|
||||
Options:
|
||||
-c --concurrency Upper bound on concurrent diffs
|
||||
-u --user Git user url
|
||||
-r --repo Git repo url
|
||||
-o --org Git organization url
|
||||
-s --since Commit to stop at
|
||||
-b --b64Entropy Base64 entropy cutoff (default is 70)
|
||||
-x --hexEntropy Hex entropy cutoff (default is 40)
|
||||
-e --entropy Enable entropy
|
||||
-j --json Output gitleaks report
|
||||
--token Github API token
|
||||
--strict Enables stopwords
|
||||
-h --help Display this message
|
||||
|
||||
docker run --rm --name=gitleaks -v /tmp/:/code/ zricethezav/gitleaks -v --repo-path=/code/gitleaks
|
||||
```
|
||||
|
||||
##### Options Explained
|
||||
By default repos cloned to memory. Using `--disk` for clone to disk or you can quickly out of memory.
|
||||
|
||||
| Option | Explanation |
|
||||
| ------------- | ------------- |
|
||||
| -c --concurrency | Set the limit on the number of concurrent diffs. If unbounded, your system would throw a `too many open files` error. Tweak `ulimit` for quicker scans at your own risk. Ex: `gitleaks -c 100 <repo_url>` |
|
||||
| -u --user | Target git user. Reports and clones are dumped to `$HOME/.gitleaks/clones/<user>/<user_repos>` and `$HOME/.gitleaks/reports/<user>/<gitleaks_reports>`. Ex: `gitleaks -u <user_git_url>`.
|
||||
| -o --org | Target git organization. Reports and clones are dumped to `$HOME/.gitleaks/clones/<org>/<org_repos>` and `$HOME/.gitleaks/reports/<org>/<gitleaks_reports>`. Ex: `gitleaks -o <org_git_url>`
|
||||
| -r --repo | Default behavior is to have gitleaks target a specific repo, so this option is unecessary, but... Target git repo. Reports and clones are dumped to `$HOME/.gitleaks/clones/<owner>/<repos>` and `$HOME/.gitleaks/reports/<owner>/<gitleaks_reports>`
|
||||
| -s --since | Since argument accepts a commit hash and will scan the repo history up to and including this hash. Ex: `gitleaks -s <HASH> <repo_url>`
|
||||
| -b --b64Entropy | Entropy cutoff for base 64 characters. Ex: `gitleaks -e -b 70 <repo_url>` |
|
||||
| -x --hexEntropy | Entropy cutoff for hex characters. Ex: `gitleaks -e -x 70 <repo_url>` |
|
||||
| -e --entroy | Enable entropy checks. Ex: `gitleaks -e <repo_url>` |
|
||||
| -j --json | Enable report generation. Ex: `gitleaks --json <repo_url>` |
|
||||
| -t --temporary | Cloned repos will be cloned into a temp directory and removed after gitleaks exits. Ex: `gitleaks -t <repo_url>` |
|
||||
| --token | NOTE: you should use env var `GITHUB_TOKEN` instead of this flag. Github API token needed for scanning private repos and pagination on repo fetching from github's api. |
|
||||
| -- strict | Enable stopwords. Ex: `gitleaks --strict <repo_url>` |
|
||||
|
||||
NOTE: your mileage may vary so if you aren't getting the results you expected try updating the regexes to fit your needs or try tweaking the entropy cutoffs and stopwords. Entropy cutoff for base64 alphabets seemed to give good results around 70 and hex alphabets seemed to give good results around 40. Entropy is calculated using [Shannon entropy](http://www.bearcave.com/misl/misl_tech/wavelets/compression/shannon.html).
|
||||
For speed up analyze operation using `--threads` parameter, which set to `ALL - 1` threads at your instance CPU.
|
||||
|
||||
|
||||
### If you find a valid leak in a repo
|
||||
Please read the [Github article on removing sensitive data from a repository](https://help.github.com/articles/removing-sensitive-data-from-a-repository/) to remove the sensitive information from your history.
|
||||
## Exit Codes
|
||||
|
||||
### Run me with docker
|
||||
Gitleaks provides consistent exist codes to assist in automation workflows such as CICD platforms and bulk scanning.
|
||||
|
||||
Simply run `docker run --rm --name=gitleaks raphaelareya/gitleaks https://github.com/zricethezav/gitleaks`
|
||||
|
||||
Or build the image yourself to get the latest version :
|
||||
|
||||
```
|
||||
docker build -t gitleaks .
|
||||
docker run --rm --name=gitleaks gitleaks https://github.com/zricethezav/gitleaks
|
||||
0: no leaks
|
||||
1: leaks present
|
||||
2: error encountered
|
||||
```
|
||||
|
||||
### Give Thanks
|
||||
|
||||
If using gitleaks has made your job easier consider [sponsoring me](https://github.com/sponsors/zricethezav) through github's sponsorship program or donating to one of [Sam](https://www.flickr.com/photos/146541520@N08/albums/72157710121716312)'s favorite places, the Japan House on the University of Illinois at Urbana-Champaign's campus: https://japanhouse.illinois.edu/make-a-gift
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
package audit
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"path"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v3/manager"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// Run accepts a manager and begins an audit based on the options/configs set in the manager.
|
||||
func Run(m *manager.Manager) error {
|
||||
if m.Opts.OwnerPath != "" {
|
||||
files, err := ioutil.ReadDir(m.Opts.OwnerPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, f := range files {
|
||||
if !f.IsDir() {
|
||||
continue
|
||||
}
|
||||
m.Opts.RepoPath = fmt.Sprintf("%s/%s", m.Opts.OwnerPath, f.Name())
|
||||
if err := runHelper(NewRepo(m)); err != nil {
|
||||
log.Warnf("%s is not a git repo, skipping", f.Name())
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
return runHelper(NewRepo(m))
|
||||
}
|
||||
|
||||
func runHelper(r *Repo) error {
|
||||
if r.Manager.Opts.OpenLocal() {
|
||||
r.Name = path.Base(r.Manager.Opts.RepoPath)
|
||||
if err := r.Open(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Check if we are checking uncommitted files. This is the default behavior
|
||||
// for a "$ gitleaks" command with no options set
|
||||
if r.Manager.Opts.CheckUncommitted() {
|
||||
if err := r.AuditUncommitted(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
} else {
|
||||
if err := r.Clone(nil); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return r.Audit()
|
||||
}
|
||||
@@ -0,0 +1,434 @@
|
||||
package audit
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"sort"
|
||||
"testing"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v3/config"
|
||||
"github.com/zricethezav/gitleaks/v3/manager"
|
||||
"github.com/zricethezav/gitleaks/v3/options"
|
||||
|
||||
"github.com/sergi/go-diff/diffmatchpatch"
|
||||
)
|
||||
|
||||
const testRepoBase = "../test_data/test_repos/"
|
||||
|
||||
func TestAudit(t *testing.T) {
|
||||
moveDotGit("dotGit", ".git")
|
||||
defer moveDotGit(".git", "dotGit")
|
||||
tests := []struct {
|
||||
description string
|
||||
opts options.Options
|
||||
wantPath string
|
||||
wantErr error
|
||||
emptyRepo bool
|
||||
wantEmpty bool
|
||||
}{
|
||||
{
|
||||
description: "test local repo one aws leak",
|
||||
opts: options.Options{
|
||||
RepoPath: "../test_data/test_repos/test_repo_1",
|
||||
Report: "../test_data/test_local_repo_one_aws_leak.json.got",
|
||||
ReportFormat: "json",
|
||||
},
|
||||
wantPath: "../test_data/test_local_repo_one_aws_leak.json",
|
||||
},
|
||||
{
|
||||
description: "test local repo one aws leak threaded",
|
||||
opts: options.Options{
|
||||
Threads: runtime.GOMAXPROCS(0),
|
||||
RepoPath: "../test_data/test_repos/test_repo_1",
|
||||
Report: "../test_data/test_local_repo_one_aws_leak.json.got",
|
||||
ReportFormat: "json",
|
||||
},
|
||||
wantPath: "../test_data/test_local_repo_one_aws_leak.json",
|
||||
},
|
||||
{
|
||||
description: "test non existent repo",
|
||||
opts: options.Options{
|
||||
RepoPath: "../test_data/test_repos/no_repo_here",
|
||||
ReportFormat: "json",
|
||||
},
|
||||
emptyRepo: true,
|
||||
},
|
||||
{
|
||||
description: "test local repo one aws leak whitelisted",
|
||||
opts: options.Options{
|
||||
RepoPath: "../test_data/test_repos/test_repo_1",
|
||||
ReportFormat: "json",
|
||||
Config: "../test_data/test_configs/aws_key_whitelist_python_files.toml",
|
||||
},
|
||||
wantEmpty: true,
|
||||
},
|
||||
{
|
||||
description: "test local repo two leaks",
|
||||
opts: options.Options{
|
||||
RepoPath: "../test_data/test_repos/test_repo_2",
|
||||
Report: "../test_data/test_local_repo_two_leaks.json.got",
|
||||
ReportFormat: "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",
|
||||
opts: options.Options{
|
||||
RepoPath: "../test_data/test_repos/test_repo_2",
|
||||
Config: "../test_data/test_configs/aws_key_global_whitelist_file.toml",
|
||||
ReportFormat: "json",
|
||||
},
|
||||
wantEmpty: true,
|
||||
},
|
||||
{
|
||||
description: "test local repo two leaks whitelisted",
|
||||
opts: options.Options{
|
||||
RepoPath: "../test_data/test_repos/test_repo_2",
|
||||
Config: "../test_data/test_configs/aws_key_whitelist_files.toml",
|
||||
ReportFormat: "json",
|
||||
},
|
||||
wantEmpty: true,
|
||||
},
|
||||
{
|
||||
description: "test local repo three leaks dev branch",
|
||||
opts: options.Options{
|
||||
RepoPath: "../test_data/test_repos/test_repo_3",
|
||||
Report: "../test_data/test_local_repo_three_leaks.json.got",
|
||||
Config: "../test_data/test_configs/aws_key.toml",
|
||||
Branch: "dev",
|
||||
ReportFormat: "json",
|
||||
},
|
||||
wantPath: "../test_data/test_local_repo_three_leaks.json",
|
||||
},
|
||||
{
|
||||
description: "test local repo branch does not exist",
|
||||
opts: options.Options{
|
||||
RepoPath: "../test_data/test_repos/test_repo_3",
|
||||
Branch: "nobranch",
|
||||
ReportFormat: "json",
|
||||
},
|
||||
wantEmpty: true,
|
||||
},
|
||||
{
|
||||
description: "test local repo one aws leak single commit",
|
||||
opts: options.Options{
|
||||
RepoPath: "../test_data/test_repos/test_repo_1",
|
||||
Report: "../test_data/test_local_repo_one_aws_leak_commit.json.got",
|
||||
Commit: "6557c92612d3b35979bd426d429255b3bf9fab74",
|
||||
ReportFormat: "json",
|
||||
},
|
||||
wantPath: "../test_data/test_local_repo_one_aws_leak_commit.json",
|
||||
},
|
||||
{
|
||||
description: "test local repo one aws leak AND leak on python files",
|
||||
opts: options.Options{
|
||||
RepoPath: "../test_data/test_repos/test_repo_1",
|
||||
Report: "../test_data/test_local_repo_one_aws_leak_and_file_leak.json.got",
|
||||
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",
|
||||
},
|
||||
{
|
||||
description: "test owner path",
|
||||
opts: options.Options{
|
||||
OwnerPath: "../test_data/test_repos/",
|
||||
Report: "../test_data/test_local_owner_aws_leak.json.got",
|
||||
ReportFormat: "json",
|
||||
},
|
||||
wantPath: "../test_data/test_local_owner_aws_leak.json",
|
||||
},
|
||||
{
|
||||
description: "test entropy",
|
||||
opts: options.Options{
|
||||
RepoPath: "../test_data/test_repos/test_repo_1",
|
||||
Report: "../test_data/test_entropy.json.got",
|
||||
Config: "../test_data/test_configs/entropy.toml",
|
||||
ReportFormat: "json",
|
||||
},
|
||||
wantPath: "../test_data/test_entropy.json",
|
||||
},
|
||||
{
|
||||
description: "test entropy and regex",
|
||||
opts: options.Options{
|
||||
RepoPath: "../test_data/test_repos/test_repo_1",
|
||||
Report: "../test_data/test_regex_entropy.json.got",
|
||||
Config: "../test_data/test_configs/regex_entropy.toml",
|
||||
ReportFormat: "json",
|
||||
},
|
||||
wantPath: "../test_data/test_regex_entropy.json",
|
||||
},
|
||||
{
|
||||
description: "test local repo four entropy alternative config",
|
||||
opts: options.Options{
|
||||
RepoPath: "../test_data/test_repos/test_repo_4",
|
||||
Report: "../test_data/test_local_repo_four_alt_config_entropy.json.got",
|
||||
RepoConfig: true,
|
||||
ReportFormat: "json",
|
||||
},
|
||||
wantPath: "../test_data/test_local_repo_four_alt_config_entropy.json",
|
||||
},
|
||||
{
|
||||
description: "test local repo four entropy alternative config",
|
||||
opts: options.Options{
|
||||
RepoPath: "../test_data/test_repos/test_repo_1",
|
||||
Report: "../test_data/test_regex_whitelist.json.got",
|
||||
Config: "../test_data/test_configs/aws_key_aws_whitelisted.toml",
|
||||
ReportFormat: "json",
|
||||
},
|
||||
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 {
|
||||
fmt.Println(test.description)
|
||||
cfg, err := config.NewConfig(test.opts)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
m, err := manager.NewManager(test.opts, cfg)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
err = Run(m)
|
||||
|
||||
if test.wantErr != nil {
|
||||
if err == nil {
|
||||
t.Errorf("did not receive wantErr: %v", test.wantErr)
|
||||
}
|
||||
if err.Error() != test.wantErr.Error() {
|
||||
t.Errorf("wantErr does not equal err received: %v", err.Error())
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
err = m.Report()
|
||||
|
||||
if test.wantEmpty {
|
||||
if len(m.GetLeaks()) != 0 {
|
||||
t.Errorf("wanted no leaks but got some instead: %+v", m.GetLeaks())
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
if test.wantPath != "" {
|
||||
err := fileCheck(test.wantPath, test.opts.Report)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestAuditUncommited(t *testing.T) {
|
||||
moveDotGit("dotGit", ".git")
|
||||
defer moveDotGit(".git", "dotGit")
|
||||
tests := []struct {
|
||||
description string
|
||||
opts options.Options
|
||||
wantPath string
|
||||
wantErr error
|
||||
emptyRepo bool
|
||||
wantEmpty bool
|
||||
fileToChange string
|
||||
addition string
|
||||
}{
|
||||
{
|
||||
description: "test audit local one leak",
|
||||
opts: options.Options{
|
||||
RepoPath: "../test_data/test_repos/test_repo_1",
|
||||
Report: "../test_data/test_local_repo_one_aws_leak_uncommitted.json.got",
|
||||
Uncommited: true,
|
||||
ReportFormat: "json",
|
||||
},
|
||||
wantPath: "../test_data/test_local_repo_one_aws_leak_uncommitted.json",
|
||||
fileToChange: "server.test.py",
|
||||
addition: " aws_access_key_id='AKIAIO5FODNN7DXAMPLE'\n\n",
|
||||
},
|
||||
{
|
||||
description: "test audit local no leak",
|
||||
opts: options.Options{
|
||||
RepoPath: "../test_data/test_repos/test_repo_1",
|
||||
Uncommited: true,
|
||||
ReportFormat: "json",
|
||||
},
|
||||
wantEmpty: true,
|
||||
fileToChange: "server.test.py",
|
||||
addition: "nothing bad",
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
fmt.Println(test.description)
|
||||
old, err := ioutil.ReadFile(fmt.Sprintf("%s/%s", test.opts.RepoPath, test.fileToChange))
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
altered, err := os.OpenFile(fmt.Sprintf("%s/%s", test.opts.RepoPath, test.fileToChange),
|
||||
os.O_WRONLY|os.O_APPEND, 0644)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
_, err = altered.WriteString(test.addition)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
cfg, err := config.NewConfig(test.opts)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
m, err := manager.NewManager(test.opts, cfg)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if err := Run(m); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if err := m.Report(); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
err = ioutil.WriteFile(fmt.Sprintf("%s/%s", test.opts.RepoPath, test.fileToChange), old, 0)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if test.wantEmpty {
|
||||
continue
|
||||
}
|
||||
|
||||
if test.wantPath != "" {
|
||||
err := fileCheck(test.wantPath, test.opts.Report)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func fileCheck(wantPath, gotPath string) error {
|
||||
var (
|
||||
gotLeaks []manager.Leak
|
||||
wantLeaks []manager.Leak
|
||||
)
|
||||
want, err := ioutil.ReadFile(wantPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
got, err := ioutil.ReadFile(gotPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
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()
|
||||
diffs := dmp.DiffMain(string(want), string(got), false)
|
||||
return fmt.Errorf("does not equal: %s", dmp.DiffPrettyText(diffs))
|
||||
}
|
||||
if err := os.Remove(gotPath); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func moveDotGit(from, to string) error {
|
||||
repoDirs, err := ioutil.ReadDir("../test_data/test_repos")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, dir := range repoDirs {
|
||||
if !dir.IsDir() {
|
||||
continue
|
||||
}
|
||||
err = os.Rename(fmt.Sprintf("%s/%s/%s", testRepoBase, dir.Name(), from),
|
||||
fmt.Sprintf("%s/%s/%s", testRepoBase, dir.Name(), to))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
+403
@@ -0,0 +1,403 @@
|
||||
package audit
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/md5"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v3/config"
|
||||
"github.com/zricethezav/gitleaks/v3/manager"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
"github.com/sergi/go-diff/diffmatchpatch"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"gopkg.in/src-d/go-billy.v4"
|
||||
"gopkg.in/src-d/go-git.v4"
|
||||
"gopkg.in/src-d/go-git.v4/plumbing"
|
||||
"gopkg.in/src-d/go-git.v4/plumbing/object"
|
||||
"gopkg.in/src-d/go-git.v4/plumbing/storer"
|
||||
"gopkg.in/src-d/go-git.v4/storage/memory"
|
||||
)
|
||||
|
||||
// Repo wraps a *git.Repository object in addition to a manager object and the name of the repo.
|
||||
// Commits are inspected from the *git.Repository object. If a commit is found then we send it
|
||||
// via the manager LeakChan where the manager receives and keeps track of all leaks.
|
||||
type Repo struct {
|
||||
*git.Repository
|
||||
|
||||
// config is used when the --repo-config option is set.
|
||||
// This allows users to load up configs specific to their repos.
|
||||
// Imagine the scenario where you are doing an audit of a large organization
|
||||
// and you want certain repos to look for specific rules. If those specific repos
|
||||
// have a gitleaks.toml or .gitleaks.toml config then those configs will be used specifically
|
||||
// for those repo audits.
|
||||
config config.Config
|
||||
|
||||
// ctx is used to signal timeouts to running goroutines
|
||||
ctx context.Context
|
||||
cancel context.CancelFunc
|
||||
|
||||
Name string
|
||||
Manager *manager.Manager
|
||||
}
|
||||
|
||||
// NewRepo initializes and returns a Repo struct.
|
||||
func NewRepo(m *manager.Manager) *Repo {
|
||||
return &Repo{
|
||||
Manager: m,
|
||||
config: m.Config,
|
||||
ctx: context.Background(),
|
||||
}
|
||||
}
|
||||
|
||||
// Clone will clone a repo and return a Repo struct which contains a go-git repo. The clone method
|
||||
// is determined by the clone options set in Manager.metadata.cloneOptions
|
||||
func (repo *Repo) Clone(cloneOption *git.CloneOptions) error {
|
||||
var (
|
||||
repository *git.Repository
|
||||
err error
|
||||
)
|
||||
if cloneOption == nil {
|
||||
cloneOption = repo.Manager.CloneOptions
|
||||
}
|
||||
|
||||
log.Infof("cloning... %s", cloneOption.URL)
|
||||
start := time.Now()
|
||||
|
||||
if repo.Manager.CloneDir != "" {
|
||||
clonePath := fmt.Sprintf("%s/%x", repo.Manager.CloneDir, md5.Sum([]byte(time.Now().String())))
|
||||
repository, err = git.PlainClone(clonePath, false, cloneOption)
|
||||
} else {
|
||||
repository, err = git.Clone(memory.NewStorage(), nil, cloneOption)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
repo.Name = filepath.Base(repo.Manager.Opts.Repo)
|
||||
repo.Repository = repository
|
||||
repo.Manager.RecordTime(manager.CloneTime(howLong(start)))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// AuditUncommitted will do a `git diff` and scan changed files that are being tracked. This is useful functionality
|
||||
// for a pre-commit hook so you can make sure your code does not have any leaks before committing.
|
||||
func (repo *Repo) AuditUncommitted() error {
|
||||
// load up alternative config if possible, if not use manager's config
|
||||
if repo.Manager.Opts.RepoConfig {
|
||||
cfg, err := repo.loadRepoConfig()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
repo.config = cfg
|
||||
}
|
||||
|
||||
if err := repo.setupTimeout(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
auditTimeStart := time.Now()
|
||||
|
||||
r, err := repo.Head()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := repo.CommitObject(r.Hash())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Staged change so the commit details do not yet exist. Insert empty defaults.
|
||||
c.Hash = plumbing.Hash{}
|
||||
c.Message = "***STAGED CHANGES***"
|
||||
c.Author.Name = ""
|
||||
c.Author.Email = ""
|
||||
c.Author.When = time.Unix(0, 0).UTC()
|
||||
|
||||
prevTree, err := c.Tree()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
wt, err := repo.Worktree()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
status, err := wt.Status()
|
||||
for fn, state := range status {
|
||||
var (
|
||||
prevFileContents string
|
||||
currFileContents string
|
||||
filename string
|
||||
)
|
||||
|
||||
if state.Staging != git.Untracked {
|
||||
if state.Staging == git.Deleted {
|
||||
// file in staging has been deleted, aka it is not on the filesystem
|
||||
// so the contents of the file are ""
|
||||
currFileContents = ""
|
||||
} else {
|
||||
workTreeBuf := bytes.NewBuffer(nil)
|
||||
workTreeFile, err := wt.Filesystem.Open(fn)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
if _, err := io.Copy(workTreeBuf, workTreeFile); err != nil {
|
||||
return err
|
||||
}
|
||||
currFileContents = workTreeBuf.String()
|
||||
filename = workTreeFile.Name()
|
||||
}
|
||||
|
||||
// get files at HEAD state
|
||||
prevFile, err := prevTree.File(fn)
|
||||
if err != nil {
|
||||
prevFileContents = ""
|
||||
|
||||
} else {
|
||||
prevFileContents, err = prevFile.Contents()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if filename == "" {
|
||||
filename = prevFile.Name
|
||||
}
|
||||
}
|
||||
|
||||
if fileMatched(filename, repo.config.Whitelist.File) {
|
||||
log.Debugf("whitelisted file found, skipping audit of file: %s", filename)
|
||||
} else if fileMatched(filename, repo.config.FileRegex) {
|
||||
repo.Manager.SendLeaks(manager.Leak{
|
||||
Line: "N/A",
|
||||
Offender: filename,
|
||||
Commit: c.Hash.String(),
|
||||
Repo: repo.Name,
|
||||
Rule: "file regex matched" + repo.config.FileRegex.String(),
|
||||
Message: c.Message,
|
||||
Author: c.Author.Name,
|
||||
Email: c.Author.Email,
|
||||
Date: c.Author.When,
|
||||
File: filename,
|
||||
})
|
||||
} else {
|
||||
dmp := diffmatchpatch.New()
|
||||
diffs := dmp.DiffMain(prevFileContents, currFileContents, false)
|
||||
var diffContents string
|
||||
for _, d := range diffs {
|
||||
switch d.Type {
|
||||
case diffmatchpatch.DiffInsert:
|
||||
diffContents += fmt.Sprintf("%s\n", d.Text)
|
||||
case diffmatchpatch.DiffDelete:
|
||||
diffContents += fmt.Sprintf("%s\n", d.Text)
|
||||
}
|
||||
}
|
||||
InspectString(diffContents, c, repo, filename)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
repo.Manager.RecordTime(manager.AuditTime(howLong(auditTimeStart)))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Audit is responsible for scanning the entire history (default behavior) of a
|
||||
// git repo. Options that can change the behavior of this function include: --commit, --depth, --branch.
|
||||
// See options/options.go for an explanation on these options.
|
||||
func (repo *Repo) Audit() error {
|
||||
if err := repo.setupTimeout(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if repo.Repository == nil {
|
||||
return fmt.Errorf("%s repo is empty", repo.Name)
|
||||
}
|
||||
|
||||
// load up alternative config if possible, if not use manager's config
|
||||
if repo.Manager.Opts.RepoConfig {
|
||||
cfg, err := repo.loadRepoConfig()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
repo.config = cfg
|
||||
}
|
||||
|
||||
auditTimeStart := time.Now()
|
||||
|
||||
// audit single Commit
|
||||
if repo.Manager.Opts.Commit != "" {
|
||||
h := plumbing.NewHash(repo.Manager.Opts.Commit)
|
||||
c, err := repo.CommitObject(h)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = inspectCommit(c, repo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
logOpts, err := getLogOptions(repo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
cIter, err := repo.Log(logOpts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cc := 0
|
||||
semaphore := make(chan bool, howManyThreads(repo.Manager.Opts.Threads))
|
||||
wg := sync.WaitGroup{}
|
||||
err = cIter.ForEach(func(c *object.Commit) error {
|
||||
if c == nil || c.Hash.String() == repo.Manager.Opts.CommitTo ||
|
||||
repo.timeoutReached() || repo.depthReached(cc) {
|
||||
return storer.ErrStop
|
||||
}
|
||||
|
||||
if len(c.ParentHashes) == 0 {
|
||||
cc++
|
||||
err = inspectCommit(c, repo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
if isCommitWhiteListed(c.Hash.String(), repo.config.Whitelist.Commits) {
|
||||
return nil
|
||||
}
|
||||
|
||||
cc++
|
||||
err = c.Parents().ForEach(func(parent *object.Commit) error {
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
// sometimes the patch generation will fail due to a known bug in
|
||||
// sergi's go-diff: https://github.com/sergi/go-diff/issues/89.
|
||||
// Once a fix has been merged I will remove this recover.
|
||||
return
|
||||
}
|
||||
}()
|
||||
if repo.timeoutReached() {
|
||||
return nil
|
||||
}
|
||||
start := time.Now()
|
||||
patch, err := c.Patch(parent)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not generate patch")
|
||||
}
|
||||
repo.Manager.RecordTime(manager.PatchTime(howLong(start)))
|
||||
wg.Add(1)
|
||||
semaphore <- true
|
||||
go func(c *object.Commit, patch *object.Patch) {
|
||||
defer func() {
|
||||
<-semaphore
|
||||
wg.Done()
|
||||
}()
|
||||
inspectPatch(patch, c, repo)
|
||||
}(c, patch)
|
||||
|
||||
return nil
|
||||
})
|
||||
return nil
|
||||
})
|
||||
|
||||
wg.Wait()
|
||||
repo.Manager.RecordTime(manager.AuditTime(howLong(auditTimeStart)))
|
||||
repo.Manager.IncrementCommits(cc)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Open opens a local repo either from repo-path or $PWD
|
||||
func (repo *Repo) Open() error {
|
||||
if repo.Manager.Opts.RepoPath != "" {
|
||||
// open git repo from repo path
|
||||
repository, err := git.PlainOpen(repo.Manager.Opts.RepoPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
repo.Repository = repository
|
||||
} else {
|
||||
// open git repo from PWD
|
||||
dir, err := os.Getwd()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
repository, err := git.PlainOpen(dir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
repo.Repository = repository
|
||||
repo.Name = path.Base(dir)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (repo *Repo) loadRepoConfig() (config.Config, error) {
|
||||
wt, err := repo.Repository.Worktree()
|
||||
if err != nil {
|
||||
return config.Config{}, err
|
||||
}
|
||||
var f billy.File
|
||||
f, _ = wt.Filesystem.Open(".gitleaks.toml")
|
||||
if f == nil {
|
||||
f, err = wt.Filesystem.Open("gitleaks.toml")
|
||||
if err != nil {
|
||||
return config.Config{}, fmt.Errorf("problem loading repo config: %v", err)
|
||||
}
|
||||
}
|
||||
defer f.Close()
|
||||
var tomlLoader config.TomlLoader
|
||||
_, err = toml.DecodeReader(f, &tomlLoader)
|
||||
return tomlLoader.Parse()
|
||||
}
|
||||
|
||||
// timeoutReached returns true if the timeout deadline has been met. This function should be used
|
||||
// at the top of loops and before potentially long running goroutines (like checking inefficient regexes)
|
||||
func (repo *Repo) timeoutReached() bool {
|
||||
if repo.ctx.Err() == context.DeadlineExceeded {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// setupTimeout parses the --timeout option and assigns a context with timeout to the manager
|
||||
// which will exit early if the timeout has been met.
|
||||
func (repo *Repo) setupTimeout() error {
|
||||
if repo.Manager.Opts.Timeout == "" {
|
||||
return nil
|
||||
}
|
||||
timeout, err := time.ParseDuration(repo.Manager.Opts.Timeout)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
repo.ctx, repo.cancel = context.WithTimeout(context.Background(), timeout)
|
||||
|
||||
go func() {
|
||||
select {
|
||||
case <-repo.ctx.Done():
|
||||
log.Warnf("Timeout deadline exceeded: %s", timeout.String())
|
||||
}
|
||||
}()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (repo *Repo) depthReached(i int) bool {
|
||||
if repo.Manager.Opts.Depth != 0 && repo.Manager.Opts.Depth == i {
|
||||
log.Warnf("Exceeded depth limit (%d)", i)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
+394
@@ -0,0 +1,394 @@
|
||||
package audit
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v3/config"
|
||||
"github.com/zricethezav/gitleaks/v3/manager"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"gopkg.in/src-d/go-git.v4"
|
||||
"gopkg.in/src-d/go-git.v4/plumbing"
|
||||
fdiff "gopkg.in/src-d/go-git.v4/plumbing/format/diff"
|
||||
"gopkg.in/src-d/go-git.v4/plumbing/object"
|
||||
)
|
||||
|
||||
// Inspect patch accepts a patch, commit, and repo. If the patches contains files that are
|
||||
// binary, then gitleaks will skip auditing that file OR if a file is matched on
|
||||
// whitelisted files set in the configuration. If a global rule for files is defined and a filename
|
||||
// matches said global rule, then a leak is sent to the manager.
|
||||
// After that, file chunks are created which are then inspected by InspectString()
|
||||
func inspectPatch(patch *object.Patch, c *object.Commit, repo *Repo) {
|
||||
for _, f := range patch.FilePatches() {
|
||||
if repo.timeoutReached() {
|
||||
return
|
||||
}
|
||||
if f.IsBinary() {
|
||||
continue
|
||||
}
|
||||
if fileMatched(getFileName(f), repo.config.Whitelist.File) {
|
||||
log.Debugf("whitelisted file found, skipping audit of file: %s", getFileName(f))
|
||||
continue
|
||||
}
|
||||
if fileMatched(getFileName(f), repo.config.FileRegex) {
|
||||
repo.Manager.SendLeaks(manager.Leak{
|
||||
Line: "N/A",
|
||||
Offender: getFileName(f),
|
||||
Commit: c.Hash.String(),
|
||||
Repo: repo.Name,
|
||||
Rule: "file regex matched" + repo.config.FileRegex.String(),
|
||||
Author: c.Author.Name,
|
||||
Email: c.Author.Email,
|
||||
Date: c.Author.When,
|
||||
File: getFileName(f),
|
||||
})
|
||||
}
|
||||
for _, chunk := range f.Chunks() {
|
||||
if chunk.Type() == fdiff.Delete || chunk.Type() == fdiff.Add {
|
||||
InspectString(chunk.Content(), c, repo, getFileName(f))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// getFileName accepts a file patch and returns the filename
|
||||
func getFileName(f fdiff.FilePatch) string {
|
||||
fn := "???"
|
||||
from, to := f.Files()
|
||||
if from != nil {
|
||||
return from.Path()
|
||||
} else if to != nil {
|
||||
return to.Path()
|
||||
}
|
||||
|
||||
return fn
|
||||
}
|
||||
|
||||
// getShannonEntropy https://en.wiktionary.org/wiki/Shannon_entropy
|
||||
func shannonEntropy(data string) (entropy float64) {
|
||||
if data == "" {
|
||||
return 0
|
||||
}
|
||||
|
||||
charCounts := make(map[rune]int)
|
||||
for _, char := range data {
|
||||
charCounts[char]++
|
||||
}
|
||||
|
||||
invLength := 1.0 / float64(len(data))
|
||||
for _, count := range charCounts {
|
||||
freq := float64(count) * invLength
|
||||
entropy -= freq * math.Log2(freq)
|
||||
}
|
||||
|
||||
return entropy
|
||||
}
|
||||
|
||||
// aws_access_key_id='AKIAIO5FODNN7EXAMPLE',
|
||||
// trippedEntropy checks if a given line falls in between entropy ranges supplied
|
||||
// by a custom gitleaks configuration. Gitleaks do not check entropy by default.
|
||||
func trippedEntropy(line string, rule config.Rule) bool {
|
||||
for _, e := range rule.Entropy {
|
||||
entropy := shannonEntropy(line)
|
||||
if entropy > e.P1 && entropy < e.P2 {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func ruleContainRegex(rule config.Rule) bool {
|
||||
if rule.Regex == nil {
|
||||
return false
|
||||
}
|
||||
if rule.Regex.String() == "" {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// InspectString accepts a string, commit object, repo, and filename. This function iterates over
|
||||
// all the rules set by the gitleaks config. If the rule contains entropy checks then entropy will be checked first.
|
||||
// Next, if the rule contains a regular expression then that will be checked.
|
||||
func InspectString(content string, c *object.Commit, repo *Repo, filename string) {
|
||||
for _, rule := range repo.config.Rules {
|
||||
// check entropy
|
||||
if len(rule.Entropy) != 0 {
|
||||
// an optimization would be to switch the regex from FindAllIndex to FindString
|
||||
// since we are iterating on the lines if entropy rules exist...
|
||||
for _, line := range strings.Split(content, "\n") {
|
||||
if repo.timeoutReached() {
|
||||
return
|
||||
}
|
||||
entropyTripped := trippedEntropy(line, rule)
|
||||
if entropyTripped && !ruleContainRegex(rule) {
|
||||
repo.Manager.SendLeaks(manager.Leak{
|
||||
Line: line,
|
||||
Offender: fmt.Sprintf("Entropy range %+v", rule.Entropy),
|
||||
Commit: c.Hash.String(),
|
||||
Repo: repo.Name,
|
||||
Message: c.Message,
|
||||
Rule: rule.Description,
|
||||
Author: c.Author.Name,
|
||||
Email: c.Author.Email,
|
||||
Date: c.Author.When,
|
||||
Tags: strings.Join(rule.Tags, ", "),
|
||||
File: filename,
|
||||
})
|
||||
} else if entropyTripped {
|
||||
if repo.timeoutReached() {
|
||||
return
|
||||
}
|
||||
// entropy has been tripped which means if there is a regex specified in the same
|
||||
// rule, we need to inspect the line for a regex match. In otherwords, the current rule has
|
||||
// both entropy and regex set which work in combination. This helps narrow down false positives
|
||||
// on searches for generic passwords in code.
|
||||
match := rule.Regex.FindString(line)
|
||||
|
||||
// check if any rules are whitelisting this leak
|
||||
if len(rule.Whitelist) != 0 {
|
||||
for _, wl := range rule.Whitelist {
|
||||
if fileMatched(filename, wl.File) {
|
||||
// if matched, go to next rule
|
||||
goto NEXTLINE
|
||||
}
|
||||
if wl.Regex.FindString(line) != "" {
|
||||
goto NEXTLINE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if match != "" {
|
||||
// both the regex and entropy in this rule have been tripped which means this line
|
||||
// contains a leak
|
||||
repo.Manager.SendLeaks(manager.Leak{
|
||||
Line: line,
|
||||
Offender: match,
|
||||
Commit: c.Hash.String(),
|
||||
Message: c.Message,
|
||||
Repo: repo.Name,
|
||||
Rule: rule.Description,
|
||||
Author: c.Author.Name,
|
||||
Email: c.Author.Email,
|
||||
Date: c.Author.When,
|
||||
Tags: strings.Join(rule.Tags, ", "),
|
||||
File: filename,
|
||||
})
|
||||
}
|
||||
}
|
||||
NEXTLINE:
|
||||
}
|
||||
return
|
||||
}
|
||||
if rule.Regex.String() == "" {
|
||||
continue
|
||||
}
|
||||
if repo.timeoutReached() {
|
||||
return
|
||||
}
|
||||
start := time.Now()
|
||||
locs := rule.Regex.FindAllIndex([]byte(content), -1)
|
||||
if len(locs) != 0 {
|
||||
// check if any rules are whitelisting this leak
|
||||
if len(rule.Whitelist) != 0 {
|
||||
for _, wl := range rule.Whitelist {
|
||||
if fileMatched(filename, wl.File) {
|
||||
// if matched, go to next rule
|
||||
goto NEXT
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, loc := range locs {
|
||||
start := loc[0]
|
||||
end := loc[1]
|
||||
for start != 0 && content[start] != '\n' {
|
||||
start = start - 1
|
||||
}
|
||||
if start != 0 {
|
||||
// skip newline
|
||||
start = start + 1
|
||||
}
|
||||
|
||||
for end < len(content)-1 && content[end] != '\n' {
|
||||
end = end + 1
|
||||
}
|
||||
|
||||
offender := content[loc[0]:loc[1]]
|
||||
line := content[start:end]
|
||||
|
||||
if len(rule.Whitelist) != 0 {
|
||||
for _, wl := range rule.Whitelist {
|
||||
if wl.Regex.FindString(line) != "" {
|
||||
goto NEXT
|
||||
}
|
||||
}
|
||||
}
|
||||
if repo.Manager.Opts.Redact {
|
||||
line = strings.ReplaceAll(line, offender, "REDACTED")
|
||||
offender = "REDACTED"
|
||||
}
|
||||
repo.Manager.SendLeaks(manager.Leak{
|
||||
Line: line,
|
||||
Offender: offender,
|
||||
Commit: c.Hash.String(),
|
||||
Message: c.Message,
|
||||
Repo: repo.Name,
|
||||
Rule: rule.Description,
|
||||
Author: c.Author.Name,
|
||||
Email: c.Author.Email,
|
||||
Date: c.Author.When,
|
||||
Tags: strings.Join(rule.Tags, ", "),
|
||||
File: filename,
|
||||
})
|
||||
}
|
||||
}
|
||||
repo.Manager.RecordTime(manager.RegexTime{
|
||||
Time: time.Now().Sub(start).Nanoseconds(),
|
||||
Regex: rule.Regex.String(),
|
||||
})
|
||||
NEXT:
|
||||
}
|
||||
}
|
||||
|
||||
// inspectCommit accepts a commit object and a repo. This function is only called when the --commit=
|
||||
// option has been set. That option tells gitleaks to look only at a single commit and check the contents
|
||||
// of said commit. Similar to inspectPatch(), if the files contained in the commit are a binaries or if they are
|
||||
// whitelisted then those files will be skipped.
|
||||
func inspectCommit(c *object.Commit, repo *Repo) error {
|
||||
fIter, err := c.Files()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = fIter.ForEach(func(f *object.File) error {
|
||||
bin, err := f.IsBinary()
|
||||
if bin || repo.timeoutReached() {
|
||||
return nil
|
||||
} else if err != nil {
|
||||
return err
|
||||
}
|
||||
if fileMatched(f, repo.config.Whitelist.File) {
|
||||
log.Debugf("whitelisted file found, skipping audit of file: %s", f.Name)
|
||||
return nil
|
||||
}
|
||||
|
||||
if fileMatched(f.Name, repo.config.FileRegex) {
|
||||
repo.Manager.SendLeaks(manager.Leak{
|
||||
Line: "N/A",
|
||||
Offender: f.Name,
|
||||
Commit: c.Hash.String(),
|
||||
Repo: repo.Name,
|
||||
Rule: "file regex matched" + repo.config.FileRegex.String(),
|
||||
Author: c.Author.Name,
|
||||
Email: c.Author.Email,
|
||||
Date: c.Author.When,
|
||||
File: f.Name,
|
||||
})
|
||||
}
|
||||
content, err := f.Contents()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
InspectString(content, c, repo, f.Name)
|
||||
|
||||
return nil
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
// howManyThreads will return a number 1-GOMAXPROCS which is the number
|
||||
// of goroutines that will spawn during gitleaks execution
|
||||
func howManyThreads(threads int) int {
|
||||
maxThreads := runtime.GOMAXPROCS(0)
|
||||
if threads == 0 {
|
||||
return 1
|
||||
} else if threads > maxThreads {
|
||||
log.Warnf("%d threads set too high, setting to system max, %d", threads, maxThreads)
|
||||
return maxThreads
|
||||
}
|
||||
return threads
|
||||
}
|
||||
|
||||
func isCommitWhiteListed(commitHash string, whitelistedCommits []string) bool {
|
||||
for _, hash := range whitelistedCommits {
|
||||
if commitHash == hash {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func fileMatched(f interface{}, re *regexp.Regexp) bool {
|
||||
if re == nil {
|
||||
return false
|
||||
}
|
||||
switch f.(type) {
|
||||
case nil:
|
||||
return false
|
||||
case string:
|
||||
if re.FindString(f.(string)) != "" {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
case *object.File:
|
||||
if re.FindString(f.(*object.File).Name) != "" {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// getLogOptions determines what log options are used when iterating through commits.
|
||||
// It is similar to `git log {branch}`. Default behavior is to log ALL branches so
|
||||
// gitleaks gets the full git history.
|
||||
func getLogOptions(repo *Repo) (*git.LogOptions, error) {
|
||||
var logOpts git.LogOptions
|
||||
if repo.Manager.Opts.CommitFrom != "" {
|
||||
logOpts.From = plumbing.NewHash(repo.Manager.Opts.CommitFrom)
|
||||
}
|
||||
if repo.Manager.Opts.Branch != "" {
|
||||
refs, err := repo.Storer.IterReferences()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = refs.ForEach(func(ref *plumbing.Reference) error {
|
||||
if ref.Name().IsTag() {
|
||||
return nil
|
||||
}
|
||||
// check heads first
|
||||
if ref.Name().String() == "refs/heads/"+repo.Manager.Opts.Branch {
|
||||
logOpts = git.LogOptions{
|
||||
From: ref.Hash(),
|
||||
}
|
||||
return nil
|
||||
} else if ref.Name().String() == "refs/remotes/origin/"+repo.Manager.Opts.Branch {
|
||||
logOpts = git.LogOptions{
|
||||
From: ref.Hash(),
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if logOpts.From.IsZero() {
|
||||
return nil, fmt.Errorf("could not find branch %s", repo.Manager.Opts.Branch)
|
||||
}
|
||||
return &logOpts, nil
|
||||
}
|
||||
if !logOpts.From.IsZero() {
|
||||
return &logOpts, nil
|
||||
}
|
||||
return &git.LogOptions{All: true}, nil
|
||||
}
|
||||
|
||||
// howLong accepts a time.Time object which is subtracted from time.Now() and
|
||||
// converted to nanoseconds which is returned
|
||||
func howLong(t time.Time) int64 {
|
||||
return time.Now().Sub(t).Nanoseconds()
|
||||
}
|
||||
@@ -1,116 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
_ "fmt"
|
||||
"math"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// TODO LOCAL REPO!!!!
|
||||
|
||||
// checks Regex and if enabled, entropy and stopwords
|
||||
func doChecks(diff string, commit Commit, opts *Options, repo RepoDesc) []LeakElem {
|
||||
var (
|
||||
match string
|
||||
leaks []LeakElem
|
||||
leak LeakElem
|
||||
)
|
||||
|
||||
lines := strings.Split(diff, "\n")
|
||||
file := "unable to determine file"
|
||||
for _, line := range lines {
|
||||
if strings.Contains(line, "diff --git a") {
|
||||
idx := fileDiffRegex.FindStringIndex(line)
|
||||
if len(idx) == 2 {
|
||||
file = line[idx[1]:]
|
||||
}
|
||||
}
|
||||
|
||||
for leakType, re := range regexes {
|
||||
match = re.FindString(line)
|
||||
if len(match) == 0 ||
|
||||
(opts.Strict && containsStopWords(line)) ||
|
||||
(opts.Entropy && !checkShannonEntropy(line, opts)) {
|
||||
continue
|
||||
}
|
||||
|
||||
leak = LeakElem{
|
||||
Line: line,
|
||||
Commit: commit.Hash,
|
||||
Offender: match,
|
||||
Reason: leakType,
|
||||
Msg: commit.Msg,
|
||||
Time: commit.Time,
|
||||
Author: commit.Author,
|
||||
File: file,
|
||||
RepoURL: repo.url,
|
||||
}
|
||||
leaks = append(leaks, leak)
|
||||
}
|
||||
}
|
||||
return leaks
|
||||
|
||||
}
|
||||
|
||||
// checkShannonEntropy checks entropy of target
|
||||
func checkShannonEntropy(target string, opts *Options) bool {
|
||||
var (
|
||||
sum float64
|
||||
targetBase64Len int
|
||||
targetHexLen int
|
||||
base64Freq = make(map[rune]float64)
|
||||
hexFreq = make(map[rune]float64)
|
||||
bits int
|
||||
)
|
||||
|
||||
index := assignRegex.FindStringIndex(target)
|
||||
if len(index) == 0 {
|
||||
return false
|
||||
}
|
||||
target = strings.Trim(target[index[1]:], " ")
|
||||
if len(target) > 100 {
|
||||
return false
|
||||
}
|
||||
|
||||
// base64Shannon
|
||||
for _, i := range target {
|
||||
if strings.Contains(base64Chars, string(i)) {
|
||||
base64Freq[i]++
|
||||
targetBase64Len++
|
||||
}
|
||||
}
|
||||
for _, v := range base64Freq {
|
||||
f := v / float64(targetBase64Len)
|
||||
sum += f * math.Log2(f)
|
||||
}
|
||||
|
||||
bits = int(math.Ceil(sum*-1)) * targetBase64Len
|
||||
if bits > opts.B64EntropyCutoff {
|
||||
return true
|
||||
}
|
||||
|
||||
// hexShannon
|
||||
sum = 0
|
||||
for _, i := range target {
|
||||
if strings.Contains(hexChars, string(i)) {
|
||||
hexFreq[i]++
|
||||
targetHexLen++
|
||||
}
|
||||
}
|
||||
for _, v := range hexFreq {
|
||||
f := v / float64(targetHexLen)
|
||||
sum += f * math.Log2(f)
|
||||
}
|
||||
bits = int(math.Ceil(sum*-1)) * targetHexLen
|
||||
return bits > opts.HexEntropyCutoff
|
||||
}
|
||||
|
||||
// containsStopWords checks if there are any stop words in target
|
||||
func containsStopWords(target string) bool {
|
||||
for _, stopWord := range stopWords {
|
||||
if strings.Contains(target, stopWord) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCheckRegex(t *testing.T) {
|
||||
var results []LeakElem
|
||||
opts := &Options{
|
||||
Concurrency: 10,
|
||||
B64EntropyCutoff: 70,
|
||||
HexEntropyCutoff: 40,
|
||||
Entropy: false,
|
||||
}
|
||||
repo := RepoDesc{
|
||||
url: "someurl",
|
||||
}
|
||||
commit := Commit{}
|
||||
checks := map[string]int{
|
||||
"aws=\"AKIALALEMEL33243OLIAE": 1,
|
||||
"aws\"afewafewafewafewaf\"": 0,
|
||||
}
|
||||
|
||||
for k, v := range checks {
|
||||
results = doChecks(k, commit, opts, repo)
|
||||
if v != len(results) {
|
||||
t.Errorf("regexCheck failed on string %s", k)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestEntropy(t *testing.T) {
|
||||
var enoughEntropy bool
|
||||
opts := &Options{
|
||||
Concurrency: 10,
|
||||
B64EntropyCutoff: 70,
|
||||
HexEntropyCutoff: 40,
|
||||
Entropy: false,
|
||||
}
|
||||
checks := map[string]bool{
|
||||
"reddit_api_secret = settings./.http}": false,
|
||||
"heroku_client_secret = simple": false,
|
||||
"reddit_api_secret = \"4ok1WFf57-EMswEfAFGewa\"": true,
|
||||
"aws_secret= \"AKIAIMNOJVGFDXXFE4OA\"": true,
|
||||
}
|
||||
for k, v := range checks {
|
||||
enoughEntropy = checkShannonEntropy(k, opts)
|
||||
if v != enoughEntropy {
|
||||
t.Errorf("checkEntropy failed for %s. Expected %t, got %t", k, v, enoughEntropy)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestStopWords(t *testing.T) {
|
||||
if containsStopWords("aws_secret=settings.AWS_SECRET") != true {
|
||||
t.Errorf("checkStopWords Failed")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,200 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v3/options"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
)
|
||||
|
||||
// Whitelist is struct containing items that if encountered will whitelist
|
||||
// a commit/line of code that would be considered a leak.
|
||||
type Whitelist struct {
|
||||
Description string
|
||||
Regex *regexp.Regexp
|
||||
File *regexp.Regexp
|
||||
}
|
||||
|
||||
// entropy represents an entropy range
|
||||
type entropy struct {
|
||||
P1, P2 float64
|
||||
}
|
||||
|
||||
// Rule is a struct that contains information that is loaded from a gitleaks config.
|
||||
// This struct is used in the Config struct as an array of Rules and is iterated
|
||||
// over during an audit. Each rule will be checked. If a regex match is found AND
|
||||
// that match is not whitelisted (globally or locally), then a leak will be appended
|
||||
// to the final audit report.
|
||||
type Rule struct {
|
||||
Description string
|
||||
Regex *regexp.Regexp
|
||||
Tags []string
|
||||
Whitelist []Whitelist
|
||||
Entropy []entropy
|
||||
}
|
||||
|
||||
// Config is a composite struct of Rules and Whitelists
|
||||
// Each Rule contains a description, regular expression, tags, and whitelists if available
|
||||
type Config struct {
|
||||
FileRegex *regexp.Regexp
|
||||
Message *regexp.Regexp
|
||||
Rules []Rule
|
||||
Whitelist struct {
|
||||
Description string
|
||||
Commits []string
|
||||
File *regexp.Regexp
|
||||
}
|
||||
}
|
||||
|
||||
// TomlLoader gets loaded with the values from a gitleaks toml config
|
||||
// see the config in config/defaults.go for an example. TomlLoader is used
|
||||
// to generate Config values (compiling regexes, etc).
|
||||
type TomlLoader struct {
|
||||
Global struct {
|
||||
File string
|
||||
Message string
|
||||
}
|
||||
Whitelist struct {
|
||||
Description string
|
||||
Commits []string
|
||||
File string
|
||||
}
|
||||
Rules []struct {
|
||||
Description string
|
||||
Regex string
|
||||
Tags []string
|
||||
Entropies []string
|
||||
Whitelist []struct {
|
||||
Description string
|
||||
Regex string
|
||||
File string
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NewConfig will create a new config struct which contains
|
||||
// rules on how gitleaks will proceed with its audit.
|
||||
// If no options are passed via cli then NewConfig will return
|
||||
// a default config which can be seen in config.go
|
||||
func NewConfig(options options.Options) (Config, error) {
|
||||
var cfg Config
|
||||
tomlLoader := TomlLoader{}
|
||||
|
||||
var err error
|
||||
if options.Config != "" {
|
||||
_, err = toml.DecodeFile(options.Config, &tomlLoader)
|
||||
} else {
|
||||
_, err = toml.Decode(DefaultConfig, &tomlLoader)
|
||||
}
|
||||
if err != nil {
|
||||
return cfg, err
|
||||
}
|
||||
|
||||
cfg, err = tomlLoader.Parse()
|
||||
if err != nil {
|
||||
return cfg, err
|
||||
}
|
||||
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
// Parse will parse the values set in a TomlLoader and use those values
|
||||
// to create compiled regular expressions and rules used in audits
|
||||
func (tomlLoader TomlLoader) Parse() (Config, error) {
|
||||
var cfg Config
|
||||
for _, rule := range tomlLoader.Rules {
|
||||
re, err := regexp.Compile(rule.Regex)
|
||||
if err != nil {
|
||||
return cfg, fmt.Errorf("problem loading config: %v", err)
|
||||
}
|
||||
|
||||
// rule specific whitelists
|
||||
var whitelists []Whitelist
|
||||
for _, wl := range rule.Whitelist {
|
||||
re, err := regexp.Compile(wl.Regex)
|
||||
if err != nil {
|
||||
return cfg, fmt.Errorf("problem loading config: %v", err)
|
||||
}
|
||||
fileRe, err := regexp.Compile(wl.File)
|
||||
if err != nil {
|
||||
return cfg, fmt.Errorf("problem loading config: %v", err)
|
||||
}
|
||||
whitelists = append(whitelists, Whitelist{
|
||||
Description: wl.Description,
|
||||
File: fileRe,
|
||||
Regex: re,
|
||||
})
|
||||
}
|
||||
|
||||
entropies, err := getEntropy(rule.Entropies)
|
||||
if err != nil {
|
||||
return cfg, err
|
||||
}
|
||||
|
||||
cfg.Rules = append(cfg.Rules, Rule{
|
||||
Description: rule.Description,
|
||||
Regex: re,
|
||||
Tags: rule.Tags,
|
||||
Whitelist: whitelists,
|
||||
Entropy: entropies,
|
||||
})
|
||||
}
|
||||
|
||||
// global leaks
|
||||
if tomlLoader.Global.File != "" {
|
||||
re, err := regexp.Compile(tomlLoader.Global.File)
|
||||
if err != nil {
|
||||
return cfg, fmt.Errorf("problem loading config: %v", err)
|
||||
}
|
||||
cfg.FileRegex = re
|
||||
}
|
||||
if tomlLoader.Global.Message != "" {
|
||||
re, err := regexp.Compile(tomlLoader.Global.Message)
|
||||
if err != nil {
|
||||
return cfg, fmt.Errorf("problem loading config: %v", err)
|
||||
}
|
||||
cfg.Message = re
|
||||
}
|
||||
|
||||
// global whitelists
|
||||
if tomlLoader.Whitelist.File != "" {
|
||||
re, err := regexp.Compile(tomlLoader.Whitelist.File)
|
||||
if err != nil {
|
||||
return cfg, fmt.Errorf("problem loading config: %v", err)
|
||||
}
|
||||
cfg.Whitelist.File = re
|
||||
}
|
||||
cfg.Whitelist.Commits = tomlLoader.Whitelist.Commits
|
||||
cfg.Whitelist.Description = tomlLoader.Whitelist.Description
|
||||
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
// getEntropy
|
||||
func getEntropy(entropyStr []string) ([]entropy, error) {
|
||||
var ranges []entropy
|
||||
for _, span := range entropyStr {
|
||||
split := strings.Split(span, "-")
|
||||
v1, err := strconv.ParseFloat(split[0], 64)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
v2, err := strconv.ParseFloat(split[1], 64)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if v1 > v2 {
|
||||
return nil, fmt.Errorf("entropy range must be ascending")
|
||||
}
|
||||
r := entropy{P1: v1, P2: v2}
|
||||
if r.P1 > 8.0 || r.P1 < 0.0 || r.P2 > 8.0 || r.P2 < 0.0 {
|
||||
return nil, fmt.Errorf("invalid entropy ranges, must be within 0.0-8.0")
|
||||
}
|
||||
ranges = append(ranges, r)
|
||||
}
|
||||
return ranges, nil
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/zricethezav/gitleaks/v3/options"
|
||||
"regexp"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestParse(t *testing.T) {
|
||||
tests := []struct {
|
||||
description string
|
||||
opts options.Options
|
||||
wantErr error
|
||||
wantFileRegex *regexp.Regexp
|
||||
wantMessages *regexp.Regexp
|
||||
wantWhitelist Whitelist
|
||||
}{
|
||||
{
|
||||
description: "default config",
|
||||
opts: options.Options{},
|
||||
},
|
||||
{
|
||||
description: "test successful load",
|
||||
opts: options.Options{
|
||||
Config: "../test_data/test_configs/aws_key.toml",
|
||||
},
|
||||
},
|
||||
{
|
||||
description: "test bad toml",
|
||||
opts: options.Options{
|
||||
Config: "../test_data/test_configs/bad_aws_key.toml",
|
||||
},
|
||||
wantErr: fmt.Errorf("Near line 7 (last key parsed 'rules.description'): expected value but found \"AWS\" instead"),
|
||||
},
|
||||
{
|
||||
description: "test bad regex",
|
||||
opts: options.Options{
|
||||
Config: "../test_data/test_configs/bad_regex_aws_key.toml",
|
||||
},
|
||||
wantErr: fmt.Errorf("problem loading config: error parsing regexp: invalid nested repetition operator: `???`"),
|
||||
},
|
||||
{
|
||||
description: "test bad global whitelist file regex",
|
||||
opts: options.Options{
|
||||
Config: "../test_data/test_configs/bad_aws_key_global_whitelist_file.toml",
|
||||
},
|
||||
wantErr: fmt.Errorf("problem loading config: error parsing regexp: missing argument to repetition operator: `??`"),
|
||||
},
|
||||
{
|
||||
description: "test bad global file regex",
|
||||
opts: options.Options{
|
||||
Config: "../test_data/test_configs/bad_aws_key_file_regex.toml",
|
||||
},
|
||||
wantErr: fmt.Errorf("problem loading config: error parsing regexp: missing argument to repetition operator: `??`"),
|
||||
},
|
||||
{
|
||||
description: "test bad global message regex",
|
||||
opts: options.Options{
|
||||
Config: "../test_data/test_configs/bad_aws_key_message_regex.toml",
|
||||
},
|
||||
wantErr: fmt.Errorf("problem loading config: error parsing regexp: missing argument to repetition operator: `??`"),
|
||||
},
|
||||
{
|
||||
description: "test successful load big ol thing",
|
||||
opts: options.Options{
|
||||
Config: "../test_data/test_configs/large.toml",
|
||||
},
|
||||
},
|
||||
{
|
||||
description: "test load entropy",
|
||||
opts: options.Options{
|
||||
Config: "../test_data/test_configs/entropy.toml",
|
||||
},
|
||||
},
|
||||
{
|
||||
description: "test entropy bad range",
|
||||
opts: options.Options{
|
||||
Config: "../test_data/test_configs/bad_entropy_1.toml",
|
||||
},
|
||||
wantErr: fmt.Errorf("entropy range must be ascending"),
|
||||
},
|
||||
{
|
||||
description: "test entropy value p2",
|
||||
opts: options.Options{
|
||||
Config: "../test_data/test_configs/bad_entropy_2.toml",
|
||||
},
|
||||
wantErr: fmt.Errorf("strconv.ParseFloat: parsing \"x\": invalid syntax"),
|
||||
},
|
||||
{
|
||||
description: "test entropy value p1",
|
||||
opts: options.Options{
|
||||
Config: "../test_data/test_configs/bad_entropy_3.toml",
|
||||
},
|
||||
wantErr: fmt.Errorf("strconv.ParseFloat: parsing \"x\": invalid syntax"),
|
||||
},
|
||||
{
|
||||
description: "test entropy value p1",
|
||||
opts: options.Options{
|
||||
Config: "../test_data/test_configs/bad_entropy_4.toml",
|
||||
},
|
||||
wantErr: fmt.Errorf("invalid entropy ranges, must be within 0.0-8.0"),
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
_, err := NewConfig(test.opts)
|
||||
if err != nil {
|
||||
if test.wantErr == nil {
|
||||
t.Error(err)
|
||||
} else if test.wantErr.Error() != err.Error() {
|
||||
t.Errorf("expected err: %s, got %s", test.wantErr, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
package config
|
||||
|
||||
// DefaultConfig is the default gitleaks configuration. If --config={path-to-config} is set than the config located
|
||||
// at {path-to-config} will be used. Alternatively, if --repo-config is set then gitleaks will attempt to
|
||||
// use the config set in a gitleaks.toml or .gitleaks.toml file in the repo that is run with --repo-config set.
|
||||
const DefaultConfig = `
|
||||
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 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 = "Asymmetric Private Key"
|
||||
regex = '''-----BEGIN ((EC|PGP|DSA|RSA|OPENSSH) )?PRIVATE KEY( BLOCK)?-----'''
|
||||
tags = ["key", "AsymmetricPrivateKey"]
|
||||
|
||||
[[rules]]
|
||||
description = "Generic Credential"
|
||||
regex = '''(?i)(api_key|apikey|secret)(.{0,20})?['|"][0-9a-zA-Z]{16,45}['|"]'''
|
||||
tags = ["key", "API", "generic"]
|
||||
|
||||
[[rules]]
|
||||
description = "Google API key"
|
||||
regex = '''AIza[0-9A-Za-z\\-_]{35}'''
|
||||
tags = ["key", "Google"]
|
||||
|
||||
|
||||
[[rules]]
|
||||
description = "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 = "SendGrid API Key"
|
||||
regex = '''SG\.[\w_]{16,32}\.[\w_]{16,64}'''
|
||||
tags = ["key", "SendGrid"]
|
||||
|
||||
[[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"]
|
||||
|
||||
[whitelist]
|
||||
description = "Whitelisted files"
|
||||
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)$'''
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
|
||||
# This is an example of what adding gitleaks to a pre-commit hook would look like.
|
||||
|
||||
gitleaksEnabled=$(git config --bool hooks.gitleaks)
|
||||
cmd="/Users/zrice/go/src/github.com/zricethezav/gitleaks/gitleaks --verbose --redact --pretty"
|
||||
if [ $gitleaksEnabled == "true" ]; then
|
||||
$cmd
|
||||
if [ $? -eq 1 ]; then
|
||||
cat <<\EOF
|
||||
Error: gitleaks has detected sensitive information in your changes.
|
||||
If you know what you are doing you can disable this check using:
|
||||
|
||||
git config hooks.gitleaks false
|
||||
|
||||
EOF
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
@@ -0,0 +1,15 @@
|
||||
# This config contains a single rule which defines a regex and a range of entropy values. If a rule has
|
||||
# both regex and entropy then that rule uses BOTH the regex and entropy in combination when performing an audit.
|
||||
# In other words, if a line of code has an entropy value that is within the range of the entropies defined and
|
||||
# a regex match is found then that line of code contains a leak.
|
||||
|
||||
# So, for this example if a line of code has an entropy value of 4.6 AND matches the regex below then we got a leak.
|
||||
|
||||
[[rules]]
|
||||
description = "entropy and regex"
|
||||
regex = '''(?i)key(.{0,20})?['|"][0-9a-zA-Z]{16,45}['|"]'''
|
||||
entropies = [
|
||||
"4.5-4.7",
|
||||
"5.5-6.3",
|
||||
]
|
||||
tags = ["entropy"]
|
||||
@@ -0,0 +1,10 @@
|
||||
# This is a simple gitleaks config that contains one rule which checks for AWS keys and a file check that will trigger
|
||||
# a leak if a .pem file is found
|
||||
|
||||
[[rules]]
|
||||
description = "AWS Manager ID"
|
||||
regex = '''(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}'''
|
||||
tags = ["key", "AWS"]
|
||||
|
||||
[Global]
|
||||
file = '''(.*)?pem$'''
|
||||
@@ -0,0 +1,13 @@
|
||||
# This config contains a single rule that checks for AWS keys. However, it also contains a whitelist table
|
||||
# where you can define one or more whitelists. What this means is that if you have an example AWS key as part of your
|
||||
# code (in a test for example), then you can whitelist that specific key so gitleaks will not label it as a leak.
|
||||
# If this line was present in a git history: `aws_access_key_id='AKIAIO5FODNN7EXAMPLE``, gitleaks would match this line
|
||||
# with the rule below, but since we have a whitelist against that specific key, it would be ignored.
|
||||
|
||||
[[rules]]
|
||||
description = "AWS Manager ID"
|
||||
regex = '''(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}'''
|
||||
tags = ["key", "AWS"]
|
||||
[[rules.whitelist]]
|
||||
regex = '''AKIAIO5FODNN7EXAMPLE.*'''
|
||||
description = "ignore example aws key"
|
||||
@@ -0,0 +1,6 @@
|
||||
# This is a simple gitleaks config that contains one rule which checks for AWS keys.
|
||||
|
||||
[[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"]
|
||||
@@ -0,0 +1,18 @@
|
||||
module github.com/zricethezav/gitleaks/v3
|
||||
|
||||
go 1.13
|
||||
|
||||
require (
|
||||
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/hako/durafmt v0.0.0-20191009132224-3f39dc1ed9f4
|
||||
github.com/jessevdk/go-flags v1.4.0
|
||||
github.com/mattn/go-colorable v0.1.2
|
||||
github.com/sergi/go-diff v1.0.0
|
||||
github.com/sirupsen/logrus v1.4.2
|
||||
github.com/xanzy/go-gitlab v0.21.0
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
|
||||
gopkg.in/src-d/go-billy.v4 v4.3.2
|
||||
gopkg.in/src-d/go-git.v4 v4.13.1
|
||||
)
|
||||
@@ -0,0 +1,123 @@
|
||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7 h1:uSoVVbwJiQipAclBbw+8quDsfcvFjOpI5iCf4p/cqCs=
|
||||
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs=
|
||||
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA=
|
||||
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
|
||||
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
|
||||
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
|
||||
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg=
|
||||
github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o=
|
||||
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 h1:BHsljHzVlRcyQhjrss6TZTdY2VfCqZPbv5k3iBFa2ZQ=
|
||||
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
|
||||
github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0=
|
||||
github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
|
||||
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
|
||||
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/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-github v17.0.0+incompatible h1:N0LgJ1j65A7kfXrZnUDaYCs/Sf4rEjNlfyDHW9dolSY=
|
||||
github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
|
||||
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
|
||||
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
|
||||
github.com/hako/durafmt v0.0.0-20191009132224-3f39dc1ed9f4 h1:60gBOooTSmNtrqNaRvrDbi8VAne0REaek2agjnITKSw=
|
||||
github.com/hako/durafmt v0.0.0-20191009132224-3f39dc1ed9f4/go.mod h1:5Scbynm8dF1XAPwIwkGPqzkM/shndPm79Jd1003hTjE=
|
||||
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
|
||||
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
|
||||
github.com/jessevdk/go-flags v1.4.0 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGARJA=
|
||||
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
|
||||
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd h1:Coekwdh0v2wtGp9Gmz1Ze3eVRAWJMLokvN3QjdzCHLY=
|
||||
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
|
||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU=
|
||||
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
||||
github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE=
|
||||
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
|
||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/pelletier/go-buffruneio v0.2.0/go.mod h1:JkE26KsDizTr40EUHkXVtNPvgGtbSNq5BcowyYOWdKo=
|
||||
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
|
||||
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
|
||||
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/src-d/gcfg v1.4.0 h1:xXbNR5AlLSA315x2UO+fTSSAXCDf+Ar38/6oyGbDKQ4=
|
||||
github.com/src-d/gcfg v1.4.0/go.mod h1:p/UMsR43ujA89BJY9duynAwIpvqEujIH/jFlfL7jWoI=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/xanzy/go-gitlab v0.21.0 h1:Ru55sR4TBoDNsAKwCOpzeaGtbiWj7xTksVmzBJbLu6c=
|
||||
github.com/xanzy/go-gitlab v0.21.0/go.mod h1:t4Bmvnxj7k37S4Y17lfLx+nLqkf/oQwT2HagfWKv5Og=
|
||||
github.com/xanzy/ssh-agent v0.2.1 h1:TCbipTQL2JiiCprBWx9frJ2eJlCYT00NmctrHxVAr70=
|
||||
github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4=
|
||||
golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 h1:HuIa8hRrWRSrqYzx1qI49NNxhdi2PrY7gxVSq1JjLDc=
|
||||
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181108082009-03003ca0c849/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80 h1:Ao/3l156eZf2AW5wK8a7/smtodRU+gha3+BeqJ69lRk=
|
||||
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0=
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190221075227-b4e8571b14e0/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e h1:D5TXcfTk7xF7hvieo4QErS3qqCB4teTffacDWr7CI+0=
|
||||
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190729092621-ff9f1409240a h1:mEQZbbaBjWyLNy0tmZmgEuQAR8XOQ3hL8GYi3J/NG64=
|
||||
golang.org/x/tools v0.0.0-20190729092621-ff9f1409240a/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/src-d/go-billy.v4 v4.3.2 h1:0SQA1pRztfTFx2miS8sA97XvooFeNOmvUenF4o0EcVg=
|
||||
gopkg.in/src-d/go-billy.v4 v4.3.2/go.mod h1:nDjArDMp+XMs1aFAESLRjfGSgfvoYN0hDfzEk0GjC98=
|
||||
gopkg.in/src-d/go-git-fixtures.v3 v3.5.0 h1:ivZFOIltbce2Mo8IjzUHAFoq/IylO9WHhNOAJK+LsJg=
|
||||
gopkg.in/src-d/go-git-fixtures.v3 v3.5.0/go.mod h1:dLBcvytrw/TYZsNTWCnkNF2DSIlzWYqTe3rJR56Ac7g=
|
||||
gopkg.in/src-d/go-git.v4 v4.13.1 h1:SRtFyV8Kxc0UP7aCHcijOMQGPxHSmMOPrzulQWolkYE=
|
||||
gopkg.in/src-d/go-git.v4 v4.13.1/go.mod h1:nx5NYcxdKxq5fpltdHnPa2Exj4Sx0EclMWZQbYDu2z8=
|
||||
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
|
||||
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
|
||||
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
+173
@@ -0,0 +1,173 @@
|
||||
package hosts
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v3/audit"
|
||||
"github.com/zricethezav/gitleaks/v3/manager"
|
||||
"github.com/zricethezav/gitleaks/v3/options"
|
||||
|
||||
"github.com/google/go-github/github"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"golang.org/x/oauth2"
|
||||
"gopkg.in/src-d/go-git.v4"
|
||||
"gopkg.in/src-d/go-git.v4/plumbing"
|
||||
"gopkg.in/src-d/go-git.v4/plumbing/object"
|
||||
)
|
||||
|
||||
// Github wraps a github client and manager. This struct implements what the Host interface defines.
|
||||
type Github struct {
|
||||
client *github.Client
|
||||
manager *manager.Manager
|
||||
wg sync.WaitGroup
|
||||
}
|
||||
|
||||
// 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.
|
||||
func NewGithubClient(m *manager.Manager) (*Github, error) {
|
||||
var err error
|
||||
ctx := context.Background()
|
||||
token := oauth2.StaticTokenSource(
|
||||
&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{
|
||||
manager: m,
|
||||
client: githubClient,
|
||||
}, err
|
||||
}
|
||||
|
||||
// Audit will audit a github user or organization's repos.
|
||||
func (g *Github) Audit() {
|
||||
ctx := context.Background()
|
||||
listOptions := github.ListOptions{
|
||||
PerPage: 100,
|
||||
Page: 1,
|
||||
}
|
||||
|
||||
var githubRepos []*github.Repository
|
||||
|
||||
for {
|
||||
var (
|
||||
_githubRepos []*github.Repository
|
||||
resp *github.Response
|
||||
err error
|
||||
)
|
||||
if g.manager.Opts.User != "" {
|
||||
_githubRepos, resp, err = g.client.Repositories.List(ctx, g.manager.Opts.User,
|
||||
&github.RepositoryListOptions{ListOptions: listOptions})
|
||||
} else if g.manager.Opts.Organization != "" {
|
||||
_githubRepos, resp, err = g.client.Repositories.ListByOrg(ctx, g.manager.Opts.Organization,
|
||||
&github.RepositoryListByOrgOptions{ListOptions: listOptions})
|
||||
}
|
||||
|
||||
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 {
|
||||
break
|
||||
}
|
||||
|
||||
if resp.LastPage != 0 {
|
||||
log.Infof("gathering github repos... progress: page %d of %d", listOptions.Page, resp.LastPage)
|
||||
} else {
|
||||
log.Infof("gathering github repos... progress: page %d of %d", listOptions.Page, listOptions.Page)
|
||||
}
|
||||
|
||||
listOptions.Page = resp.NextPage
|
||||
if err != nil || listOptions.Page == 0 {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
for _, repo := range githubRepos {
|
||||
r := audit.NewRepo(g.manager)
|
||||
r.Name = *repo.Name
|
||||
err := r.Clone(&git.CloneOptions{
|
||||
URL: *repo.CloneURL,
|
||||
})
|
||||
if err != nil {
|
||||
log.Warn("unable to clone via https and access token, attempting with ssh now")
|
||||
auth, err := options.SSHAuth(g.manager.Opts)
|
||||
if err != nil {
|
||||
log.Warnf("unable to get ssh auth, skipping clone and audit for repo %s: %+v\n", *repo.CloneURL, err)
|
||||
}
|
||||
err = r.Clone(&git.CloneOptions{
|
||||
URL: *repo.SSHURL,
|
||||
Auth: auth,
|
||||
})
|
||||
if err != nil {
|
||||
log.Warnf("err cloning %s, skipping clone and audit: %+v\n", *repo.SSHURL, err)
|
||||
}
|
||||
}
|
||||
if err = r.Audit(); err != nil {
|
||||
log.Warn(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// AuditPR audits a single github PR
|
||||
func (g *Github) AuditPR() {
|
||||
ctx := context.Background()
|
||||
splits := strings.Split(g.manager.Opts.PullRequest, "/")
|
||||
owner := splits[len(splits)-4]
|
||||
repoName := splits[len(splits)-3]
|
||||
prNum, err := strconv.Atoi(splits[len(splits)-1])
|
||||
repo := audit.NewRepo(g.manager)
|
||||
repo.Name = repoName
|
||||
log.Infof("auditing pr %s\n", g.manager.Opts.PullRequest)
|
||||
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
page := 1
|
||||
for {
|
||||
commits, resp, err := g.client.PullRequests.ListCommits(ctx, owner, repoName, prNum, &github.ListOptions{
|
||||
PerPage: 100, Page: page})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
for _, c := range commits {
|
||||
c, _, err := g.client.Repositories.GetCommit(ctx, owner, repo.Name, *c.SHA)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
commitObj := object.Commit{
|
||||
Hash: plumbing.NewHash(*c.SHA),
|
||||
Author: object.Signature{
|
||||
Name: *c.Commit.Author.Name,
|
||||
Email: *c.Commit.Author.Email,
|
||||
When: *c.Commit.Author.Date,
|
||||
},
|
||||
}
|
||||
for _, f := range c.Files {
|
||||
if f.Patch == nil {
|
||||
continue
|
||||
}
|
||||
audit.InspectString(*f.Patch, &commitObj, repo, *f.Filename)
|
||||
}
|
||||
}
|
||||
page = resp.NextPage
|
||||
if resp.LastPage == 0 {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
+108
@@ -0,0 +1,108 @@
|
||||
package hosts
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v3/audit"
|
||||
"github.com/zricethezav/gitleaks/v3/manager"
|
||||
"github.com/zricethezav/gitleaks/v3/options"
|
||||
|
||||
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.
|
||||
type Gitlab struct {
|
||||
client *gitlab.Client
|
||||
manager *manager.Manager
|
||||
ctx context.Context
|
||||
wg sync.WaitGroup
|
||||
}
|
||||
|
||||
// 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.
|
||||
func NewGitlabClient(m *manager.Manager) (*Gitlab, error) {
|
||||
var err error
|
||||
|
||||
gitlabClient := &Gitlab{
|
||||
manager: m,
|
||||
ctx: context.Background(),
|
||||
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.
|
||||
func (g *Gitlab) Audit() {
|
||||
var (
|
||||
projects []*gitlab.Project
|
||||
resp *gitlab.Response
|
||||
err error
|
||||
)
|
||||
|
||||
page := 1
|
||||
listOpts := gitlab.ListOptions{
|
||||
PerPage: 100,
|
||||
Page: page,
|
||||
}
|
||||
for {
|
||||
var _projects []*gitlab.Project
|
||||
if g.manager.Opts.User != "" {
|
||||
glOpts := &gitlab.ListProjectsOptions{
|
||||
ListOptions: listOpts,
|
||||
}
|
||||
_projects, resp, err = g.client.Projects.ListUserProjects(g.manager.Opts.User, glOpts)
|
||||
|
||||
} else if g.manager.Opts.Organization != "" {
|
||||
glOpts := &gitlab.ListGroupProjectsOptions{
|
||||
ListOptions: listOpts,
|
||||
}
|
||||
_projects, resp, err = g.client.Groups.ListGroupProjects(g.manager.Opts.Organization, glOpts)
|
||||
}
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
|
||||
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 {
|
||||
break
|
||||
}
|
||||
if page >= resp.TotalPages {
|
||||
// exit when we've seen all pages
|
||||
break
|
||||
}
|
||||
page = resp.NextPage
|
||||
}
|
||||
|
||||
// iterate of gitlab projects
|
||||
for _, p := range projects {
|
||||
r := audit.NewRepo(g.manager)
|
||||
cloneOpts := g.manager.CloneOptions
|
||||
cloneOpts.URL = p.HTTPURLToRepo
|
||||
err := r.Clone(cloneOpts)
|
||||
// TODO handle clone retry with ssh like github host
|
||||
r.Name = p.Name
|
||||
|
||||
if err = r.Audit(); err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// AuditPR TODO not implemented
|
||||
func (g *Gitlab) AuditPR() {
|
||||
log.Error("AuditPR is not implemented in Gitlab host yet...")
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package hosts
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v3/manager"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
_github int = iota + 1
|
||||
_gitlab
|
||||
)
|
||||
|
||||
// Host is an interface used for defining external git hosting providers like github and gitlab.
|
||||
// TODO add bitbucket
|
||||
type Host interface {
|
||||
Audit()
|
||||
AuditPR()
|
||||
}
|
||||
|
||||
// Run kicks off a host audit. This function accepts a manager and determines what host it should audit
|
||||
func Run(m *manager.Manager) error {
|
||||
var host Host
|
||||
var err error
|
||||
switch getHost(m.Opts.Host) {
|
||||
case _github:
|
||||
host, err = NewGithubClient(m)
|
||||
case _gitlab:
|
||||
host, err = NewGitlabClient(m)
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
|
||||
if m.Opts.PullRequest != "" {
|
||||
host.AuditPR()
|
||||
} else {
|
||||
host.Audit()
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func getHost(host string) int {
|
||||
if strings.ToLower(host) == "github" {
|
||||
return _github
|
||||
} else if strings.ToLower(host) == "gitlab" {
|
||||
return _gitlab
|
||||
}
|
||||
return -1
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package hosts
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"github.com/zricethezav/gitleaks/v3/config"
|
||||
"github.com/zricethezav/gitleaks/v3/manager"
|
||||
"github.com/zricethezav/gitleaks/v3/options"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
var (
|
||||
integration = flag.Bool("integration", false, "run github/gitlab integration test")
|
||||
)
|
||||
|
||||
func TestGithub(t *testing.T) {
|
||||
flag.Parse()
|
||||
if !*integration {
|
||||
fmt.Println("skipping github integration tests")
|
||||
return
|
||||
}
|
||||
if os.Getenv("GITHUB_TOKEN") == "" {
|
||||
t.Log("skipping github integration tests, need env var GITLAB_TOKEN")
|
||||
return
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
opts options.Options
|
||||
desiredLeaks int
|
||||
}{
|
||||
{
|
||||
opts: options.Options{
|
||||
Host: "github",
|
||||
User: "gitleakstest",
|
||||
AccessToken: os.Getenv("GITHUB_TOKEN"),
|
||||
},
|
||||
desiredLeaks: 2,
|
||||
},
|
||||
{
|
||||
opts: options.Options{
|
||||
Host: "github",
|
||||
PullRequest: "https://github.com/gitleakstest/gronit/pull/1",
|
||||
AccessToken: os.Getenv("GITHUB_TOKEN"),
|
||||
},
|
||||
desiredLeaks: 4,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
cfg, err := config.NewConfig(test.opts)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
m, err := manager.NewManager(test.opts, cfg)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
err = Run(m)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if test.desiredLeaks != len(m.GetLeaks()) {
|
||||
t.Errorf("got %d leaks, want %d", len(m.GetLeaks()), test.desiredLeaks)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGitlab(t *testing.T) {
|
||||
flag.Parse()
|
||||
if !*integration {
|
||||
fmt.Println("skipping gitlab integration tests")
|
||||
return
|
||||
}
|
||||
if os.Getenv("GITLAB_TOKEN") == "" {
|
||||
t.Log("skipping github integration tests, need env var GITLAB_TOKEN")
|
||||
return
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
opts options.Options
|
||||
desiredLeaks int
|
||||
}{
|
||||
{
|
||||
opts: options.Options{
|
||||
Host: "gitlab",
|
||||
User: "gitleakstest",
|
||||
AccessToken: os.Getenv("GITLAB_TOKEN"),
|
||||
},
|
||||
desiredLeaks: 2,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
cfg, err := config.NewConfig(test.opts)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
m, err := manager.NewManager(test.opts, cfg)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
err = Run(m)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if test.desiredLeaks != len(m.GetLeaks()) {
|
||||
t.Errorf("got %d leaks, want %d", len(m.GetLeaks()), test.desiredLeaks)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,220 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"os/signal"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// LeakElem contains the line and commit of a leak
|
||||
type LeakElem struct {
|
||||
Line string `json:"line"`
|
||||
Commit string `json:"commit"`
|
||||
Offender string `json:"string"`
|
||||
Reason string `json:"reason"`
|
||||
Msg string `json:"commitMsg"`
|
||||
Time string `json:"time"`
|
||||
Author string `json:"author"`
|
||||
File string `json:"file"`
|
||||
RepoURL string `json:"repoURL"`
|
||||
}
|
||||
|
||||
type Commit struct {
|
||||
Hash string
|
||||
Author string
|
||||
Time string
|
||||
Msg string
|
||||
}
|
||||
|
||||
func rmTmp(owner *Owner) {
|
||||
if _, err := os.Stat(owner.path); err == nil {
|
||||
err := os.RemoveAll(owner.path)
|
||||
log.Printf("\nCleaning up tmp repos in %s\n", owner.path)
|
||||
if err != nil {
|
||||
log.Printf("failed to properly remove tmp gitleaks dir: %v", err)
|
||||
}
|
||||
}
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// start
|
||||
func start(repos []RepoDesc, owner *Owner, opts *Options) {
|
||||
var report []LeakElem
|
||||
if opts.Tmp {
|
||||
defer rmTmp(owner)
|
||||
}
|
||||
|
||||
// interrupt handling
|
||||
c := make(chan os.Signal, 2)
|
||||
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
|
||||
go func() {
|
||||
<-c
|
||||
if opts.Tmp {
|
||||
rmTmp(owner)
|
||||
}
|
||||
os.Exit(1)
|
||||
}()
|
||||
|
||||
// run checks on repos
|
||||
for _, repo := range repos {
|
||||
dotGitPath := filepath.Join(repo.path, ".git")
|
||||
if _, err := os.Stat(dotGitPath); err == nil {
|
||||
if err := os.Chdir(fmt.Sprintf(repo.path)); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
// use pre-cloned repo
|
||||
fmt.Printf("Checking \x1b[37;1m%s\x1b[0m...\n", repo.url)
|
||||
err := exec.Command("git", "fetch").Run()
|
||||
if err != nil {
|
||||
log.Printf("failed to fetch repo %v", err)
|
||||
return
|
||||
}
|
||||
report = getLeaks(repo, owner, opts)
|
||||
} else {
|
||||
// no repo present, clone it
|
||||
if err := os.Chdir(fmt.Sprintf(owner.path)); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
fmt.Printf("Cloning \x1b[37;1m%s\x1b[0m...\n", repo.url)
|
||||
err := exec.Command("git", "clone", repo.url).Run()
|
||||
if err != nil {
|
||||
fmt.Printf("failed to clone repo %v", err)
|
||||
return
|
||||
}
|
||||
report = getLeaks(repo, owner, opts)
|
||||
}
|
||||
|
||||
if len(report) == 0 {
|
||||
fmt.Printf("No Leaks detected for \x1b[35;2m%s\x1b[0m...\n\n", repo.url)
|
||||
}
|
||||
|
||||
if opts.EnableJSON {
|
||||
outputGitLeaksReport(report, repo, opts)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// outputGitLeaksReport
|
||||
func outputGitLeaksReport(report []LeakElem, repo RepoDesc, opts *Options) {
|
||||
reportJSON, _ := json.MarshalIndent(report, "", "\t")
|
||||
if _, err := os.Stat(repo.owner.reportPath); os.IsNotExist(err) {
|
||||
os.Mkdir(repo.owner.reportPath, os.ModePerm)
|
||||
}
|
||||
|
||||
reportFileName := fmt.Sprintf("%s_leaks.json", repo.name)
|
||||
reportFile := filepath.Join(repo.owner.reportPath, reportFileName)
|
||||
err := ioutil.WriteFile(reportFile, reportJSON, 0644)
|
||||
if err != nil {
|
||||
log.Fatalf("Can't write to file: %s", err)
|
||||
}
|
||||
fmt.Printf("Report written to %s\n", reportFile)
|
||||
}
|
||||
|
||||
// getLeaks will attempt to find gitleaks
|
||||
func getLeaks(repo RepoDesc, owner *Owner, opts *Options) []LeakElem {
|
||||
var (
|
||||
out []byte
|
||||
err error
|
||||
commitWG sync.WaitGroup
|
||||
gitLeakReceiverWG sync.WaitGroup
|
||||
gitLeaks = make(chan LeakElem)
|
||||
report []LeakElem
|
||||
)
|
||||
semaphoreChan := make(chan struct{}, opts.Concurrency)
|
||||
|
||||
go func(commitWG *sync.WaitGroup, gitLeakReceiverWG *sync.WaitGroup) {
|
||||
for gitLeak := range gitLeaks {
|
||||
b, err := json.MarshalIndent(gitLeak, "", " ")
|
||||
if err != nil {
|
||||
fmt.Println("failed to output leak:", err)
|
||||
}
|
||||
fmt.Println(string(b))
|
||||
report = append(report, gitLeak)
|
||||
gitLeakReceiverWG.Done()
|
||||
}
|
||||
}(&commitWG, &gitLeakReceiverWG)
|
||||
|
||||
if err := os.Chdir(fmt.Sprintf(repo.path)); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
gitFormat := "--format=%H%n%an%n%s%n%ci"
|
||||
out, err = exec.Command("git", "rev-list", "--all",
|
||||
"--remotes", "--topo-order", gitFormat).Output()
|
||||
if err != nil {
|
||||
log.Fatalf("error retrieving commits%v\n", err)
|
||||
}
|
||||
|
||||
revListLines := bytes.Split(out, []byte("\n"))
|
||||
commits := parseFormattedRevList(revListLines)
|
||||
|
||||
for _, commit := range commits {
|
||||
if commit.Hash == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
commitWG.Add(1)
|
||||
go func(currCommit Commit, repoName string, commitWG *sync.WaitGroup,
|
||||
gitLeakReceiverWG *sync.WaitGroup, opts *Options) {
|
||||
defer commitWG.Done()
|
||||
if err := os.Chdir(fmt.Sprintf(repo.path)); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
commitCmp := fmt.Sprintf("%s^!", currCommit.Hash)
|
||||
semaphoreChan <- struct{}{}
|
||||
out, err := exec.Command("git", "diff", commitCmp).Output()
|
||||
<-semaphoreChan
|
||||
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "too many files open") {
|
||||
log.Printf("error retrieving diff for commit %s. Try turning concurrency down. %v\n", currCommit, err)
|
||||
}
|
||||
if opts.Tmp {
|
||||
rmTmp(owner)
|
||||
}
|
||||
}
|
||||
|
||||
leaks := doChecks(string(out), currCommit, opts, repo)
|
||||
if len(leaks) == 0 {
|
||||
return
|
||||
}
|
||||
for _, leak := range leaks {
|
||||
gitLeakReceiverWG.Add(1)
|
||||
gitLeaks <- leak
|
||||
}
|
||||
|
||||
}(commit, repo.name, &commitWG, &gitLeakReceiverWG, opts)
|
||||
|
||||
if commit.Hash == opts.SinceCommit {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
commitWG.Wait()
|
||||
gitLeakReceiverWG.Wait()
|
||||
return report
|
||||
}
|
||||
|
||||
func parseFormattedRevList(revList [][]byte) []Commit {
|
||||
var commits []Commit
|
||||
for i := 0; i < len(revList)-1; i = i + 5 {
|
||||
commit := Commit{
|
||||
Hash: string(revList[i+1]),
|
||||
Author: string(revList[i+2]),
|
||||
Msg: string(revList[i+3]),
|
||||
Time: string(revList[i+4]),
|
||||
}
|
||||
commits = append(commits, commit)
|
||||
}
|
||||
return commits
|
||||
}
|
||||
@@ -1,222 +1,97 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/google/go-github/github"
|
||||
"github.com/mitchellh/go-homedir"
|
||||
"golang.org/x/oauth2"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v3/audit"
|
||||
"github.com/zricethezav/gitleaks/v3/config"
|
||||
"github.com/zricethezav/gitleaks/v3/hosts"
|
||||
"github.com/zricethezav/gitleaks/v3/manager"
|
||||
"github.com/zricethezav/gitleaks/v3/options"
|
||||
|
||||
"github.com/hako/durafmt"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
var (
|
||||
regexes map[string]*regexp.Regexp
|
||||
stopWords []string
|
||||
base64Chars string
|
||||
hexChars string
|
||||
assignRegex *regexp.Regexp
|
||||
fileDiffRegex *regexp.Regexp
|
||||
gitLeaksPath string
|
||||
gitLeaksClonePath string
|
||||
gitLeaksReportPath string
|
||||
)
|
||||
|
||||
type RepoDesc struct {
|
||||
name string
|
||||
url string
|
||||
path string
|
||||
owner *Owner
|
||||
}
|
||||
|
||||
type Owner struct {
|
||||
name string
|
||||
url string
|
||||
accountType string
|
||||
path string
|
||||
reportPath string
|
||||
}
|
||||
|
||||
func init() {
|
||||
base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
|
||||
hexChars = "1234567890abcdefABCDEF"
|
||||
|
||||
stopWords = []string{"setting", "Setting", "SETTING", "info",
|
||||
"Info", "INFO", "env", "Env", "ENV", "environment", "Environment", "ENVIRONMENT"}
|
||||
|
||||
regexes = map[string]*regexp.Regexp{
|
||||
"PKCS8": regexp.MustCompile("-----BEGIN PRIVATE KEY-----"),
|
||||
"RSA": regexp.MustCompile("-----BEGIN RSA PRIVATE KEY-----"),
|
||||
"SSH": regexp.MustCompile("-----BEGIN OPENSSH PRIVATE KEY-----"),
|
||||
"Facebook": regexp.MustCompile("(?i)facebook.*['|\"][0-9a-f]{32}['|\"]"),
|
||||
"Twitter": regexp.MustCompile("(?i)twitter.*['|\"][0-9a-zA-Z]{35,44}['|\"]"),
|
||||
"Github": regexp.MustCompile("(?i)github.*[['|\"]0-9a-zA-Z]{35,40}['|\"]"),
|
||||
"AWS": regexp.MustCompile("AKIA[0-9A-Z]{16}"),
|
||||
"Reddit": regexp.MustCompile("(?i)reddit.*['|\"][0-9a-zA-Z]{14}['|\"]"),
|
||||
"Heroku": regexp.MustCompile("(?i)heroku.*[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}"),
|
||||
// "Custom": regexp.MustCompile(".*")
|
||||
}
|
||||
assignRegex = regexp.MustCompile(`(=|:|:=|<-)`)
|
||||
fileDiffRegex = regexp.MustCompile("diff --git a.+b/")
|
||||
homeDir, err := homedir.Dir()
|
||||
if err != nil {
|
||||
log.Fatal("Cant find home dir")
|
||||
}
|
||||
|
||||
gitLeaksPath = filepath.Join(homeDir, ".gitleaks")
|
||||
if _, err := os.Stat(gitLeaksPath); os.IsNotExist(err) {
|
||||
os.Mkdir(gitLeaksPath, os.ModePerm)
|
||||
}
|
||||
gitLeaksClonePath = filepath.Join(gitLeaksPath, "clones")
|
||||
if _, err := os.Stat(gitLeaksClonePath); os.IsNotExist(err) {
|
||||
os.Mkdir(gitLeaksClonePath, os.ModePerm)
|
||||
}
|
||||
gitLeaksReportPath = filepath.Join(gitLeaksPath, "report")
|
||||
if _, err := os.Stat(gitLeaksReportPath); os.IsNotExist(err) {
|
||||
os.Mkdir(gitLeaksReportPath, os.ModePerm)
|
||||
}
|
||||
}
|
||||
|
||||
// getOwner
|
||||
func getOwner(opts *Options) *Owner {
|
||||
var owner Owner
|
||||
if opts.RepoURL != "" {
|
||||
splitSlashes := strings.Split(opts.RepoURL, "/")
|
||||
owner = Owner{
|
||||
name: splitSlashes[len(splitSlashes)-2],
|
||||
url: opts.RepoURL,
|
||||
accountType: "users",
|
||||
}
|
||||
|
||||
} else if opts.UserURL != "" {
|
||||
_, ownerName := path.Split(opts.UserURL)
|
||||
owner = Owner{
|
||||
name: ownerName,
|
||||
url: opts.UserURL,
|
||||
accountType: "user",
|
||||
}
|
||||
} else if opts.OrgURL != "" {
|
||||
_, ownerName := path.Split(opts.OrgURL)
|
||||
owner = Owner{
|
||||
name: ownerName,
|
||||
url: opts.OrgURL,
|
||||
accountType: "org",
|
||||
}
|
||||
}
|
||||
|
||||
if opts.Tmp {
|
||||
dir, err := ioutil.TempDir("", owner.name)
|
||||
if err != nil {
|
||||
log.Fatal("Cant make temp dir")
|
||||
}
|
||||
owner.path = dir
|
||||
} else {
|
||||
owner.path = filepath.Join(gitLeaksClonePath, owner.name)
|
||||
if _, err := os.Stat(owner.path); os.IsNotExist(err) {
|
||||
os.Mkdir(owner.path, os.ModePerm)
|
||||
}
|
||||
}
|
||||
owner.reportPath = filepath.Join(gitLeaksPath, "report", owner.name)
|
||||
return &owner
|
||||
}
|
||||
|
||||
// getRepos
|
||||
func getRepos(opts *Options, owner *Owner) []RepoDesc {
|
||||
var (
|
||||
allRepos []*github.Repository
|
||||
repos []*github.Repository
|
||||
repoDescs []RepoDesc
|
||||
resp *github.Response
|
||||
ctx = context.Background()
|
||||
err error
|
||||
)
|
||||
if opts.RepoURL != "" {
|
||||
_, repoName := path.Split(opts.RepoURL)
|
||||
if strings.HasSuffix(repoName, ".git") {
|
||||
repoName = repoName[:len(repoName)-4]
|
||||
}
|
||||
ownerPath := filepath.Join(owner.path, repoName)
|
||||
repo := RepoDesc{
|
||||
name: repoName,
|
||||
url: opts.RepoURL,
|
||||
owner: owner,
|
||||
path: ownerPath}
|
||||
repoDescs = append(repoDescs, repo)
|
||||
return repoDescs
|
||||
}
|
||||
|
||||
tokenClient := getAccessToken(opts)
|
||||
gitClient := github.NewClient(tokenClient)
|
||||
|
||||
// TODO include fork check
|
||||
orgOpt := &github.RepositoryListByOrgOptions{
|
||||
ListOptions: github.ListOptions{PerPage: 10},
|
||||
}
|
||||
userOpt := &github.RepositoryListOptions{
|
||||
ListOptions: github.ListOptions{PerPage: 10},
|
||||
}
|
||||
|
||||
for {
|
||||
if opts.UserURL != "" {
|
||||
repos, resp, err = gitClient.Repositories.List(
|
||||
ctx, owner.name, userOpt)
|
||||
} else if opts.OrgURL != "" {
|
||||
repos, resp, err = gitClient.Repositories.ListByOrg(
|
||||
ctx, owner.name, orgOpt)
|
||||
}
|
||||
allRepos = append(allRepos, repos...)
|
||||
if resp.NextPage == 0 || err != nil {
|
||||
break
|
||||
}
|
||||
|
||||
for _, repo := range repos {
|
||||
repoPath := filepath.Join(owner.path, *repo.Name)
|
||||
repoDescs = append(repoDescs,
|
||||
RepoDesc{
|
||||
name: *repo.Name,
|
||||
url: *repo.CloneURL,
|
||||
owner: owner,
|
||||
path: repoPath})
|
||||
}
|
||||
|
||||
orgOpt.Page = resp.NextPage
|
||||
userOpt.Page = resp.NextPage
|
||||
}
|
||||
|
||||
return repoDescs
|
||||
}
|
||||
|
||||
// getAccessToken checks
|
||||
// 1. option
|
||||
// 2. env var
|
||||
// TODO. $HOME/.gitleaks/.creds
|
||||
func getAccessToken(opts *Options) *http.Client {
|
||||
var token string
|
||||
if opts.Token != "" {
|
||||
token = opts.Token
|
||||
} else {
|
||||
token = os.Getenv("GITHUB_TOKEN")
|
||||
}
|
||||
if token == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
tokenService := oauth2.StaticTokenSource(
|
||||
&oauth2.Token{AccessToken: token},
|
||||
)
|
||||
tokenClient := oauth2.NewClient(context.Background(), tokenService)
|
||||
return tokenClient
|
||||
}
|
||||
|
||||
func main() {
|
||||
args := os.Args[1:]
|
||||
opts := parseOptions(args)
|
||||
owner := getOwner(opts)
|
||||
repos := getRepos(opts, owner)
|
||||
start(repos, owner, opts)
|
||||
opts, err := options.ParseOptions()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
os.Exit(options.ErrorEncountered)
|
||||
}
|
||||
|
||||
err = opts.Guard()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
os.Exit(options.ErrorEncountered)
|
||||
}
|
||||
|
||||
cfg, err := config.NewConfig(opts)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
os.Exit(options.ErrorEncountered)
|
||||
}
|
||||
|
||||
m, err := manager.NewManager(opts, cfg)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
os.Exit(options.ErrorEncountered)
|
||||
}
|
||||
|
||||
err = Run(m)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
os.Exit(options.ErrorEncountered)
|
||||
}
|
||||
|
||||
leaks := m.GetLeaks()
|
||||
metadata := m.GetMetadata()
|
||||
|
||||
if len(m.GetLeaks()) != 0 {
|
||||
if m.Opts.CheckUncommitted() {
|
||||
log.Warnf("%d leaks detected in staged changes", len(leaks))
|
||||
} else {
|
||||
log.Warnf("%d leaks detected. %d commits audited in %s", len(leaks),
|
||||
metadata.Commits, durafmt.Parse(time.Duration(metadata.AuditTime)*time.Nanosecond))
|
||||
}
|
||||
os.Exit(options.LeaksPresent)
|
||||
} else {
|
||||
if m.Opts.CheckUncommitted() {
|
||||
log.Infof("No leaks detected in staged changes")
|
||||
} else {
|
||||
log.Infof("No leaks detected. %d commits audited in %s",
|
||||
metadata.Commits, durafmt.Parse(time.Duration(metadata.AuditTime)*time.Nanosecond))
|
||||
}
|
||||
os.Exit(options.Success)
|
||||
}
|
||||
}
|
||||
|
||||
// Run begins the program and contains some basic logic on how to continue with the audit. If any external git host
|
||||
// options are set (like auditing a gitlab or github user) then a specific host client will be created and
|
||||
// then Audit() and Report() will be called. Otherwise, gitleaks will create a new repo and an audit will proceed.
|
||||
// If no options or the uncommitted option is set then a pre-commit audit will
|
||||
// take place -- this is similar to running `git diff` on all the tracked files.
|
||||
func Run(m *manager.Manager) error {
|
||||
if m.Opts.Disk {
|
||||
dir, err := ioutil.TempDir("", "gitleaks")
|
||||
defer os.RemoveAll(dir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
m.CloneDir = dir
|
||||
}
|
||||
|
||||
var err error
|
||||
if m.Opts.Host != "" {
|
||||
err = hosts.Run(m)
|
||||
} else {
|
||||
err = audit.Run(m)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return m.Report()
|
||||
}
|
||||
@@ -0,0 +1,308 @@
|
||||
package manager
|
||||
|
||||
import (
|
||||
"crypto/sha1"
|
||||
"encoding/csv"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"runtime"
|
||||
"sync"
|
||||
"text/tabwriter"
|
||||
"time"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v3/config"
|
||||
"github.com/zricethezav/gitleaks/v3/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.
|
||||
// This struct is passed into each NewRepo so we are not passing around the manager in func params.
|
||||
type Manager struct {
|
||||
Opts options.Options
|
||||
Config config.Config
|
||||
|
||||
CloneOptions *git.CloneOptions
|
||||
CloneDir string
|
||||
|
||||
leaks []Leak
|
||||
leakChan chan Leak
|
||||
leakWG *sync.WaitGroup
|
||||
leakCache map[string]bool
|
||||
|
||||
stopChan chan os.Signal
|
||||
metadata Metadata
|
||||
metaWG *sync.WaitGroup
|
||||
}
|
||||
|
||||
// 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
|
||||
type Leak struct {
|
||||
Line string `json:"line"`
|
||||
Offender string `json:"offender"`
|
||||
Commit string `json:"commit"`
|
||||
Repo string `json:"repo"`
|
||||
Rule string `json:"rule"`
|
||||
Message string `json:"commitMessage"`
|
||||
Author string `json:"author"`
|
||||
Email string `json:"email"`
|
||||
File string `json:"file"`
|
||||
Date time.Time `json:"date"`
|
||||
Tags string `json:"tags"`
|
||||
lookupHash string
|
||||
}
|
||||
|
||||
// AuditTime is a type used to determine total audit time
|
||||
type AuditTime int64
|
||||
|
||||
// PatchTime is a type used to determine total patch time during an audit
|
||||
type PatchTime int64
|
||||
|
||||
// CloneTime is a type used to determine total clone time
|
||||
type CloneTime int64
|
||||
|
||||
// RegexTime is a type used to determine the time each rules' regex takes. This is especially useful
|
||||
// if you notice that gitleaks is taking a long time. You can use --debug to see the output of the regexTime
|
||||
// so you can determine which regex is not performing well.
|
||||
type RegexTime struct {
|
||||
Time int64
|
||||
Regex string
|
||||
}
|
||||
|
||||
// Metadata is a struct used to communicate metadata about an audit like timings and total commit counts.
|
||||
type Metadata struct {
|
||||
mux *sync.Mutex
|
||||
data map[string]interface{}
|
||||
|
||||
timings chan interface{}
|
||||
|
||||
RegexTime map[string]int64
|
||||
Commits int
|
||||
AuditTime int64
|
||||
patchTime int64
|
||||
cloneTime int64
|
||||
}
|
||||
|
||||
func init() {
|
||||
log.SetOutput(os.Stdout)
|
||||
log.SetFormatter(&log.TextFormatter{
|
||||
ForceColors: true,
|
||||
FullTimestamp: true,
|
||||
})
|
||||
// Fix colors on Windows
|
||||
if runtime.GOOS == "windows" {
|
||||
log.SetOutput(colorable.NewColorableStdout())
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
func (manager *Manager) GetLeaks() []Leak {
|
||||
// need to wait for any straggling leaks
|
||||
manager.leakWG.Wait()
|
||||
return manager.leaks
|
||||
}
|
||||
|
||||
// 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.
|
||||
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.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
|
||||
// manager's leaks for future reporting. If the -v/--verbose option is set the leaks will marshaled into
|
||||
// json and printed out.
|
||||
func (manager *Manager) receiveLeaks() {
|
||||
for leak := range manager.leakChan {
|
||||
if manager.alreadySeen(leak) {
|
||||
manager.leakWG.Done()
|
||||
continue
|
||||
}
|
||||
manager.leaks = append(manager.leaks, leak)
|
||||
if manager.Opts.Verbose {
|
||||
var b []byte
|
||||
if manager.Opts.PrettyPrint {
|
||||
b, _ = json.MarshalIndent(leak, "", " ")
|
||||
} else {
|
||||
b, _ = json.Marshal(leak)
|
||||
}
|
||||
fmt.Println(string(b))
|
||||
}
|
||||
manager.leakWG.Done()
|
||||
}
|
||||
}
|
||||
|
||||
// GetMetadata returns the metadata. TODO this may not need to be private
|
||||
func (manager *Manager) GetMetadata() Metadata {
|
||||
manager.metaWG.Wait()
|
||||
return manager.metadata
|
||||
}
|
||||
|
||||
// receiveMetadata is where the messages sent to the metadata channel get consumed. You can view metadata
|
||||
// by running gitleaks with the --debug option set. This is extremely useful when trying to optimize regular
|
||||
// expressions as that what gitleaks spends most of its cycles on.
|
||||
func (manager *Manager) receiveMetadata() {
|
||||
for t := range manager.metadata.timings {
|
||||
switch ti := t.(type) {
|
||||
case CloneTime:
|
||||
manager.metadata.cloneTime += int64(ti)
|
||||
case AuditTime:
|
||||
manager.metadata.AuditTime += int64(ti)
|
||||
case PatchTime:
|
||||
manager.metadata.patchTime += int64(ti)
|
||||
case RegexTime:
|
||||
manager.metadata.RegexTime[ti.Regex] = manager.metadata.RegexTime[ti.Regex] + ti.Time
|
||||
}
|
||||
manager.metaWG.Done()
|
||||
}
|
||||
}
|
||||
|
||||
// IncrementCommits increments total commits during an audit by i.
|
||||
func (manager *Manager) IncrementCommits(i int) {
|
||||
manager.metadata.mux.Lock()
|
||||
manager.metadata.Commits += i
|
||||
manager.metadata.mux.Unlock()
|
||||
}
|
||||
|
||||
// RecordTime accepts an interface and sends it to the manager's time channel
|
||||
func (manager *Manager) RecordTime(t interface{}) {
|
||||
manager.metaWG.Add(1)
|
||||
manager.metadata.timings <- t
|
||||
}
|
||||
|
||||
// DebugOutput logs metadata and other messages that occurred during a gitleaks audit
|
||||
func (manager *Manager) DebugOutput() {
|
||||
log.Debugf("-------------------------\n")
|
||||
log.Debugf("| Times and Commit Counts|\n")
|
||||
log.Debugf("-------------------------\n")
|
||||
fmt.Println("totalAuditTime: ", durafmt.Parse(time.Duration(manager.metadata.AuditTime)*time.Nanosecond))
|
||||
fmt.Println("totalPatchTime: ", durafmt.Parse(time.Duration(manager.metadata.patchTime)*time.Nanosecond))
|
||||
fmt.Println("totalCloneTime: ", durafmt.Parse(time.Duration(manager.metadata.cloneTime)*time.Nanosecond))
|
||||
fmt.Println("totalCommits: ", manager.metadata.Commits)
|
||||
|
||||
const padding = 6
|
||||
w := tabwriter.NewWriter(os.Stdout, 0, 0, padding, '.', 0)
|
||||
|
||||
log.Debugf("--------------------------\n")
|
||||
log.Debugf("| Individual Regex Times |\n")
|
||||
log.Debugf("--------------------------\n")
|
||||
for k, v := range manager.metadata.RegexTime {
|
||||
_, _ = fmt.Fprintf(w, "%s\t%s\n", k, durafmt.Parse(time.Duration(v)*time.Nanosecond))
|
||||
}
|
||||
_ = w.Flush()
|
||||
|
||||
}
|
||||
|
||||
// Report saves gitleaks leaks to a json specified by --report={report.json}
|
||||
func (manager *Manager) Report() error {
|
||||
close(manager.leakChan)
|
||||
close(manager.metadata.timings)
|
||||
|
||||
if log.IsLevelEnabled(log.DebugLevel) {
|
||||
manager.DebugOutput()
|
||||
}
|
||||
|
||||
if manager.Opts.Report != "" {
|
||||
if len(manager.GetLeaks()) == 0 {
|
||||
log.Infof("no leaks found, skipping writing report")
|
||||
return nil
|
||||
}
|
||||
file, err := os.Create(manager.Opts.Report)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if manager.Opts.ReportFormat == "json" {
|
||||
encoder := json.NewEncoder(file)
|
||||
encoder.SetIndent("", " ")
|
||||
err = encoder.Encode(manager.leaks)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
w := csv.NewWriter(file)
|
||||
_ = w.Write([]string{"repo", "line", "commit", "offender", "rule", "tags", "commitMsg", "author", "email", "file", "date"})
|
||||
for _, leak := range manager.GetLeaks() {
|
||||
w.Write([]string{leak.Repo, leak.Line, leak.Commit, leak.Offender, leak.Rule, leak.Tags, leak.Message, leak.Author, leak.Email, leak.File, leak.Date.Format(time.RFC3339)})
|
||||
}
|
||||
w.Flush()
|
||||
}
|
||||
_ = file.Close()
|
||||
|
||||
log.Infof("report written to %s", manager.Opts.Report)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (manager *Manager) receiveInterrupt() {
|
||||
<-manager.stopChan
|
||||
if manager.Opts.Report != "" {
|
||||
err := manager.Report()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
}
|
||||
log.Info("gitleaks received interrupt, stopping audit")
|
||||
os.Exit(options.ErrorEncountered)
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package manager
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"fmt"
|
||||
"github.com/zricethezav/gitleaks/v3/config"
|
||||
"github.com/zricethezav/gitleaks/v3/options"
|
||||
"io"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TODO
|
||||
// add more substantial tests... but since literally every pkg uses manager
|
||||
// these tests are kind of redundant
|
||||
func TestSendReceiveLeaks(t *testing.T) {
|
||||
|
||||
tests := []struct {
|
||||
leaksToAdd int
|
||||
goRoutines int
|
||||
}{
|
||||
{
|
||||
leaksToAdd: 10,
|
||||
},
|
||||
{
|
||||
leaksToAdd: 1000,
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
opts := options.Options{}
|
||||
cfg, _ := config.NewConfig(opts)
|
||||
m, _ := NewManager(opts, cfg)
|
||||
|
||||
for i := 0; i < test.leaksToAdd; i++ {
|
||||
// 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()
|
||||
if len(got) != test.leaksToAdd {
|
||||
t.Errorf("got %d, wanted %d leaks", len(got), test.leaksToAdd)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSendReceiveMeta(t *testing.T) {
|
||||
tests := []struct {
|
||||
auditTime int64
|
||||
patchTime int64
|
||||
cloneTime int64
|
||||
regexTime int64
|
||||
iterations int
|
||||
}{
|
||||
{
|
||||
auditTime: 1000,
|
||||
patchTime: 1000,
|
||||
cloneTime: 1000,
|
||||
regexTime: 1000,
|
||||
iterations: 100,
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
opts := options.Options{}
|
||||
cfg, _ := config.NewConfig(opts)
|
||||
m, _ := NewManager(opts, cfg)
|
||||
|
||||
for i := 0; i < test.iterations; i++ {
|
||||
m.RecordTime(AuditTime(test.auditTime))
|
||||
m.RecordTime(PatchTime(test.patchTime))
|
||||
m.RecordTime(CloneTime(test.cloneTime))
|
||||
m.RecordTime(RegexTime{
|
||||
Regex: "regex",
|
||||
Time: test.regexTime,
|
||||
})
|
||||
m.RecordTime(RegexTime{
|
||||
Regex: "regex2",
|
||||
Time: test.regexTime,
|
||||
})
|
||||
}
|
||||
md := m.GetMetadata()
|
||||
if md.cloneTime != test.cloneTime*int64(test.iterations) {
|
||||
t.Errorf("clone time mismatch, got %d, wanted %d",
|
||||
md.cloneTime, test.cloneTime*int64(test.iterations))
|
||||
}
|
||||
if md.AuditTime != test.auditTime*int64(test.iterations) {
|
||||
t.Errorf("audit time mismatch, got %d, wanted %d",
|
||||
md.AuditTime, test.auditTime*int64(test.iterations))
|
||||
}
|
||||
if md.patchTime != test.patchTime*int64(test.iterations) {
|
||||
t.Errorf("clone time mismatch, got %d, wanted %d",
|
||||
md.patchTime, test.patchTime*int64(test.iterations))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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:])
|
||||
}
|
||||
-136
@@ -1,136 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
const usage = `usage: gitleaks [options] <url>
|
||||
|
||||
Options:
|
||||
-c --concurrency Upper bound on concurrent diffs
|
||||
-u --user Git user url
|
||||
-r --repo Git repo url
|
||||
-o --org Git organization url
|
||||
-s --since Commit to stop at
|
||||
-b --b64Entropy Base64 entropy cutoff (default is 70)
|
||||
-x --hexEntropy Hex entropy cutoff (default is 40)
|
||||
-e --entropy Enable entropy
|
||||
-j --json Output gitleaks report
|
||||
-h --help Display this message
|
||||
--token Github API token
|
||||
--strict Enables stopwords
|
||||
`
|
||||
|
||||
// Options for gitleaks
|
||||
type Options struct {
|
||||
Concurrency int
|
||||
B64EntropyCutoff int
|
||||
HexEntropyCutoff int
|
||||
UserURL string
|
||||
OrgURL string
|
||||
RepoURL string
|
||||
Strict bool
|
||||
Entropy bool
|
||||
SinceCommit string
|
||||
Persist bool
|
||||
IncludeForks bool
|
||||
Tmp bool
|
||||
EnableJSON bool
|
||||
Token string
|
||||
Verbose bool
|
||||
}
|
||||
|
||||
// help prints the usage string and exits
|
||||
func help() {
|
||||
os.Stderr.WriteString(usage)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// optionsNextInt is a parseOptions helper that returns the value (int) of an option if valid
|
||||
func optionsNextInt(args []string, i *int) int {
|
||||
if len(args) > *i+1 {
|
||||
*i++
|
||||
} else {
|
||||
help()
|
||||
}
|
||||
argInt, err := strconv.Atoi(args[*i])
|
||||
if err != nil {
|
||||
fmt.Printf("Invalid %s option: %s\n", args[*i-1], args[*i])
|
||||
help()
|
||||
}
|
||||
return argInt
|
||||
}
|
||||
|
||||
// optionsNextString is a parseOptions helper that returns the value (string) of an option if valid
|
||||
func optionsNextString(args []string, i *int) string {
|
||||
if len(args) > *i+1 {
|
||||
*i++
|
||||
} else {
|
||||
fmt.Printf("Invalid %s option: %s\n", args[*i-1], args[*i])
|
||||
help()
|
||||
}
|
||||
return args[*i]
|
||||
}
|
||||
|
||||
// parseOptions
|
||||
func parseOptions(args []string) *Options {
|
||||
opts := &Options{
|
||||
Concurrency: 10,
|
||||
B64EntropyCutoff: 70,
|
||||
HexEntropyCutoff: 40,
|
||||
}
|
||||
|
||||
if len(args) == 0 {
|
||||
help()
|
||||
}
|
||||
|
||||
for i := 0; i < len(args); i++ {
|
||||
arg := args[i]
|
||||
switch arg {
|
||||
case "-s", "--since":
|
||||
opts.SinceCommit = optionsNextString(args, &i)
|
||||
case "--strict":
|
||||
opts.Strict = true
|
||||
case "-b", "--b64Entropy":
|
||||
opts.B64EntropyCutoff = optionsNextInt(args, &i)
|
||||
case "-x", "--hexEntropy":
|
||||
opts.HexEntropyCutoff = optionsNextInt(args, &i)
|
||||
case "-e", "--entropy":
|
||||
opts.Entropy = true
|
||||
case "-c", "--concurrency":
|
||||
opts.Concurrency = optionsNextInt(args, &i)
|
||||
case "-o", "--org":
|
||||
opts.OrgURL = optionsNextString(args, &i)
|
||||
case "-u", "--user":
|
||||
opts.UserURL = optionsNextString(args, &i)
|
||||
case "-r", "--repo":
|
||||
opts.RepoURL = optionsNextString(args, &i)
|
||||
case "-t", "--temporary":
|
||||
opts.Tmp = true
|
||||
case "--token":
|
||||
opts.Token = optionsNextString(args, &i)
|
||||
case "-j", "--json":
|
||||
opts.EnableJSON = true
|
||||
case "-h", "--help":
|
||||
help()
|
||||
return nil
|
||||
default:
|
||||
if i == len(args)-1 && opts.OrgURL == "" && opts.RepoURL == "" &&
|
||||
opts.UserURL == "" {
|
||||
opts.RepoURL = arg
|
||||
} else {
|
||||
fmt.Printf("Uknown option %s\n\n", arg)
|
||||
help()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// "guards"
|
||||
if opts.Tmp && opts.EnableJSON {
|
||||
fmt.Println("Report generation with temporary clones not supported")
|
||||
}
|
||||
|
||||
return opts
|
||||
}
|
||||
@@ -0,0 +1,246 @@
|
||||
package options
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/user"
|
||||
"strings"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v3/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
|
||||
// This block defines the exit codes. Success
|
||||
const (
|
||||
// No leaks or early exit due to invalid options
|
||||
Success = 0
|
||||
LeaksPresent = 1
|
||||
ErrorEncountered = 2
|
||||
)
|
||||
|
||||
// Options stores values of command line options
|
||||
type Options struct {
|
||||
Verbose bool `short:"v" long:"verbose" description:"Show verbose output from audit"`
|
||||
Repo string `short:"r" long:"repo" description:"Target repository"`
|
||||
Config string `long:"config" description:"config path"`
|
||||
Disk bool `long:"disk" description:"Clones repo(s) to disk"`
|
||||
Version bool `long:"version" description:"version number"`
|
||||
Username string `long:"username" description:"Username for git repo"`
|
||||
Password string `long:"password" description:"Password for git repo"`
|
||||
AccessToken string `long:"access-token" description:"Access token for git repo"`
|
||||
Commit string `long:"commit" description:"sha of commit to audit"`
|
||||
Threads int `long:"threads" description:"Maximum number of threads gitleaks spawns"`
|
||||
SSH string `long:"ssh-key" description:"path to ssh key used for auth"`
|
||||
Uncommited bool `long:"uncommitted" description:"run gitleaks on uncommitted code"`
|
||||
RepoPath string `long:"repo-path" description:"Path to repo"`
|
||||
OwnerPath string `long:"owner-path" description:"Path to owner directory (repos discovered)"`
|
||||
Branch string `long:"branch" description:"Branch to audit"`
|
||||
Report string `long:"report" description:"path to write json leaks file"`
|
||||
ReportFormat string `long:"report-format" default:"json" description:"json or csv"`
|
||||
Redact bool `long:"redact" description:"redact secrets from log messages and leaks"`
|
||||
Debug bool `long:"debug" description:"log debug messages"`
|
||||
RepoConfig bool `long:"repo-config" description:"Load config from target repo. Config file must be \".gitleaks.toml\" or \"gitleaks.toml\""`
|
||||
PrettyPrint bool `long:"pretty" description:"Pretty print json if leaks are present"`
|
||||
CommitFrom string `long:"commit-from" description:"Commit to start audit from"`
|
||||
CommitTo string `long:"commit-to" description:"Commit to stop audit"`
|
||||
Timeout string `long:"timeout" description:"Time allowed per audit. Ex: 10us, 30s, 1m, 1h10m1s"`
|
||||
Depth int `long:"depth" description:"Number of commits to audit"`
|
||||
|
||||
// Hosts
|
||||
Host string `long:"host" description:"git hosting service like gitlab or github. Supported hosts include: Github, Gitlab"`
|
||||
BaseURL string `long:"baseurl" description:"Base URL for API requests. Defaults to the public GitLab or GitHub API, but can be set to a domain endpoint to use with a self hosted server."`
|
||||
Organization string `long:"org" description:"organization to audit"`
|
||||
User string `long:"user" description:"user to audit"`
|
||||
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
|
||||
// is returned if successful. This struct is passed around the program
|
||||
// and will determine how the program executes. If err, an err message or help message
|
||||
// will be displayed and the program will exit with code 0.
|
||||
func ParseOptions() (Options, error) {
|
||||
var opts Options
|
||||
parser := flags.NewParser(&opts, flags.Default)
|
||||
_, err := parser.Parse()
|
||||
|
||||
if err != nil {
|
||||
if flagsErr, ok := err.(*flags.Error); ok && flagsErr.Type != flags.ErrHelp {
|
||||
parser.WriteHelp(os.Stdout)
|
||||
}
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
if opts.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)
|
||||
}
|
||||
|
||||
if opts.Debug {
|
||||
log.SetLevel(log.DebugLevel)
|
||||
}
|
||||
|
||||
return opts, nil
|
||||
}
|
||||
|
||||
// Guard checks to makes sure there are no invalid options set.
|
||||
// If invalid sets of options are present, a descriptive error will return
|
||||
// else nil is returned
|
||||
func (opts Options) Guard() error {
|
||||
if !oneOrNoneSet(opts.Repo, opts.OwnerPath, opts.RepoPath, opts.Host) {
|
||||
return fmt.Errorf("only one target option must can be set. target options: repo, owner-path, repo-path, host")
|
||||
}
|
||||
if !oneOrNoneSet(opts.Organization, opts.User, opts.PullRequest) {
|
||||
return fmt.Errorf("only one target option must can be set. target options: repo, owner-path, repo-path, host")
|
||||
}
|
||||
if !oneOrNoneSet(opts.AccessToken, opts.Password) {
|
||||
log.Warn("both access-token and password are set. Only password will be attempted")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func oneOrNoneSet(optStr ...string) bool {
|
||||
c := 0
|
||||
for _, s := range optStr {
|
||||
if s != "" {
|
||||
c++
|
||||
}
|
||||
}
|
||||
if c <= 1 {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// CloneOptions returns a git.cloneOptions pointer. The authentication method
|
||||
// is determined by what is passed in via command-Line options. If No
|
||||
// Username/PW or AccessToken is available and the repo target is not using the
|
||||
// git protocol then the repo must be a available via no auth.
|
||||
func (opts Options) CloneOptions() (*git.CloneOptions, error) {
|
||||
progress := ioutil.Discard
|
||||
if opts.Verbose {
|
||||
progress = os.Stdout
|
||||
}
|
||||
|
||||
if strings.HasPrefix(opts.Repo, "git") {
|
||||
// using git protocol so needs ssh auth
|
||||
auth, err := SSHAuth(opts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &git.CloneOptions{
|
||||
URL: opts.Repo,
|
||||
Auth: auth,
|
||||
Progress: progress,
|
||||
}, nil
|
||||
}
|
||||
if opts.Password != "" && opts.Username != "" {
|
||||
// auth using username and password
|
||||
return &git.CloneOptions{
|
||||
URL: opts.Repo,
|
||||
Auth: &http.BasicAuth{
|
||||
Username: opts.Username,
|
||||
Password: opts.Password,
|
||||
},
|
||||
Progress: progress,
|
||||
}, nil
|
||||
}
|
||||
if opts.AccessToken != "" {
|
||||
return &git.CloneOptions{
|
||||
URL: opts.Repo,
|
||||
Auth: &http.BasicAuth{
|
||||
Username: "gitleaks_user",
|
||||
Password: opts.AccessToken,
|
||||
},
|
||||
Progress: progress,
|
||||
}, nil
|
||||
}
|
||||
if os.Getenv("GITLEAKS_ACCESS_TOKEN") != "" {
|
||||
return &git.CloneOptions{
|
||||
URL: opts.Repo,
|
||||
Auth: &http.BasicAuth{
|
||||
Username: "gitleaks_user",
|
||||
Password: os.Getenv("GITLEAKS_ACCESS_TOKEN"),
|
||||
},
|
||||
Progress: progress,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// No Auth, publicly available
|
||||
return &git.CloneOptions{
|
||||
URL: opts.Repo,
|
||||
Progress: progress,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// SSHAuth tried to generate ssh public keys based on what was passed via cli. If no
|
||||
// path was passed via cli then this will attempt to retrieve keys from the default
|
||||
// location for ssh keys, $HOME/.ssh/id_rsa. This function is only called if the
|
||||
// repo url using the git:// protocol.
|
||||
func SSHAuth(opts Options) (*ssh.PublicKeys, error) {
|
||||
if opts.SSH != "" {
|
||||
return ssh.NewPublicKeysFromFile("git", opts.SSH, "")
|
||||
}
|
||||
c, err := user.Current()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defaultPath := fmt.Sprintf("%s/.ssh/id_rsa", c.HomeDir)
|
||||
return ssh.NewPublicKeysFromFile("git", defaultPath, "")
|
||||
}
|
||||
|
||||
// OpenLocal checks what options are set, if no remote targets are set
|
||||
// then return true
|
||||
func (opts Options) OpenLocal() bool {
|
||||
if opts.Uncommited || opts.RepoPath != "" || opts.Repo == "" {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// CheckUncommitted returns a boolean that indicates whether or not gitleaks should check unstaged pre-commit changes
|
||||
// or if gitleaks should check the entire git history
|
||||
func (opts Options) CheckUncommitted() bool {
|
||||
// check to make sure no remote shit is set
|
||||
if opts.Uncommited {
|
||||
return true
|
||||
}
|
||||
if opts == (Options{}) {
|
||||
return true
|
||||
}
|
||||
if opts.Repo != "" {
|
||||
return false
|
||||
}
|
||||
if opts.RepoPath != "" {
|
||||
return false
|
||||
}
|
||||
if opts.OwnerPath != "" {
|
||||
return false
|
||||
}
|
||||
if opts.Host != "" {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// GetAccessToken accepts options and returns a string which is the access token to a git host.
|
||||
// Setting this option or environment var is necessary if performing an audit with any of the git hosting providers
|
||||
// in the host pkg. The access token set by cli options takes precedence over env vars.
|
||||
func GetAccessToken(opts Options) string {
|
||||
if opts.AccessToken != "" {
|
||||
return opts.AccessToken
|
||||
}
|
||||
return os.Getenv("GITLEAKS_ACCESS_TOKEN")
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
package options
|
||||
@@ -0,0 +1,9 @@
|
||||
[[rules]]
|
||||
description = "AWS Secret Key"
|
||||
regex = '''(?i)aws(.{0,20})?(?-i)['\"][0-9a-zA-Z\/+]{40}['\"]'''
|
||||
tags = ["key", "AWS"]
|
||||
|
||||
[[rules]]
|
||||
description = "AWS Manager ID"
|
||||
regex = '''(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}'''
|
||||
tags = ["key", "AWS"]
|
||||
@@ -0,0 +1,7 @@
|
||||
[[rules]]
|
||||
description = "AWS Manager ID"
|
||||
regex = '''(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}'''
|
||||
tags = ["key", "AWS"]
|
||||
[[rules.whitelist]]
|
||||
regex = '''AKIAIO5FODNN7EXAMPLE.*'''
|
||||
description = "ignore aws key"
|
||||
@@ -0,0 +1,13 @@
|
||||
[[rules]]
|
||||
description = "AWS Secret Key"
|
||||
regex = '''(?i)aws(.{0,20})?(?-i)['\"][0-9a-zA-Z\/+]{40}['\"]'''
|
||||
tags = ["key", "AWS"]
|
||||
|
||||
[[rules]]
|
||||
description = "AWS Manager ID"
|
||||
regex = '''(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}'''
|
||||
tags = ["key", "AWS"]
|
||||
|
||||
[Global]
|
||||
file = '''(.*)?py$'''
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
[[rules]]
|
||||
description = "AWS Manager ID"
|
||||
regex = '''(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}'''
|
||||
tags = ["key", "AWS"]
|
||||
|
||||
[whitelist]
|
||||
description = "ignore md files"
|
||||
file = '''(.*)?md$'''
|
||||
@@ -0,0 +1,14 @@
|
||||
[[rules]]
|
||||
description = "AWS Manager ID"
|
||||
regex = '''(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}'''
|
||||
tags = ["key", "AWS"]
|
||||
[[rules.whitelist]]
|
||||
description = "ignore md files"
|
||||
file = '''(.*)?md$'''
|
||||
[[rules.whitelist]]
|
||||
description = "ignore this regex"
|
||||
regex = '''ignore$'''
|
||||
[[rules.whitelist]]
|
||||
description = "ignore regex and md files"
|
||||
regex = '''ignore$'''
|
||||
file = '''(.*)?md$'''
|
||||
@@ -0,0 +1,7 @@
|
||||
[[rules]]
|
||||
description = "AWS Manager ID"
|
||||
regex = '''(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}'''
|
||||
tags = ["key", "AWS"]
|
||||
[[rules.whitelist]]
|
||||
description = "ignore python files"
|
||||
file = '''(.*)?py$'''
|
||||
@@ -0,0 +1,9 @@
|
||||
[[rules]]
|
||||
description = "AWS Secret Key"
|
||||
regex = '''(?i)aws(.{0,20})?(?-i)['\"][0-9a-zA-Z\/+]{40}['\"]'''
|
||||
tags = ["key", "AWS"]
|
||||
|
||||
[[rules]]
|
||||
description = AWS Manager ID"
|
||||
regex = '''(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}'''
|
||||
tags = ["key", "AWS"]
|
||||
@@ -0,0 +1,13 @@
|
||||
[[rules]]
|
||||
description = "AWS Secret Key"
|
||||
regex = '''(?i)aws(.{0,20})?(?-i)['\"][0-9a-zA-Z\/+]{40}['\"]'''
|
||||
tags = ["key", "AWS"]
|
||||
|
||||
[[rules]]
|
||||
description = "AWS Manager ID"
|
||||
regex = '''(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}'''
|
||||
tags = ["key", "AWS"]
|
||||
|
||||
[Global]
|
||||
file = '''?????????????'''
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
[[rules]]
|
||||
description = "AWS Manager ID"
|
||||
regex = '''(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}'''
|
||||
tags = ["key", "AWS"]
|
||||
|
||||
[whitelist]
|
||||
description = "ignore md files"
|
||||
file = '''???????'''
|
||||
@@ -0,0 +1,13 @@
|
||||
[[rules]]
|
||||
description = "AWS Secret Key"
|
||||
regex = '''(?i)aws(.{0,20})?(?-i)['\"][0-9a-zA-Z\/+]{40}['\"]'''
|
||||
tags = ["key", "AWS"]
|
||||
|
||||
[[rules]]
|
||||
description = "AWS Manager ID"
|
||||
regex = '''(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}'''
|
||||
tags = ["key", "AWS"]
|
||||
|
||||
[Global]
|
||||
message = '''?????????????'''
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
[[rules]]
|
||||
description = "entropy"
|
||||
entropies = [
|
||||
"4.3-4.1",
|
||||
]
|
||||
tags = ["entropy"]
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
[[rules]]
|
||||
description = "entropy"
|
||||
entropies = [
|
||||
"4.3-x",
|
||||
]
|
||||
tags = ["entropy"]
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
[[rules]]
|
||||
description = "entropy"
|
||||
entropies = [
|
||||
"x-4.3",
|
||||
]
|
||||
tags = ["entropy"]
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
[[rules]]
|
||||
description = "entropy"
|
||||
entropies = [
|
||||
"1-8.9",
|
||||
]
|
||||
tags = ["entropy"]
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
[[rules]]
|
||||
description = "AWS Secret Key"
|
||||
regex = '''$$$???$$$??$?$?$'''
|
||||
tags = ["key", "AWS"]
|
||||
|
||||
[[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"]
|
||||
@@ -0,0 +1,8 @@
|
||||
[[rules]]
|
||||
description = "entropy"
|
||||
entropies = [
|
||||
"4.5-4.7",
|
||||
"5.5-6.3",
|
||||
]
|
||||
tags = ["entropy"]
|
||||
|
||||
@@ -0,0 +1,145 @@
|
||||
title = "gitleaks config"
|
||||
|
||||
[[rules]]
|
||||
description = "AWS Secret Key"
|
||||
regex = '''(?i)aws(.{0,20})?(?-i)['\"][0-9a-zA-Z\/+]{40}['\"]'''
|
||||
tags = ["key", "AWS"]
|
||||
|
||||
[[rules]]
|
||||
description = "AWS MWS key"
|
||||
regex = '''amzn\.mws\.[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'''
|
||||
tags = ["key", "AWS", "MWS"]
|
||||
|
||||
[[rules]]
|
||||
description = "Facebook Secret Key"
|
||||
regex = '''(?i)(facebook|fb)(.{0,20})?(?-i)['\"][0-9a-f]{32}['\"]'''
|
||||
tags = ["key", "Facebook"]
|
||||
|
||||
[[rules]]
|
||||
description = "Facebook Client ID"
|
||||
regex = '''(?i)(facebook|fb)(.{0,20})?['\"][0-9]{13,17}['\"]'''
|
||||
tags = ["key", "Facebook"]
|
||||
|
||||
[[rules]]
|
||||
description = "Twitter Secret Key"
|
||||
regex = '''(?i)twitter(.{0,20})?['\"][0-9a-z]{35,44}['\"]'''
|
||||
tags = ["key", "Twitter"]
|
||||
|
||||
[[rules]]
|
||||
description = "Twitter Client ID"
|
||||
regex = '''(?i)twitter(.{0,20})?['\"][0-9a-z]{18,25}['\"]'''
|
||||
tags = ["client", "Twitter"]
|
||||
|
||||
[[rules]]
|
||||
description = "Github"
|
||||
regex = '''(?i)github(.{0,20})?(?-i)['\"][0-9a-zA-Z]{35,40}['\"]'''
|
||||
tags = ["key", "Github"]
|
||||
|
||||
[[rules]]
|
||||
description = "LinkedIn Client ID"
|
||||
regex = '''(?i)linkedin(.{0,20})?(?-i)['\"][0-9a-z]{12}['\"]'''
|
||||
tags = ["client", "LinkedIn"]
|
||||
|
||||
[[rules]]
|
||||
description = "LinkedIn Secret Key"
|
||||
regex = '''(?i)linkedin(.{0,20})?['\"][0-9a-z]{16}['\"]'''
|
||||
tags = ["secret", "LinkedIn"]
|
||||
|
||||
[[rules]]
|
||||
description = "Slack"
|
||||
regex = '''xox[baprs]-([0-9a-zA-Z]{10,48})?'''
|
||||
tags = ["key", "Slack"]
|
||||
|
||||
[[rules]]
|
||||
description = "EC"
|
||||
regex = '''-----BEGIN EC PRIVATE KEY-----'''
|
||||
tags = ["key", "EC"]
|
||||
|
||||
[[rules]]
|
||||
description = "Generic API key"
|
||||
regex = '''(?i)(api_key|apikey)(.{0,20})?['|"][0-9a-zA-Z]{32,45}['|"]'''
|
||||
tags = ["key", "API", "generic"]
|
||||
|
||||
[[rules]]
|
||||
description = "Generic Secret"
|
||||
regex = '''(?i)secret(.{0,20})?['|"][0-9a-zA-Z]{32,45}['|"]'''
|
||||
tags = ["key", "Secret", "generic"]
|
||||
|
||||
[[rules]]
|
||||
description = "Google API key"
|
||||
regex = '''AIza[0-9A-Za-z\\-_]{35}'''
|
||||
tags = ["key", "Google"]
|
||||
|
||||
|
||||
[[rules]]
|
||||
description = "Heroku API key"
|
||||
regex = '''(?i)heroku(.{0,20})?['"][0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}['"]'''
|
||||
tags = ["key", "Heroku"]
|
||||
|
||||
[[rules]]
|
||||
description = "MailChimp API key"
|
||||
regex = '''(?i)(mailchimp|mc)(.{0,20})?['"][0-9a-f]{32}-us[0-9]{1,2}['"]'''
|
||||
tags = ["key", "Mailchimp"]
|
||||
|
||||
[[rules]]
|
||||
description = "Mailgun API key"
|
||||
regex = '''(?i)(mailgun|mg)(.{0,20})?['"][0-9a-z]{32}['"]'''
|
||||
tags = ["key", "Mailgun"]
|
||||
|
||||
[[rules]]
|
||||
description = "PayPal Braintree access token"
|
||||
regex = '''access_token\$production\$[0-9a-z]{16}\$[0-9a-f]{32}'''
|
||||
tags = ["key", "Paypal"]
|
||||
|
||||
[[rules]]
|
||||
description = "Picatic API key"
|
||||
regex = '''sk_live_[0-9a-z]{32}'''
|
||||
tags = ["key", "Picatic"]
|
||||
|
||||
[[rules]]
|
||||
description = "Slack Webhook"
|
||||
regex = '''https://hooks.slack.com/services/T[a-zA-Z0-9_]{8}/B[a-zA-Z0-9_]{8}/[a-zA-Z0-9_]{24}'''
|
||||
tags = ["key", "slack"]
|
||||
|
||||
[[rules]]
|
||||
description = "Stripe API key"
|
||||
regex = '''(?i)stripe(.{0,20})?['\"][sk|rk]_live_[0-9a-zA-Z]{24}'''
|
||||
tags = ["key", "Stripe"]
|
||||
|
||||
[[rules]]
|
||||
description = "Square access token"
|
||||
regex = '''sq0atp-[0-9A-Za-z\-_]{22}'''
|
||||
tags = ["key", "square"]
|
||||
|
||||
[[rules]]
|
||||
description = "Square OAuth secret"
|
||||
regex = '''sq0csp-[0-9A-Za-z\\-_]{43}'''
|
||||
tags = ["key", "square"]
|
||||
|
||||
[[rules]]
|
||||
description = "Twilio API key"
|
||||
regex = '''(?i)twilio(.{0,20})?['\"][0-9a-f]{32}['\"]'''
|
||||
tags = ["key", "twilio"]
|
||||
|
||||
[[rules]]
|
||||
description = "AWS Manager ID"
|
||||
regex = '''(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}'''
|
||||
tags = ["key", "AWS"]
|
||||
[[rules.whitelist]]
|
||||
description = "ignore common jenkins functions"
|
||||
regex = '''whitelistme'''
|
||||
file = '''(.*)?Jenkinsfile$'''
|
||||
[[rules.whitelist]]
|
||||
description = "ignore common jenkins functions2"
|
||||
regex = '''whitelistme'''
|
||||
file = '''(.*)?Jenkinsfile$'''
|
||||
|
||||
# Global rules. This instructs gitleaks to ignore all .pem files or if a message with
|
||||
[Global]
|
||||
file = '''(.*?)(pem)'''
|
||||
message = '''somethingbad'''
|
||||
|
||||
[whitelist]
|
||||
description = "image whitelists"
|
||||
file = '''(.*?)(jpg|gif|doc|pdf|bin)$'''
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
[[rules]]
|
||||
description = "entropy and regex"
|
||||
regex = '''(?i)key(.{0,20})?['|"][0-9a-zA-Z]{16,45}['|"]'''
|
||||
entropies = [
|
||||
"4.5-4.7",
|
||||
"5.5-6.3",
|
||||
]
|
||||
tags = ["entropy"]
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
[
|
||||
{
|
||||
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||
"offender": "Entropy range [{P1:4.5 P2:4.7} {P1:5.5 P2:6.3}]",
|
||||
"commit": "6557c92612d3b35979bd426d429255b3bf9fab74",
|
||||
"repo": "test_repo_1",
|
||||
"rule": "entropy",
|
||||
"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": "entropy"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,236 @@
|
||||
[
|
||||
{
|
||||
"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": "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"
|
||||
},
|
||||
{
|
||||
"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"
|
||||
},
|
||||
{
|
||||
"line": "AWS secret: \"AKIALALEMEL33243OLIAE\"",
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "64cfcee9aad1c84581631636bfc54f2050718d1a",
|
||||
"repo": "test_repo_3",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "rm secrets\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:36:22-04:00",
|
||||
"tags": "key, AWS"
|
||||
},
|
||||
{
|
||||
"line": "AWS secret: \"AKIALALEMEL33243OLIAE\"",
|
||||
"offender": "secret: \"AKIALALEMEL33243OLIAE\"",
|
||||
"commit": "64cfcee9aad1c84581631636bfc54f2050718d1a",
|
||||
"repo": "test_repo_3",
|
||||
"rule": "Generic Credential",
|
||||
"commitMessage": "rm secrets\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:36:22-04:00",
|
||||
"tags": "key, API, generic"
|
||||
},
|
||||
{
|
||||
"line": "AWS secret: \"AKIALALEMEL33243OLIAE\"",
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "deea550dd6c7acaf0e59432600593533984a2125",
|
||||
"repo": "test_repo_3",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "dev branch\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:35:03-04:00",
|
||||
"tags": "key, AWS"
|
||||
},
|
||||
{
|
||||
"line": "AWS secret: \"AKIALALEMEL33243OLIAE\"",
|
||||
"offender": "secret: \"AKIALALEMEL33243OLIAE\"",
|
||||
"commit": "deea550dd6c7acaf0e59432600593533984a2125",
|
||||
"repo": "test_repo_3",
|
||||
"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"
|
||||
}
|
||||
]
|
||||
@@ -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"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,28 @@
|
||||
[
|
||||
{
|
||||
"line": " Just moments after the Cessna's inquiry, a Twin Beech piped up on frequency, in a rather superior tone, asking for his ground speed. \"I have you at one hundred and twenty-five knots of ground spe...",
|
||||
"offender": "Entropy range [{P1:4.5 P2:4.7}]",
|
||||
"commit": "d8ac0b73aeeb45843319cdc5ce506516eb49bf7a",
|
||||
"repo": "test_repo_4",
|
||||
"rule": "entropy",
|
||||
"commitMessage": "removing secret.pem\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secret.pem",
|
||||
"date": "2019-10-25T13:08:39-04:00",
|
||||
"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...",
|
||||
"offender": "Entropy range [{P1:4.5 P2:4.7}]",
|
||||
"commit": "996865bb912f3bc45898a370a13aadb315014b55",
|
||||
"repo": "test_repo_4",
|
||||
"rule": "entropy",
|
||||
"commitMessage": "committing pem\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secret.pem",
|
||||
"date": "2019-10-25T13:07:41-04:00",
|
||||
"tags": "entropy"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,15 @@
|
||||
[
|
||||
{
|
||||
"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"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,41 @@
|
||||
[
|
||||
{
|
||||
"line": "N/A",
|
||||
"offender": "server.test.py",
|
||||
"commit": "d274003914c707212cbe84e3e466a00013ccb639",
|
||||
"repo": "test_repo_1",
|
||||
"rule": "file regex matched(.*)?py$",
|
||||
"commitMessage": "",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "server.test.py",
|
||||
"date": "2019-10-24T10:03:38-04:00",
|
||||
"tags": ""
|
||||
},
|
||||
{
|
||||
"line": "N/A",
|
||||
"offender": "server.test.py",
|
||||
"commit": "6557c92612d3b35979bd426d429255b3bf9fab74",
|
||||
"repo": "test_repo_1",
|
||||
"rule": "file regex matched(.*)?py$",
|
||||
"commitMessage": "",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "server.test.py",
|
||||
"date": "2019-10-24T09:29:27-04:00",
|
||||
"tags": ""
|
||||
},
|
||||
{
|
||||
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||
"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"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,15 @@
|
||||
[
|
||||
{
|
||||
"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"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,15 @@
|
||||
[
|
||||
{
|
||||
"line": " aws_access_key_id='AKIAIO5FODNN7DXAMPLE'",
|
||||
"offender": "AKIAIO5FODNN7DXAMPLE",
|
||||
"commit": "0000000000000000000000000000000000000000",
|
||||
"repo": "test_repo_1",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "***STAGED CHANGES***",
|
||||
"author": "",
|
||||
"email": "",
|
||||
"file": "server.test.py",
|
||||
"date": "1970-01-01T00:00:00Z",
|
||||
"tags": "key, AWS"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,93 @@
|
||||
[
|
||||
{
|
||||
"line": "AWS secret: \"AKIALALEMEL33243OLIAE\"",
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "64cfcee9aad1c84581631636bfc54f2050718d1a",
|
||||
"repo": "test_repo_3",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "rm secrets\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:36:22-04:00",
|
||||
"tags": "key, AWS"
|
||||
},
|
||||
{
|
||||
"line": "AWS secret: \"AKIALALEMEL33243OLIAE\"",
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "deea550dd6c7acaf0e59432600593533984a2125",
|
||||
"repo": "test_repo_3",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "dev branch\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:35:03-04:00",
|
||||
"tags": "key, AWS"
|
||||
},
|
||||
{
|
||||
"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 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": "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": "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"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,119 @@
|
||||
[
|
||||
{
|
||||
"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": "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,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"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,15 @@
|
||||
[
|
||||
{
|
||||
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||
"offender": "key_id='AKIAIO5FODNN7EXAMPLE'",
|
||||
"commit": "6557c92612d3b35979bd426d429255b3bf9fab74",
|
||||
"repo": "test_repo_1",
|
||||
"rule": "entropy and regex",
|
||||
"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": "entropy"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,15 @@
|
||||
[
|
||||
{
|
||||
"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"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1 @@
|
||||
comment
|
||||
@@ -0,0 +1 @@
|
||||
ref: refs/heads/master
|
||||
@@ -0,0 +1,7 @@
|
||||
[core]
|
||||
repositoryformatversion = 0
|
||||
filemode = true
|
||||
bare = false
|
||||
logallrefupdates = true
|
||||
ignorecase = true
|
||||
precomposeunicode = true
|
||||
@@ -0,0 +1 @@
|
||||
Unnamed repository; edit this file 'description' to name the repository.
|
||||
Binary file not shown.
@@ -0,0 +1,6 @@
|
||||
# git ls-files --others --exclude-from=.git/info/exclude
|
||||
# Lines that start with '#' are comments.
|
||||
# For a project mostly in C, the following would be a good set of
|
||||
# exclude patterns (uncomment them if you want to use them):
|
||||
# *.[oa]
|
||||
# *~
|
||||
@@ -0,0 +1,2 @@
|
||||
0000000000000000000000000000000000000000 6557c92612d3b35979bd426d429255b3bf9fab74 zach rice <zricer@protonmail.com> 1571923767 -0400 commit (initial): commit 1 with secrets
|
||||
6557c92612d3b35979bd426d429255b3bf9fab74 d274003914c707212cbe84e3e466a00013ccb639 zach rice <zricer@protonmail.com> 1571925818 -0400 commit: comment
|
||||
@@ -0,0 +1,2 @@
|
||||
0000000000000000000000000000000000000000 6557c92612d3b35979bd426d429255b3bf9fab74 zach rice <zricer@protonmail.com> 1571923767 -0400 commit (initial): commit 1 with secrets
|
||||
6557c92612d3b35979bd426d429255b3bf9fab74 d274003914c707212cbe84e3e466a00013ccb639 zach rice <zricer@protonmail.com> 1571925818 -0400 commit: comment
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
+3
@@ -0,0 +1,3 @@
|
||||
xMŽO‚@Ĺ;ď§č`‘%:XjE ˘<Éş;�¤»°ł~űĚ
|
||||
z§÷`~ďMVęFţ´Ó…P�ŇnÜHZ"�•-xIL”Eca™¶Ú÷>±Ç ‘Cľă¶®«,�¬)TNŔéżČm7
|
||||
]U¨$JŻ%ů“R.Ąw¬ÓBÎś`łÖ‡q|÷űIt␍vÇmôÝy_6ďŮ?¨!ć‹0Šb´ťÔW\>ε9ć …ęr:-†Aň+a}Ć^K§N$
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
xuPMOÃ0åÚüŠGV1lc.LEB`†Ä¸!Miç*a]R5!þ;N‡øââÄö{ÏÏÎ+—ãìôt§³;Ì�z-:¢ƒKzQ«º"hç–ðEcê€à°RKÂÚ\‰zí5\Œ³~À¬™¦/š7Ì~Ú‘‡ªª_h|PMÀÆ�næªXf]Rv�†ž¨ßTVÙh²Ì$ÈmSþÔ„ñÑׂ�D+dUÎþƒæF\âˆ%Z}VJ{²n¨ßPAæ™ä@S"�è[Èôz2›ß=Üß̧w³Éôv~5}¸�IÁ¬HLv,’�nu"C¦F¢_ÅÏ?¼dáD’гª 9¬){üeÆŠ/,Ó$axZòu ƒgm
|
||||
‹(·jÏòc•~Üøé[+Ñ9ÈÞ%.öN"s<æ¸=àVéÅŒâ¯
|
||||
~L–îïbÔãþÂY¥eMª$
|
||||
BIN
Binary file not shown.
+1
@@ -0,0 +1 @@
|
||||
x-�±jÃ0„;ç)<¤␍µSJ§B¦@¦¾Aé Û¿lI¤_¸Yú쑃·ãø¾»Þ³ÇûÇÛSƒÉ)|nó’ѶÔYÒäoðe”Ö&†SW©£‹–ÇÞ5ør±:EV“‹Óûf“C�¨¹«ä… ×Ä_�Yý␍.âüZu�¥÷\\œ°°ø½Tz"GdQÐÖ…íW£*)f<—¸=¬ÎâÆ‚ÅD…%Ë£ù¬ò¡û¦ùYÃÿîá›SC
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
Loaded 100 of 412 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user