mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-27 11:44:23 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ef4655fcf1 | ||
|
|
01b553a75d | ||
|
|
fae366a404 | ||
|
|
6129b1a15d | ||
|
|
31d03a1146 | ||
|
|
eabc7b5c12 | ||
|
|
1dc7569f95 | ||
|
|
1797e9c966 | ||
|
|
e2eaceb4cd | ||
|
|
c637b129ec | ||
|
|
8470e43d7f | ||
|
|
94f5950d68 | ||
|
|
fe69a17c9c | ||
|
|
6ca7a11d88 | ||
|
|
cfbb600fcb | ||
|
|
e36b550851 | ||
|
|
2232dc191c | ||
|
|
bdc688dd53 | ||
|
|
e0f6399d5c | ||
|
|
3e88ac6726 | ||
|
|
d0088f6c7c | ||
|
|
0d7c18cb39 | ||
|
|
d0e98416b9 | ||
|
|
b7438011b4 | ||
|
|
4e59d3bf19 | ||
|
|
e4b26aea4a | ||
|
|
473d0d55a7 | ||
|
|
8bd4649b01 | ||
|
|
a69df84325 | ||
|
|
0faebdefea | ||
|
|
a728e3abf3 | ||
|
|
e87c62fe72 | ||
|
|
4801818e3d | ||
|
|
b4a0577786 | ||
|
|
212232f80a | ||
|
|
11dcb44e41 | ||
|
|
af0df6ea2c | ||
|
|
9db91442b3 | ||
|
|
9d76070806 | ||
|
|
2fa580f1bb | ||
|
|
c6f15b768e | ||
|
|
779937ca87 | ||
|
|
731856e974 | ||
|
|
baf54631c7 | ||
|
|
3e760d7fed | ||
|
|
679f00dc9c | ||
|
|
dae5c142d7 | ||
|
|
8e8873286e | ||
|
|
6693cbdde3 | ||
|
|
8b3ce2cb1e | ||
|
|
94cae90d1e | ||
|
|
c4b07f5113 | ||
|
|
01d73028f8 | ||
|
|
862f1203ed | ||
|
|
581e81c16e | ||
|
|
6c166c9530 | ||
|
|
4181ede6cd | ||
|
|
10745be661 | ||
|
|
ee2d73c740 | ||
|
|
e7fbcf5333 | ||
|
|
2810eccc82 | ||
|
|
baff419091 | ||
|
|
d13e0fdfde | ||
|
|
5a300c3c64 | ||
|
|
d8ddb9630a | ||
|
|
1537eeb5fa | ||
|
|
1a492537dd | ||
|
|
bd4107b002 | ||
|
|
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 |
No files matched your search
@@ -0,0 +1,4 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: [zricethezav]
|
||||
custom: ["https://www.paypal.me/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
|
||||
+2
-13
@@ -1,19 +1,8 @@
|
||||
sudo: required
|
||||
language: go
|
||||
go:
|
||||
- 1.9
|
||||
- 1.14.x
|
||||
services:
|
||||
- docker
|
||||
script:
|
||||
- make test
|
||||
after_success:
|
||||
- export REPO=zricethezav/gitleaks
|
||||
- export TAG=`if [ "$TRAVIS_BRANCH" == "master" ]; then echo "latest"; else echo $TRAVIS_BRANCH;
|
||||
fi`
|
||||
- if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then make deploy; fi
|
||||
env:
|
||||
global:
|
||||
- secure: kUjq6Jgnm57V+ikDoYJ4IrFu4bLMHkaBb9uLtbQj0A545zZt4Dbooarnwqbfz2efqqMDZ9TXP6kN6677yWm0DyvFOCYx/Xq2innnVbBJczQciEUb5PI/9fcmLOfTe/QgGNi0GZOCdIOGlki2sbKxob6tTOUsm52ugRSJU92cXkX8w+Gzc6pC6fAb4moLE2QpwK1xWDHm2sHiZYExpBOH8eidSH5VPGVdNE9QmUA/FwwJ9NFGsZ8BgWCJPy7IJreyixsv2nNpiZNHoj0UgKe4wylzceu4sG/yQDIYk3fLVWBXSm/nSA17QYIjVMzQFjSAVC5dRqzq8HzFYiAYLKzkoOtrbBqEGtXzYZMN6yC8zEedk9gX6P6mvGpWYBy280uumcpGl6eoKYj5ke2H6kfcCUhMNTGZP17nmnTa1KFLAz1nxB1jfJwwO6v1l+xdytju5yAhm049Af7VyDM5GmE2x5ha48uKvK7wHtv+IKiZbbcR9ExsXvm21+7NVjQvRPzAw4/Sor9SG/yjoA/Sf7e4evy1w3fALv4WlaSisj5Yalmv7mzeeFZaIB7EIq6OryeRld2Rr1MZwwhZgIs7+SWwpjKfwhkfLVEUvSWCdnS2tnTydK6R6OFxfG5TGfR/WHooXLHEv5gMuKhUu/CqnbLyvI+8IOH2ybz2AtZWjf5n7oY=
|
||||
- secure: cIxKSkBNkPFAn243eHtwHJb8z6Uty1cZ43ZK/UABjwJoSrhu/roK4soqdZLwdVRA/0QswAlp6AC25Zs3ngLKGxxFHoeB8Tx6VLanE1zoi8OT0I2KbT92FdrLV4HlcRshKZtTFoTCfgVKPnWNKC+hil97CQzQPGRpZLBSfNefk5uCMnQiAzaJ5lyWPx+sjLHzpVlGA6aQx9ZeBQqngQJoDHKc0K3hKwug4h9mkkhyaYE3kgxtsdOYlHvOtQgVk+Zih5uW7ABOQCyAOaQVipXBC+uiuNf2DeAuGDaX69DTRKqPzuIasbhwyGqlfsr2JeofEWgZGmTaWGKMi03hnIY+U9+lHjygBW1qqVglODboouUrV3LwER9kqrT+ZFTM5Ca8VB+Gx5khkknbjWd06jpzRQxNXdukYN89kEaAHkBH844G99pMDqcZ32lHK7lpCu8n1H/Liz3ygoV6ScJXnYAP6y9rrd3bb9KEmnKhmFacVLRIAUw1vN/cgspJpl/Mk6s5rvGwsbQih1OxGyooOLxGjEGWqVDFgHFtyiwX9s9kT+hNTwKgbhp7Ragk/QuDYUPZ3Vum7HoiNPS9KpQNstLvDckdtd8h13JIw6nX+xdWbNKjjdYbAZRstJHUROQtNq3XdWNQ9YjqbCoybaxCOwOUTwOiTSWNKXjTFbFI5mR/ZO0=
|
||||
- COMMIT=${TRAVIS_COMMIT::8}
|
||||
- secure: o6uPX071qGRKgOQmitxiDr1j+KRW8W6ru0wmKNBFuUlZvQudwCUZMnVfk6OeofT1IgLCHmLS8ST81cTyeXqOQhYVZrlxTmEUpDHHRTu6dOj3eqRzdJow1LIWNpw5xfOaqXUdQ8+SQ47ZeSFapsmaY9oeRDvSJ8zLS4qUdgUylvZFJWjSrjzi2xemJa1l3MDdZRhEaNkfMliDGCv2vuUFp7tYz0QtyqBkBMORQl53dzgrcQcsRjDSE274WJl9CUg1l0pNMFsAbVCUGwUqCmKace9LXZ9JV00TRdg4EpryDsUCi23q0THnwstvRffwyJrw+xbhY/X3GKC4zOKqiCLJ4MTPQEIKlpVJQ9e9lWJ8FYhpUrl3QaHfEPINJ0taUfGhCyNzi5QBkSWbTcWVmRMmu+QIy7moW9crcz2xmVEUey7AaGwZT2Kk6JGw26w5q9IUy1Z9mwaljmHrUTqZrOX4Hj3UblpkHN+mGkoia/ipta5KhN5lTTIs4N3V+El7O2R2GggBrVHNiSualfydo+RX8k/S6PM1/C88IQO3Y2utoJrr415CznncvhF9Sc6tncZcShcNQj1iEOSsGxY2noW265eHzTMKJ/xuN6Bp9OXVK+8iOcUsz1T7F0UqwY3xnD8F7fBZ7IGG41DsXBDIcPmb+SIYbhv0uJjm3BEuv4TzIU0=
|
||||
- make security-scan
|
||||
+5
-4
@@ -1,9 +1,10 @@
|
||||
FROM golang:1.10.0 AS build
|
||||
FROM golang:1.14.1 AS build
|
||||
WORKDIR /go/src/github.com/zricethezav/gitleaks
|
||||
ARG ldflags
|
||||
COPY . .
|
||||
RUN CGO_ENABLED=0 go build -o bin/gitleaks *.go
|
||||
RUN GO111MODULE=on CGO_ENABLED=0 go build -o bin/gitleaks -ldflags "-X="${ldflags} *.go
|
||||
|
||||
FROM alpine:3.7
|
||||
FROM alpine:3.11
|
||||
RUN apk add --no-cache bash git openssh
|
||||
COPY --from=build /go/src/github.com/zricethezav/gitleaks/bin/* /usr/bin/
|
||||
ENTRYPOINT ["gitleaks"]
|
||||
@@ -11,6 +12,6 @@ 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
-153
@@ -1,153 +0,0 @@
|
||||
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
|
||||
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/BurntSushi/toml"
|
||||
packages = ["."]
|
||||
revision = "b26d9c308763d68093482582cea63d69be07a0f0"
|
||||
version = "v0.3.0"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/emirpasic/gods"
|
||||
packages = ["containers","lists","lists/arraylist","trees","trees/binaryheap","utils"]
|
||||
revision = "f6c17b524822278a87e3b3bd809fec33b51f5b46"
|
||||
version = "v1.9.0"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/franela/goblin"
|
||||
packages = ["."]
|
||||
revision = "cd5d08fb4ede9eaac1812fdb513552e7404eae2e"
|
||||
version = "0.0.2"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/golang/protobuf"
|
||||
packages = ["proto"]
|
||||
revision = "b4deda0973fb4c70b50d226b1af49f3da59f5265"
|
||||
version = "v1.1.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/jbenet/go-context"
|
||||
packages = ["io"]
|
||||
revision = "d14ea06fba99483203c19d92cfcd13ebe73135f4"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/jessevdk/go-flags"
|
||||
packages = ["."]
|
||||
revision = "c6ca198ec95c841fdb89fc0de7496fed11ab854e"
|
||||
version = "v1.4.0"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/kevinburke/ssh_config"
|
||||
packages = ["."]
|
||||
revision = "9fc7bb800b555d63157c65a904c86a2cc7b4e795"
|
||||
version = "0.4"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/mitchellh/go-homedir"
|
||||
packages = ["."]
|
||||
revision = "3864e76763d94a6df2f9960b16a20a33da9f9a66"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/pelletier/go-buffruneio"
|
||||
packages = ["."]
|
||||
revision = "c37440a7cf42ac63b919c752ca73a85067e05992"
|
||||
version = "v0.2.0"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/sergi/go-diff"
|
||||
packages = ["diffmatchpatch"]
|
||||
revision = "1744e2970ca51c86172c8190fadad617561ed6e7"
|
||||
version = "v1.0.0"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/sirupsen/logrus"
|
||||
packages = ["."]
|
||||
revision = "c155da19408a8799da419ed3eeb0cb5db0ad5dbc"
|
||||
version = "v1.0.5"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/src-d/gcfg"
|
||||
packages = [".","scanner","token","types"]
|
||||
revision = "f187355171c936ac84a82793659ebb4936bc1c23"
|
||||
version = "v1.3.0"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/xanzy/ssh-agent"
|
||||
packages = ["."]
|
||||
revision = "640f0ab560aeb89d523bb6ac322b1244d5c3796c"
|
||||
version = "v0.2.0"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "golang.org/x/crypto"
|
||||
packages = ["cast5","curve25519","ed25519","ed25519/internal/edwards25519","internal/chacha20","internal/subtle","openpgp","openpgp/armor","openpgp/elgamal","openpgp/errors","openpgp/packet","openpgp/s2k","poly1305","ssh","ssh/agent","ssh/knownhosts","ssh/terminal"]
|
||||
revision = "a49355c7e3f8fe157a85be2f77e6e269a0f89602"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "golang.org/x/net"
|
||||
packages = ["context","context/ctxhttp"]
|
||||
revision = "d0887baf81f4598189d4e12a37c6da86f0bba4d0"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "golang.org/x/oauth2"
|
||||
packages = [".","internal"]
|
||||
revision = "ef147856a6ddbb60760db74283d2424e98c87bff"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "golang.org/x/sys"
|
||||
packages = ["unix","windows"]
|
||||
revision = "ac767d655b305d4e9612f5f6e33120b9176c4ad4"
|
||||
|
||||
[[projects]]
|
||||
name = "golang.org/x/text"
|
||||
packages = ["internal/gen","internal/triegen","internal/ucd","transform","unicode/cldr","unicode/norm"]
|
||||
revision = "f21a4dfb5e38f5895301dc265a8def02365cc3d0"
|
||||
version = "v0.3.0"
|
||||
|
||||
[[projects]]
|
||||
name = "google.golang.org/appengine"
|
||||
packages = ["internal","internal/base","internal/datastore","internal/log","internal/remote_api","internal/urlfetch","urlfetch"]
|
||||
revision = "b1f26356af11148e710935ed1ac8a7f5702c7612"
|
||||
version = "v1.1.0"
|
||||
|
||||
[[projects]]
|
||||
name = "gopkg.in/src-d/go-billy.v4"
|
||||
packages = [".","helper/chroot","helper/polyfill","osfs","util"]
|
||||
revision = "83cf655d40b15b427014d7875d10850f96edba14"
|
||||
version = "v4.2.0"
|
||||
|
||||
[[projects]]
|
||||
name = "gopkg.in/src-d/go-git.v4"
|
||||
packages = [".","config","internal/revision","plumbing","plumbing/cache","plumbing/filemode","plumbing/format/config","plumbing/format/diff","plumbing/format/gitignore","plumbing/format/idxfile","plumbing/format/index","plumbing/format/objfile","plumbing/format/packfile","plumbing/format/pktline","plumbing/object","plumbing/protocol/packp","plumbing/protocol/packp/capability","plumbing/protocol/packp/sideband","plumbing/revlist","plumbing/storer","plumbing/transport","plumbing/transport/client","plumbing/transport/file","plumbing/transport/git","plumbing/transport/http","plumbing/transport/internal/common","plumbing/transport/server","plumbing/transport/ssh","storage","storage/filesystem","storage/filesystem/dotgit","storage/memory","utils/binary","utils/diff","utils/ioutil","utils/merkletrie","utils/merkletrie/filesystem","utils/merkletrie/index","utils/merkletrie/internal/frame","utils/merkletrie/noder"]
|
||||
revision = "3bd5e82b2512d85becae9677fa06b5a973fd4cfb"
|
||||
version = "v4.5.0"
|
||||
|
||||
[[projects]]
|
||||
name = "gopkg.in/warnings.v0"
|
||||
packages = ["."]
|
||||
revision = "ec4a0fea49c7b46c2aeb0b51aac55779c607e52b"
|
||||
version = "v0.1.2"
|
||||
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
inputs-digest = "5af7c639081bd99afc4a673e96079d2ed9e76d0e1bf0d2cc5ad9c71274beaa86"
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
||||
-58
@@ -1,58 +0,0 @@
|
||||
# Gopkg.toml example
|
||||
#
|
||||
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
|
||||
# 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/BurntSushi/toml"
|
||||
version = "0.3.0"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/franela/goblin"
|
||||
version = "0.0.2"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/google/go-github"
|
||||
version = "15.0.0"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/jessevdk/go-flags"
|
||||
version = "1.4.0"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/sirupsen/logrus"
|
||||
version = "1.0.5"
|
||||
|
||||
[[constraint]]
|
||||
branch = "master"
|
||||
name = "golang.org/x/oauth2"
|
||||
|
||||
[[constraint]]
|
||||
name = "gopkg.in/src-d/go-git.v4"
|
||||
version = "4.5.0"
|
||||
|
||||
[prune]
|
||||
go-tests = true
|
||||
unused-packages = true
|
||||
@@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2014 Simon Eskildsen
|
||||
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
|
||||
@@ -9,13 +9,13 @@ 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 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.
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -1,21 +1,52 @@
|
||||
.PHONY: test build-all release
|
||||
.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/v6/version.Version=$(VERSION)"
|
||||
_LDFLAGS="github.com/zricethezav/gitleaks/v6/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 github.com/golang/lint/golint
|
||||
go fmt
|
||||
golint
|
||||
go test --race -cover
|
||||
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)
|
||||
|
||||
security-scan:
|
||||
go get github.com/securego/gosec/cmd/gosec
|
||||
gosec -no-fail ./...
|
||||
|
||||
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 -f Dockerfile -t $(REPO):$(TAG) .
|
||||
echo "Pushing $(REPO):$(COMMIT) $(REPO):$(TAG)"
|
||||
docker push $(REPO)
|
||||
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
|
||||
|
||||
build-all:
|
||||
mkdir build
|
||||
env GOOS="windows" GOARCH="amd64" go build -o "build/gitleaks-windows-amd64.exe"
|
||||
env GOOS="windows" GOARCH="386" go build -o "build/gitleaks-windows-386.exe"
|
||||
env GOOS="linux" GOARCH="amd64" go build -o "build/gitleaks-linux-amd64"
|
||||
env GOOS="linux" GOARCH="arm" go build -o "build/gitleaks-linux-arm"
|
||||
env GOOS="linux" GOARCH="mips" go build -o "build/gitleaks-linux-mips"
|
||||
env GOOS="linux" GOARCH="mips" go build -o "build/gitleaks-linux-mips"
|
||||
dockerbuild:
|
||||
docker build --build-arg ldflags=$(_LDFLAGS) -f Dockerfile -t zricethezav/gitleaks:latest -t zricethezav/gitleaks:$(VERSION) .
|
||||
@@ -1,59 +1,39 @@
|
||||
<p align="center">
|
||||
<img alt="gitleaks" src="https://raw.githubusercontent.com/zricethezav/gifs/master/gitleaks5.png" height="140" />
|
||||
<img alt="gitleaks" src="https://raw.githubusercontent.com/zricethezav/gifs/master/gitleakslogo.png" height="70" />
|
||||
<p align="center">
|
||||
<a href="https://travis-ci.org/zricethezav/gitleaks"><img alt="Travis" src="https://img.shields.io/travis/zricethezav/gitleaks/master.svg?style=flat-square"></a>
|
||||
</p>
|
||||
</p>
|
||||
|
||||
## Audit git repos for secrets, keys, and whatever.
|
||||
### Powered by src-d's [go-git](https://github.com/src-d/go-git)
|
||||
|
||||
#### Installing
|
||||
|
||||
```bash
|
||||
go get -u github.com/zricethezav/gitleaks
|
||||
```
|
||||
Or download from release binaries [here](https://github.com/zricethezav/gitleaks/releases)
|
||||
Gitleaks is a SAST tool for detecting hardcoded secrets like passwords, api keys, and tokens in git repos. Gitleaks aims to be the **easy-to-use, all-in-one solution** for finding secrets, past or present, in your code.
|
||||
|
||||
### Features:
|
||||
- Scans for [commited](https://github.com/zricethezav/gitleaks/wiki/Scanning) secrets
|
||||
- Scans for [uncommitted](https://github.com/zricethezav/gitleaks/wiki/Scanning#uncommitted-changes-scan) secrets as part of shifting security left
|
||||
- Available [Github Action](https://github.com/marketplace/actions/gitleaks)
|
||||
- Gitlab and Github API support which allows scans of whole organizations, users, and pull/merge requests
|
||||
- [Custom rules](https://github.com/zricethezav/gitleaks/wiki/Configuration) via toml configuration
|
||||
- High performance using [go-git](https://github.com/go-git/go-git)
|
||||
- JSON and CSV reporting
|
||||
- Private repo scans using key or password based authentication
|
||||
|
||||
|
||||
#### Usage and Options
|
||||
```
|
||||
Usage:
|
||||
gitleaks [OPTIONS]
|
||||
## Installation, Documentation and Examples
|
||||
This project is documented [here](https://github.com/zricethezav/gitleaks/wiki)
|
||||
|
||||
Application Options:
|
||||
-r, --repo= Repo url to audit
|
||||
--github-user= User url to audit
|
||||
--github-org= Organization url to audit
|
||||
-p, --private Include private repos in audit
|
||||
-c, --commit= sha of commit to stop at
|
||||
--repo-path= Path to repo
|
||||
--owner-path= Path to owner directory (repos discovered)
|
||||
--max-go= Maximum number of concurrent go-routines gitleaks spawns
|
||||
-m, --in-memory Run gitleaks in memory
|
||||
--all-refs run audit on all refs
|
||||
--single-search= single regular expression to search for
|
||||
--config= path to gitleaks config
|
||||
--ssh-key= path to ssh key
|
||||
-l, --log= log level
|
||||
-v, --verbose Show verbose output from gitleaks audit
|
||||
--report= path to write report file
|
||||
--redact redact secrets from log messages and report
|
||||
|
||||
Help Options:
|
||||
-h, --help Show this help message
|
||||
```
|
||||
#### Exit Codes
|
||||
```
|
||||
1: leaks present
|
||||
0: no leaks
|
||||
```
|
||||
### Sponsors ❤️
|
||||
#### Corporate Sponsors
|
||||
[](https://gammanet.com/?utm_source=gitleaks&utm_medium=homepage&utm_campaign=gitleaks_promotion)
|
||||
|
||||
#### Additional Examples and Explanations
|
||||
Check the wiki [here](https://github.com/zricethezav/gitleaks/wiki)
|
||||
Gamma proactively detects and remediates data leaks across cloud apps. Scan your public repos for secret leaks with [Gamma](https://gammanet.com/github-demo?utm_source=gitleaks&utm_medium=homepage&utm_campaign=gitleaks_promotion)
|
||||
|
||||
### If you find a valid leak in a repo
|
||||
Please read this [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.
|
||||
#### Individual Sponsors
|
||||
These users are [sponsors](https://github.com/sponsors/zricethezav) of gitleaks:
|
||||
|
||||
[](https://github.com/adamdecaf) | [](https://github.com/gramidt) |
|
||||
---|---|
|
||||
----
|
||||
#### Logo Attribution
|
||||
The Gitleaks logo uses the Git Logo created <a href="https://twitter.com/jasonlong">Jason Long</a> is licensed under the <a href="https://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution 3.0 Unported License</a>.
|
||||
|
||||
### Run me with docker
|
||||
Simply run `docker run --rm --name=gitleaks zricethezav/gitleaks https://github.com/zricethezav/gitleaks`
|
||||
@@ -0,0 +1,249 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path"
|
||||
"regexp"
|
||||
"strconv"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v6/options"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// AllowList is struct containing items that if encountered will allowlist
|
||||
// a commit/line of code that would be considered a leak.
|
||||
type AllowList struct {
|
||||
Description string
|
||||
Regexes []*regexp.Regexp
|
||||
Commits []string
|
||||
Files []*regexp.Regexp
|
||||
Paths []*regexp.Regexp
|
||||
Repos []*regexp.Regexp
|
||||
}
|
||||
|
||||
// Entropy represents an entropy range
|
||||
type Entropy struct {
|
||||
Min float64
|
||||
Max float64
|
||||
Group int
|
||||
}
|
||||
|
||||
// Rule is a struct that contains information that is loaded from a gitleaks config.
|
||||
// This struct is used in the Config struct as an array of Rules and is iterated
|
||||
// over during an scan. Each rule will be checked. If a regex match is found AND
|
||||
// that match is not allowlisted (globally or locally), then a leak will be appended
|
||||
// to the final scan report.
|
||||
type Rule struct {
|
||||
Description string
|
||||
Regex *regexp.Regexp
|
||||
File *regexp.Regexp
|
||||
Path *regexp.Regexp
|
||||
Tags []string
|
||||
AllowList AllowList
|
||||
Entropies []Entropy
|
||||
}
|
||||
|
||||
// Config is a composite struct of Rules and Allowlists
|
||||
// Each Rule contains a description, regular expression, tags, and allowlists if available
|
||||
type Config struct {
|
||||
Rules []Rule
|
||||
Allowlist AllowList
|
||||
}
|
||||
|
||||
// TomlAllowList is a struct used in the TomlLoader that loads in allowlists from
|
||||
// specific rules or globally at the top level config
|
||||
type TomlAllowList struct {
|
||||
Description string
|
||||
Regexes []string
|
||||
Commits []string
|
||||
Files []string
|
||||
Paths []string
|
||||
Repos []string
|
||||
}
|
||||
|
||||
// TomlLoader gets loaded with the values from a gitleaks toml config
|
||||
// see the config in config/defaults.go for an example. TomlLoader is used
|
||||
// to generate Config values (compiling regexes, etc).
|
||||
type TomlLoader struct {
|
||||
AllowList TomlAllowList
|
||||
Rules []struct {
|
||||
Description string
|
||||
Regex string
|
||||
File string
|
||||
Path string
|
||||
Tags []string
|
||||
Entropies []struct {
|
||||
Min string
|
||||
Max string
|
||||
Group string
|
||||
}
|
||||
AllowList TomlAllowList
|
||||
}
|
||||
}
|
||||
|
||||
// NewConfig will create a new config struct which contains
|
||||
// rules on how gitleaks will proceed with its scan.
|
||||
// If no options are passed via cli then NewConfig will return
|
||||
// a default config which can be seen in config.go
|
||||
func NewConfig(options options.Options) (Config, error) {
|
||||
var cfg Config
|
||||
tomlLoader := TomlLoader{}
|
||||
|
||||
var err error
|
||||
if options.Config != "" {
|
||||
_, err = toml.DecodeFile(options.Config, &tomlLoader)
|
||||
// append a allowlist rule for allowlisting the config
|
||||
tomlLoader.AllowList.Files = append(tomlLoader.AllowList.Files, path.Base(options.Config))
|
||||
} else {
|
||||
_, err = toml.Decode(DefaultConfig, &tomlLoader)
|
||||
}
|
||||
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 scans
|
||||
func (tomlLoader TomlLoader) Parse() (Config, error) {
|
||||
var cfg Config
|
||||
for _, rule := range tomlLoader.Rules {
|
||||
// check and make sure the rule is valid
|
||||
if rule.Regex == "" && rule.Path == "" && rule.File == "" && len(rule.Entropies) == 0 {
|
||||
log.Warnf("Rule %s does not define any actionable data", rule.Description)
|
||||
continue
|
||||
}
|
||||
re, err := regexp.Compile(rule.Regex)
|
||||
if err != nil {
|
||||
return cfg, fmt.Errorf("problem loading config: %v", err)
|
||||
}
|
||||
fileNameRe, err := regexp.Compile(rule.File)
|
||||
if err != nil {
|
||||
return cfg, fmt.Errorf("problem loading config: %v", err)
|
||||
}
|
||||
filePathRe, err := regexp.Compile(rule.Path)
|
||||
if err != nil {
|
||||
return cfg, fmt.Errorf("problem loading config: %v", err)
|
||||
}
|
||||
|
||||
// rule specific allowlists
|
||||
var allowList AllowList
|
||||
|
||||
// rule specific regexes
|
||||
for _, re := range rule.AllowList.Regexes {
|
||||
allowListedRegex, err := regexp.Compile(re)
|
||||
if err != nil {
|
||||
return cfg, fmt.Errorf("problem loading config: %v", err)
|
||||
}
|
||||
allowList.Regexes = append(allowList.Regexes, allowListedRegex)
|
||||
}
|
||||
|
||||
// rule specific filenames
|
||||
for _, re := range rule.AllowList.Files {
|
||||
allowListedRegex, err := regexp.Compile(re)
|
||||
if err != nil {
|
||||
return cfg, fmt.Errorf("problem loading config: %v", err)
|
||||
}
|
||||
allowList.Files = append(allowList.Files, allowListedRegex)
|
||||
}
|
||||
|
||||
// rule specific paths
|
||||
for _, re := range rule.AllowList.Paths {
|
||||
allowListedRegex, err := regexp.Compile(re)
|
||||
if err != nil {
|
||||
return cfg, fmt.Errorf("problem loading config: %v", err)
|
||||
}
|
||||
allowList.Paths = append(allowList.Paths, allowListedRegex)
|
||||
}
|
||||
|
||||
var entropies []Entropy
|
||||
for _, e := range rule.Entropies {
|
||||
min, err := strconv.ParseFloat(e.Min, 64)
|
||||
if err != nil {
|
||||
return cfg, err
|
||||
}
|
||||
max, err := strconv.ParseFloat(e.Max, 64)
|
||||
if err != nil {
|
||||
return cfg, err
|
||||
}
|
||||
if e.Group == "" {
|
||||
e.Group = "0"
|
||||
}
|
||||
group, err := strconv.ParseInt(e.Group, 10, 64)
|
||||
if err != nil {
|
||||
return cfg, err
|
||||
} else if int(group) >= len(re.SubexpNames()) {
|
||||
return cfg, fmt.Errorf("problem loading config: group cannot be higher than number of groups in regexp")
|
||||
} else if group < 0 {
|
||||
return cfg, fmt.Errorf("problem loading config: group cannot be lower than 0")
|
||||
} else if min > 8.0 || min < 0.0 || max > 8.0 || max < 0.0 {
|
||||
return cfg, fmt.Errorf("problem loading config: invalid entropy ranges, must be within 0.0-8.0")
|
||||
} else if min > max {
|
||||
return cfg, fmt.Errorf("problem loading config: entropy Min value cannot be higher than Max value")
|
||||
}
|
||||
|
||||
entropies = append(entropies, Entropy{Min: min, Max: max, Group: int(group)})
|
||||
}
|
||||
|
||||
r := Rule{
|
||||
Description: rule.Description,
|
||||
Regex: re,
|
||||
File: fileNameRe,
|
||||
Path: filePathRe,
|
||||
Tags: rule.Tags,
|
||||
AllowList: allowList,
|
||||
Entropies: entropies,
|
||||
}
|
||||
|
||||
cfg.Rules = append(cfg.Rules, r)
|
||||
}
|
||||
|
||||
// global regex allowLists
|
||||
for _, allowListRegex := range tomlLoader.AllowList.Regexes {
|
||||
re, err := regexp.Compile(allowListRegex)
|
||||
if err != nil {
|
||||
return cfg, fmt.Errorf("problem loading config: %v", err)
|
||||
}
|
||||
cfg.Allowlist.Regexes = append(cfg.Allowlist.Regexes, re)
|
||||
}
|
||||
|
||||
// global file name allowLists
|
||||
for _, allowListFileName := range tomlLoader.AllowList.Files {
|
||||
re, err := regexp.Compile(allowListFileName)
|
||||
if err != nil {
|
||||
return cfg, fmt.Errorf("problem loading config: %v", err)
|
||||
}
|
||||
cfg.Allowlist.Files = append(cfg.Allowlist.Files, re)
|
||||
}
|
||||
|
||||
// global file path allowLists
|
||||
for _, allowListFilePath := range tomlLoader.AllowList.Paths {
|
||||
re, err := regexp.Compile(allowListFilePath)
|
||||
if err != nil {
|
||||
return cfg, fmt.Errorf("problem loading config: %v", err)
|
||||
}
|
||||
cfg.Allowlist.Paths = append(cfg.Allowlist.Paths, re)
|
||||
}
|
||||
|
||||
// global repo allowLists
|
||||
for _, allowListRepo := range tomlLoader.AllowList.Repos {
|
||||
re, err := regexp.Compile(allowListRepo)
|
||||
if err != nil {
|
||||
return cfg, fmt.Errorf("problem loading config: %v", err)
|
||||
}
|
||||
cfg.Allowlist.Repos = append(cfg.Allowlist.Repos, re)
|
||||
}
|
||||
|
||||
cfg.Allowlist.Commits = tomlLoader.AllowList.Commits
|
||||
cfg.Allowlist.Description = tomlLoader.AllowList.Description
|
||||
|
||||
return cfg, nil
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"testing"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v6/options"
|
||||
)
|
||||
|
||||
func TestParse(t *testing.T) {
|
||||
tests := []struct {
|
||||
description string
|
||||
opts options.Options
|
||||
wantErr error
|
||||
wantFileRegex *regexp.Regexp
|
||||
wantMessages *regexp.Regexp
|
||||
wantAllowlist AllowList
|
||||
}{
|
||||
{
|
||||
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 allowlist file regex",
|
||||
opts: options.Options{
|
||||
Config: "../test_data/test_configs/bad_aws_key_global_allowlist_file.toml",
|
||||
},
|
||||
wantErr: fmt.Errorf("problem loading config: error parsing regexp: missing argument to repetition operator: `??`"),
|
||||
},
|
||||
{
|
||||
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 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("problem loading config: entropy Min value cannot be higher than Max value"),
|
||||
},
|
||||
{
|
||||
description: "test entropy value max",
|
||||
opts: options.Options{
|
||||
Config: "../test_data/test_configs/bad_entropy_2.toml",
|
||||
},
|
||||
wantErr: fmt.Errorf("strconv.ParseFloat: parsing \"x\": invalid syntax"),
|
||||
},
|
||||
{
|
||||
description: "test entropy value min",
|
||||
opts: options.Options{
|
||||
Config: "../test_data/test_configs/bad_entropy_3.toml",
|
||||
},
|
||||
wantErr: fmt.Errorf("strconv.ParseFloat: parsing \"x\": invalid syntax"),
|
||||
},
|
||||
{
|
||||
description: "test entropy value group",
|
||||
opts: options.Options{
|
||||
Config: "../test_data/test_configs/bad_entropy_4.toml",
|
||||
},
|
||||
wantErr: fmt.Errorf("strconv.ParseInt: parsing \"x\": invalid syntax"),
|
||||
},
|
||||
{
|
||||
description: "test entropy value group",
|
||||
opts: options.Options{
|
||||
Config: "../test_data/test_configs/bad_entropy_5.toml",
|
||||
},
|
||||
wantErr: fmt.Errorf("problem loading config: group cannot be lower than 0"),
|
||||
},
|
||||
{
|
||||
description: "test entropy value group",
|
||||
opts: options.Options{
|
||||
Config: "../test_data/test_configs/bad_entropy_6.toml",
|
||||
},
|
||||
wantErr: fmt.Errorf("problem loading config: group cannot be higher than number of groups in regexp"),
|
||||
},
|
||||
{
|
||||
description: "test entropy range limits",
|
||||
opts: options.Options{
|
||||
Config: "../test_data/test_configs/bad_entropy_7.toml",
|
||||
},
|
||||
wantErr: fmt.Errorf("problem loading config: invalid entropy ranges, must be within 0.0-8.0"),
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
_, err := NewConfig(test.opts)
|
||||
if err != nil {
|
||||
if test.wantErr == nil {
|
||||
t.Error(test.description, err)
|
||||
} else if test.wantErr.Error() != err.Error() {
|
||||
t.Errorf("expected err: %s, got %s", test.wantErr, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
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 = "Google API key"
|
||||
regex = '''AIza[0-9A-Za-z\\-_]{35}'''
|
||||
tags = ["key", "Google"]
|
||||
|
||||
[[rules]]
|
||||
description = "Google (GCP) Service Account"
|
||||
regex = '''"type": "service_account"'''
|
||||
tags = ["key", "Google"]
|
||||
|
||||
[[rules]]
|
||||
description = "Heroku API key"
|
||||
regex = '''(?i)heroku(.{0,20})?[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'''
|
||||
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})?)?key-[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})?[sr]k_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})?SK[0-9a-f]{32}'''
|
||||
tags = ["key", "twilio"]
|
||||
|
||||
[allowlist]
|
||||
description = "Allowlisted files"
|
||||
files = ['''^\.?gitleaks.toml$''',
|
||||
'''(.*?)(jpg|gif|doc|pdf|bin)$''',
|
||||
'''(go.mod|go.sum)$''']
|
||||
`
|
||||
@@ -0,0 +1,195 @@
|
||||
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)(apikey|secret|key|api|password|pass|pw|host)=[0-9a-zA-Z-_.{}]{4,120}'''
|
||||
|
||||
[[rules]]
|
||||
description = "Port"
|
||||
regex = '''(?i)port(.{0,4})?[0-9]{1,10}'''
|
||||
[rules.allowlist]
|
||||
regexes = ['''(?i)port ''']
|
||||
description = "ignore export "
|
||||
|
||||
|
||||
|
||||
[[rules]]
|
||||
description = "Email"
|
||||
regex = '''[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}'''
|
||||
tags = ["email"]
|
||||
[rules.allowlist]
|
||||
files = ['''(?i)bashrc''']
|
||||
description = "ignore bashrc emails"
|
||||
|
||||
|
||||
[[rules]]
|
||||
description = "Generic Credential"
|
||||
regex = '''(?i)(dbpasswd|dbuser|dbname|dbhost|api_key|apikey|secret|key|api|password|user|guid|hostname|pw|auth)(.{0,20})?['|"]([0-9a-zA-Z-_\/+!{}/=]{4,120})['|"]'''
|
||||
tags = ["key", "API", "generic"]
|
||||
# ignore leaks with specific identifiers like slack and aws
|
||||
[rules.allowlist]
|
||||
description = "ignore slack, mailchimp, aws"
|
||||
regexes = [
|
||||
'''xox[baprs]-([0-9a-zA-Z]{10,48})''',
|
||||
'''(?i)(.{0,20})?['"][0-9a-f]{32}-us[0-9]{1,2}['"]''',
|
||||
'''(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}'''
|
||||
]
|
||||
|
||||
[[rules]]
|
||||
description = "High Entropy"
|
||||
regex = '''[0-9a-zA-Z-_!{}/=]{4,120}'''
|
||||
file = '''(?i)(dump.sql|high-entropy-misc.txt)$'''
|
||||
tags = ["entropy"]
|
||||
[[rules.Entropies]]
|
||||
Min = "4.3"
|
||||
Max = "7.0"
|
||||
[rules.allowlist]
|
||||
description = "ignore ssh key and pems"
|
||||
files = ['''(pem|ppk|env)$''']
|
||||
paths = ['''(.*)?ssh''']
|
||||
|
||||
[[rules]]
|
||||
description = "Potential bash var"
|
||||
regex='''(?i)(=)([0-9a-zA-Z-_!{}=]{4,120})'''
|
||||
tags = ["key", "bash", "API", "generic"]
|
||||
[[rules.Entropies]]
|
||||
Min = "3.5"
|
||||
Max = "4.5"
|
||||
Group = "1"
|
||||
|
||||
[[rules]]
|
||||
description = "WP-Config"
|
||||
regex='''define(.{0,20})?(DB_CHARSET|NONCE_SALT|LOGGED_IN_SALT|AUTH_SALT|NONCE_KEY|DB_HOST|DB_PASSWORD|AUTH_KEY|SECURE_AUTH_KEY|LOGGED_IN_KEY|DB_NAME|DB_USER)(.{0,20})?['|"].{10,120}['|"]'''
|
||||
tags = ["key", "API", "generic"]
|
||||
|
||||
[[rules]]
|
||||
description = "Files with keys and credentials"
|
||||
file = '''(?i)(id_rsa|passwd|id_rsa.pub|pgpass|pem|key|shadow)'''
|
||||
|
||||
# Global allowlist
|
||||
[allowlist]
|
||||
description = "image allowlists"
|
||||
files = ['''(.*?)(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,17 @@
|
||||
# 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 scan.
|
||||
# In other words, if a line of code has an entropy value that is within the range of the entropies defined and
|
||||
# a regex match is found then that line of code contains a leak.
|
||||
|
||||
# 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}['|"]'''
|
||||
tags = ["entropy"]
|
||||
[[rules.Entropies]]
|
||||
Min = "4.5"
|
||||
Max = "5.7"
|
||||
[[rules.Entropies]]
|
||||
Min = "5.5"
|
||||
Max = "6.3"
|
||||
@@ -0,0 +1,13 @@
|
||||
# This config contains a single rule that checks for AWS keys. However, it also contains a allowlist table
|
||||
# where you can define one or more allowlists. What this means is that if you have an example AWS key as part of your
|
||||
# code (in a test for example), then you can allowlist that specific key so gitleaks will not label it as a leak.
|
||||
# If this line was present in a git history: `aws_access_key_id='AKIAIO5FODNN7EXAMPLE``, gitleaks would match this line
|
||||
# with the rule below, but since we have a allowlist against that specific key, it would be ignored.
|
||||
|
||||
[[rules]]
|
||||
description = "AWS Manager ID"
|
||||
regex = '''(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}'''
|
||||
tags = ["key", "AWS"]
|
||||
[rules.allowlist]
|
||||
regexes = ['''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"]
|
||||
@@ -1,30 +0,0 @@
|
||||
title = "gitleaks config"
|
||||
[[regexes]]
|
||||
description = "AWS"
|
||||
regex = '''AKIA[0-9A-Z]{16}'''
|
||||
[[regexes]]
|
||||
description = "RKCS8"
|
||||
regex = '''-----BEGIN PRIVATE KEY-----'''
|
||||
[[regexes]]
|
||||
description = "RSA"
|
||||
regex = '''-----BEGIN RSA PRIVATE KEY-----'''
|
||||
[[regexes]]
|
||||
description = "Github"
|
||||
regex = '''(?i)github.*['\"][0-9a-zA-Z]{35,40}['\"]'''
|
||||
[[regexes]]
|
||||
description = "SSH"
|
||||
regex = '''-----BEGIN OPENSSH PRIVATE KEY-----'''
|
||||
[[regexes]]
|
||||
description = "Facebook"
|
||||
regex = '''(?i)facebook.*['\"][0-9a-f]{32}['\"]'''
|
||||
[[regexes]]
|
||||
description = "Facebook"
|
||||
regex = '''(?i)twitter.*['\"][0-9a-zA-Z]{35,44}['\"]'''
|
||||
|
||||
[whitelist]
|
||||
regexes = [
|
||||
"AKIA.*",
|
||||
]
|
||||
files = [
|
||||
"(.*?)(jpg|gif|doc|pdf|bin|go)$"
|
||||
]
|
||||
@@ -1,650 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"regexp"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/franela/goblin"
|
||||
git "gopkg.in/src-d/go-git.v4"
|
||||
"gopkg.in/src-d/go-git.v4/storage/memory"
|
||||
)
|
||||
|
||||
const testWhitelistCommit = `
|
||||
[[regexes]]
|
||||
description = "AWS"
|
||||
regex = '''AKIA[0-9A-Z]{16}'''
|
||||
|
||||
[whitelist]
|
||||
commits = [
|
||||
"eaeffdc65b4c73ccb67e75d96bd8743be2c85973",
|
||||
]
|
||||
`
|
||||
const testWhitelistFile = `
|
||||
[[regexes]]
|
||||
description = "AWS"
|
||||
regex = '''AKIA[0-9A-Z]{16}'''
|
||||
|
||||
[whitelist]
|
||||
files = [
|
||||
".go",
|
||||
]
|
||||
`
|
||||
const testWhitelistBranch = `
|
||||
[[regexes]]
|
||||
description = "AWS"
|
||||
regex = '''AKIA[0-9A-Z]{16}'''
|
||||
|
||||
[whitelist]
|
||||
branches = [
|
||||
"origin/master",
|
||||
]
|
||||
`
|
||||
|
||||
const testWhitelistRegex = `
|
||||
[[regexes]]
|
||||
description = "AWS"
|
||||
regex = '''AKIA[0-9A-Z]{16}'''
|
||||
|
||||
[whitelist]
|
||||
regexes= [
|
||||
"AKIA",
|
||||
]
|
||||
`
|
||||
|
||||
func TestGetRepo(t *testing.T) {
|
||||
var err error
|
||||
dir, err = ioutil.TempDir("", "gitleaksTestRepo")
|
||||
defer os.RemoveAll(dir)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
_, err = git.PlainClone(dir, false, &git.CloneOptions{
|
||||
URL: "https://github.com/gitleakstest/gronit",
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
var tests = []struct {
|
||||
testOpts Options
|
||||
description string
|
||||
expectedErrMsg string
|
||||
}{
|
||||
{
|
||||
testOpts: Options{
|
||||
Repo: "https://github.com/gitleakstest/gronit",
|
||||
},
|
||||
description: "test plain clone remote repo",
|
||||
expectedErrMsg: "",
|
||||
},
|
||||
{
|
||||
testOpts: Options{
|
||||
Repo: "https://github.com/gitleakstest/gronit",
|
||||
InMem: true,
|
||||
},
|
||||
description: "test inmem clone remote repo",
|
||||
expectedErrMsg: "",
|
||||
},
|
||||
{
|
||||
testOpts: Options{
|
||||
RepoPath: dir,
|
||||
},
|
||||
description: "test local clone repo",
|
||||
expectedErrMsg: "",
|
||||
},
|
||||
{
|
||||
testOpts: Options{
|
||||
Repo: "https://github.com/gitleakstest/nope",
|
||||
},
|
||||
description: "test no repo",
|
||||
expectedErrMsg: "authentication required",
|
||||
},
|
||||
{
|
||||
testOpts: Options{
|
||||
Repo: "https://github.com/gitleakstest/private",
|
||||
IncludePrivate: true,
|
||||
},
|
||||
description: "test private repo",
|
||||
expectedErrMsg: "invalid auth method",
|
||||
},
|
||||
{
|
||||
testOpts: Options{
|
||||
Repo: "https://github.com/gitleakstest/private",
|
||||
IncludePrivate: true,
|
||||
InMem: true,
|
||||
},
|
||||
description: "test private repo",
|
||||
expectedErrMsg: "invalid auth method",
|
||||
},
|
||||
}
|
||||
g := goblin.Goblin(t)
|
||||
for _, test := range tests {
|
||||
g.Describe("TestGetRepo", func() {
|
||||
g.It(test.description, func() {
|
||||
opts = test.testOpts
|
||||
_, err := getRepo()
|
||||
if err != nil {
|
||||
g.Assert(err.Error()).Equal(test.expectedErrMsg)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetOwnerRepo(t *testing.T) {
|
||||
var err error
|
||||
dir, err = ioutil.TempDir("", "gitleaksTestOwner")
|
||||
defer os.RemoveAll(dir)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
git.PlainClone(dir+"/gronit", false, &git.CloneOptions{
|
||||
URL: "https://github.com/gitleakstest/gronit",
|
||||
})
|
||||
git.PlainClone(dir+"/h1domains", false, &git.CloneOptions{
|
||||
URL: "https://github.com/gitleakstest/h1domains",
|
||||
})
|
||||
var tests = []struct {
|
||||
testOpts Options
|
||||
description string
|
||||
expectedErrMsg string
|
||||
numRepos int
|
||||
}{
|
||||
{
|
||||
testOpts: Options{
|
||||
GithubUser: "gitleakstest",
|
||||
},
|
||||
description: "test github user",
|
||||
numRepos: 2,
|
||||
expectedErrMsg: "",
|
||||
},
|
||||
{
|
||||
testOpts: Options{
|
||||
GithubUser: "gitleakstest",
|
||||
InMem: true,
|
||||
},
|
||||
description: "test github user in mem",
|
||||
numRepos: 2,
|
||||
expectedErrMsg: "",
|
||||
},
|
||||
{
|
||||
testOpts: Options{
|
||||
GithubOrg: "gitleakstestorg",
|
||||
},
|
||||
description: "test github org",
|
||||
numRepos: 2,
|
||||
expectedErrMsg: "",
|
||||
},
|
||||
{
|
||||
testOpts: Options{
|
||||
OwnerPath: dir,
|
||||
},
|
||||
description: "test plain clone remote repo",
|
||||
numRepos: 2,
|
||||
expectedErrMsg: "",
|
||||
},
|
||||
{
|
||||
testOpts: Options{
|
||||
GithubOrg: "gitleakstestorg",
|
||||
IncludePrivate: true,
|
||||
},
|
||||
description: "test private org no ssh",
|
||||
numRepos: 0,
|
||||
expectedErrMsg: "no ssh auth available",
|
||||
},
|
||||
{
|
||||
testOpts: Options{
|
||||
GithubOrg: "gitleakstestorg",
|
||||
InMem: true,
|
||||
},
|
||||
description: "test org in mem",
|
||||
numRepos: 2,
|
||||
expectedErrMsg: "",
|
||||
},
|
||||
{
|
||||
testOpts: Options{
|
||||
GithubOrg: "gitleakstestorg",
|
||||
IncludePrivate: true,
|
||||
InMem: true,
|
||||
},
|
||||
description: "test private org in mem no ssh",
|
||||
numRepos: 0,
|
||||
expectedErrMsg: "no ssh auth available",
|
||||
},
|
||||
}
|
||||
g := goblin.Goblin(t)
|
||||
for _, test := range tests {
|
||||
g.Describe("TestGetOwnerRepo", func() {
|
||||
g.It(test.description, func() {
|
||||
opts = test.testOpts
|
||||
repos, err := getOwnerRepos()
|
||||
if err != nil {
|
||||
g.Assert(err.Error()).Equal(test.expectedErrMsg)
|
||||
}
|
||||
g.Assert(len(repos)).Equal(test.numRepos)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestWriteReport(t *testing.T) {
|
||||
tmpDir, _ := ioutil.TempDir("", "reportDir")
|
||||
reportFile := path.Join(tmpDir, "report.json")
|
||||
defer os.RemoveAll(tmpDir)
|
||||
leaks := []Leak{
|
||||
{
|
||||
Line: "eat",
|
||||
Commit: "your",
|
||||
Offender: "veggies",
|
||||
Type: "and",
|
||||
Message: "get",
|
||||
Author: "some",
|
||||
File: "sleep",
|
||||
Branch: "thxu",
|
||||
},
|
||||
}
|
||||
|
||||
var tests = []struct {
|
||||
leaks []Leak
|
||||
reportFile string
|
||||
fileName string
|
||||
description string
|
||||
testOpts Options
|
||||
}{
|
||||
{
|
||||
leaks: leaks,
|
||||
reportFile: reportFile,
|
||||
fileName: "report.json",
|
||||
description: "can we write a file",
|
||||
testOpts: Options{
|
||||
Report: reportFile,
|
||||
},
|
||||
},
|
||||
}
|
||||
g := goblin.Goblin(t)
|
||||
for _, test := range tests {
|
||||
g.Describe("TestWriteReport", func() {
|
||||
g.It(test.description, func() {
|
||||
opts = test.testOpts
|
||||
writeReport(test.leaks)
|
||||
f, _ := os.Stat(test.reportFile)
|
||||
g.Assert(f.Name()).Equal(test.fileName)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func testTomlLoader() string {
|
||||
tmpDir, _ := ioutil.TempDir("", "whiteListConfigs")
|
||||
ioutil.WriteFile(path.Join(tmpDir, "regex"), []byte(testWhitelistRegex), 0644)
|
||||
ioutil.WriteFile(path.Join(tmpDir, "branch"), []byte(testWhitelistBranch), 0644)
|
||||
ioutil.WriteFile(path.Join(tmpDir, "commit"), []byte(testWhitelistCommit), 0644)
|
||||
ioutil.WriteFile(path.Join(tmpDir, "file"), []byte(testWhitelistFile), 0644)
|
||||
return tmpDir
|
||||
}
|
||||
|
||||
func TestAuditRepo(t *testing.T) {
|
||||
var leaks []Leak
|
||||
err := loadToml()
|
||||
configsDir := testTomlLoader()
|
||||
defer os.RemoveAll(configsDir)
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
leaksRepo, err := git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
|
||||
URL: "https://github.com/gitleakstest/gronit.git",
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
cleanRepo, err := git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
|
||||
URL: "https://github.com/gitleakstest/h1domains.git",
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
var tests = []struct {
|
||||
testOpts Options
|
||||
description string
|
||||
expectedErrMsg string
|
||||
numLeaks int
|
||||
repo *git.Repository
|
||||
whiteListFiles []*regexp.Regexp
|
||||
whiteListCommits map[string]bool
|
||||
whiteListBranches []string
|
||||
whiteListRegexes []*regexp.Regexp
|
||||
configPath string
|
||||
}{
|
||||
{
|
||||
repo: leaksRepo,
|
||||
description: "two leaks present",
|
||||
numLeaks: 2,
|
||||
},
|
||||
{
|
||||
repo: leaksRepo,
|
||||
description: "two leaks present limit goroutines",
|
||||
numLeaks: 2,
|
||||
testOpts: Options{
|
||||
MaxGoRoutines: 2,
|
||||
},
|
||||
},
|
||||
{
|
||||
repo: leaksRepo,
|
||||
description: "audit all branch",
|
||||
numLeaks: 6,
|
||||
testOpts: Options{
|
||||
AuditAllRefs: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
repo: leaksRepo,
|
||||
description: "audit all branch whitelist 1",
|
||||
numLeaks: 4,
|
||||
testOpts: Options{
|
||||
AuditAllRefs: true,
|
||||
},
|
||||
whiteListBranches: []string{
|
||||
"origin/master",
|
||||
},
|
||||
},
|
||||
{
|
||||
repo: leaksRepo,
|
||||
description: "two leaks present whitelist AWS.. no leaks",
|
||||
whiteListRegexes: []*regexp.Regexp{
|
||||
regexp.MustCompile("AKIA"),
|
||||
},
|
||||
numLeaks: 0,
|
||||
},
|
||||
{
|
||||
repo: leaksRepo,
|
||||
description: "two leaks present limit goroutines",
|
||||
numLeaks: 2,
|
||||
},
|
||||
{
|
||||
repo: cleanRepo,
|
||||
description: "no leaks present",
|
||||
numLeaks: 0,
|
||||
},
|
||||
{
|
||||
repo: leaksRepo,
|
||||
description: "two leaks present whitelist go files",
|
||||
whiteListFiles: []*regexp.Regexp{
|
||||
regexp.MustCompile(".go"),
|
||||
},
|
||||
numLeaks: 0,
|
||||
},
|
||||
{
|
||||
repo: leaksRepo,
|
||||
description: "two leaks present whitelist bad commit",
|
||||
whiteListCommits: map[string]bool{
|
||||
"eaeffdc65b4c73ccb67e75d96bd8743be2c85973": true,
|
||||
},
|
||||
numLeaks: 1,
|
||||
},
|
||||
{
|
||||
repo: leaksRepo,
|
||||
description: "redact",
|
||||
testOpts: Options{
|
||||
Redact: true,
|
||||
},
|
||||
numLeaks: 2,
|
||||
},
|
||||
{
|
||||
repo: leaksRepo,
|
||||
description: "toml whitelist regex",
|
||||
configPath: path.Join(configsDir, "regex"),
|
||||
numLeaks: 0,
|
||||
},
|
||||
{
|
||||
repo: leaksRepo,
|
||||
description: "toml whitelist branch",
|
||||
configPath: path.Join(configsDir, "branch"),
|
||||
testOpts: Options{
|
||||
AuditAllRefs: true,
|
||||
},
|
||||
numLeaks: 4,
|
||||
},
|
||||
{
|
||||
repo: leaksRepo,
|
||||
description: "toml whitelist file",
|
||||
configPath: path.Join(configsDir, "file"),
|
||||
numLeaks: 0,
|
||||
},
|
||||
{
|
||||
repo: leaksRepo,
|
||||
description: "toml whitelist commit",
|
||||
configPath: path.Join(configsDir, "commit"),
|
||||
numLeaks: 1,
|
||||
},
|
||||
}
|
||||
|
||||
whiteListCommits = make(map[string]bool)
|
||||
g := goblin.Goblin(t)
|
||||
for _, test := range tests {
|
||||
g.Describe("TestAuditRepo", func() {
|
||||
g.It(test.description, func() {
|
||||
opts = test.testOpts
|
||||
// settin da globs
|
||||
if test.whiteListFiles != nil {
|
||||
whiteListFiles = test.whiteListFiles
|
||||
} else {
|
||||
whiteListFiles = nil
|
||||
}
|
||||
if test.whiteListCommits != nil {
|
||||
whiteListCommits = test.whiteListCommits
|
||||
} else {
|
||||
whiteListCommits = nil
|
||||
}
|
||||
if test.whiteListBranches != nil {
|
||||
whiteListBranches = test.whiteListBranches
|
||||
} else {
|
||||
whiteListBranches = nil
|
||||
}
|
||||
if test.whiteListRegexes != nil {
|
||||
whiteListRegexes = test.whiteListRegexes
|
||||
} else {
|
||||
whiteListRegexes = nil
|
||||
}
|
||||
|
||||
// config paths
|
||||
if test.configPath != "" {
|
||||
os.Setenv("GITLEAKS_CONFIG", test.configPath)
|
||||
loadToml()
|
||||
}
|
||||
|
||||
leaks, err = auditRepo(test.repo)
|
||||
|
||||
if opts.Redact {
|
||||
g.Assert(leaks[0].Offender).Equal("REDACTED")
|
||||
}
|
||||
g.Assert(len(leaks)).Equal(test.numLeaks)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestOptionGuard(t *testing.T) {
|
||||
var tests = []struct {
|
||||
testOpts Options
|
||||
githubToken bool
|
||||
description string
|
||||
expectedErrMsg string
|
||||
expectedErrMsgFuzzy string
|
||||
}{
|
||||
{
|
||||
testOpts: Options{},
|
||||
description: "default no opts",
|
||||
expectedErrMsg: "",
|
||||
},
|
||||
{
|
||||
testOpts: Options{
|
||||
IncludePrivate: true,
|
||||
GithubOrg: "fakeOrg",
|
||||
},
|
||||
description: "private org no githubtoken",
|
||||
expectedErrMsg: "user/organization private repos require env var GITHUB_TOKEN to be set",
|
||||
githubToken: false,
|
||||
},
|
||||
{
|
||||
testOpts: Options{
|
||||
IncludePrivate: true,
|
||||
GithubUser: "fakeUser",
|
||||
},
|
||||
description: "private user no githubtoken",
|
||||
expectedErrMsg: "user/organization private repos require env var GITHUB_TOKEN to be set",
|
||||
githubToken: false,
|
||||
},
|
||||
{
|
||||
testOpts: Options{
|
||||
IncludePrivate: true,
|
||||
GithubUser: "fakeUser",
|
||||
GithubOrg: "fakeOrg",
|
||||
},
|
||||
description: "double owner",
|
||||
expectedErrMsg: "github user and organization set",
|
||||
},
|
||||
{
|
||||
testOpts: Options{
|
||||
IncludePrivate: true,
|
||||
GithubOrg: "fakeOrg",
|
||||
OwnerPath: "/dev/null",
|
||||
},
|
||||
description: "local and remote target",
|
||||
expectedErrMsg: "github organization set and local owner path",
|
||||
},
|
||||
{
|
||||
testOpts: Options{
|
||||
IncludePrivate: true,
|
||||
GithubUser: "fakeUser",
|
||||
OwnerPath: "/dev/null",
|
||||
},
|
||||
description: "local and remote target",
|
||||
expectedErrMsg: "github user set and local owner path",
|
||||
},
|
||||
{
|
||||
testOpts: Options{
|
||||
GithubUser: "fakeUser",
|
||||
SingleSearch: "*/./....",
|
||||
},
|
||||
description: "single search invalid regex gaurd",
|
||||
expectedErrMsgFuzzy: "unable to compile regex: */./...., ",
|
||||
},
|
||||
{
|
||||
testOpts: Options{
|
||||
GithubUser: "fakeUser",
|
||||
SingleSearch: "mystring",
|
||||
},
|
||||
description: "single search regex gaurd",
|
||||
expectedErrMsg: "",
|
||||
},
|
||||
}
|
||||
g := goblin.Goblin(t)
|
||||
for _, test := range tests {
|
||||
g.Describe("Test Option Gaurd", func() {
|
||||
g.It(test.description, func() {
|
||||
os.Clearenv()
|
||||
opts = test.testOpts
|
||||
if test.githubToken {
|
||||
os.Setenv("GITHUB_TOKEN", "fakeToken")
|
||||
}
|
||||
err := optsGuard()
|
||||
if err != nil {
|
||||
if test.expectedErrMsgFuzzy != "" {
|
||||
g.Assert(strings.Contains(err.Error(), test.expectedErrMsgFuzzy)).Equal(true)
|
||||
} else {
|
||||
g.Assert(err.Error()).Equal(test.expectedErrMsg)
|
||||
}
|
||||
} else {
|
||||
g.Assert("").Equal(test.expectedErrMsg)
|
||||
}
|
||||
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadToml(t *testing.T) {
|
||||
tmpDir, _ := ioutil.TempDir("", "gitleaksTestConfigDir")
|
||||
defer os.RemoveAll(tmpDir)
|
||||
err := ioutil.WriteFile(path.Join(tmpDir, "gitleaksConfig"), []byte(defaultConfig), 0644)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
configPath := path.Join(tmpDir, "gitleaksConfig")
|
||||
noConfigPath := path.Join(tmpDir, "gitleaksConfigNope")
|
||||
|
||||
var tests = []struct {
|
||||
testOpts Options
|
||||
description string
|
||||
configPath string
|
||||
expectedErrMsg string
|
||||
singleSearch bool
|
||||
}{
|
||||
{
|
||||
testOpts: Options{
|
||||
ConfigPath: configPath,
|
||||
},
|
||||
description: "path to config",
|
||||
},
|
||||
{
|
||||
testOpts: Options{},
|
||||
description: "env var path to no config",
|
||||
singleSearch: true,
|
||||
},
|
||||
{
|
||||
testOpts: Options{
|
||||
ConfigPath: noConfigPath,
|
||||
},
|
||||
description: "no path to config",
|
||||
expectedErrMsg: fmt.Sprintf("no gitleaks config at %s", noConfigPath),
|
||||
},
|
||||
{
|
||||
testOpts: Options{},
|
||||
description: "env var path to config",
|
||||
configPath: configPath,
|
||||
expectedErrMsg: "",
|
||||
},
|
||||
{
|
||||
testOpts: Options{},
|
||||
description: "env var path to no config",
|
||||
configPath: noConfigPath,
|
||||
expectedErrMsg: fmt.Sprintf("problem loading config: open %s: no such file or directory", noConfigPath),
|
||||
},
|
||||
}
|
||||
|
||||
g := goblin.Goblin(t)
|
||||
for _, test := range tests {
|
||||
g.Describe("TestLoadToml", func() {
|
||||
g.It(test.description, func() {
|
||||
opts = test.testOpts
|
||||
if test.singleSearch {
|
||||
singleSearchRegex = regexp.MustCompile("test")
|
||||
} else {
|
||||
singleSearchRegex = nil
|
||||
}
|
||||
if test.configPath != "" {
|
||||
os.Setenv("GITLEAKS_CONFIG", test.configPath)
|
||||
} else {
|
||||
os.Clearenv()
|
||||
}
|
||||
err := loadToml()
|
||||
if err != nil {
|
||||
g.Assert(err.Error()).Equal(test.expectedErrMsg)
|
||||
} else {
|
||||
g.Assert("").Equal(test.expectedErrMsg)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
module github.com/zricethezav/gitleaks/v6
|
||||
|
||||
go 1.14
|
||||
|
||||
require (
|
||||
github.com/BurntSushi/toml v0.3.1
|
||||
github.com/go-git/go-billy/v5 v5.0.0
|
||||
github.com/go-git/go-git/v5 v5.1.0
|
||||
github.com/google/go-cmp v0.4.0 // indirect
|
||||
github.com/google/go-github/v31 v31.0.0
|
||||
github.com/hako/durafmt v0.0.0-20191009132224-3f39dc1ed9f4
|
||||
github.com/jessevdk/go-flags v1.4.0
|
||||
github.com/mattn/go-colorable v0.1.2
|
||||
github.com/sergi/go-diff v1.1.0
|
||||
github.com/sirupsen/logrus v1.4.2
|
||||
github.com/xanzy/go-gitlab v0.21.0
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
|
||||
)
|
||||
@@ -0,0 +1,127 @@
|
||||
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.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
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/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4=
|
||||
github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E=
|
||||
github.com/go-git/go-billy/v5 v5.0.0 h1:7NQHvd9FVid8VL4qVUMm8XifBK+2xCoZ2lSk0agRrHM=
|
||||
github.com/go-git/go-billy/v5 v5.0.0/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0=
|
||||
github.com/go-git/go-git-fixtures/v4 v4.0.1 h1:q+IFMfLx200Q3scvt2hN79JsEzy4AmBTp/pqnefH+Bc=
|
||||
github.com/go-git/go-git-fixtures/v4 v4.0.1/go.mod h1:m+ICp2rF3jDhFgEZ/8yziagdT1C+ZpZcrJjappBCDSw=
|
||||
github.com/go-git/go-git/v5 v5.1.0 h1:HxJn9g/E7eYvKW3Fm7Jt4ee8LXfPOm/H1cdDu8vEssk=
|
||||
github.com/go-git/go-git/v5 v5.1.0/go.mod h1:ZKfuPUoY1ZqIG4QG9BDBh3G4gLM5zvPuSJAozQrZuyM=
|
||||
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-github/v31 v31.0.0 h1:JJUxlP9lFK+ziXKimTCprajMApV1ecWD4NB6CCb0plo=
|
||||
github.com/google/go-github/v31 v31.0.0/go.mod h1:NQPZol8/1sMoWYGN2yaALIBytu17gAWfhbweiEed3pM=
|
||||
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
|
||||
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
|
||||
github.com/hako/durafmt v0.0.0-20191009132224-3f39dc1ed9f4 h1:60gBOooTSmNtrqNaRvrDbi8VAne0REaek2agjnITKSw=
|
||||
github.com/hako/durafmt v0.0.0-20191009132224-3f39dc1ed9f4/go.mod h1:5Scbynm8dF1XAPwIwkGPqzkM/shndPm79Jd1003hTjE=
|
||||
github.com/imdario/mergo v0.3.9 h1:UauaLniWCFHWd+Jp9oCEkTBj8VO/9DKg3PV3VCNMDIg=
|
||||
github.com/imdario/mergo v0.3.9/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
||||
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
|
||||
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
|
||||
github.com/jessevdk/go-flags v1.4.0 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGARJA=
|
||||
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/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU=
|
||||
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
||||
github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE=
|
||||
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
|
||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
|
||||
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
|
||||
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/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/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
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-20200302210943-78000ba7a073 h1:xMPOj6Pz6UipU1wXLkrtqpHbR0AVFnyPEQq/wRWz9lM=
|
||||
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181108082009-03003ca0c849/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20200301022130-244492dfa37a h1:GuSPYbZzB5/dcLNCwLQLsg3obCJtX9IJhpXkvY7kzk0=
|
||||
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0=
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/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-20200302150141-5c8b2ff67527 h1:uYVVQ9WP/Ds2ROhcaGPeIdVq0RIXVLwsHlnvJ+cT1So=
|
||||
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
|
||||
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
|
||||
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=
|
||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
+190
@@ -0,0 +1,190 @@
|
||||
package hosts
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v6/manager"
|
||||
"github.com/zricethezav/gitleaks/v6/options"
|
||||
"github.com/zricethezav/gitleaks/v6/scan"
|
||||
|
||||
"github.com/go-git/go-git/v5"
|
||||
"github.com/go-git/go-git/v5/plumbing"
|
||||
"github.com/go-git/go-git/v5/plumbing/object"
|
||||
"github.com/go-git/go-git/v5/plumbing/transport"
|
||||
"github.com/google/go-github/v31/github"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"golang.org/x/oauth2"
|
||||
)
|
||||
|
||||
// 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 scan 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
|
||||
}
|
||||
|
||||
// Scan will scan a github user or organization's repos.
|
||||
func (g *Github) Scan() {
|
||||
ctx := context.Background()
|
||||
listOptions := github.ListOptions{
|
||||
PerPage: 100,
|
||||
Page: 1,
|
||||
}
|
||||
|
||||
var (
|
||||
githubRepos []*github.Repository
|
||||
auth transport.AuthMethod
|
||||
)
|
||||
|
||||
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})
|
||||
} else {
|
||||
_githubRepos, resp, err = g.client.Repositories.List(ctx, "",
|
||||
&github.RepositoryListOptions{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 := scan.NewRepo(g.manager)
|
||||
|
||||
if g.manager.CloneOptions != nil {
|
||||
auth = g.manager.CloneOptions.Auth
|
||||
}
|
||||
err := r.Clone(&git.CloneOptions{
|
||||
URL: *repo.CloneURL,
|
||||
Auth: auth,
|
||||
})
|
||||
r.Name = *repo.Name
|
||||
if err != nil {
|
||||
log.Warn("unable to clone via https and access token, attempting with ssh now")
|
||||
auth, err := options.SSHAuth(g.manager.Opts)
|
||||
if err != nil {
|
||||
log.Warnf("unable to get ssh auth, skipping clone and scan for repo %s: %+v\n", *repo.CloneURL, err)
|
||||
continue
|
||||
}
|
||||
err = r.Clone(&git.CloneOptions{
|
||||
URL: *repo.SSHURL,
|
||||
Auth: auth,
|
||||
})
|
||||
if err != nil {
|
||||
log.Warnf("err cloning %s, skipping clone and scan: %+v\n", *repo.SSHURL, err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
if err = r.Scan(); err != nil {
|
||||
log.Warn(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ScanPR scan a single github PR
|
||||
func (g *Github) ScanPR() {
|
||||
ctx := context.Background()
|
||||
splits := strings.Split(g.manager.Opts.PullRequest, "/")
|
||||
owner := splits[len(splits)-4]
|
||||
repoName := splits[len(splits)-3]
|
||||
prNum, err := strconv.Atoi(splits[len(splits)-1])
|
||||
repo := scan.NewRepo(g.manager)
|
||||
repo.Name = repoName
|
||||
log.Infof("scanning 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
|
||||
}
|
||||
repo.CheckRules(&scan.Bundle{
|
||||
Content: *f.Patch,
|
||||
FilePath: *f.Filename,
|
||||
Commit: &commitObj,
|
||||
})
|
||||
}
|
||||
}
|
||||
page = resp.NextPage
|
||||
if resp.LastPage == 0 {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
package hosts
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v6/manager"
|
||||
"github.com/zricethezav/gitleaks/v6/options"
|
||||
"github.com/zricethezav/gitleaks/v6/scan"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/xanzy/go-gitlab"
|
||||
)
|
||||
|
||||
// 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 scan 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
|
||||
}
|
||||
|
||||
// Scan will scan a github user or organization's repos.
|
||||
func (g *Gitlab) Scan() {
|
||||
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 := scan.NewRepo(g.manager)
|
||||
cloneOpts := g.manager.CloneOptions
|
||||
cloneOpts.URL = p.HTTPURLToRepo
|
||||
err := r.Clone(cloneOpts)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
continue
|
||||
}
|
||||
// TODO handle clone retry with ssh like github host
|
||||
r.Name = p.Name
|
||||
|
||||
if err = r.Scan(); err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ScanPR TODO not implemented
|
||||
func (g *Gitlab) ScanPR() {
|
||||
log.Error("ScanPR is not implemented in Gitlab host yet...")
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package hosts
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v6/manager"
|
||||
)
|
||||
|
||||
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 {
|
||||
Scan()
|
||||
ScanPR()
|
||||
}
|
||||
|
||||
// Run kicks off a host scan. This function accepts a manager and determines what host it should scan
|
||||
func Run(m *manager.Manager) error {
|
||||
var host Host
|
||||
var err error
|
||||
switch getHost(m.Opts.Host) {
|
||||
case _github:
|
||||
host, err = NewGithubClient(m)
|
||||
case _gitlab:
|
||||
host, err = NewGitlabClient(m)
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if m.Opts.PullRequest != "" {
|
||||
host.ScanPR()
|
||||
} else {
|
||||
host.Scan()
|
||||
}
|
||||
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,116 @@
|
||||
package hosts
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v6/config"
|
||||
"github.com/zricethezav/gitleaks/v6/manager"
|
||||
"github.com/zricethezav/gitleaks/v6/options"
|
||||
)
|
||||
|
||||
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,810 +1,97 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/md5"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/user"
|
||||
"path"
|
||||
"regexp"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"gopkg.in/src-d/go-git.v4/plumbing"
|
||||
"github.com/zricethezav/gitleaks/v6/config"
|
||||
"github.com/zricethezav/gitleaks/v6/hosts"
|
||||
"github.com/zricethezav/gitleaks/v6/manager"
|
||||
"github.com/zricethezav/gitleaks/v6/options"
|
||||
"github.com/zricethezav/gitleaks/v6/scan"
|
||||
|
||||
"golang.org/x/oauth2"
|
||||
"gopkg.in/src-d/go-git.v4/plumbing/object"
|
||||
"gopkg.in/src-d/go-git.v4/plumbing/transport/ssh"
|
||||
"gopkg.in/src-d/go-git.v4/storage/memory"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
"github.com/google/go-github/github"
|
||||
flags "github.com/jessevdk/go-flags"
|
||||
"github.com/hako/durafmt"
|
||||
log "github.com/sirupsen/logrus"
|
||||
git "gopkg.in/src-d/go-git.v4"
|
||||
)
|
||||
|
||||
// Leak represents a leaked secret or regex match. This will be output to stdout and/or the report
|
||||
type Leak struct {
|
||||
Line string `json:"line"`
|
||||
Commit string `json:"commit"`
|
||||
Offender string `json:"offender"`
|
||||
Type string `json:"reason"`
|
||||
Message string `json:"commitMsg"`
|
||||
Author string `json:"author"`
|
||||
File string `json:"file"`
|
||||
Branch string `json:"branch"`
|
||||
}
|
||||
|
||||
// Repo contains the actual git repository and meta data about the repo
|
||||
type Repo struct {
|
||||
path string
|
||||
url string
|
||||
name string
|
||||
leaks []Leak
|
||||
repository *git.Repository
|
||||
}
|
||||
|
||||
// Owner contains a collection of repos. This could represent an org or user.
|
||||
type Owner struct {
|
||||
path string
|
||||
url string
|
||||
repos []Repo
|
||||
}
|
||||
|
||||
// Options for gitleaks
|
||||
type Options struct {
|
||||
// remote target options
|
||||
Repo string `short:"r" long:"repo" description:"Repo url to audit"`
|
||||
GithubUser string `long:"github-user" description:"User url to audit"`
|
||||
GithubOrg string `long:"github-org" description:"Organization url to audit"`
|
||||
IncludePrivate bool `short:"p" long:"private" description:"Include private repos in audit"`
|
||||
|
||||
/*
|
||||
TODO:
|
||||
GitLabUser string `long:"gitlab-user" description:"User url to audit"`
|
||||
GitLabOrg string `long:"gitlab-org" description:"Organization url to audit"`
|
||||
*/
|
||||
|
||||
Branch string `short:"b" long:"branch" description:"branch name to audit (defaults to HEAD)"`
|
||||
Commit string `short:"c" long:"commit" description:"sha of commit to stop at"`
|
||||
|
||||
// local target option
|
||||
RepoPath string `long:"repo-path" description:"Path to repo"`
|
||||
OwnerPath string `long:"owner-path" description:"Path to owner directory (repos discovered)"`
|
||||
|
||||
// Process options
|
||||
MaxGoRoutines int `long:"max-go" description:"Maximum number of concurrent go-routines gitleaks spawns"`
|
||||
InMem bool `short:"m" long:"in-memory" description:"Run gitleaks in memory"`
|
||||
AuditAllRefs bool `long:"all-refs" description:"run audit on all refs"`
|
||||
SingleSearch string `long:"single-search" description:"single regular expression to search for"`
|
||||
ConfigPath string `long:"config" description:"path to gitleaks config"`
|
||||
SSHKey string `long:"ssh-key" description:"path to ssh key"`
|
||||
// TODO: IncludeMessages string `long:"messages" description:"include commit messages in audit"`
|
||||
|
||||
// Output options
|
||||
Log string `short:"l" long:"log" description:"log level"`
|
||||
Verbose bool `short:"v" long:"verbose" description:"Show verbose output from gitleaks audit"`
|
||||
Report string `long:"report" description:"path to write report file"`
|
||||
Redact bool `long:"redact" description:"redact secrets from log messages and report"`
|
||||
}
|
||||
|
||||
// Config struct for regexes matching and whitelisting
|
||||
type Config struct {
|
||||
Regexes []struct {
|
||||
Description string
|
||||
Regex string
|
||||
}
|
||||
Whitelist struct {
|
||||
Files []string
|
||||
Regexes []string
|
||||
Commits []string
|
||||
Branches []string
|
||||
}
|
||||
}
|
||||
|
||||
const defaultConfig = `
|
||||
title = "gitleaks config"
|
||||
# add regexes to the regex table
|
||||
[[regexes]]
|
||||
description = "AWS"
|
||||
regex = '''AKIA[0-9A-Z]{16}'''
|
||||
[[regexes]]
|
||||
description = "RKCS8"
|
||||
regex = '''-----BEGIN PRIVATE KEY-----'''
|
||||
[[regexes]]
|
||||
description = "RSA"
|
||||
regex = '''-----BEGIN RSA PRIVATE KEY-----'''
|
||||
[[regexes]]
|
||||
description = "Github"
|
||||
regex = '''(?i)github.*['\"][0-9a-zA-Z]{35,40}['\"]'''
|
||||
[[regexes]]
|
||||
description = "SSH"
|
||||
regex = '''-----BEGIN OPENSSH PRIVATE KEY-----'''
|
||||
[[regexes]]
|
||||
description = "Facebook"
|
||||
regex = '''(?i)facebook.*['\"][0-9a-f]{32}['\"]'''
|
||||
[[regexes]]
|
||||
description = "Facebook"
|
||||
regex = '''(?i)twitter.*['\"][0-9a-zA-Z]{35,44}['\"]'''
|
||||
|
||||
[whitelist]
|
||||
|
||||
#regexes = [
|
||||
# "AKAIMYFAKEAWKKEY",
|
||||
#]
|
||||
|
||||
#files = [
|
||||
# "(.*?)(jpg|gif|doc|pdf|bin)$"
|
||||
#]
|
||||
|
||||
#commits = [
|
||||
# "BADHA5H1",
|
||||
# "BADHA5H2",
|
||||
#]
|
||||
|
||||
#branches = [
|
||||
# "dev/STUPDIFKNFEATURE"
|
||||
#]
|
||||
`
|
||||
|
||||
var (
|
||||
opts Options
|
||||
regexes map[string]*regexp.Regexp
|
||||
singleSearchRegex *regexp.Regexp
|
||||
whiteListRegexes []*regexp.Regexp
|
||||
whiteListFiles []*regexp.Regexp
|
||||
whiteListCommits map[string]bool
|
||||
whiteListBranches []string
|
||||
fileDiffRegex *regexp.Regexp
|
||||
sshAuth *ssh.PublicKeys
|
||||
dir string
|
||||
)
|
||||
|
||||
func init() {
|
||||
log.SetOutput(os.Stdout)
|
||||
regexes = make(map[string]*regexp.Regexp)
|
||||
whiteListCommits = make(map[string]bool)
|
||||
}
|
||||
|
||||
func main() {
|
||||
var (
|
||||
leaks []Leak
|
||||
repos []Repo
|
||||
)
|
||||
_, err := flags.Parse(&opts)
|
||||
opts, err := options.ParseOptions()
|
||||
if err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
setLogLevel()
|
||||
|
||||
err = optsGuard()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
log.Error(err)
|
||||
os.Exit(options.ErrorEncountered)
|
||||
}
|
||||
|
||||
err = loadToml()
|
||||
err = opts.Guard()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
log.Error(err)
|
||||
os.Exit(options.ErrorEncountered)
|
||||
}
|
||||
|
||||
if opts.IncludePrivate {
|
||||
// if including private repos use ssh as authentication
|
||||
sshAuth, err = getSSHAuth()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
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 scanned in %s", len(leaks),
|
||||
metadata.Commits, durafmt.Parse(time.Duration(metadata.ScanTime)*time.Nanosecond))
|
||||
}
|
||||
os.Exit(options.LeaksPresent)
|
||||
} else {
|
||||
if m.Opts.CheckUncommitted() {
|
||||
log.Infof("No leaks detected in staged changes")
|
||||
} else {
|
||||
log.Infof("No leaks detected. %d commits scanned in %s",
|
||||
metadata.Commits, durafmt.Parse(time.Duration(metadata.ScanTime)*time.Nanosecond))
|
||||
}
|
||||
os.Exit(options.Success)
|
||||
}
|
||||
}
|
||||
|
||||
if !opts.InMem {
|
||||
// temporary directory where all the gitleaks plain clones will reside
|
||||
dir, err = ioutil.TempDir("", "gitleaks")
|
||||
// Run begins the program and contains some basic logic on how to continue with the scan. If any external git host
|
||||
// options are set (like scanning a gitlab or github user) then a specific host client will be created and
|
||||
// then Scan() and Report() will be called. Otherwise, gitleaks will create a new repo and an scan will proceed.
|
||||
// If no options or the uncommitted option is set then a pre-commit scan will
|
||||
// take place -- this is similar to running `git diff` on all the tracked files.
|
||||
func Run(m *manager.Manager) error {
|
||||
if m.Opts.Disk {
|
||||
dir, err := ioutil.TempDir("", "gitleaks")
|
||||
defer os.RemoveAll(dir)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
return err
|
||||
}
|
||||
m.CloneDir = dir
|
||||
}
|
||||
|
||||
// start audits
|
||||
if opts.Repo != "" || opts.RepoPath != "" {
|
||||
r, err := getRepo()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
repos = append(repos, r)
|
||||
} else if ownerTarget() {
|
||||
repos, err = getOwnerRepos()
|
||||
}
|
||||
for _, r := range repos {
|
||||
l, err := auditRepo(r.repository)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
leaks = append(leaks, l...)
|
||||
}
|
||||
|
||||
if opts.Report != "" {
|
||||
writeReport(leaks)
|
||||
}
|
||||
|
||||
if len(leaks) != 0 {
|
||||
log.Debug("leaks detected")
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
// writeReport writes a report to opts.Report in JSON.
|
||||
// TODO support yaml
|
||||
func writeReport(leaks []Leak) error {
|
||||
log.Info("writing report to %s", opts.Report)
|
||||
reportJSON, _ := json.MarshalIndent(leaks, "", "\t")
|
||||
err := ioutil.WriteFile(opts.Report, reportJSON, 0644)
|
||||
return err
|
||||
}
|
||||
|
||||
// getRepo is responsible for cloning a repo in-memory or to disk, or opening a local repo and creating
|
||||
// a repo object
|
||||
func getRepo() (Repo, error) {
|
||||
var (
|
||||
err error
|
||||
r *git.Repository
|
||||
)
|
||||
|
||||
if opts.InMem {
|
||||
if opts.IncludePrivate {
|
||||
r, err = git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
|
||||
URL: opts.Repo,
|
||||
Progress: os.Stdout,
|
||||
Auth: sshAuth,
|
||||
})
|
||||
} else {
|
||||
r, err = git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
|
||||
URL: opts.Repo,
|
||||
Progress: os.Stdout,
|
||||
})
|
||||
}
|
||||
} else if opts.RepoPath != "" {
|
||||
// use existing repo
|
||||
r, err = git.PlainOpen(opts.RepoPath)
|
||||
var err error
|
||||
if m.Opts.Host != "" {
|
||||
err = hosts.Run(m)
|
||||
} else {
|
||||
cloneTarget := fmt.Sprintf("%s/%x", dir, md5.Sum([]byte(fmt.Sprintf("%s%s", opts.GithubUser, opts.Repo))))
|
||||
if opts.IncludePrivate {
|
||||
r, err = git.PlainClone(cloneTarget, false, &git.CloneOptions{
|
||||
URL: opts.Repo,
|
||||
Progress: os.Stdout,
|
||||
Auth: sshAuth,
|
||||
})
|
||||
} else {
|
||||
r, err = git.PlainClone(cloneTarget, false, &git.CloneOptions{
|
||||
URL: opts.Repo,
|
||||
Progress: os.Stdout,
|
||||
})
|
||||
}
|
||||
err = scan.Run(m)
|
||||
}
|
||||
if err != nil {
|
||||
return Repo{}, err
|
||||
}
|
||||
return Repo{
|
||||
repository: r,
|
||||
path: opts.RepoPath,
|
||||
url: opts.Repo,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// auditRef audits a git reference
|
||||
// TODO: need to add a layer of parallelism here and a cache for parent+child commits so we don't
|
||||
// double dip
|
||||
func auditRef(r *git.Repository, ref *plumbing.Reference, commitWg *sync.WaitGroup, commitChan chan []Leak) error {
|
||||
var (
|
||||
err error
|
||||
// prevTree *object.Tree
|
||||
prevCommit *object.Commit
|
||||
limitGoRoutines bool
|
||||
semaphore chan bool
|
||||
)
|
||||
|
||||
// goroutine limiting
|
||||
if opts.MaxGoRoutines != 0 {
|
||||
semaphore = make(chan bool, opts.MaxGoRoutines)
|
||||
limitGoRoutines = true
|
||||
}
|
||||
cIter, err := r.Log(&git.LogOptions{From: ref.Hash()})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = cIter.ForEach(func(c *object.Commit) error {
|
||||
if c.Hash.String() == opts.Commit {
|
||||
cIter.Close()
|
||||
}
|
||||
if whiteListCommits[c.Hash.String()] {
|
||||
log.Infof("skipping commit: %s\n", c.Hash.String())
|
||||
return nil
|
||||
}
|
||||
if limitGoRoutines {
|
||||
semaphore <- true
|
||||
}
|
||||
if prevCommit == nil {
|
||||
prevCommit = c
|
||||
}
|
||||
|
||||
commitWg.Add(1)
|
||||
go func(c *object.Commit, prevCommit *object.Commit) {
|
||||
var (
|
||||
leaks []Leak
|
||||
filePath string
|
||||
skipFile bool
|
||||
)
|
||||
patch, _ := c.Patch(prevCommit)
|
||||
for _, f := range patch.FilePatches() {
|
||||
skipFile = false
|
||||
from, to := f.Files()
|
||||
filePath = "???"
|
||||
if from != nil {
|
||||
filePath = from.Path()
|
||||
} else if to != nil {
|
||||
filePath = to.Path()
|
||||
}
|
||||
for _, re := range whiteListFiles {
|
||||
if re.FindString(filePath) != "" {
|
||||
skipFile = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if skipFile {
|
||||
continue
|
||||
}
|
||||
chunks := f.Chunks()
|
||||
for _, chunk := range chunks {
|
||||
if chunk.Type() == 1 || chunk.Type() == 2 {
|
||||
// only check if adding or removing
|
||||
leaks = append(leaks, checkDiff(chunk.Content(), c, filePath, string(ref.Name()))...)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if limitGoRoutines {
|
||||
<-semaphore
|
||||
}
|
||||
commitChan <- leaks
|
||||
}(c, prevCommit)
|
||||
|
||||
prevCommit = c
|
||||
return nil
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
// auditRepo performs an audit on a repository checking for regex matching and ignoring
|
||||
// files and regexes that are whitelisted
|
||||
func auditRepo(r *git.Repository) ([]Leak, error) {
|
||||
var (
|
||||
err error
|
||||
leaks []Leak
|
||||
commitWg sync.WaitGroup
|
||||
)
|
||||
|
||||
ref, err := r.Head()
|
||||
if err != nil {
|
||||
return leaks, err
|
||||
}
|
||||
|
||||
// leak messaging
|
||||
commitChan := make(chan []Leak, 1)
|
||||
|
||||
if opts.AuditAllRefs {
|
||||
skipBranch := false
|
||||
refs, err := r.Storer.IterReferences()
|
||||
if err != nil {
|
||||
return leaks, err
|
||||
}
|
||||
err = refs.ForEach(func(ref *plumbing.Reference) error {
|
||||
for _, b := range whiteListBranches {
|
||||
if strings.HasSuffix(string(ref.Name()), b) {
|
||||
skipBranch = true
|
||||
}
|
||||
}
|
||||
if skipBranch {
|
||||
skipBranch = false
|
||||
return nil
|
||||
}
|
||||
auditRef(r, ref, &commitWg, commitChan)
|
||||
return nil
|
||||
})
|
||||
} else {
|
||||
auditRef(r, ref, &commitWg, commitChan)
|
||||
}
|
||||
|
||||
go func() {
|
||||
for commitLeaks := range commitChan {
|
||||
if commitLeaks != nil {
|
||||
for _, leak := range commitLeaks {
|
||||
leaks = append(leaks, leak)
|
||||
}
|
||||
|
||||
}
|
||||
commitWg.Done()
|
||||
}
|
||||
}()
|
||||
|
||||
commitWg.Wait()
|
||||
|
||||
return leaks, err
|
||||
}
|
||||
|
||||
// checkDiff accepts a string diff and commit object then performs a
|
||||
// regex check
|
||||
func checkDiff(diff string, commit *object.Commit, filePath string, branch string) []Leak {
|
||||
lines := strings.Split(diff, "\n")
|
||||
var (
|
||||
leaks []Leak
|
||||
skipLine bool
|
||||
)
|
||||
|
||||
for _, line := range lines {
|
||||
skipLine = false
|
||||
for leakType, re := range regexes {
|
||||
match := re.FindString(line)
|
||||
if match == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
// whitelists
|
||||
for _, wRe := range whiteListRegexes {
|
||||
whitelistMatch := wRe.FindString(line)
|
||||
if whitelistMatch != "" {
|
||||
skipLine = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if skipLine {
|
||||
break
|
||||
}
|
||||
|
||||
leak := Leak{
|
||||
Line: line,
|
||||
Commit: commit.Hash.String(),
|
||||
Offender: match,
|
||||
Type: leakType,
|
||||
Message: commit.Message,
|
||||
Author: commit.Author.String(),
|
||||
File: filePath,
|
||||
Branch: branch,
|
||||
}
|
||||
if opts.Verbose {
|
||||
leak.log()
|
||||
}
|
||||
if opts.Redact {
|
||||
leak.Offender = "REDACTED"
|
||||
}
|
||||
leaks = append(leaks, leak)
|
||||
}
|
||||
}
|
||||
return leaks
|
||||
}
|
||||
|
||||
// auditOwner audits all of the owner's(user or org) repos
|
||||
func getOwnerRepos() ([]Repo, error) {
|
||||
var (
|
||||
err error
|
||||
repos []Repo
|
||||
)
|
||||
ctx := context.Background()
|
||||
|
||||
if opts.OwnerPath != "" {
|
||||
repos, err = discoverRepos(opts.OwnerPath)
|
||||
} else if opts.GithubOrg != "" {
|
||||
githubClient := github.NewClient(githubToken())
|
||||
githubOptions := github.RepositoryListByOrgOptions{
|
||||
ListOptions: github.ListOptions{PerPage: 10},
|
||||
}
|
||||
repos, err = getOrgGithubRepos(ctx, &githubOptions, githubClient)
|
||||
} else if opts.GithubUser != "" {
|
||||
githubClient := github.NewClient(githubToken())
|
||||
githubOptions := github.RepositoryListOptions{
|
||||
Affiliation: "owner",
|
||||
ListOptions: github.ListOptions{
|
||||
PerPage: 10,
|
||||
},
|
||||
}
|
||||
repos, err = getUserGithubRepos(ctx, &githubOptions, githubClient)
|
||||
}
|
||||
|
||||
return repos, err
|
||||
}
|
||||
|
||||
// getUserGithubRepos
|
||||
func getUserGithubRepos(ctx context.Context, listOpts *github.RepositoryListOptions, client *github.Client) ([]Repo, error) {
|
||||
var (
|
||||
err error
|
||||
repos []Repo
|
||||
r *git.Repository
|
||||
rs []*github.Repository
|
||||
resp *github.Response
|
||||
)
|
||||
|
||||
for {
|
||||
if opts.IncludePrivate {
|
||||
rs, resp, err = client.Repositories.List(ctx, "", listOpts)
|
||||
} else {
|
||||
rs, resp, err = client.Repositories.List(ctx, opts.GithubUser, listOpts)
|
||||
}
|
||||
|
||||
for _, rDesc := range rs {
|
||||
log.Debugf("Cloning: %s from %s", *rDesc.Name, *rDesc.SSHURL)
|
||||
if opts.InMem {
|
||||
if opts.IncludePrivate {
|
||||
r, err = git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
|
||||
URL: *rDesc.SSHURL,
|
||||
Auth: sshAuth,
|
||||
})
|
||||
} else {
|
||||
r, err = git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
|
||||
URL: *rDesc.CloneURL,
|
||||
})
|
||||
}
|
||||
} else {
|
||||
ownerDir, err := ioutil.TempDir(dir, opts.GithubUser)
|
||||
if err != nil {
|
||||
return repos, fmt.Errorf("unable to generater owner temp dir: %v", err)
|
||||
}
|
||||
if opts.IncludePrivate {
|
||||
r, err = git.PlainClone(fmt.Sprintf("%s/%s", ownerDir, *rDesc.Name), false, &git.CloneOptions{
|
||||
URL: *rDesc.SSHURL,
|
||||
Auth: sshAuth,
|
||||
})
|
||||
} else {
|
||||
r, err = git.PlainClone(fmt.Sprintf("%s/%s", ownerDir, *rDesc.Name), false, &git.CloneOptions{
|
||||
URL: *rDesc.CloneURL,
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return repos, fmt.Errorf("problem cloning %s -- %v", *rDesc.Name, err)
|
||||
}
|
||||
repos = append(repos, Repo{
|
||||
name: *rDesc.Name,
|
||||
url: *rDesc.SSHURL,
|
||||
repository: r,
|
||||
})
|
||||
}
|
||||
if resp.NextPage == 0 {
|
||||
break
|
||||
}
|
||||
listOpts.Page = resp.NextPage
|
||||
}
|
||||
return repos, err
|
||||
}
|
||||
|
||||
// getOrgGithubRepos
|
||||
func getOrgGithubRepos(ctx context.Context, listOpts *github.RepositoryListByOrgOptions, client *github.Client) ([]Repo, error) {
|
||||
var (
|
||||
err error
|
||||
repos []Repo
|
||||
r *git.Repository
|
||||
ownerDir string
|
||||
)
|
||||
|
||||
for {
|
||||
rs, resp, err := client.Repositories.ListByOrg(ctx, opts.GithubOrg, listOpts)
|
||||
for _, rDesc := range rs {
|
||||
log.Debugf("Cloning: %s from %s", *rDesc.Name, *rDesc.SSHURL)
|
||||
if opts.InMem {
|
||||
if opts.IncludePrivate {
|
||||
if sshAuth == nil {
|
||||
return nil, fmt.Errorf("no ssh auth available")
|
||||
}
|
||||
r, err = git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
|
||||
URL: *rDesc.SSHURL,
|
||||
Auth: sshAuth,
|
||||
})
|
||||
} else {
|
||||
r, err = git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
|
||||
URL: *rDesc.CloneURL,
|
||||
})
|
||||
}
|
||||
} else {
|
||||
ownerDir, err = ioutil.TempDir(dir, opts.GithubUser)
|
||||
if err != nil {
|
||||
return repos, fmt.Errorf("unable to generater owner temp dir: %v", err)
|
||||
}
|
||||
if opts.IncludePrivate {
|
||||
if sshAuth == nil {
|
||||
return nil, fmt.Errorf("no ssh auth available")
|
||||
}
|
||||
r, err = git.PlainClone(fmt.Sprintf("%s/%s", ownerDir, *rDesc.Name), false, &git.CloneOptions{
|
||||
URL: *rDesc.SSHURL,
|
||||
Auth: sshAuth,
|
||||
})
|
||||
} else {
|
||||
r, err = git.PlainClone(fmt.Sprintf("%s/%s", ownerDir, *rDesc.Name), false, &git.CloneOptions{
|
||||
URL: *rDesc.CloneURL,
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
repos = append(repos, Repo{
|
||||
url: *rDesc.SSHURL,
|
||||
name: *rDesc.Name,
|
||||
repository: r,
|
||||
})
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if resp.NextPage == 0 {
|
||||
break
|
||||
}
|
||||
listOpts.Page = resp.NextPage
|
||||
}
|
||||
|
||||
return repos, err
|
||||
}
|
||||
|
||||
func githubToken() *http.Client {
|
||||
githubToken := os.Getenv("GITHUB_TOKEN")
|
||||
if githubToken == "" {
|
||||
return nil
|
||||
}
|
||||
ts := oauth2.StaticTokenSource(
|
||||
&oauth2.Token{AccessToken: githubToken},
|
||||
)
|
||||
return oauth2.NewClient(context.Background(), ts)
|
||||
}
|
||||
|
||||
// discoverRepos walks all the children of `path`. If a child directory
|
||||
// contain a .git file then that repo will be added
|
||||
func discoverRepos(ownerPath string) ([]Repo, error) {
|
||||
var (
|
||||
err error
|
||||
repos []Repo
|
||||
)
|
||||
files, err := ioutil.ReadDir(ownerPath)
|
||||
if err != nil {
|
||||
return repos, err
|
||||
}
|
||||
for _, f := range files {
|
||||
if f.IsDir() {
|
||||
repoPath := path.Join(ownerPath, f.Name())
|
||||
r, err := git.PlainOpen(repoPath)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
repos = append(repos, Repo{
|
||||
repository: r,
|
||||
name: f.Name(),
|
||||
path: repoPath,
|
||||
})
|
||||
}
|
||||
}
|
||||
return repos, err
|
||||
}
|
||||
|
||||
// setLogLevel sets log level for gitleaks. Default is Warning
|
||||
func setLogLevel() {
|
||||
switch opts.Log {
|
||||
case "info":
|
||||
log.SetLevel(log.InfoLevel)
|
||||
case "debug":
|
||||
log.SetLevel(log.DebugLevel)
|
||||
case "warn":
|
||||
log.SetLevel(log.WarnLevel)
|
||||
default:
|
||||
log.SetLevel(log.WarnLevel)
|
||||
}
|
||||
}
|
||||
|
||||
// optsGuard prevents invalid options
|
||||
func optsGuard() error {
|
||||
var err error
|
||||
if opts.GithubOrg != "" && opts.GithubUser != "" {
|
||||
return fmt.Errorf("github user and organization set")
|
||||
} else if opts.GithubOrg != "" && opts.OwnerPath != "" {
|
||||
return fmt.Errorf("github organization set and local owner path")
|
||||
} else if opts.GithubUser != "" && opts.OwnerPath != "" {
|
||||
return fmt.Errorf("github user set and local owner path")
|
||||
} else if opts.IncludePrivate && os.Getenv("GITHUB_TOKEN") == "" && (opts.GithubOrg != "" || opts.GithubUser != "") {
|
||||
return fmt.Errorf("user/organization private repos require env var GITHUB_TOKEN to be set")
|
||||
}
|
||||
|
||||
if opts.SingleSearch != "" {
|
||||
singleSearchRegex, err = regexp.Compile(opts.SingleSearch)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to compile regex: %s, %v", opts.SingleSearch, err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// loadToml loads of the toml config containing regexes.
|
||||
// 1. look for config path
|
||||
// 2. two, look for gitleaks config env var
|
||||
func loadToml() error {
|
||||
var (
|
||||
config Config
|
||||
configPath string
|
||||
)
|
||||
if opts.ConfigPath != "" {
|
||||
configPath = opts.ConfigPath
|
||||
_, err := os.Stat(configPath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("no gitleaks config at %s", configPath)
|
||||
}
|
||||
} else {
|
||||
configPath = os.Getenv("GITLEAKS_CONFIG")
|
||||
}
|
||||
|
||||
if configPath != "" {
|
||||
if _, err := toml.DecodeFile(configPath, &config); err != nil {
|
||||
return fmt.Errorf("problem loading config: %v", err)
|
||||
}
|
||||
} else {
|
||||
_, err := toml.Decode(defaultConfig, &config)
|
||||
if err != nil {
|
||||
return fmt.Errorf("problem loading default config: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// load up regexes
|
||||
if singleSearchRegex != nil {
|
||||
// single search takes precedence over default regex
|
||||
regexes["singleSearch"] = singleSearchRegex
|
||||
} else {
|
||||
for _, regex := range config.Regexes {
|
||||
regexes[regex.Description] = regexp.MustCompile(regex.Regex)
|
||||
}
|
||||
}
|
||||
whiteListBranches = config.Whitelist.Branches
|
||||
whiteListCommits = make(map[string]bool)
|
||||
for _, commit := range config.Whitelist.Commits {
|
||||
whiteListCommits[commit] = true
|
||||
}
|
||||
for _, regex := range config.Whitelist.Files {
|
||||
whiteListFiles = append(whiteListFiles, regexp.MustCompile(regex))
|
||||
}
|
||||
for _, regex := range config.Whitelist.Regexes {
|
||||
whiteListRegexes = append(whiteListRegexes, regexp.MustCompile(regex))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ownerTarget checks if we are dealing with a remote owner
|
||||
func ownerTarget() bool {
|
||||
if opts.GithubOrg != "" ||
|
||||
opts.GithubUser != "" ||
|
||||
opts.OwnerPath != "" {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// getSSHAuth generates ssh auth
|
||||
func getSSHAuth() (*ssh.PublicKeys, error) {
|
||||
var (
|
||||
sshKeyPath string
|
||||
)
|
||||
if opts.SSHKey != "" {
|
||||
sshKeyPath = opts.SSHKey
|
||||
} else {
|
||||
c, _ := user.Current()
|
||||
sshKeyPath = fmt.Sprintf("%s/.ssh/id_rsa", c.HomeDir)
|
||||
}
|
||||
sshAuth, err := ssh.NewPublicKeysFromFile("git", sshKeyPath, "")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to generate ssh key: %v", err)
|
||||
}
|
||||
return sshAuth, err
|
||||
}
|
||||
|
||||
func (leak *Leak) log() {
|
||||
b, _ := json.MarshalIndent(leak, "", " ")
|
||||
fmt.Println(string(b))
|
||||
return m.Report()
|
||||
}
|
||||
@@ -0,0 +1,274 @@
|
||||
package manager
|
||||
|
||||
import (
|
||||
"crypto/sha1"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
"text/tabwriter"
|
||||
"time"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v6/config"
|
||||
"github.com/zricethezav/gitleaks/v6/options"
|
||||
|
||||
"github.com/go-git/go-git/v5"
|
||||
"github.com/hako/durafmt"
|
||||
"github.com/mattn/go-colorable"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
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"`
|
||||
LineNumber int `json:"lineNumber"`
|
||||
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"`
|
||||
Operation string `json:"operation"`
|
||||
lookupHash string
|
||||
}
|
||||
|
||||
// ScanTime is a type used to determine total scan time
|
||||
type ScanTime int64
|
||||
|
||||
// PatchTime is a type used to determine total patch time during an scan
|
||||
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 scan 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
|
||||
ScanTime 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 scan pkg. This is the public function
|
||||
// that allows other packages to send leaks to the manager.
|
||||
func (manager *Manager) SendLeaks(l Leak) {
|
||||
if len(l.Line) > maxLineLen {
|
||||
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.Line + string(l.LineNumber)))
|
||||
l.lookupHash = hex.EncodeToString(h.Sum(nil))
|
||||
if manager.Opts.Redact {
|
||||
l.Line = strings.ReplaceAll(l.Line, l.Offender, "REDACTED")
|
||||
l.Offender = "REDACTED"
|
||||
}
|
||||
manager.leakWG.Add(1)
|
||||
manager.leakChan <- l
|
||||
}
|
||||
|
||||
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 ScanTime:
|
||||
manager.metadata.ScanTime += 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 scan 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 scan
|
||||
func (manager *Manager) DebugOutput() {
|
||||
log.Debugf("-------------------------\n")
|
||||
log.Debugf("| Times and Commit Counts|\n")
|
||||
log.Debugf("-------------------------\n")
|
||||
fmt.Println("totalScanTime: ", durafmt.Parse(time.Duration(manager.metadata.ScanTime)*time.Nanosecond))
|
||||
fmt.Println("totalPatchTime: ", durafmt.Parse(time.Duration(manager.metadata.patchTime)*time.Nanosecond))
|
||||
fmt.Println("totalCloneTime: ", durafmt.Parse(time.Duration(manager.metadata.cloneTime)*time.Nanosecond))
|
||||
fmt.Println("totalCommits: ", manager.metadata.Commits)
|
||||
|
||||
const padding = 6
|
||||
w := tabwriter.NewWriter(os.Stdout, 0, 0, padding, '.', 0)
|
||||
|
||||
log.Debugf("--------------------------\n")
|
||||
log.Debugf("| Individual Regexes Times |\n")
|
||||
log.Debugf("--------------------------\n")
|
||||
for k, v := range manager.metadata.RegexTime {
|
||||
_, _ = fmt.Fprintf(w, "%s\t%s\n", k, durafmt.Parse(time.Duration(v)*time.Nanosecond))
|
||||
}
|
||||
_ = w.Flush()
|
||||
|
||||
}
|
||||
|
||||
|
||||
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 scan")
|
||||
os.Exit(options.ErrorEncountered)
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package manager
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"fmt"
|
||||
"github.com/zricethezav/gitleaks/v6/config"
|
||||
"github.com/zricethezav/gitleaks/v6/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 {
|
||||
scanTime int64
|
||||
patchTime int64
|
||||
cloneTime int64
|
||||
regexTime int64
|
||||
iterations int
|
||||
}{
|
||||
{
|
||||
scanTime: 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(ScanTime(test.scanTime))
|
||||
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.ScanTime != test.scanTime*int64(test.iterations) {
|
||||
t.Errorf("scan time mismatch, got %d, wanted %d",
|
||||
md.ScanTime, test.scanTime*int64(test.iterations))
|
||||
}
|
||||
if md.patchTime != test.patchTime*int64(test.iterations) {
|
||||
t.Errorf("clone time mismatch, got %d, wanted %d",
|
||||
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:])
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package manager
|
||||
|
||||
import (
|
||||
"encoding/csv"
|
||||
"encoding/json"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v6/version"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// Report saves gitleaks leaks to a json specified by --report={report.json}
|
||||
func (manager *Manager) Report() error {
|
||||
close(manager.leakChan)
|
||||
close(manager.metadata.timings)
|
||||
|
||||
if log.IsLevelEnabled(log.DebugLevel) {
|
||||
manager.DebugOutput()
|
||||
}
|
||||
|
||||
if manager.Opts.Report != "" {
|
||||
if len(manager.GetLeaks()) == 0 {
|
||||
log.Infof("no leaks found, skipping writing report")
|
||||
return nil
|
||||
}
|
||||
file, err := os.Create(manager.Opts.Report)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
switch manager.Opts.ReportFormat {
|
||||
case "json":
|
||||
encoder := json.NewEncoder(file)
|
||||
encoder.SetIndent("", " ")
|
||||
err = encoder.Encode(manager.leaks)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
case "csv":
|
||||
w := csv.NewWriter(file)
|
||||
_ = w.Write([]string{"repo", "line", "commit", "offender", "rule", "tags", "commitMsg", "author", "email", "file", "date"})
|
||||
for _, leak := range manager.GetLeaks() {
|
||||
w.Write([]string{leak.Repo, leak.Line, leak.Commit, leak.Offender, leak.Rule, leak.Tags, leak.Message, leak.Author, leak.Email, leak.File, leak.Date.Format(time.RFC3339)})
|
||||
}
|
||||
w.Flush()
|
||||
case "sarif":
|
||||
s := Sarif{
|
||||
Schema: "https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0-rtm.5.json",
|
||||
Version: "2.1.0",
|
||||
Runs: []Runs{
|
||||
{
|
||||
Tool: Tool{
|
||||
Driver: Driver{
|
||||
Name: "Gitleaks",
|
||||
SemanticVersion: version.Version,
|
||||
Rules: manager.configToRules(),
|
||||
},
|
||||
},
|
||||
Results: manager.leaksToResults(),
|
||||
},
|
||||
},
|
||||
}
|
||||
encoder := json.NewEncoder(file)
|
||||
encoder.SetIndent("", " ")
|
||||
err = encoder.Encode(s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
_ = file.Close()
|
||||
|
||||
log.Infof("report written to %s", manager.Opts.Report)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -0,0 +1,153 @@
|
||||
package manager
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
//Sarif ...
|
||||
type Sarif struct {
|
||||
Schema string `json:"$schema"`
|
||||
Version string `json:"version"`
|
||||
Runs []Runs `json:"runs"`
|
||||
}
|
||||
|
||||
//ShortDescription ...
|
||||
type ShortDescription struct {
|
||||
Text string `json:"text"`
|
||||
}
|
||||
|
||||
//FullDescription ...
|
||||
type FullDescription struct {
|
||||
Text string `json:"text"`
|
||||
}
|
||||
|
||||
//Rules ...
|
||||
type Rules struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
//Driver ...
|
||||
type Driver struct {
|
||||
Name string `json:"name"`
|
||||
SemanticVersion string `json:"semanticVersion"`
|
||||
Rules []Rules `json:"rules"`
|
||||
}
|
||||
|
||||
//Tool ...
|
||||
type Tool struct {
|
||||
Driver Driver `json:"driver"`
|
||||
}
|
||||
|
||||
//Message ...
|
||||
type Message struct {
|
||||
Text string `json:"text"`
|
||||
}
|
||||
|
||||
//ArtifactLocation ...
|
||||
type ArtifactLocation struct {
|
||||
URI string `json:"uri"`
|
||||
}
|
||||
|
||||
//Region ...
|
||||
type Region struct {
|
||||
StartLine int `json:"startLine"`
|
||||
Snippet Snippet `json:"snippet"`
|
||||
}
|
||||
|
||||
//Snippet ...
|
||||
type Snippet struct {
|
||||
Text string `json:"text"`
|
||||
}
|
||||
|
||||
//PhysicalLocation ...
|
||||
type PhysicalLocation struct {
|
||||
ArtifactLocation ArtifactLocation `json:"artifactLocation"`
|
||||
Region Region `json:"region"`
|
||||
}
|
||||
|
||||
//Locations ...
|
||||
type Locations struct {
|
||||
PhysicalLocation PhysicalLocation `json:"physicalLocation"`
|
||||
}
|
||||
|
||||
//Results ...
|
||||
type Results struct {
|
||||
Message Message `json:"message"`
|
||||
Properties ResultProperties `json:"properties"`
|
||||
Locations []Locations `json:"locations"`
|
||||
}
|
||||
|
||||
//ResultProperties ...
|
||||
type ResultProperties struct {
|
||||
Commit string `json:"commit"`
|
||||
Offender string `json:"offender"`
|
||||
Date time.Time `json:"date"`
|
||||
Author string `json:"author"`
|
||||
Email string `json:"email"`
|
||||
CommitMessage string `json:"commitMessage"`
|
||||
Operation string `json:"gitOperation"`
|
||||
Repo string `json:"repo"`
|
||||
}
|
||||
|
||||
//Runs ...
|
||||
type Runs struct {
|
||||
Tool Tool `json:"tool"`
|
||||
Results []Results `json:"results"`
|
||||
}
|
||||
|
||||
func (manager *Manager) configToRules() []Rules {
|
||||
var rules []Rules
|
||||
for _, rule := range manager.Config.Rules {
|
||||
rules = append(rules, Rules{
|
||||
ID: rule.Description,
|
||||
Name: rule.Description,
|
||||
})
|
||||
}
|
||||
return rules
|
||||
}
|
||||
|
||||
func (manager *Manager) leaksToResults() []Results {
|
||||
var results []Results
|
||||
for _, leak := range manager.leaks {
|
||||
results = append(results, Results{
|
||||
Message: Message{
|
||||
Text: fmt.Sprintf("%s secret detected", leak.Rule),
|
||||
},
|
||||
Properties: ResultProperties{
|
||||
Commit: leak.Commit,
|
||||
Offender: leak.Offender,
|
||||
Date: leak.Date,
|
||||
Author: leak.Author,
|
||||
Email: leak.Email,
|
||||
CommitMessage: leak.Message,
|
||||
Operation: leak.Operation,
|
||||
Repo: leak.Repo,
|
||||
},
|
||||
Locations: leakToLocation(leak),
|
||||
})
|
||||
}
|
||||
|
||||
return results
|
||||
}
|
||||
|
||||
func leakToLocation(leak Leak) []Locations {
|
||||
return []Locations{
|
||||
{
|
||||
PhysicalLocation:
|
||||
PhysicalLocation{
|
||||
ArtifactLocation: ArtifactLocation{
|
||||
URI: leak.File,
|
||||
},
|
||||
Region: Region{
|
||||
StartLine: leak.LineNumber,
|
||||
Snippet: Snippet{
|
||||
Text: leak.Line,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,252 @@
|
||||
package options
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/user"
|
||||
"strings"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v6/version"
|
||||
|
||||
"github.com/go-git/go-git/v5"
|
||||
"github.com/go-git/go-git/v5/plumbing/transport/http"
|
||||
"github.com/go-git/go-git/v5/plumbing/transport/ssh"
|
||||
"github.com/jessevdk/go-flags"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// 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
|
||||
donateMessage = "👋 maintaining gitleaks takes a lot of work so consider sponsoring me or donating a little something\n❤️ https://github.com/sponsors/zricethezav\n💸 https://www.paypal.me/zricethezav\n₿ btc:3GndEzRZa6rJ8ZpkLureUcc5TDHMYfpDxn"
|
||||
)
|
||||
|
||||
// Options stores values of command line options
|
||||
type Options struct {
|
||||
Verbose bool `short:"v" long:"verbose" description:"Show verbose output from scan"`
|
||||
Repo string `short:"r" long:"repo" description:"Target repository"`
|
||||
Config string `long:"config" description:"config path"`
|
||||
Disk bool `long:"disk" description:"Clones repo(s) to disk"`
|
||||
Version bool `long:"version" description:"version number"`
|
||||
Username string `long:"username" description:"Username for git repo"`
|
||||
Password string `long:"password" description:"Password for git repo"`
|
||||
AccessToken string `long:"access-token" description:"Access token for git repo"`
|
||||
Commit string `long:"commit" description:"sha of commit to scan or \"latest\" to scan the last commit of the repository"`
|
||||
FilesAtCommit string `long:"files-at-commit" description:"sha of commit to scan all files at commit"`
|
||||
Threads int `long:"threads" description:"Maximum number of threads gitleaks spawns"`
|
||||
SSH string `long:"ssh-key" description:"path to ssh key used for auth"`
|
||||
Uncommited bool `long:"uncommitted" description:"run gitleaks on uncommitted code"`
|
||||
RepoPath string `long:"repo-path" description:"Path to repo"`
|
||||
OwnerPath string `long:"owner-path" description:"Path to owner directory (repos discovered)"`
|
||||
Branch string `long:"branch" description:"Branch to scan"`
|
||||
Report string `long:"report" description:"path to write json leaks file"`
|
||||
ReportFormat string `long:"report-format" default:"json" description:"json, csv, sarif"`
|
||||
Redact bool `long:"redact" description:"redact secrets from log messages and leaks"`
|
||||
Debug bool `long:"debug" description:"log debug messages"`
|
||||
RepoConfig bool `long:"repo-config" description:"Load config from target repo. Config file must be \".gitleaks.toml\" or \"gitleaks.toml\""`
|
||||
PrettyPrint bool `long:"pretty" description:"Pretty print json if leaks are present"`
|
||||
CommitFrom string `long:"commit-from" description:"Commit to start scan from"`
|
||||
CommitTo string `long:"commit-to" description:"Commit to stop scan"`
|
||||
CommitSince string `long:"commit-since" description:"Scan commits more recent than a specific date. Ex: '2006-01-02' or '2006-01-02T15:04:05-0700' format."`
|
||||
CommitUntil string `long:"commit-until" description:"Scan commits older than a specific date. Ex: '2006-01-02' or '2006-01-02T15:04:05-0700' format."`
|
||||
Timeout string `long:"timeout" description:"Time allowed per scan. Ex: 10us, 30s, 1m, 1h10m1s"`
|
||||
Depth int `long:"depth" description:"Number of commits to scan"`
|
||||
Deletion bool `long:"include-deletion" description:"Scan for patch deletions in addition to patch additions"`
|
||||
|
||||
// Hosts
|
||||
Host string `long:"host" description:"git hosting service like gitlab or github. Supported hosts include: Github, Gitlab"`
|
||||
BaseURL string `long:"baseurl" description:"Base URL for API requests. Defaults to the public GitLab or GitHub API, but can be set to a domain endpoint to use with a self hosted server."`
|
||||
Organization string `long:"org" description:"organization to scan"`
|
||||
User string `long:"user" description:"user to scan"`
|
||||
PullRequest string `long:"pr" description:"pull/merge request url"`
|
||||
ExcludeForks bool `long:"exclude-forks" description:"scan 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)
|
||||
}
|
||||
fmt.Println(donateMessage)
|
||||
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 scan with any of the git hosting providers
|
||||
// in the host pkg. The access token set by cli options takes precedence over env vars.
|
||||
func GetAccessToken(opts Options) string {
|
||||
if opts.AccessToken != "" {
|
||||
return opts.AccessToken
|
||||
}
|
||||
return os.Getenv("GITLEAKS_ACCESS_TOKEN")
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
package options
|
||||
+296
@@ -0,0 +1,296 @@
|
||||
package scan
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/md5"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v6/config"
|
||||
"github.com/zricethezav/gitleaks/v6/manager"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
"github.com/go-git/go-billy/v5"
|
||||
"github.com/go-git/go-git/v5"
|
||||
"github.com/go-git/go-git/v5/plumbing"
|
||||
"github.com/go-git/go-git/v5/storage/memory"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// Repo wraps a *git.Repository object in addition to a manager object and the name of the repo.
|
||||
// Commits are inspected from the *git.Repository object. If a Commit is found then we send it
|
||||
// via the manager LeakChan where the manager receives and keeps track of all leaks.
|
||||
type Repo struct {
|
||||
*git.Repository
|
||||
|
||||
// config is used when the --repo-config option is set.
|
||||
// This allows users to load up configs specific to their repos.
|
||||
// Imagine the scenario where you are doing an scan of a large organization
|
||||
// and you want certain repos to look for specific rules. If those specific repos
|
||||
// have a gitleaks.toml or .gitleaks.toml config then those configs will be used specifically
|
||||
// for those repo scans.
|
||||
config config.Config
|
||||
|
||||
// ctx is used to signal timeouts to running goroutines
|
||||
ctx context.Context
|
||||
cancel context.CancelFunc
|
||||
|
||||
Name string
|
||||
Manager *manager.Manager
|
||||
}
|
||||
|
||||
// NewRepo initializes and returns a Repo struct.
|
||||
func NewRepo(m *manager.Manager) *Repo {
|
||||
return &Repo{
|
||||
Manager: m,
|
||||
config: m.Config,
|
||||
ctx: context.Background(),
|
||||
}
|
||||
}
|
||||
|
||||
// Run accepts a manager and begins an scan based on the options/configs set in the manager.
|
||||
func Run(m *manager.Manager) error {
|
||||
if m.Opts.OwnerPath != "" {
|
||||
files, err := ioutil.ReadDir(m.Opts.OwnerPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, f := range files {
|
||||
if !f.IsDir() {
|
||||
continue
|
||||
}
|
||||
m.Opts.RepoPath = fmt.Sprintf("%s/%s", m.Opts.OwnerPath, f.Name())
|
||||
if err := runHelper(NewRepo(m)); err != nil {
|
||||
log.Warnf("%s is not a git repo, skipping", f.Name())
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
return runHelper(NewRepo(m))
|
||||
}
|
||||
|
||||
func runHelper(r *Repo) error {
|
||||
// Ignore allowlisted repos
|
||||
for _, allowListedRepo := range r.Manager.Config.Allowlist.Repos {
|
||||
if RegexMatched(r.Manager.Opts.RepoPath, allowListedRepo) {
|
||||
return nil
|
||||
}
|
||||
if RegexMatched(r.Manager.Opts.Repo, allowListedRepo) {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
if r.Manager.Opts.OpenLocal() {
|
||||
r.Name = path.Base(r.Manager.Opts.RepoPath)
|
||||
if err := r.Open(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Check if we are checking uncommitted files. This is the default behavior
|
||||
// for a "$ gitleaks" command with no options set
|
||||
if r.Manager.Opts.CheckUncommitted() {
|
||||
if err := r.scanUncommitted(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
} else {
|
||||
if err := r.Clone(nil); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return r.Scan()
|
||||
}
|
||||
|
||||
// Clone will clone a repo and return a Repo struct which contains a go-git repo. The clone method
|
||||
// is determined by the clone options set in Manager.metadata.cloneOptions
|
||||
func (repo *Repo) Clone(cloneOption *git.CloneOptions) error {
|
||||
var (
|
||||
repository *git.Repository
|
||||
err error
|
||||
)
|
||||
if cloneOption == nil {
|
||||
cloneOption = repo.Manager.CloneOptions
|
||||
}
|
||||
|
||||
log.Infof("cloning... %s", cloneOption.URL)
|
||||
start := time.Now()
|
||||
|
||||
if repo.Manager.CloneDir != "" {
|
||||
clonePath := fmt.Sprintf("%s/%x", repo.Manager.CloneDir, md5.Sum([]byte(time.Now().String())))
|
||||
repository, err = git.PlainClone(clonePath, false, cloneOption)
|
||||
} else {
|
||||
repository, err = git.Clone(memory.NewStorage(), nil, cloneOption)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
repo.Name = filepath.Base(repo.Manager.Opts.Repo)
|
||||
repo.Repository = repository
|
||||
repo.Manager.RecordTime(manager.CloneTime(howLong(start)))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// howManyThreads will return a number 1-GOMAXPROCS which is the number
|
||||
// of goroutines that will spawn during gitleaks execution
|
||||
func howManyThreads(threads int) int {
|
||||
maxThreads := runtime.GOMAXPROCS(0)
|
||||
if threads == 0 {
|
||||
return 1
|
||||
} else if threads > maxThreads {
|
||||
log.Warnf("%d threads set too high, setting to system max, %d", threads, maxThreads)
|
||||
return maxThreads
|
||||
}
|
||||
return threads
|
||||
}
|
||||
|
||||
// getLogOptions determines what log options are used when iterating through commits.
|
||||
// It is similar to `git log {branch}`. Default behavior is to log ALL branches so
|
||||
// gitleaks gets the full git history.
|
||||
func getLogOptions(repo *Repo) (*git.LogOptions, error) {
|
||||
var logOpts git.LogOptions
|
||||
const dateformat string = "2006-01-02"
|
||||
const timeformat string = "2006-01-02T15:04:05-0700"
|
||||
if repo.Manager.Opts.CommitFrom != "" {
|
||||
logOpts.From = plumbing.NewHash(repo.Manager.Opts.CommitFrom)
|
||||
}
|
||||
if repo.Manager.Opts.CommitSince != "" {
|
||||
if t, err := time.Parse(timeformat, repo.Manager.Opts.CommitSince); err == nil {
|
||||
logOpts.Since = &t
|
||||
} else if t, err := time.Parse(dateformat, repo.Manager.Opts.CommitSince); err == nil {
|
||||
logOpts.Since = &t
|
||||
} else {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if repo.Manager.Opts.CommitUntil != "" {
|
||||
if t, err := time.Parse(timeformat, repo.Manager.Opts.CommitUntil); err == nil {
|
||||
logOpts.Until = &t
|
||||
} else if t, err := time.Parse(dateformat, repo.Manager.Opts.CommitUntil); err == nil {
|
||||
logOpts.Until = &t
|
||||
} else {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if repo.Manager.Opts.Branch != "" {
|
||||
refs, err := repo.Storer.IterReferences()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = refs.ForEach(func(ref *plumbing.Reference) error {
|
||||
if ref.Name().IsTag() {
|
||||
return nil
|
||||
}
|
||||
// check heads first
|
||||
if ref.Name().String() == "refs/heads/"+repo.Manager.Opts.Branch {
|
||||
logOpts = git.LogOptions{
|
||||
From: ref.Hash(),
|
||||
}
|
||||
return nil
|
||||
} else if ref.Name().String() == "refs/remotes/origin/"+repo.Manager.Opts.Branch {
|
||||
logOpts = git.LogOptions{
|
||||
From: ref.Hash(),
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if logOpts.From.IsZero() {
|
||||
return nil, fmt.Errorf("could not find branch %s", repo.Manager.Opts.Branch)
|
||||
}
|
||||
return &logOpts, nil
|
||||
}
|
||||
if !logOpts.From.IsZero() || logOpts.Since != nil || logOpts.Until != nil {
|
||||
return &logOpts, nil
|
||||
}
|
||||
return &git.LogOptions{All: true}, nil
|
||||
}
|
||||
|
||||
// howLong accepts a time.Time object which is subtracted from time.Now() and
|
||||
// converted to nanoseconds which is returned
|
||||
func howLong(t time.Time) int64 {
|
||||
return time.Now().Sub(t).Nanoseconds()
|
||||
}
|
||||
|
||||
// Open opens a local repo either from repo-path or $PWD
|
||||
func (repo *Repo) Open() error {
|
||||
if repo.Manager.Opts.RepoPath != "" {
|
||||
// open git repo from repo path
|
||||
repository, err := git.PlainOpen(repo.Manager.Opts.RepoPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
repo.Repository = repository
|
||||
} else {
|
||||
// open git repo from PWD
|
||||
dir, err := os.Getwd()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
repository, err := git.PlainOpen(dir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
repo.Repository = repository
|
||||
repo.Name = path.Base(dir)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (repo *Repo) loadRepoConfig() (config.Config, error) {
|
||||
wt, err := repo.Repository.Worktree()
|
||||
if err != nil {
|
||||
return config.Config{}, err
|
||||
}
|
||||
var f billy.File
|
||||
f, _ = wt.Filesystem.Open(".gitleaks.toml")
|
||||
if f == nil {
|
||||
f, err = wt.Filesystem.Open("gitleaks.toml")
|
||||
if err != nil {
|
||||
return config.Config{}, fmt.Errorf("problem loading repo config: %v", err)
|
||||
}
|
||||
}
|
||||
defer f.Close()
|
||||
var tomlLoader config.TomlLoader
|
||||
_, err = toml.DecodeReader(f, &tomlLoader)
|
||||
return tomlLoader.Parse()
|
||||
}
|
||||
|
||||
// timeoutReached returns true if the timeout deadline has been met. This function should be used
|
||||
// at the top of loops and before potentially long running goroutines (like checking inefficient regexes)
|
||||
func (repo *Repo) timeoutReached() bool {
|
||||
if repo.ctx.Err() == context.DeadlineExceeded {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// setupTimeout parses the --timeout option and assigns a context with timeout to the manager
|
||||
// which will exit early if the timeout has been met.
|
||||
func (repo *Repo) setupTimeout() error {
|
||||
if repo.Manager.Opts.Timeout == "" {
|
||||
return nil
|
||||
}
|
||||
timeout, err := time.ParseDuration(repo.Manager.Opts.Timeout)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
repo.ctx, repo.cancel = context.WithTimeout(context.Background(), timeout)
|
||||
|
||||
go func() {
|
||||
select {
|
||||
case <-repo.ctx.Done():
|
||||
if repo.timeoutReached() {
|
||||
log.Warnf("Timeout deadline (%s) exceeded for %s", timeout.String(), repo.Name)
|
||||
}
|
||||
}
|
||||
}()
|
||||
return nil
|
||||
}
|
||||
+381
@@ -0,0 +1,381 @@
|
||||
package scan
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"io"
|
||||
"math"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v6/config"
|
||||
"github.com/zricethezav/gitleaks/v6/manager"
|
||||
|
||||
fdiff "github.com/go-git/go-git/v5/plumbing/format/diff"
|
||||
"github.com/go-git/go-git/v5/plumbing/object"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
const (
|
||||
diffAddPrefix = "+"
|
||||
diffAddFilePrefix = "+++ b"
|
||||
diffAddFilePrefixSlash = "+++ b/"
|
||||
diffLineSignature = " @@"
|
||||
defaultLineNumber = -1
|
||||
)
|
||||
|
||||
// CheckRules accepts bundle and checks each rule defined in the config against the bundle's content.
|
||||
func (repo *Repo) CheckRules(bundle *Bundle) {
|
||||
filename := filepath.Base(bundle.FilePath)
|
||||
path := filepath.Dir(bundle.FilePath)
|
||||
|
||||
bundle.lineLookup = make(map[string]bool)
|
||||
|
||||
// We want to check if there is a allowlist for this file
|
||||
if len(repo.config.Allowlist.Files) != 0 {
|
||||
for _, reFileName := range repo.config.Allowlist.Files {
|
||||
if RegexMatched(filename, reFileName) {
|
||||
log.Debugf("allowlisted file found, skipping scan of file: %s", filename)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// We want to check if there is a allowlist for this path
|
||||
if len(repo.config.Allowlist.Paths) != 0 {
|
||||
for _, reFilePath := range repo.config.Allowlist.Paths {
|
||||
if RegexMatched(path, reFilePath) {
|
||||
log.Debugf("file in allowlisted path found, skipping scan of file: %s", filename)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for _, rule := range repo.config.Rules {
|
||||
start := time.Now()
|
||||
|
||||
// For each rule we want to check filename allowlists
|
||||
if isAllowListed(filename, rule.AllowList.Files) || isAllowListed(path, rule.AllowList.Paths) {
|
||||
continue
|
||||
}
|
||||
|
||||
// If it has fileNameRegex and it doesnt match we continue to next rule
|
||||
if ruleContainFileRegex(rule) && !RegexMatched(filename, rule.File) {
|
||||
continue
|
||||
}
|
||||
|
||||
// If it has filePathRegex and it doesnt match we continue to next rule
|
||||
if ruleContainPathRegex(rule) && !RegexMatched(path, rule.Path) {
|
||||
continue
|
||||
}
|
||||
|
||||
// If it doesnt contain a Content regex then it is a filename regex match
|
||||
if !ruleContainRegex(rule) {
|
||||
repo.Manager.SendLeaks(manager.Leak{
|
||||
LineNumber: defaultLineNumber,
|
||||
Line: "N/A",
|
||||
Offender: "Filename/path offender: " + filename,
|
||||
Commit: bundle.Commit.Hash.String(),
|
||||
Repo: repo.Name,
|
||||
Message: bundle.Commit.Message,
|
||||
Rule: rule.Description,
|
||||
Author: bundle.Commit.Author.Name,
|
||||
Email: bundle.Commit.Author.Email,
|
||||
Date: bundle.Commit.Author.When,
|
||||
Tags: strings.Join(rule.Tags, ", "),
|
||||
File: filename,
|
||||
Operation: diffOpToString(bundle.Operation),
|
||||
})
|
||||
} else {
|
||||
//otherwise we check if it matches Content regex
|
||||
locs := rule.Regex.FindAllIndex([]byte(bundle.Content), -1)
|
||||
if len(locs) != 0 {
|
||||
for _, loc := range locs {
|
||||
start := loc[0]
|
||||
end := loc[1]
|
||||
for start != 0 && bundle.Content[start] != '\n' {
|
||||
start--
|
||||
}
|
||||
|
||||
if bundle.Content[start] == '\n' {
|
||||
start++
|
||||
}
|
||||
|
||||
for end < len(bundle.Content)-1 && bundle.Content[end] != '\n' {
|
||||
end++
|
||||
}
|
||||
|
||||
line := bundle.Content[start:end]
|
||||
offender := bundle.Content[loc[0]:loc[1]]
|
||||
groups := rule.Regex.FindStringSubmatch(offender)
|
||||
|
||||
if isAllowListed(line, append(rule.AllowList.Regexes, repo.config.Allowlist.Regexes...)) {
|
||||
continue
|
||||
}
|
||||
|
||||
if len(rule.Entropies) != 0 && !trippedEntropy(groups, rule) {
|
||||
continue
|
||||
}
|
||||
|
||||
leak := manager.Leak{
|
||||
LineNumber: defaultLineNumber,
|
||||
Line: line,
|
||||
Offender: offender,
|
||||
Commit: bundle.Commit.Hash.String(),
|
||||
Repo: repo.Name,
|
||||
Message: bundle.Commit.Message,
|
||||
Rule: rule.Description,
|
||||
Author: bundle.Commit.Author.Name,
|
||||
Email: bundle.Commit.Author.Email,
|
||||
Date: bundle.Commit.Author.When,
|
||||
Tags: strings.Join(rule.Tags, ", "),
|
||||
File: bundle.FilePath,
|
||||
Operation: diffOpToString(bundle.Operation),
|
||||
}
|
||||
|
||||
// only search for line numbers on non-deletions
|
||||
if bundle.Operation != fdiff.Delete {
|
||||
extractAndInjectLineNumber(&leak, bundle, repo)
|
||||
}
|
||||
|
||||
repo.Manager.SendLeaks(leak)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
repo.Manager.RecordTime(manager.RegexTime{
|
||||
Time: howLong(start),
|
||||
Regex: rule.Regex.String(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// RegexMatched matched an interface to a regular expression. The interface f can
|
||||
// be a string type or go-git *object.File type.
|
||||
func RegexMatched(f interface{}, re *regexp.Regexp) bool {
|
||||
if re == nil {
|
||||
return false
|
||||
}
|
||||
switch f.(type) {
|
||||
case nil:
|
||||
return false
|
||||
case string:
|
||||
if re.FindString(f.(string)) != "" {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
case *object.File:
|
||||
if re.FindString(f.(*object.File).Name) != "" {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// diffOpToString converts a fdiff.Operation to a string
|
||||
func diffOpToString(operation fdiff.Operation) string {
|
||||
switch operation {
|
||||
case fdiff.Add:
|
||||
return "addition"
|
||||
case fdiff.Equal:
|
||||
return "equal"
|
||||
default:
|
||||
return "deletion"
|
||||
}
|
||||
}
|
||||
|
||||
// extractAndInjectLine accepts a leak, bundle, and repo which it uses to do a reverse search in order to extract
|
||||
// the line number of a historic or present leak. The function is only called when the git operation is an addition
|
||||
// or none, it does not get called when the git operation is deletion.
|
||||
func extractAndInjectLineNumber(leak *manager.Leak, bundle *Bundle, repo *Repo) {
|
||||
var err error
|
||||
|
||||
switch bundle.scanType {
|
||||
case patchScan:
|
||||
if bundle.Patch == "" {
|
||||
return
|
||||
}
|
||||
|
||||
// This is needed as some patches generate strings that are larger than
|
||||
// scanners max size (MaxScanTokenSize = 64 * 1024)
|
||||
// https://github.com/zricethezav/gitleaks/issues/413
|
||||
buf := make([]byte, len(bundle.Patch))
|
||||
scanner := bufio.NewScanner(strings.NewReader(bundle.Patch))
|
||||
scanner.Buffer(buf, len(bundle.Patch))
|
||||
scanner.Split(bufio.ScanLines)
|
||||
|
||||
currFile := ""
|
||||
currLine := 0
|
||||
currStartDiffLine := 0
|
||||
|
||||
for scanner.Scan() {
|
||||
txt := scanner.Text()
|
||||
if strings.HasPrefix(txt, diffAddFilePrefix) {
|
||||
currStartDiffLine = 1
|
||||
currLine = 0
|
||||
currFile = strings.Split(txt, diffAddFilePrefixSlash)[1]
|
||||
|
||||
// next line contains diff line information so lets scan it here
|
||||
scanner.Scan()
|
||||
|
||||
txt := scanner.Text()
|
||||
i := strings.Index(txt, diffAddPrefix)
|
||||
pairs := strings.Split(strings.Split(txt[i+1:], diffLineSignature)[0], ",")
|
||||
currStartDiffLine, err = strconv.Atoi(pairs[0])
|
||||
if err != nil {
|
||||
log.Debug(err)
|
||||
return
|
||||
}
|
||||
continue
|
||||
} else if strings.HasPrefix(txt, diffAddPrefix) && strings.Contains(txt, leak.Line) && leak.File == currFile {
|
||||
potentialLine := currLine + currStartDiffLine
|
||||
if _, ok := bundle.lineLookup[fmt.Sprintf("%s%d%s", leak.Line, potentialLine, currFile)]; !ok {
|
||||
bundle.lineLookup[fmt.Sprintf("%s%d%s", leak.Line, potentialLine, currFile)] = true
|
||||
leak.LineNumber = potentialLine
|
||||
return
|
||||
}
|
||||
}
|
||||
currLine++
|
||||
}
|
||||
case commitScan:
|
||||
if bundle.Commit == nil {
|
||||
return
|
||||
}
|
||||
f, err := bundle.Commit.File(bundle.FilePath)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
}
|
||||
r, err := f.Reader()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
}
|
||||
leak.LineNumber = extractLineHelper(r, bundle, leak)
|
||||
case uncommittedScan:
|
||||
wt, err := repo.Worktree()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
}
|
||||
f, err := wt.Filesystem.Open(leak.File)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
}
|
||||
leak.LineNumber = extractLineHelper(f, bundle, leak)
|
||||
}
|
||||
}
|
||||
|
||||
// extractLineHelper consolidates code for checking the leak line against the contents of a reader to find the
|
||||
// line number of the leak.
|
||||
func extractLineHelper(r io.Reader, bundle *Bundle, leak *manager.Leak) int {
|
||||
scanner := bufio.NewScanner(r)
|
||||
lineNumber := 1
|
||||
for scanner.Scan() {
|
||||
if leak.Line == scanner.Text() {
|
||||
if _, ok := bundle.lineLookup[fmt.Sprintf("%s%d%s", leak.Line, lineNumber, bundle.FilePath)]; !ok {
|
||||
bundle.lineLookup[fmt.Sprintf("%s%d%s", leak.Line, lineNumber, bundle.FilePath)] = true
|
||||
return lineNumber
|
||||
}
|
||||
}
|
||||
lineNumber++
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
// trippedEntropy checks if a given capture group or offender falls in between entropy ranges
|
||||
// supplied by a custom gitleaks configuration. Gitleaks do not check entropy by default.
|
||||
func trippedEntropy(groups []string, rule config.Rule) bool {
|
||||
for _, e := range rule.Entropies {
|
||||
if len(groups) > e.Group {
|
||||
entropy := shannonEntropy(groups[e.Group])
|
||||
if entropy >= e.Min && entropy <= e.Max {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// shannonEntropy calculates the entropy of data using the formula defined here:
|
||||
// https://en.wiktionary.org/wiki/Shannon_entropy
|
||||
// Another way to think about what this is doing is calculating the number of bits
|
||||
// needed to on average encode the data. So, the higher the entropy, the more random the data, the
|
||||
// more bits needed to encode that data.
|
||||
func shannonEntropy(data string) (entropy float64) {
|
||||
if data == "" {
|
||||
return 0
|
||||
}
|
||||
|
||||
charCounts := make(map[rune]int)
|
||||
for _, char := range data {
|
||||
charCounts[char]++
|
||||
}
|
||||
|
||||
invLength := 1.0 / float64(len(data))
|
||||
for _, count := range charCounts {
|
||||
freq := float64(count) * invLength
|
||||
entropy -= freq * math.Log2(freq)
|
||||
}
|
||||
|
||||
return entropy
|
||||
}
|
||||
|
||||
// Checks if the given rule has a regex
|
||||
func ruleContainRegex(rule config.Rule) bool {
|
||||
if rule.Regex == nil {
|
||||
return false
|
||||
}
|
||||
if rule.Regex.String() == "" {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// Checks if the given rule has a file name regex
|
||||
func ruleContainFileRegex(rule config.Rule) bool {
|
||||
if rule.File == nil {
|
||||
return false
|
||||
}
|
||||
if rule.File.String() == "" {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// Checks if the given rule has a file path regex
|
||||
func ruleContainPathRegex(rule config.Rule) bool {
|
||||
if rule.Path == nil {
|
||||
return false
|
||||
}
|
||||
if rule.Path.String() == "" {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func isCommitAllowListed(commitHash string, allowlistedCommits []string) bool {
|
||||
for _, hash := range allowlistedCommits {
|
||||
if commitHash == hash {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func isAllowListed(target string, allowList []*regexp.Regexp) bool {
|
||||
if len(allowList) != 0 {
|
||||
for _, re := range allowList {
|
||||
if re.FindString(target) != "" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
|
||||
}
|
||||
+462
@@ -0,0 +1,462 @@
|
||||
package scan
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v6/manager"
|
||||
|
||||
"github.com/go-git/go-git/v5"
|
||||
"github.com/go-git/go-git/v5/plumbing"
|
||||
fdiff "github.com/go-git/go-git/v5/plumbing/format/diff"
|
||||
"github.com/go-git/go-git/v5/plumbing/object"
|
||||
"github.com/go-git/go-git/v5/plumbing/storer"
|
||||
"github.com/sergi/go-diff/diffmatchpatch"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// Bundle contains various git information for scans.
|
||||
type Bundle struct {
|
||||
Commit *object.Commit
|
||||
Patch string
|
||||
Content string
|
||||
FilePath string
|
||||
Operation fdiff.Operation
|
||||
|
||||
reader io.Reader
|
||||
lineLookup map[string]bool
|
||||
scanType int
|
||||
}
|
||||
|
||||
// commitScanner is a function signature for scanning commits. There is some
|
||||
// redundant work needed by scanning all files at a commit (--files-at-commit=) and scanning
|
||||
// the patches generated by a commit (--commit=). The function scanCommit wraps that redundant work
|
||||
// and accepts a commitScanner for the different logic needed between the two cases described above.
|
||||
type commitScanner func(c *object.Commit, repo *Repo) error
|
||||
|
||||
const (
|
||||
// We need to differentiate between scans as the logic for line searching is different between
|
||||
// scanning patches, commits, and uncommitted files.
|
||||
patchScan int = iota + 1
|
||||
uncommittedScan
|
||||
commitScan
|
||||
)
|
||||
|
||||
// Scan is responsible for scanning the entire history (default behavior) of a
|
||||
// git repo. Options that can change the behavior of this function include: --Commit, --depth, --branch.
|
||||
// See options/options.go for an explanation on these options.
|
||||
func (repo *Repo) Scan() error {
|
||||
if err := repo.setupTimeout(); err != nil {
|
||||
return err
|
||||
}
|
||||
if repo.cancel != nil {
|
||||
defer repo.cancel()
|
||||
}
|
||||
|
||||
if repo.Repository == nil {
|
||||
return fmt.Errorf("%s repo is empty", repo.Name)
|
||||
}
|
||||
|
||||
// load up alternative config if possible, if not use manager's config
|
||||
if repo.Manager.Opts.RepoConfig {
|
||||
cfg, err := repo.loadRepoConfig()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
repo.config = cfg
|
||||
}
|
||||
|
||||
scanTimeStart := time.Now()
|
||||
|
||||
// scan Commit patches OR all files at Commit. See https://github.com/zricethezav/gitleaks/issues/326
|
||||
if repo.Manager.Opts.Commit != "" {
|
||||
return scanCommit(repo.Manager.Opts.Commit, repo, scanCommitPatches)
|
||||
} else if repo.Manager.Opts.FilesAtCommit != "" {
|
||||
return scanCommit(repo.Manager.Opts.FilesAtCommit, repo, scanFilesAtCommit)
|
||||
}
|
||||
|
||||
logOpts, err := getLogOptions(repo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
cIter, err := repo.Log(logOpts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cc := 0
|
||||
semaphore := make(chan bool, howManyThreads(repo.Manager.Opts.Threads))
|
||||
wg := sync.WaitGroup{}
|
||||
err = cIter.ForEach(func(c *object.Commit) error {
|
||||
if c == nil || repo.timeoutReached() || repo.depthReached(cc) {
|
||||
return storer.ErrStop
|
||||
}
|
||||
|
||||
// Check if Commit is allowlisted
|
||||
if isCommitAllowListed(c.Hash.String(), repo.config.Allowlist.Commits) {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Check if at root
|
||||
if len(c.ParentHashes) == 0 {
|
||||
cc++
|
||||
err = scanFilesAtCommit(c, repo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// increase Commit counter
|
||||
cc++
|
||||
|
||||
// inspect first parent only as all other parents will be eventually reached
|
||||
// (they exist as the tip of other branches, etc)
|
||||
// See https://github.com/zricethezav/gitleaks/issues/413 for details
|
||||
parent, err := c.Parent(0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
// sometimes the Patch generation will fail due to a known bug in
|
||||
// sergi's go-diff: https://github.com/sergi/go-diff/issues/89.
|
||||
// Once a fix has been merged I will remove this recover.
|
||||
return
|
||||
}
|
||||
}()
|
||||
if repo.timeoutReached() {
|
||||
return nil
|
||||
}
|
||||
if parent == nil {
|
||||
// shouldn't reach this point but just in case
|
||||
return nil
|
||||
}
|
||||
|
||||
start := time.Now()
|
||||
patch, err := parent.Patch(c)
|
||||
if err != nil {
|
||||
log.Errorf("could not generate Patch")
|
||||
}
|
||||
repo.Manager.RecordTime(manager.PatchTime(howLong(start)))
|
||||
|
||||
wg.Add(1)
|
||||
semaphore <- true
|
||||
go func(c *object.Commit, patch *object.Patch) {
|
||||
defer func() {
|
||||
<-semaphore
|
||||
wg.Done()
|
||||
}()
|
||||
scanPatch(patch, c, repo)
|
||||
}(c, patch)
|
||||
|
||||
if c.Hash.String() == repo.Manager.Opts.CommitTo {
|
||||
return storer.ErrStop
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
wg.Wait()
|
||||
repo.Manager.RecordTime(manager.ScanTime(howLong(scanTimeStart)))
|
||||
repo.Manager.IncrementCommits(cc)
|
||||
return nil
|
||||
}
|
||||
|
||||
// scanEmpty scans an empty repo without any commits. See https://github.com/zricethezav/gitleaks/issues/352
|
||||
func (repo *Repo) scanEmpty() error {
|
||||
scanTimeStart := time.Now()
|
||||
wt, err := repo.Worktree()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
status, err := wt.Status()
|
||||
for fn := range status {
|
||||
workTreeBuf := bytes.NewBuffer(nil)
|
||||
workTreeFile, err := wt.Filesystem.Open(fn)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
if _, err := io.Copy(workTreeBuf, workTreeFile); err != nil {
|
||||
return err
|
||||
}
|
||||
repo.CheckRules(&Bundle{
|
||||
Content: workTreeBuf.String(),
|
||||
FilePath: workTreeFile.Name(),
|
||||
Commit: emptyCommit(),
|
||||
scanType: uncommittedScan,
|
||||
})
|
||||
}
|
||||
repo.Manager.RecordTime(manager.ScanTime(howLong(scanTimeStart)))
|
||||
return nil
|
||||
}
|
||||
|
||||
// scanUncommitted will do a `git diff` and scan changed files that are being tracked. This is useful functionality
|
||||
// for a pre-Commit hook so you can make sure your code does not have any leaks before committing.
|
||||
func (repo *Repo) scanUncommitted() error {
|
||||
// load up alternative config if possible, if not use manager's config
|
||||
if repo.Manager.Opts.RepoConfig {
|
||||
cfg, err := repo.loadRepoConfig()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
repo.config = cfg
|
||||
}
|
||||
|
||||
if err := repo.setupTimeout(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
r, err := repo.Head()
|
||||
if err == plumbing.ErrReferenceNotFound {
|
||||
// possibly an empty repo, or maybe its not, either way lets scan all the files in the directory
|
||||
return repo.scanEmpty()
|
||||
} else if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
scanTimeStart := time.Now()
|
||||
|
||||
c, err := repo.CommitObject(r.Hash())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Staged change so the Commit details do not yet exist. Insert empty defaults.
|
||||
c.Hash = plumbing.Hash{}
|
||||
c.Message = "***STAGED CHANGES***"
|
||||
c.Author.Name = ""
|
||||
c.Author.Email = ""
|
||||
c.Author.When = time.Unix(0, 0).UTC()
|
||||
|
||||
prevTree, err := c.Tree()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
wt, err := repo.Worktree()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
status, err := wt.Status()
|
||||
for fn, state := range status {
|
||||
var (
|
||||
prevFileContents string
|
||||
currFileContents string
|
||||
filename string
|
||||
)
|
||||
|
||||
if state.Staging != git.Untracked {
|
||||
if state.Staging == git.Deleted {
|
||||
// file in staging has been deleted, aka it is not on the filesystem
|
||||
// so the contents of the file are ""
|
||||
currFileContents = ""
|
||||
} else {
|
||||
workTreeBuf := bytes.NewBuffer(nil)
|
||||
workTreeFile, err := wt.Filesystem.Open(fn)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
if _, err := io.Copy(workTreeBuf, workTreeFile); err != nil {
|
||||
return err
|
||||
}
|
||||
currFileContents = workTreeBuf.String()
|
||||
filename = workTreeFile.Name()
|
||||
}
|
||||
|
||||
// get files at HEAD state
|
||||
prevFile, err := prevTree.File(fn)
|
||||
if err != nil {
|
||||
prevFileContents = ""
|
||||
|
||||
} else {
|
||||
prevFileContents, err = prevFile.Contents()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if filename == "" {
|
||||
filename = prevFile.Name
|
||||
}
|
||||
}
|
||||
|
||||
dmp := diffmatchpatch.New()
|
||||
diffs := dmp.DiffCleanupSemantic(dmp.DiffMain(prevFileContents, currFileContents, false))
|
||||
var diffContents string
|
||||
for _, d := range diffs {
|
||||
if d.Type == diffmatchpatch.DiffInsert {
|
||||
diffContents += fmt.Sprintf("%s\n", d.Text)
|
||||
}
|
||||
}
|
||||
repo.CheckRules(&Bundle{
|
||||
Content: diffContents,
|
||||
FilePath: filename,
|
||||
Commit: c,
|
||||
scanType: uncommittedScan,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
repo.Manager.RecordTime(manager.ScanTime(howLong(scanTimeStart)))
|
||||
return nil
|
||||
}
|
||||
|
||||
// scan accepts a Patch, Commit, and repo. If the patches contains files that are
|
||||
// binary, then gitleaks will skip scanning that file OR if a file is matched on
|
||||
// allowlisted files set in the configuration. If a global rule for files is defined and a filename
|
||||
// matches said global rule, then a leak is sent to the manager.
|
||||
// After that, file chunks are created which are then inspected by InspectString()
|
||||
func scanPatch(patch *object.Patch, c *object.Commit, repo *Repo) {
|
||||
bundle := Bundle{
|
||||
Commit: c,
|
||||
Patch: patch.String(),
|
||||
scanType: patchScan,
|
||||
}
|
||||
for _, f := range patch.FilePatches() {
|
||||
if repo.timeoutReached() {
|
||||
return
|
||||
}
|
||||
if f.IsBinary() {
|
||||
continue
|
||||
}
|
||||
for _, chunk := range f.Chunks() {
|
||||
if chunk.Type() == fdiff.Add || (repo.Manager.Opts.Deletion && chunk.Type() == fdiff.Delete) {
|
||||
bundle.Content = chunk.Content()
|
||||
bundle.Operation = chunk.Type()
|
||||
|
||||
// get filepath
|
||||
from, to := f.Files()
|
||||
if from != nil {
|
||||
bundle.FilePath = from.Path()
|
||||
} else if to != nil {
|
||||
bundle.FilePath = to.Path()
|
||||
} else {
|
||||
bundle.FilePath = "???"
|
||||
}
|
||||
repo.CheckRules(&bundle)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// scanCommit accepts a Commit hash, repo, and commit scanning function. A new Commit
|
||||
// object will be created from the hash which will be passed into either scanCommitPatches
|
||||
// or scanFilesAtCommit depending on the options set.
|
||||
func scanCommit(commit string, repo *Repo, f commitScanner) error {
|
||||
if commit == "latest" {
|
||||
ref, err := repo.Repository.Head()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
commit = ref.Hash().String()
|
||||
}
|
||||
repo.Manager.IncrementCommits(1)
|
||||
h := plumbing.NewHash(commit)
|
||||
c, err := repo.CommitObject(h)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return f(c, repo)
|
||||
}
|
||||
|
||||
// scanCommitPatches accepts a Commit object and a repo. This function is only called when the --Commit=
|
||||
// option has been set. That option tells gitleaks to look only at a single Commit and check the contents
|
||||
// of said Commit. Similar to scan(), if the files contained in the Commit are a binaries or if they are
|
||||
// allowlisted then those files will be skipped.
|
||||
func scanCommitPatches(c *object.Commit, repo *Repo) error {
|
||||
if len(c.ParentHashes) == 0 {
|
||||
err := scanFilesAtCommit(c, repo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return c.Parents().ForEach(func(parent *object.Commit) error {
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
// sometimes the Patch generation will fail due to a known bug in
|
||||
// sergi's go-diff: https://github.com/sergi/go-diff/issues/89.
|
||||
// Once a fix has been merged I will remove this recover.
|
||||
return
|
||||
}
|
||||
}()
|
||||
if repo.timeoutReached() {
|
||||
return nil
|
||||
}
|
||||
if parent == nil {
|
||||
return nil
|
||||
}
|
||||
start := time.Now()
|
||||
patch, err := parent.Patch(c)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not generate Patch")
|
||||
}
|
||||
repo.Manager.RecordTime(manager.PatchTime(howLong(start)))
|
||||
|
||||
scanPatch(patch, c, repo)
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// scanFilesAtCommit accepts a Commit object and a repo. This function is only called when the --files-at-Commit=
|
||||
// option has been set. That option tells gitleaks to look only at ALL the files at a Commit and check the contents
|
||||
// of said Commit. Similar to scan(), if the files contained in the Commit are a binaries or if they are
|
||||
// allowlisted then those files will be skipped.
|
||||
func scanFilesAtCommit(c *object.Commit, repo *Repo) error {
|
||||
fIter, err := c.Files()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = fIter.ForEach(func(f *object.File) error {
|
||||
bin, err := f.IsBinary()
|
||||
if bin || repo.timeoutReached() {
|
||||
return nil
|
||||
} else if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
content, err := f.Contents()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
repo.CheckRules(&Bundle{
|
||||
Content: content,
|
||||
FilePath: f.Name,
|
||||
Commit: c,
|
||||
scanType: commitScan,
|
||||
Operation: fdiff.Add,
|
||||
})
|
||||
return nil
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
// depthReached checks if i meets the depth (--depth=) if set
|
||||
func (repo *Repo) depthReached(i int) bool {
|
||||
if repo.Manager.Opts.Depth != 0 && repo.Manager.Opts.Depth == i {
|
||||
log.Warnf("Exceeded depth limit (%d)", i)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// emptyCommit generates an empty commit used for scanning uncommitted changes
|
||||
func emptyCommit() *object.Commit {
|
||||
return &object.Commit{
|
||||
Hash: plumbing.Hash{},
|
||||
Message: "***STAGED CHANGES***",
|
||||
Author: object.Signature{
|
||||
Name: "",
|
||||
Email: "",
|
||||
When: time.Unix(0, 0).UTC(),
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,605 @@
|
||||
package scan
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"sort"
|
||||
"testing"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v6/config"
|
||||
"github.com/zricethezav/gitleaks/v6/manager"
|
||||
"github.com/zricethezav/gitleaks/v6/options"
|
||||
|
||||
"github.com/sergi/go-diff/diffmatchpatch"
|
||||
)
|
||||
|
||||
const testRepoBase = "../test_data/test_repos/"
|
||||
|
||||
func TestScan(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 allowlisted",
|
||||
opts: options.Options{
|
||||
RepoPath: "../test_data/test_repos/test_repo_1",
|
||||
ReportFormat: "json",
|
||||
Config: "../test_data/test_configs/aws_key_allowlist_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 allowlisted",
|
||||
opts: options.Options{
|
||||
RepoPath: "../test_data/test_repos/test_repo_2",
|
||||
Config: "../test_data/test_configs/aws_key_global_allowlist_file.toml",
|
||||
ReportFormat: "json",
|
||||
},
|
||||
wantEmpty: true,
|
||||
},
|
||||
{
|
||||
description: "test local repo two leaks allowlisted",
|
||||
opts: options.Options{
|
||||
RepoPath: "../test_data/test_repos/test_repo_2",
|
||||
Config: "../test_data/test_configs/aws_key_allowlist_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 owner path allowlist repo",
|
||||
opts: options.Options{
|
||||
OwnerPath: "../test_data/test_repos/",
|
||||
Report: "../test_data/test_local_owner_aws_leak_allowlist_repo.json.got",
|
||||
ReportFormat: "json",
|
||||
Config: "../test_data/test_configs/aws_key_local_owner_allowlist_repo.toml",
|
||||
},
|
||||
wantPath: "../test_data/test_local_owner_aws_leak_allowlist_repo.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_allowlist.json.got",
|
||||
Config: "../test_data/test_configs/aws_key_aws_allowlisted.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",
|
||||
},
|
||||
{
|
||||
description: "test local repo five files at Commit",
|
||||
opts: options.Options{
|
||||
RepoPath: "../test_data/test_repos/test_repo_5",
|
||||
Report: "../test_data/test_local_repo_five_files_at_commit.json.got",
|
||||
FilesAtCommit: "a4c9fb737d5552fd96fce5cc7eedb23353ba9ed0",
|
||||
ReportFormat: "json",
|
||||
},
|
||||
wantPath: "../test_data/test_local_repo_five_files_at_commit.json",
|
||||
},
|
||||
{
|
||||
description: "test local repo five files at latest Commit",
|
||||
opts: options.Options{
|
||||
RepoPath: "../test_data/test_repos/test_repo_5",
|
||||
Report: "../test_data/test_local_repo_five_files_at_latest_commit.json.got",
|
||||
FilesAtCommit: "latest",
|
||||
ReportFormat: "json",
|
||||
},
|
||||
wantPath: "../test_data/test_local_repo_five_files_at_commit.json",
|
||||
},
|
||||
{
|
||||
description: "test local repo five at Commit",
|
||||
opts: options.Options{
|
||||
RepoPath: "../test_data/test_repos/test_repo_5",
|
||||
Report: "../test_data/test_local_repo_five_commit.json.got",
|
||||
Commit: "a4c9fb737d5552fd96fce5cc7eedb23353ba9ed0",
|
||||
ReportFormat: "json",
|
||||
Config: "../test_data/test_configs/generic.toml",
|
||||
},
|
||||
wantPath: "../test_data/test_local_repo_five_commit.json",
|
||||
},
|
||||
{
|
||||
description: "test local repo five at latest Commit",
|
||||
opts: options.Options{
|
||||
RepoPath: "../test_data/test_repos/test_repo_5",
|
||||
Report: "../test_data/test_local_repo_five_at_latest_commit.json.got",
|
||||
Commit: "latest",
|
||||
ReportFormat: "json",
|
||||
Config: "../test_data/test_configs/generic.toml",
|
||||
},
|
||||
wantPath: "../test_data/test_local_repo_five_at_latest_commit.json",
|
||||
},
|
||||
{
|
||||
description: "test local repo six filename",
|
||||
opts: options.Options{
|
||||
RepoPath: "../test_data/test_repos/test_repo_6",
|
||||
Report: "../test_data/test_local_repo_six_filename.json.got",
|
||||
Config: "../test_data/test_configs/regex_filename.toml",
|
||||
ReportFormat: "json",
|
||||
},
|
||||
wantPath: "../test_data/test_local_repo_six_filename.json",
|
||||
},
|
||||
{
|
||||
description: "test local repo six filepath",
|
||||
opts: options.Options{
|
||||
RepoPath: "../test_data/test_repos/test_repo_6",
|
||||
Report: "../test_data/test_local_repo_six_filepath.json.got",
|
||||
Config: "../test_data/test_configs/regex_filepath.toml",
|
||||
ReportFormat: "json",
|
||||
},
|
||||
wantPath: "../test_data/test_local_repo_six_filepath.json",
|
||||
},
|
||||
{
|
||||
description: "test local repo six filename and filepath",
|
||||
opts: options.Options{
|
||||
RepoPath: "../test_data/test_repos/test_repo_6",
|
||||
Report: "../test_data/test_local_repo_six_filepath_filename.json.got",
|
||||
Config: "../test_data/test_configs/regex_filepath_filename.toml",
|
||||
ReportFormat: "json",
|
||||
},
|
||||
wantPath: "../test_data/test_local_repo_six_filepath_filename.json",
|
||||
},
|
||||
{
|
||||
description: "test local repo six path globally allowlisted",
|
||||
opts: options.Options{
|
||||
RepoPath: "../test_data/test_repos/test_repo_6",
|
||||
Report: "../test_data/test_local_repo_six_path_globally_allowlisted.json.got",
|
||||
Config: "../test_data/test_configs/aws_key_global_allowlist_path.toml",
|
||||
ReportFormat: "json",
|
||||
},
|
||||
wantPath: "../test_data/test_local_repo_six_path_globally_allowlisted.json",
|
||||
},
|
||||
{
|
||||
description: "test local repo six leaks since date",
|
||||
opts: options.Options{
|
||||
RepoPath: "../test_data/test_repos/test_repo_6",
|
||||
Report: "../test_data/test_local_repo_six_leaks_since_date.json.got",
|
||||
ReportFormat: "json",
|
||||
CommitSince: "2019-10-25",
|
||||
},
|
||||
wantPath: "../test_data/test_local_repo_six_leaks_since_date.json",
|
||||
},
|
||||
{
|
||||
description: "test local repo two leaks until date",
|
||||
opts: options.Options{
|
||||
RepoPath: "../test_data/test_repos/test_repo_6",
|
||||
Report: "../test_data/test_local_repo_six_leaks_until_date.json.got",
|
||||
ReportFormat: "json",
|
||||
CommitUntil: "2019-10-25",
|
||||
},
|
||||
wantPath: "../test_data/test_local_repo_six_leaks_until_date.json",
|
||||
},
|
||||
{
|
||||
description: "test local repo four leaks timerange Commit",
|
||||
opts: options.Options{
|
||||
RepoPath: "../test_data/test_repos/test_repo_4",
|
||||
Report: "../test_data/test_local_repo_four_leaks_commit_timerange.json.got",
|
||||
ReportFormat: "json",
|
||||
CommitSince: "2019-10-25T13:01:27-0400",
|
||||
CommitUntil: "2019-10-25T13:12:32-0400",
|
||||
},
|
||||
wantPath: "../test_data/test_local_repo_four_leaks_commit_timerange.json",
|
||||
},
|
||||
{
|
||||
description: "test local repo two allowlist Commit config",
|
||||
opts: options.Options{
|
||||
RepoPath: "../test_data/test_repos/test_repo_2",
|
||||
Report: "../test_data/test_local_repo_two_allowlist_commits.json.got",
|
||||
Config: "../test_data/test_configs/allowlist_commit.toml",
|
||||
ReportFormat: "json",
|
||||
},
|
||||
wantPath: "../test_data/test_local_repo_two_allowlist_commits.json",
|
||||
},
|
||||
{
|
||||
description: "test local repo two deletion",
|
||||
opts: options.Options{
|
||||
RepoPath: "../test_data/test_repos/test_repo_2",
|
||||
Report: "../test_data/test_local_repo_two_leaks_deletion.json.got",
|
||||
ReportFormat: "json",
|
||||
Deletion: true,
|
||||
},
|
||||
wantPath: "../test_data/test_local_repo_two_leaks_deletion.json",
|
||||
},
|
||||
{
|
||||
description: "test local repo eight (merges)",
|
||||
opts: options.Options{
|
||||
RepoPath: "../test_data/test_repos/test_repo_8",
|
||||
Report: "../test_data/test_local_repo_eight.json.got",
|
||||
ReportFormat: "json",
|
||||
},
|
||||
wantPath: "../test_data/test_local_repo_eight.json",
|
||||
},
|
||||
{
|
||||
description: "test local repo nine",
|
||||
opts: options.Options{
|
||||
RepoPath: "../test_data/test_repos/test_repo_9",
|
||||
Report: "../test_data/test_local_repo_nine_aws_leak.json.got",
|
||||
Config: "../test_data/test_configs/large_with_global_allowlist_regex.toml",
|
||||
ReportFormat: "json",
|
||||
},
|
||||
wantPath: "../test_data/test_local_repo_nine_aws_leak.json",
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
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 TestScanUncommited(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 scan local one leak",
|
||||
opts: options.Options{
|
||||
RepoPath: "../test_data/test_repos/test_repo_1",
|
||||
Report: "../test_data/test_local_repo_one_aws_leak_uncommitted.json.got",
|
||||
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 scan 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",
|
||||
},
|
||||
{
|
||||
description: "test scan repo with no commits",
|
||||
opts: options.Options{
|
||||
RepoPath: "../test_data/test_repos/test_repo_7",
|
||||
Report: "../test_data/test_local_repo_seven_aws_leak_uncommitted.json.got",
|
||||
Uncommited: true,
|
||||
ReportFormat: "json",
|
||||
},
|
||||
wantPath: "../test_data/test_local_repo_seven_aws_leak_uncommitted.json",
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
var (
|
||||
old []byte
|
||||
err error
|
||||
)
|
||||
fmt.Println(test.description)
|
||||
if test.fileToChange != "" {
|
||||
old, err = ioutil.ReadFile(fmt.Sprintf("%s/%s", test.opts.RepoPath, test.fileToChange))
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
altered, err := os.OpenFile(fmt.Sprintf("%s/%s", test.opts.RepoPath, test.fileToChange),
|
||||
os.O_WRONLY|os.O_APPEND, 0644)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
_, err = altered.WriteString(test.addition)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
if test.fileToChange != "" {
|
||||
err = ioutil.WriteFile(fmt.Sprintf("%s/%s", test.opts.RepoPath, test.fileToChange), old, 0)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
if test.wantEmpty {
|
||||
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("%s does not equal %s: %s", wantPath, gotPath, 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
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
[[rules]]
|
||||
description = "AWS Manager ID"
|
||||
regex = '''(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}'''
|
||||
tags = ["key", "AWS"]
|
||||
|
||||
|
||||
[allowlist]
|
||||
commits = [
|
||||
"b10b3e2cb320a8c211fda94c4567299d37de7776",
|
||||
"17471a5fda722a9e423f1a0d3f0d267ea009d41c",
|
||||
"996865bb912f3bc45898a370a13aadb315014b55"
|
||||
]
|
||||
|
||||
@@ -0,0 +1,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,8 @@
|
||||
[[rules]]
|
||||
description = "AWS Manager ID"
|
||||
regex = '''(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}'''
|
||||
tags = ["key", "AWS"]
|
||||
[rules.allowlist]
|
||||
description = "ignore sample regex md files"
|
||||
files = ['''(.*)?md$''']
|
||||
regexes = ['''ignore$''']
|
||||
@@ -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.allowlist]
|
||||
description = "ignore python files"
|
||||
files = ['''(.*)?py$''']
|
||||
@@ -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.allowlist]
|
||||
description = "ignore aws key"
|
||||
regexes = ['''AKIAIO5FODNN7EXAMPLE.*''']
|
||||
@@ -0,0 +1,14 @@
|
||||
[[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"]
|
||||
|
||||
## this is an example of a rule that won't work
|
||||
[[rules]]
|
||||
description = "Python files"
|
||||
fileRegex = "(?i)*.py"
|
||||
@@ -0,0 +1,10 @@
|
||||
[[rules]]
|
||||
description = "AWS Manager ID"
|
||||
regex = '''(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}'''
|
||||
tags = ["key", "AWS"]
|
||||
|
||||
[allowlist]
|
||||
description = "ignore md files"
|
||||
files = [
|
||||
'''(.*)?md$'''
|
||||
]
|
||||
@@ -0,0 +1,10 @@
|
||||
[[rules]]
|
||||
description = "AWS Manager ID"
|
||||
regex = '''(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}'''
|
||||
tags = ["key", "AWS"]
|
||||
|
||||
[allowlist]
|
||||
description = "ignore config folders"
|
||||
paths = [
|
||||
'''config(uration)?'''
|
||||
]
|
||||
@@ -0,0 +1,9 @@
|
||||
[[rules]]
|
||||
description = "AWS Manager ID"
|
||||
regex = '''(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}'''
|
||||
tags = ["key", "AWS"]
|
||||
[allowlist]
|
||||
description = "allowlist repo"
|
||||
repos = [
|
||||
'''test_repo_1'''
|
||||
]
|
||||
@@ -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"]
|
||||
|
||||
[allowlist]
|
||||
description = "ignore md files"
|
||||
files = ['''???????''']
|
||||
@@ -0,0 +1,8 @@
|
||||
[[rules]]
|
||||
description = "entropy"
|
||||
regex = '''['|"]([0-9a-zA-Z-._{}$\/\+=]{20,120})['|"]'''
|
||||
tags = ["entropy"]
|
||||
[[rules.Entropies]]
|
||||
Min = "4.3"
|
||||
Max = "4.1"
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
[[rules]]
|
||||
description = "entropy"
|
||||
regex = '''['|"]([0-9a-zA-Z-._{}$\/\+=]{20,120})['|"]'''
|
||||
tags = ["entropy"]
|
||||
[[rules.Entropies]]
|
||||
Min = "4.3"
|
||||
Max = "x"
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
[[rules]]
|
||||
description = "entropy"
|
||||
regex = '''['|"]([0-9a-zA-Z-._{}$\/\+=]{20,120})['|"]'''
|
||||
tags = ["entropy"]
|
||||
[[rules.Entropies]]
|
||||
Min = "x"
|
||||
Max = "4.1"
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
[[rules]]
|
||||
description = "entropy"
|
||||
regex = '''['|"]([0-9a-zA-Z-._{}$\/\+=]{20,120})['|"]'''
|
||||
tags = ["entropy"]
|
||||
[[rules.Entropies]]
|
||||
Min = "1.0"
|
||||
Max = "8"
|
||||
Group = "x"
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
[[rules]]
|
||||
description = "entropy"
|
||||
regex = '''['|"]([0-9a-zA-Z-._{}$\/\+=]{20,120})['|"]'''
|
||||
tags = ["entropy"]
|
||||
[[rules.Entropies]]
|
||||
Min = "1.0"
|
||||
Max = "8.5"
|
||||
Group = "-2"
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
[[rules]]
|
||||
description = "entropy"
|
||||
regex = '''['|"]([0-9a-zA-Z-._{}$\/\+=]{20,120})['|"]'''
|
||||
tags = ["entropy"]
|
||||
[[rules.Entropies]]
|
||||
Min = "1.0"
|
||||
Max = "8.5"
|
||||
Group = "2"
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
[[rules]]
|
||||
description = "entropy"
|
||||
regex = '''['|"]([0-9a-zA-Z-._{}$\/\+=]{20,120})['|"]'''
|
||||
tags = ["entropy"]
|
||||
[[rules.Entropies]]
|
||||
Min = "1.0"
|
||||
Max = "8.5"
|
||||
Group = "0"
|
||||
|
||||
@@ -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,11 @@
|
||||
[[rules]]
|
||||
description = "entropy"
|
||||
regex = '''['|"]([0-9a-zA-Z-._{}$\/\+=]{40,120})['|"]'''
|
||||
tags = ["entropy"]
|
||||
[[rules.Entropies]]
|
||||
Min = "4.5"
|
||||
Max = "4.7"
|
||||
[[rules.Entropies]]
|
||||
Min = "5.5"
|
||||
Max = "6.3"
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
[[rules]]
|
||||
description = "Generic Credential"
|
||||
regex = '''(?i)(api_key|apikey|secret|password|pass|pw|key)(.{0,20})?[0-9a-zA-Z]{16,45}'''
|
||||
tags = ["key", "API", "generic"]
|
||||
@@ -0,0 +1,148 @@
|
||||
title = "gitleaks config"
|
||||
|
||||
[[rules]]
|
||||
description = "AWS Secret Key"
|
||||
regex = '''(?i)aws(.{0,20})?(?-i)['\"][0-9a-zA-Z\/+]{40}['\"]'''
|
||||
tags = ["key", "AWS"]
|
||||
|
||||
[[rules]]
|
||||
description = "AWS MWS key"
|
||||
regex = '''amzn\.mws\.[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'''
|
||||
tags = ["key", "AWS", "MWS"]
|
||||
|
||||
[[rules]]
|
||||
description = "Facebook Secret Key"
|
||||
regex = '''(?i)(facebook|fb)(.{0,20})?(?-i)['\"][0-9a-f]{32}['\"]'''
|
||||
tags = ["key", "Facebook"]
|
||||
|
||||
[[rules]]
|
||||
description = "Facebook Client ID"
|
||||
regex = '''(?i)(facebook|fb)(.{0,20})?['\"][0-9]{13,17}['\"]'''
|
||||
tags = ["key", "Facebook"]
|
||||
|
||||
[[rules]]
|
||||
description = "Twitter Secret Key"
|
||||
regex = '''(?i)twitter(.{0,20})?['\"][0-9a-z]{35,44}['\"]'''
|
||||
tags = ["key", "Twitter"]
|
||||
|
||||
[[rules]]
|
||||
description = "Twitter Client ID"
|
||||
regex = '''(?i)twitter(.{0,20})?['\"][0-9a-z]{18,25}['\"]'''
|
||||
tags = ["client", "Twitter"]
|
||||
|
||||
[[rules]]
|
||||
description = "Github"
|
||||
regex = '''(?i)github(.{0,20})?(?-i)['\"][0-9a-zA-Z]{35,40}['\"]'''
|
||||
tags = ["key", "Github"]
|
||||
|
||||
[[rules]]
|
||||
description = "LinkedIn Client ID"
|
||||
regex = '''(?i)linkedin(.{0,20})?(?-i)['\"][0-9a-z]{12}['\"]'''
|
||||
tags = ["client", "LinkedIn"]
|
||||
|
||||
[[rules]]
|
||||
description = "LinkedIn Secret Key"
|
||||
regex = '''(?i)linkedin(.{0,20})?['\"][0-9a-z]{16}['\"]'''
|
||||
tags = ["secret", "LinkedIn"]
|
||||
|
||||
[[rules]]
|
||||
description = "Slack"
|
||||
regex = '''xox[baprs]-([0-9a-zA-Z]{10,48})?'''
|
||||
tags = ["key", "Slack"]
|
||||
|
||||
[[rules]]
|
||||
description = "EC"
|
||||
regex = '''-----BEGIN EC PRIVATE KEY-----'''
|
||||
tags = ["key", "EC"]
|
||||
|
||||
[[rules]]
|
||||
description = "Generic API key"
|
||||
regex = '''(?i)(api_key|apikey)(.{0,20})?['|"][0-9a-zA-Z]{32,45}['|"]'''
|
||||
tags = ["key", "API", "generic"]
|
||||
|
||||
[[rules]]
|
||||
description = "Generic Secret"
|
||||
regex = '''(?i)secret(.{0,20})?['|"][0-9a-zA-Z]{32,45}['|"]'''
|
||||
tags = ["key", "Secret", "generic"]
|
||||
|
||||
[[rules]]
|
||||
description = "Google API key"
|
||||
regex = '''AIza[0-9A-Za-z\\-_]{35}'''
|
||||
tags = ["key", "Google"]
|
||||
|
||||
|
||||
[[rules]]
|
||||
description = "Heroku API key"
|
||||
regex = '''(?i)heroku(.{0,20})?['"][0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}['"]'''
|
||||
tags = ["key", "Heroku"]
|
||||
|
||||
[[rules]]
|
||||
description = "MailChimp API key"
|
||||
regex = '''(?i)(mailchimp|mc)(.{0,20})?['"][0-9a-f]{32}-us[0-9]{1,2}['"]'''
|
||||
tags = ["key", "Mailchimp"]
|
||||
|
||||
[[rules]]
|
||||
description = "Mailgun API key"
|
||||
regex = '''(?i)(mailgun|mg)(.{0,20})?['"][0-9a-z]{32}['"]'''
|
||||
tags = ["key", "Mailgun"]
|
||||
|
||||
[[rules]]
|
||||
description = "PayPal Braintree access token"
|
||||
regex = '''access_token\$production\$[0-9a-z]{16}\$[0-9a-f]{32}'''
|
||||
tags = ["key", "Paypal"]
|
||||
|
||||
[[rules]]
|
||||
description = "Picatic API key"
|
||||
regex = '''sk_live_[0-9a-z]{32}'''
|
||||
tags = ["key", "Picatic"]
|
||||
|
||||
[[rules]]
|
||||
description = "Slack Webhook"
|
||||
regex = '''https://hooks.slack.com/services/T[a-zA-Z0-9_]{8}/B[a-zA-Z0-9_]{8}/[a-zA-Z0-9_]{24}'''
|
||||
tags = ["key", "slack"]
|
||||
|
||||
[[rules]]
|
||||
description = "Stripe API key"
|
||||
regex = '''(?i)stripe(.{0,20})?['\"][sk|rk]_live_[0-9a-zA-Z]{24}'''
|
||||
tags = ["key", "Stripe"]
|
||||
|
||||
[[rules]]
|
||||
description = "Square access token"
|
||||
regex = '''sq0atp-[0-9A-Za-z\-_]{22}'''
|
||||
tags = ["key", "square"]
|
||||
|
||||
[[rules]]
|
||||
description = "Square OAuth secret"
|
||||
regex = '''sq0csp-[0-9A-Za-z\\-_]{43}'''
|
||||
tags = ["key", "square"]
|
||||
|
||||
[[rules]]
|
||||
description = "Twilio API key"
|
||||
regex = '''(?i)twilio(.{0,20})?['\"][0-9a-f]{32}['\"]'''
|
||||
tags = ["key", "twilio"]
|
||||
|
||||
[[rules]]
|
||||
description = "AWS Manager ID"
|
||||
regex = '''(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}'''
|
||||
tags = ["key", "AWS"]
|
||||
[rules.allowlist]
|
||||
description = "ignore common jenkins functions"
|
||||
regexes = [
|
||||
'''allowlistme'''
|
||||
]
|
||||
files = [
|
||||
'''(.*)?Jenkinsfile$'''
|
||||
]
|
||||
|
||||
# Global rules. This instructs gitleaks to ignore all .pem files or if a message with
|
||||
[[rules]]
|
||||
description = "Files with keys and credentials"
|
||||
file = '''(.*?)(pem)'''
|
||||
|
||||
[allowlist]
|
||||
description = "File allowlists"
|
||||
files = [
|
||||
'''(.*?)(jpg|gif)$''',
|
||||
'''(.*?)(doc|pdf|bin)$'''
|
||||
]
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
title = "gitleaks config"
|
||||
|
||||
[[rules]]
|
||||
description = "AWS Secret Key"
|
||||
regex = '''(?i)aws(.{0,20})?(?-i)['\"][0-9a-zA-Z\/+]{40}['\"]'''
|
||||
tags = ["key", "AWS"]
|
||||
|
||||
[[rules]]
|
||||
description = "AWS MWS key"
|
||||
regex = '''amzn\.mws\.[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'''
|
||||
tags = ["key", "AWS", "MWS"]
|
||||
|
||||
[[rules]]
|
||||
description = "Facebook Secret Key"
|
||||
regex = '''(?i)(facebook|fb)(.{0,20})?(?-i)['\"][0-9a-f]{32}['\"]'''
|
||||
tags = ["key", "Facebook"]
|
||||
|
||||
[[rules]]
|
||||
description = "Facebook Client ID"
|
||||
regex = '''(?i)(facebook|fb)(.{0,20})?['\"][0-9]{13,17}['\"]'''
|
||||
tags = ["key", "Facebook"]
|
||||
|
||||
[[rules]]
|
||||
description = "Twitter Secret Key"
|
||||
regex = '''(?i)twitter(.{0,20})?['\"][0-9a-z]{35,44}['\"]'''
|
||||
tags = ["key", "Twitter"]
|
||||
|
||||
[[rules]]
|
||||
description = "Twitter Client ID"
|
||||
regex = '''(?i)twitter(.{0,20})?['\"][0-9a-z]{18,25}['\"]'''
|
||||
tags = ["client", "Twitter"]
|
||||
|
||||
[[rules]]
|
||||
description = "Github"
|
||||
regex = '''(?i)github(.{0,20})?(?-i)['\"][0-9a-zA-Z]{35,40}['\"]'''
|
||||
tags = ["key", "Github"]
|
||||
|
||||
[[rules]]
|
||||
description = "LinkedIn Client ID"
|
||||
regex = '''(?i)linkedin(.{0,20})?(?-i)['\"][0-9a-z]{12}['\"]'''
|
||||
tags = ["client", "LinkedIn"]
|
||||
|
||||
[[rules]]
|
||||
description = "LinkedIn Secret Key"
|
||||
regex = '''(?i)linkedin(.{0,20})?['\"][0-9a-z]{16}['\"]'''
|
||||
tags = ["secret", "LinkedIn"]
|
||||
|
||||
[[rules]]
|
||||
description = "Slack"
|
||||
regex = '''xox[baprs]-([0-9a-zA-Z]{10,48})?'''
|
||||
tags = ["key", "Slack"]
|
||||
|
||||
[[rules]]
|
||||
description = "EC"
|
||||
regex = '''-----BEGIN EC PRIVATE KEY-----'''
|
||||
tags = ["key", "EC"]
|
||||
|
||||
[[rules]]
|
||||
description = "Generic API key"
|
||||
regex = '''(?i)(api_key|apikey)(.{0,20})?['|"][0-9a-zA-Z]{32,45}['|"]'''
|
||||
tags = ["key", "API", "generic"]
|
||||
|
||||
[[rules]]
|
||||
description = "Generic Secret"
|
||||
regex = '''(?i)secret(.{0,20})?['|"][0-9a-zA-Z]{32,45}['|"]'''
|
||||
tags = ["key", "Secret", "generic"]
|
||||
|
||||
[[rules]]
|
||||
description = "Google API key"
|
||||
regex = '''AIza[0-9A-Za-z\\-_]{35}'''
|
||||
tags = ["key", "Google"]
|
||||
|
||||
|
||||
[[rules]]
|
||||
description = "Heroku API key"
|
||||
regex = '''(?i)heroku(.{0,20})?['"][0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}['"]'''
|
||||
tags = ["key", "Heroku"]
|
||||
|
||||
[[rules]]
|
||||
description = "MailChimp API key"
|
||||
regex = '''(?i)(mailchimp|mc)(.{0,20})?['"][0-9a-f]{32}-us[0-9]{1,2}['"]'''
|
||||
tags = ["key", "Mailchimp"]
|
||||
|
||||
[[rules]]
|
||||
description = "Mailgun API key"
|
||||
regex = '''(?i)(mailgun|mg)(.{0,20})?['"][0-9a-z]{32}['"]'''
|
||||
tags = ["key", "Mailgun"]
|
||||
|
||||
[[rules]]
|
||||
description = "PayPal Braintree access token"
|
||||
regex = '''access_token\$production\$[0-9a-z]{16}\$[0-9a-f]{32}'''
|
||||
tags = ["key", "Paypal"]
|
||||
|
||||
[[rules]]
|
||||
description = "Picatic API key"
|
||||
regex = '''sk_live_[0-9a-z]{32}'''
|
||||
tags = ["key", "Picatic"]
|
||||
|
||||
[[rules]]
|
||||
description = "Slack Webhook"
|
||||
regex = '''https://hooks.slack.com/services/T[a-zA-Z0-9_]{8}/B[a-zA-Z0-9_]{8}/[a-zA-Z0-9_]{24}'''
|
||||
tags = ["key", "slack"]
|
||||
|
||||
[[rules]]
|
||||
description = "Stripe API key"
|
||||
regex = '''(?i)stripe(.{0,20})?['\"][sk|rk]_live_[0-9a-zA-Z]{24}'''
|
||||
tags = ["key", "Stripe"]
|
||||
|
||||
[[rules]]
|
||||
description = "Square access token"
|
||||
regex = '''sq0atp-[0-9A-Za-z\-_]{22}'''
|
||||
tags = ["key", "square"]
|
||||
|
||||
[[rules]]
|
||||
description = "Square OAuth secret"
|
||||
regex = '''sq0csp-[0-9A-Za-z\\-_]{43}'''
|
||||
tags = ["key", "square"]
|
||||
|
||||
[[rules]]
|
||||
description = "Twilio API key"
|
||||
regex = '''(?i)twilio(.{0,20})?['\"][0-9a-f]{32}['\"]'''
|
||||
tags = ["key", "twilio"]
|
||||
|
||||
[[rules]]
|
||||
description = "AWS Manager ID"
|
||||
regex = '''(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}'''
|
||||
tags = ["key", "AWS"]
|
||||
[rules.allowlist]
|
||||
description = "ignore common jenkins functions"
|
||||
regexes = [
|
||||
'''allowlistme'''
|
||||
]
|
||||
files = [
|
||||
'''(.*)?Jenkinsfile$'''
|
||||
]
|
||||
|
||||
[[rules]]
|
||||
description = "Files with keys and credentials"
|
||||
file = '''(.*?)(pem)'''
|
||||
|
||||
# Global allowlist
|
||||
[allowlist]
|
||||
description = "global allowlists"
|
||||
files = [
|
||||
'''(.*?)(jpg|gif)$''',
|
||||
'''(.*?)(doc|pdf|bin)$'''
|
||||
]
|
||||
regexes = [
|
||||
'''(.*?)gitleaks:allow'''
|
||||
]
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
[[rules]]
|
||||
description = "entropy and regex"
|
||||
regex = '''['|"]([0-9a-zA-Z-._{}$\/\+=]{20,120})['|"]'''
|
||||
tags = ["entropy"]
|
||||
[[rules.Entropies]]
|
||||
Min = "4.5"
|
||||
Max = "4.7"
|
||||
Group = "1"
|
||||
[[rules.Entropies]]
|
||||
Min = "5.5"
|
||||
Max = "6.3"
|
||||
Group = "1"
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
[[rules]]
|
||||
description = "Generic password"
|
||||
regex = '''(?i)(password|token).{0,20}?\s*[:|=]\s*?(?-i)([0-9a-zA-Z\/+]{4,40})'''
|
||||
file = '''.*\.ya?ml'''
|
||||
tags = ["key", "Yml", "Yaml"]
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
[[rules]]
|
||||
description = "AWS Manager ID"
|
||||
regex = '''(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}'''
|
||||
path = '''config(guration)?'''
|
||||
tags = ["key", "AWS"]
|
||||
@@ -0,0 +1,7 @@
|
||||
|
||||
[[rules]]
|
||||
description = "Generic password"
|
||||
regex = '''(?i)(password|token).{0,20}?\s*[:|=]\s*?(?-i)([0-9a-zA-Z\/+]{4,40})'''
|
||||
file = '''.*\.properties'''
|
||||
path = '''config(guration)?'''
|
||||
tags = ["key", "Yml", "Yaml"]
|
||||
@@ -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,197 @@
|
||||
[
|
||||
{
|
||||
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||
"lineNumber": 5,
|
||||
"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",
|
||||
"operation": "addition"
|
||||
},
|
||||
{
|
||||
"line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"",
|
||||
"lineNumber": 5,
|
||||
"offender": "AKIALALEMEL33243OLIB",
|
||||
"commit": "b2eb34a61c988afd9b4aaa9dd58c8dd7d5f14dba",
|
||||
"repo": "test_repo_2",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "adding another one\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:12:08-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
},
|
||||
{
|
||||
"line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"",
|
||||
"lineNumber": 5,
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c",
|
||||
"repo": "test_repo_2",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "wait this is actually adding an aws secret\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:01:27-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
},
|
||||
{
|
||||
"line": "Here's an AWS secret: AKIALALEMEL33243OLIAE",
|
||||
"lineNumber": 3,
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "b10b3e2cb320a8c211fda94c4567299d37de7776",
|
||||
"repo": "test_repo_2",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "adding aws key\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T12:58:39-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
},
|
||||
{
|
||||
"line": "const AWSKEY = \"AKIALALEMEL33243OLIAE\"",
|
||||
"lineNumber": 4,
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "84ac4e80d4dbf2c968b64e9d4005f5079795bb81",
|
||||
"repo": "test_repo_3",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "more secrets\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:54:08-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
},
|
||||
{
|
||||
"line": "AWS secret: \"AKIALALEMEL33243OLIAE\"",
|
||||
"lineNumber": 6,
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "deea550dd6c7acaf0e59432600593533984a2125",
|
||||
"repo": "test_repo_3",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "dev branch\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:35:03-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
},
|
||||
{
|
||||
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPL2'",
|
||||
"lineNumber": 4,
|
||||
"offender": "AKIAIO5FODNN7EXAMPL2",
|
||||
"commit": "ca71fcdeda15f25f0cc661d90e8785c255925c27",
|
||||
"repo": "test_repo_5",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "introduce more secrets\n",
|
||||
"author": "Zach Rice",
|
||||
"email": "zrice@gitlab.com",
|
||||
"file": "secrets.py",
|
||||
"date": "2020-02-01T10:08:04-05:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
},
|
||||
{
|
||||
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPLE'",
|
||||
"lineNumber": 1,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "1f2a4abc47dabf991e6af6f9770867ce0ac1f360",
|
||||
"repo": "test_repo_5",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "introduce secrets\n",
|
||||
"author": "Zach Rice",
|
||||
"email": "zrice@gitlab.com",
|
||||
"file": "secrets.py",
|
||||
"date": "2020-02-01T10:07:34-05:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
},
|
||||
{
|
||||
"line": "aws_access_key_id=AKIAIO5FODNN7EXAMPLE",
|
||||
"lineNumber": 3,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "98b6c7cb3fb29a5993c4c95c56a2dc53050b9247",
|
||||
"repo": "test_repo_6",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "Adding some secrets in config folder\n\n",
|
||||
"author": "Noel Algora",
|
||||
"email": "noealgigu@gmail.com",
|
||||
"file": "config/application.properties",
|
||||
"date": "2020-02-24T14:13:15-05:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
},
|
||||
{
|
||||
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||
"lineNumber": 6,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "748f11eaf2c38c3cf0ac6a22e44208777e79fa6f",
|
||||
"repo": "test_repo_8",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "Merge pull request #1 from zricethezav/additional-secret-branch\n\nUpdate dummy.txt",
|
||||
"author": "Zachary Rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "dummy.txt",
|
||||
"date": "2020-07-25T14:44:48-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
},
|
||||
{
|
||||
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||
"lineNumber": 2,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "ce7e8177bbf8a172c06b6a1e370a374d5c19f660",
|
||||
"repo": "test_repo_8",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "dummy.txt w/ text",
|
||||
"author": "Zachary Rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "dummy.txt",
|
||||
"date": "2020-07-25T14:39:11-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
},
|
||||
{
|
||||
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||
"lineNumber": 6,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "9267bc86ec1497471cbc6f3308f3527f7ef34b9d",
|
||||
"repo": "test_repo_8",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "Update dummy.txt",
|
||||
"author": "Zachary Rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "dummy.txt",
|
||||
"date": "2020-07-25T14:41:11-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
},
|
||||
{
|
||||
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE', #gitleaks:allow",
|
||||
"lineNumber": 6,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "8d1fb60d2d80f0590f191ed5ace1e45ef780909a",
|
||||
"repo": "test_repo_9",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "gitleaks allow secret\n",
|
||||
"author": "Zach Rice",
|
||||
"email": "zrice@gitlab.com",
|
||||
"file": "server.test.py",
|
||||
"date": "2020-08-12T13:36:20-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,197 @@
|
||||
[
|
||||
{
|
||||
"line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"",
|
||||
"lineNumber": 5,
|
||||
"offender": "AKIALALEMEL33243OLIB",
|
||||
"commit": "b2eb34a61c988afd9b4aaa9dd58c8dd7d5f14dba",
|
||||
"repo": "test_repo_2",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "adding another one\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:12:08-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
},
|
||||
{
|
||||
"line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"",
|
||||
"lineNumber": 5,
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c",
|
||||
"repo": "test_repo_2",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "wait this is actually adding an aws secret\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:01:27-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
},
|
||||
{
|
||||
"line": "Here's an AWS secret: AKIALALEMEL33243OLIAE",
|
||||
"lineNumber": 3,
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "b10b3e2cb320a8c211fda94c4567299d37de7776",
|
||||
"repo": "test_repo_2",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "adding aws key\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T12:58:39-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
},
|
||||
{
|
||||
"line": "const AWSKEY = \"AKIALALEMEL33243OLIAE\"",
|
||||
"lineNumber": 4,
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "84ac4e80d4dbf2c968b64e9d4005f5079795bb81",
|
||||
"repo": "test_repo_3",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "more secrets\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:54:08-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
},
|
||||
{
|
||||
"line": "AWS secret: \"AKIALALEMEL33243OLIAE\"",
|
||||
"lineNumber": 6,
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "deea550dd6c7acaf0e59432600593533984a2125",
|
||||
"repo": "test_repo_3",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "dev branch\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:35:03-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
},
|
||||
{
|
||||
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPL2'",
|
||||
"lineNumber": 4,
|
||||
"offender": "AKIAIO5FODNN7EXAMPL2",
|
||||
"commit": "ca71fcdeda15f25f0cc661d90e8785c255925c27",
|
||||
"repo": "test_repo_5",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "introduce more secrets\n",
|
||||
"author": "Zach Rice",
|
||||
"email": "zrice@gitlab.com",
|
||||
"file": "secrets.py",
|
||||
"date": "2020-02-01T10:08:04-05:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
},
|
||||
{
|
||||
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPLE'",
|
||||
"lineNumber": 1,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "1f2a4abc47dabf991e6af6f9770867ce0ac1f360",
|
||||
"repo": "test_repo_5",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "introduce secrets\n",
|
||||
"author": "Zach Rice",
|
||||
"email": "zrice@gitlab.com",
|
||||
"file": "secrets.py",
|
||||
"date": "2020-02-01T10:07:34-05:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
},
|
||||
{
|
||||
"line": "aws_access_key_id=AKIAIO5FODNN7EXAMPLE",
|
||||
"lineNumber": 3,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "98b6c7cb3fb29a5993c4c95c56a2dc53050b9247",
|
||||
"repo": "test_repo_6",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "Adding some secrets in config folder\n\n",
|
||||
"author": "Noel Algora",
|
||||
"email": "noealgigu@gmail.com",
|
||||
"file": "config/application.properties",
|
||||
"date": "2020-02-24T14:13:15-05:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
},
|
||||
{
|
||||
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||
"lineNumber": 5,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "6557c92612d3b35979bd426d429255b3bf9fab74",
|
||||
"repo": "test_repo_6",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "commit 1 with secrets\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "server.test.py",
|
||||
"date": "2019-10-24T09:29:27-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
},
|
||||
{
|
||||
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||
"lineNumber": 6,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "748f11eaf2c38c3cf0ac6a22e44208777e79fa6f",
|
||||
"repo": "test_repo_8",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "Merge pull request #1 from zricethezav/additional-secret-branch\n\nUpdate dummy.txt",
|
||||
"author": "Zachary Rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "dummy.txt",
|
||||
"date": "2020-07-25T14:44:48-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
},
|
||||
{
|
||||
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||
"lineNumber": 2,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "ce7e8177bbf8a172c06b6a1e370a374d5c19f660",
|
||||
"repo": "test_repo_8",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "dummy.txt w/ text",
|
||||
"author": "Zachary Rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "dummy.txt",
|
||||
"date": "2020-07-25T14:39:11-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
},
|
||||
{
|
||||
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||
"lineNumber": 6,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "9267bc86ec1497471cbc6f3308f3527f7ef34b9d",
|
||||
"repo": "test_repo_8",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "Update dummy.txt",
|
||||
"author": "Zachary Rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "dummy.txt",
|
||||
"date": "2020-07-25T14:41:11-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
},
|
||||
{
|
||||
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE', #gitleaks:allow",
|
||||
"lineNumber": 6,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "8d1fb60d2d80f0590f191ed5ace1e45ef780909a",
|
||||
"repo": "test_repo_9",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "gitleaks allow secret\n",
|
||||
"author": "Zach Rice",
|
||||
"email": "zrice@gitlab.com",
|
||||
"file": "server.test.py",
|
||||
"date": "2020-08-12T13:36:20-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,107 @@
|
||||
[
|
||||
{
|
||||
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||
"lineNumber": 5,
|
||||
"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",
|
||||
"operation": "addition"
|
||||
},
|
||||
{
|
||||
"line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"",
|
||||
"lineNumber": 5,
|
||||
"offender": "AKIALALEMEL33243OLIB",
|
||||
"commit": "b2eb34a61c988afd9b4aaa9dd58c8dd7d5f14dba",
|
||||
"repo": "test_repo_2",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "adding another one\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:12:08-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
},
|
||||
{
|
||||
"line": "const AWSKEY = \"AKIALALEMEL33243OLIAE\"",
|
||||
"lineNumber": 4,
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "84ac4e80d4dbf2c968b64e9d4005f5079795bb81",
|
||||
"repo": "test_repo_3",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "more secrets\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:54:08-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
},
|
||||
{
|
||||
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPL2'",
|
||||
"lineNumber": 4,
|
||||
"offender": "AKIAIO5FODNN7EXAMPL2",
|
||||
"commit": "ca71fcdeda15f25f0cc661d90e8785c255925c27",
|
||||
"repo": "test_repo_5",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "introduce more secrets\n",
|
||||
"author": "Zach Rice",
|
||||
"email": "zrice@gitlab.com",
|
||||
"file": "secrets.py",
|
||||
"date": "2020-02-01T10:08:04-05:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
},
|
||||
{
|
||||
"line": "aws_access_key_id=AKIAIO5FODNN7EXAMPLE",
|
||||
"lineNumber": 3,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "98b6c7cb3fb29a5993c4c95c56a2dc53050b9247",
|
||||
"repo": "test_repo_6",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "Adding some secrets in config folder\n\n",
|
||||
"author": "Noel Algora",
|
||||
"email": "noealgigu@gmail.com",
|
||||
"file": "config/application.properties",
|
||||
"date": "2020-02-24T14:13:15-05:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
},
|
||||
{
|
||||
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||
"lineNumber": 6,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "748f11eaf2c38c3cf0ac6a22e44208777e79fa6f",
|
||||
"repo": "test_repo_8",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "Merge pull request #1 from zricethezav/additional-secret-branch\n\nUpdate dummy.txt",
|
||||
"author": "Zachary Rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "dummy.txt",
|
||||
"date": "2020-07-25T14:44:48-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
},
|
||||
{
|
||||
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE', #gitleaks:allow",
|
||||
"lineNumber": 6,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "8d1fb60d2d80f0590f191ed5ace1e45ef780909a",
|
||||
"repo": "test_repo_9",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "gitleaks allow secret\n",
|
||||
"author": "Zach Rice",
|
||||
"email": "zrice@gitlab.com",
|
||||
"file": "server.test.py",
|
||||
"date": "2020-08-12T13:36:20-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,47 @@
|
||||
[
|
||||
{
|
||||
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||
"lineNumber": 6,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "748f11eaf2c38c3cf0ac6a22e44208777e79fa6f",
|
||||
"repo": "test_repo_8",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "Merge pull request #1 from zricethezav/additional-secret-branch\n\nUpdate dummy.txt",
|
||||
"author": "Zachary Rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "dummy.txt",
|
||||
"date": "2020-07-25T14:44:48-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
},
|
||||
{
|
||||
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||
"lineNumber": 2,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "ce7e8177bbf8a172c06b6a1e370a374d5c19f660",
|
||||
"repo": "test_repo_8",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "dummy.txt w/ text",
|
||||
"author": "Zachary Rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "dummy.txt",
|
||||
"date": "2020-07-25T14:39:11-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
},
|
||||
{
|
||||
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||
"lineNumber": 6,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "9267bc86ec1497471cbc6f3308f3527f7ef34b9d",
|
||||
"repo": "test_repo_8",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "Update dummy.txt",
|
||||
"author": "Zachary Rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "dummy.txt",
|
||||
"date": "2020-07-25T14:41:11-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,17 @@
|
||||
[
|
||||
{
|
||||
"line": "more_secrets = '99432bfewaf823ec3294e231'",
|
||||
"lineNumber": 7,
|
||||
"offender": "secrets = '99432bfewaf823ec3294e231",
|
||||
"commit": "a4c9fb737d5552fd96fce5cc7eedb23353ba9ed0",
|
||||
"repo": "test_repo_5",
|
||||
"rule": "Generic Credential",
|
||||
"commitMessage": "even more secrets\n",
|
||||
"author": "Zach Rice",
|
||||
"email": "zrice@gitlab.com",
|
||||
"file": "secrets.py",
|
||||
"date": "2020-02-01T10:30:22-05:00",
|
||||
"tags": "key, API, generic",
|
||||
"operation": "addition"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,17 @@
|
||||
[
|
||||
{
|
||||
"line": "more_secrets = '99432bfewaf823ec3294e231'",
|
||||
"lineNumber": 7,
|
||||
"offender": "secrets = '99432bfewaf823ec3294e231",
|
||||
"commit": "a4c9fb737d5552fd96fce5cc7eedb23353ba9ed0",
|
||||
"repo": "test_repo_5",
|
||||
"rule": "Generic Credential",
|
||||
"commitMessage": "even more secrets\n",
|
||||
"author": "Zach Rice",
|
||||
"email": "zrice@gitlab.com",
|
||||
"file": "secrets.py",
|
||||
"date": "2020-02-01T10:30:22-05:00",
|
||||
"tags": "key, API, generic",
|
||||
"operation": "addition"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,32 @@
|
||||
[
|
||||
{
|
||||
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPLE'",
|
||||
"lineNumber": 1,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "a4c9fb737d5552fd96fce5cc7eedb23353ba9ed0",
|
||||
"repo": "test_repo_5",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "even more secrets\n",
|
||||
"author": "Zach Rice",
|
||||
"email": "zrice@gitlab.com",
|
||||
"file": "secrets.py",
|
||||
"date": "2020-02-01T10:30:22-05:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
},
|
||||
{
|
||||
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPL2'",
|
||||
"lineNumber": 4,
|
||||
"offender": "AKIAIO5FODNN7EXAMPL2",
|
||||
"commit": "a4c9fb737d5552fd96fce5cc7eedb23353ba9ed0",
|
||||
"repo": "test_repo_5",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "even more secrets\n",
|
||||
"author": "Zach Rice",
|
||||
"email": "zrice@gitlab.com",
|
||||
"file": "secrets.py",
|
||||
"date": "2020-02-01T10:30:22-05:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,32 @@
|
||||
[
|
||||
{
|
||||
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPLE'",
|
||||
"lineNumber": 1,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "a4c9fb737d5552fd96fce5cc7eedb23353ba9ed0",
|
||||
"repo": "test_repo_5",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "even more secrets\n",
|
||||
"author": "Zach Rice",
|
||||
"email": "zrice@gitlab.com",
|
||||
"file": "secrets.py",
|
||||
"date": "2020-02-01T10:30:22-05:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
},
|
||||
{
|
||||
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPL2'",
|
||||
"lineNumber": 4,
|
||||
"offender": "AKIAIO5FODNN7EXAMPL2",
|
||||
"commit": "a4c9fb737d5552fd96fce5cc7eedb23353ba9ed0",
|
||||
"repo": "test_repo_5",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "even more secrets\n",
|
||||
"author": "Zach Rice",
|
||||
"email": "zrice@gitlab.com",
|
||||
"file": "secrets.py",
|
||||
"date": "2020-02-01T10:30:22-05:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,32 @@
|
||||
[
|
||||
{
|
||||
"line": "const AWSSECRET = \"99432bfewaf823ec3294e231\"",
|
||||
"lineNumber": 5,
|
||||
"offender": "\"99432bfewaf823ec3294e231\"",
|
||||
"commit": "84ac4e80d4dbf2c968b64e9d4005f5079795bb81",
|
||||
"repo": "test_repo_4",
|
||||
"rule": "entropy",
|
||||
"commitMessage": "more secrets\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:54:08-04:00",
|
||||
"tags": "entropy",
|
||||
"operation": "addition"
|
||||
},
|
||||
{
|
||||
"line": " const AWSSECRET = \"99432bfewaf823ec3294e231\"",
|
||||
"lineNumber": 6,
|
||||
"offender": "\"99432bfewaf823ec3294e231\"",
|
||||
"commit": "b2eb34a61c988afd9b4aaa9dd58c8dd7d5f14dba",
|
||||
"repo": "test_repo_4",
|
||||
"rule": "entropy",
|
||||
"commitMessage": "adding another one\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:12:08-04:00",
|
||||
"tags": "entropy",
|
||||
"operation": "addition"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,32 @@
|
||||
[
|
||||
{
|
||||
"line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"",
|
||||
"lineNumber": 5,
|
||||
"offender": "AKIALALEMEL33243OLIB",
|
||||
"commit": "b2eb34a61c988afd9b4aaa9dd58c8dd7d5f14dba",
|
||||
"repo": "test_repo_4",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "adding another one\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:12:08-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
},
|
||||
{
|
||||
"line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"",
|
||||
"lineNumber": 5,
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c",
|
||||
"repo": "test_repo_4",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "wait this is actually adding an aws secret\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:01:27-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,17 @@
|
||||
[
|
||||
{
|
||||
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||
"lineNumber": 5,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "6557c92612d3b35979bd426d429255b3bf9fab74",
|
||||
"repo": "test_repo_9",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "commit 1 with secrets\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "server.test.py",
|
||||
"date": "2019-10-24T09:29:27-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,17 @@
|
||||
[
|
||||
{
|
||||
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||
"lineNumber": 5,
|
||||
"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",
|
||||
"operation": "addition"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,17 @@
|
||||
[
|
||||
{
|
||||
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||
"lineNumber": 5,
|
||||
"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",
|
||||
"operation": "addition"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,17 @@
|
||||
[
|
||||
{
|
||||
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||
"lineNumber": 5,
|
||||
"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",
|
||||
"operation": "addition"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,17 @@
|
||||
[
|
||||
{
|
||||
"line": " aws_access_key_id='AKIAIO5FODNN7DXAMPLE'",
|
||||
"lineNumber": 10,
|
||||
"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",
|
||||
"operation": "equal"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,17 @@
|
||||
[
|
||||
{
|
||||
"line": "AKIAIO5FODNN7EXAMPLE",
|
||||
"lineNumber": 5,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "0000000000000000000000000000000000000000",
|
||||
"repo": "test_repo_7",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "***STAGED CHANGES***",
|
||||
"author": "",
|
||||
"email": "",
|
||||
"file": "file",
|
||||
"date": "1970-01-01T00:00:00Z",
|
||||
"tags": "key, AWS",
|
||||
"operation": "equal"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,44 @@
|
||||
[
|
||||
{
|
||||
"line": "api_token: exampleSecretPassword",
|
||||
"lineNumber": 3,
|
||||
"offender": "token: exampleSecretPassword",
|
||||
"commit": "e7bf376f855ae9bc6e3bb27b5f9d65c57eba799d",
|
||||
"repo": "test_repo_6",
|
||||
"rule": "Generic password",
|
||||
"commitMessage": "More secrets\n\n",
|
||||
"author": "Noel Algora",
|
||||
"email": "noealgigu@gmail.com",
|
||||
"file": "config/config.yaml",
|
||||
"date": "2020-02-19T04:08:26-05:00",
|
||||
"tags": "key, Yml, Yaml"
|
||||
},
|
||||
{
|
||||
"line": "db_password_token: exampleSecretPassword",
|
||||
"lineNumber": 3,
|
||||
"offender": "password_token: exampleSecretPassword",
|
||||
"commit": "e7bf376f855ae9bc6e3bb27b5f9d65c57eba799d",
|
||||
"repo": "test_repo_6",
|
||||
"rule": "Generic password",
|
||||
"commitMessage": "More secrets\n\n",
|
||||
"author": "Noel Algora",
|
||||
"email": "noealgigu@gmail.com",
|
||||
"file": "config/config.yaml",
|
||||
"date": "2020-02-19T04:08:26-05:00",
|
||||
"tags": "key, Yml, Yaml"
|
||||
},
|
||||
{
|
||||
"line": "aws_access_key_id=AKIAIO5FODNN7EXAMPLE",
|
||||
"lineNumber": 1,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "95cf0237f8cdfc0686a29df08260d8635f46c9b0",
|
||||
"repo": "test_repo_6",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "AWS Key in properties\n\n",
|
||||
"author": "Noel Algora",
|
||||
"email": "noealgigu@gmail.com",
|
||||
"file": "config/application.properties",
|
||||
"date": "2020-02-19T04:04:15-05:00",
|
||||
"tags": "key, AWS"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,32 @@
|
||||
[
|
||||
{
|
||||
"line": "api_token: exampleSecretPassword",
|
||||
"lineNumber": 2,
|
||||
"offender": "token: exampleSecretPassword",
|
||||
"commit": "98b6c7cb3fb29a5993c4c95c56a2dc53050b9247",
|
||||
"repo": "test_repo_6",
|
||||
"rule": "Generic password",
|
||||
"commitMessage": "Adding some secrets in config folder\n\n",
|
||||
"author": "Noel Algora",
|
||||
"email": "noealgigu@gmail.com",
|
||||
"file": "application.yaml",
|
||||
"date": "2020-02-24T14:13:15-05:00",
|
||||
"tags": "key, Yml, Yaml",
|
||||
"operation": "addition"
|
||||
},
|
||||
{
|
||||
"line": "db_password: verySecretProductionPassword",
|
||||
"lineNumber": 3,
|
||||
"offender": "password: verySecretProductionPassword",
|
||||
"commit": "98b6c7cb3fb29a5993c4c95c56a2dc53050b9247",
|
||||
"repo": "test_repo_6",
|
||||
"rule": "Generic password",
|
||||
"commitMessage": "Adding some secrets in config folder\n\n",
|
||||
"author": "Noel Algora",
|
||||
"email": "noealgigu@gmail.com",
|
||||
"file": "application.yaml",
|
||||
"date": "2020-02-24T14:13:15-05:00",
|
||||
"tags": "key, Yml, Yaml",
|
||||
"operation": "addition"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,17 @@
|
||||
[
|
||||
{
|
||||
"line": "aws_access_key_id=AKIAIO5FODNN7EXAMPLE",
|
||||
"lineNumber": 3,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "98b6c7cb3fb29a5993c4c95c56a2dc53050b9247",
|
||||
"repo": "test_repo_6",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "Adding some secrets in config folder\n\n",
|
||||
"author": "Noel Algora",
|
||||
"email": "noealgigu@gmail.com",
|
||||
"file": "config/application.properties",
|
||||
"date": "2020-02-24T14:13:15-05:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,17 @@
|
||||
[
|
||||
{
|
||||
"line": "apiToken=d41d8cd98f00b204e9800998ecf8427e",
|
||||
"lineNumber": 2,
|
||||
"offender": "Token=d41d8cd98f00b204e9800998ecf8427e",
|
||||
"commit": "98b6c7cb3fb29a5993c4c95c56a2dc53050b9247",
|
||||
"repo": "test_repo_6",
|
||||
"rule": "Generic password",
|
||||
"commitMessage": "Adding some secrets in config folder\n\n",
|
||||
"author": "Noel Algora",
|
||||
"email": "noealgigu@gmail.com",
|
||||
"file": "config/application.properties",
|
||||
"date": "2020-02-24T14:13:15-05:00",
|
||||
"tags": "key, Yml, Yaml",
|
||||
"operation": "addition"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,17 @@
|
||||
[
|
||||
{
|
||||
"line": "aws_access_key_id=AKIAIO5FODNN7EXAMPLE",
|
||||
"lineNumber": 3,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "98b6c7cb3fb29a5993c4c95c56a2dc53050b9247",
|
||||
"repo": "test_repo_6",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "Adding some secrets in config folder\n\n",
|
||||
"author": "Noel Algora",
|
||||
"email": "noealgigu@gmail.com",
|
||||
"file": "config/application.properties",
|
||||
"date": "2020-02-24T14:13:15-05:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,17 @@
|
||||
[
|
||||
{
|
||||
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||
"lineNumber": 5,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "6557c92612d3b35979bd426d429255b3bf9fab74",
|
||||
"repo": "test_repo_6",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "commit 1 with secrets\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "server.test.py",
|
||||
"date": "2019-10-24T09:29:27-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,17 @@
|
||||
[
|
||||
{
|
||||
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||
"lineNumber": 5,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "6557c92612d3b35979bd426d429255b3bf9fab74",
|
||||
"repo": "test_repo_6",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "commit 1 with secrets\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "server.test.py",
|
||||
"date": "2019-10-24T09:29:27-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,62 @@
|
||||
[
|
||||
{
|
||||
"line": "AWS secret: \"AKIALALEMEL33243OLIAE\"",
|
||||
"lineNumber": 6,
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "deea550dd6c7acaf0e59432600593533984a2125",
|
||||
"repo": "test_repo_3",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "dev branch\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:35:03-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
},
|
||||
{
|
||||
"line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"",
|
||||
"lineNumber": 5,
|
||||
"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",
|
||||
"operation": "addition"
|
||||
},
|
||||
{
|
||||
"line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"",
|
||||
"lineNumber": 5,
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c",
|
||||
"repo": "test_repo_3",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "wait this is actually adding an aws secret\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:01:27-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
},
|
||||
{
|
||||
"line": "Here's an AWS secret: AKIALALEMEL33243OLIAE",
|
||||
"lineNumber": 3,
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "b10b3e2cb320a8c211fda94c4567299d37de7776",
|
||||
"repo": "test_repo_3",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "adding aws key\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T12:58:39-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,17 @@
|
||||
[
|
||||
{
|
||||
"line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"",
|
||||
"lineNumber": 5,
|
||||
"offender": "AKIALALEMEL33243OLIB",
|
||||
"commit": "b2eb34a61c988afd9b4aaa9dd58c8dd7d5f14dba",
|
||||
"repo": "test_repo_2",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "adding another one\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:12:08-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,47 @@
|
||||
[
|
||||
{
|
||||
"line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"",
|
||||
"lineNumber": 5,
|
||||
"offender": "AKIALALEMEL33243OLIB",
|
||||
"commit": "b2eb34a61c988afd9b4aaa9dd58c8dd7d5f14dba",
|
||||
"repo": "test_repo_2",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "adding another one\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:12:08-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
},
|
||||
{
|
||||
"line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"",
|
||||
"lineNumber": 5,
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c",
|
||||
"repo": "test_repo_2",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "wait this is actually adding an aws secret\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:01:27-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
},
|
||||
{
|
||||
"line": "Here's an AWS secret: AKIALALEMEL33243OLIAE",
|
||||
"lineNumber": 3,
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "b10b3e2cb320a8c211fda94c4567299d37de7776",
|
||||
"repo": "test_repo_2",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "adding aws key\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T12:58:39-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,32 @@
|
||||
[
|
||||
{
|
||||
"line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"",
|
||||
"lineNumber": 5,
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c",
|
||||
"repo": "test_repo_2",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "wait this is actually adding an aws secret\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:01:27-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
},
|
||||
{
|
||||
"line": "Here's an AWS secret: AKIALALEMEL33243OLIAE",
|
||||
"lineNumber": 3,
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "b10b3e2cb320a8c211fda94c4567299d37de7776",
|
||||
"repo": "test_repo_2",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "adding aws key\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T12:58:39-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,17 @@
|
||||
[
|
||||
{
|
||||
"line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"",
|
||||
"lineNumber": 5,
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c",
|
||||
"repo": "test_repo_2",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "wait this is actually adding an aws secret\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:01:27-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,17 @@
|
||||
[
|
||||
{
|
||||
"line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"",
|
||||
"lineNumber": 5,
|
||||
"offender": "AKIALALEMEL33243OLIB",
|
||||
"commit": "b2eb34a61c988afd9b4aaa9dd58c8dd7d5f14dba",
|
||||
"repo": "test_repo_2",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "adding another one\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:12:08-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,92 @@
|
||||
[
|
||||
{
|
||||
"line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"",
|
||||
"lineNumber": -1,
|
||||
"offender": "AKIALALEMEL33243OLIB",
|
||||
"commit": "f61cd8587b7ac1d75a89a0c9af870a2f24c60263",
|
||||
"repo": "test_repo_2",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "rm secrets again\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:12:32-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "deletion"
|
||||
},
|
||||
{
|
||||
"line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"",
|
||||
"lineNumber": 5,
|
||||
"offender": "AKIALALEMEL33243OLIB",
|
||||
"commit": "b2eb34a61c988afd9b4aaa9dd58c8dd7d5f14dba",
|
||||
"repo": "test_repo_2",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "adding another one\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:12:08-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
},
|
||||
{
|
||||
"line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"",
|
||||
"lineNumber": -1,
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "996865bb912f3bc45898a370a13aadb315014b55",
|
||||
"repo": "test_repo_2",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "committing pem\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:07:41-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "deletion"
|
||||
},
|
||||
{
|
||||
"line": "Here's an AWS secret: AKIALALEMEL33243OLIAE",
|
||||
"lineNumber": -1,
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c",
|
||||
"repo": "test_repo_2",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "wait this is actually adding an aws secret\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:01:27-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "deletion"
|
||||
},
|
||||
{
|
||||
"line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"",
|
||||
"lineNumber": 5,
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c",
|
||||
"repo": "test_repo_2",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "wait this is actually adding an aws secret\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:01:27-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
},
|
||||
{
|
||||
"line": "Here's an AWS secret: AKIALALEMEL33243OLIAE",
|
||||
"lineNumber": 3,
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "b10b3e2cb320a8c211fda94c4567299d37de7776",
|
||||
"repo": "test_repo_2",
|
||||
"rule": "AWS Manager ID",
|
||||
"commitMessage": "adding aws key\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T12:58:39-04:00",
|
||||
"tags": "key, AWS",
|
||||
"operation": "addition"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,17 @@
|
||||
[
|
||||
{
|
||||
"line": " aws_secret_access_key='ABCDEF+c2L7yXeGvUyrPgYsDnWRRC1AYEXAMPLE'",
|
||||
"lineNumber": 6,
|
||||
"offender": "'ABCDEF+c2L7yXeGvUyrPgYsDnWRRC1AYEXAMPLE'",
|
||||
"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",
|
||||
"operation": "addition"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1 @@
|
||||
comment
|
||||
Loaded 100 of 1301 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user