mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-27 03:34:22 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
78f2c46517 | ||
|
|
bdcb9e33a8 | ||
|
|
6e4e9df55f | ||
|
|
b3bed5658d | ||
|
|
a10ae91ba7 | ||
|
|
a8dbc7f107 | ||
|
|
4544156b44 | ||
|
|
b52e8c9c7c | ||
|
|
0ce1249b95 | ||
|
|
3932ed6baf | ||
|
|
981b636920 | ||
|
|
c8e15c731a | ||
|
|
901f932a89 | ||
|
|
c0a9580a65 | ||
|
|
8be91eea5d | ||
|
|
1c6f2252b8 | ||
|
|
58d130c5f3 | ||
|
|
091ea81e68 | ||
|
|
f036dce6ab | ||
|
|
2d58f1f94e | ||
|
|
86cfe0848b | ||
|
|
973d74e592 | ||
|
|
3909ebe03b | ||
|
|
65f42020af | ||
|
|
65a91ae976 | ||
|
|
7db08bfd90 | ||
|
|
af26553292 | ||
|
|
d5e431e7d4 | ||
|
|
54ba3ec377 | ||
|
|
656ef1c9a7 | ||
|
|
b8accd7273 | ||
|
|
238c31beaa | ||
|
|
eb31190f31 | ||
|
|
389d45e380 | ||
|
|
81b3a6e279 | ||
|
|
c50906373c | ||
|
|
40545fb680 | ||
|
|
2acc34dfdf | ||
|
|
ede68fd95d | ||
|
|
6c60c3dde3 | ||
|
|
ad505754fc | ||
|
|
21d81879e2 | ||
|
|
b5ca2ba614 | ||
|
|
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 | ||
|
|
1f80d14f3f | ||
|
|
91eb014f17 | ||
|
|
6122092224 | ||
|
|
55102bd461 | ||
|
|
9927c0bd4b | ||
|
|
ba6f0c4d88 | ||
|
|
a52abe0b31 | ||
|
|
b1ae2a02fe | ||
|
|
f7fca41beb | ||
|
|
a257e9ed2e | ||
|
|
c51944c4d2 | ||
|
|
8e59bf766a | ||
|
|
fa498287b9 | ||
|
|
c77421d077 | ||
|
|
fe977ea857 | ||
|
|
ccef3680d5 | ||
|
|
2c80ad5ea9 | ||
|
|
f5ae1ae88b | ||
|
|
f653ab71c2 | ||
|
|
aec926df5e | ||
|
|
7bbf07e7e6 | ||
|
|
9f3ae4efa0 | ||
|
|
2fd1d44e0a | ||
|
|
e2060e9cd3 | ||
|
|
ce44961e6e | ||
|
|
078b951a43 | ||
|
|
b6b3e768dc | ||
|
|
2fadf219d9 | ||
|
|
ae71ce6ea0 | ||
|
|
041c11d9fc | ||
|
|
c019a9d80d | ||
|
|
0ed0489c2d | ||
|
|
2d27ce7cdf | ||
|
|
032c616f63 | ||
|
|
36c31bf181 | ||
|
|
d85c8d8abd | ||
|
|
39c9cb617c | ||
|
|
648ae701bf | ||
|
|
9dd624affa | ||
|
|
17efe94f95 | ||
|
|
25736d115f | ||
|
|
0d75136c1c | ||
|
|
7919e15a65 | ||
|
|
faca0e14d9 | ||
|
|
59f1f02480 | ||
|
|
c8880ed911 | ||
|
|
095279d60c | ||
|
|
91c39935e4 | ||
|
|
d972792aa1 | ||
|
|
9d544f474a | ||
|
|
01c54e55e7 | ||
|
|
4b21bbef2e | ||
|
|
9e87d94ce7 | ||
|
|
27ab66827d | ||
|
|
87ee13fb3d | ||
|
|
4b4fa00b69 | ||
|
|
1cecd5e090 | ||
|
|
93380ad86a | ||
|
|
c104ff9157 | ||
|
|
73387cbc53 | ||
|
|
bc0dab1c56 | ||
|
|
7554b51ad5 | ||
|
|
224ba41968 | ||
|
|
1b06f1a0dc | ||
|
|
a63f5059f2 | ||
|
|
9393f06d19 | ||
|
|
c11171f47d | ||
|
|
801254f97e | ||
|
|
7a0ce07f99 | ||
|
|
d16d584efa | ||
|
|
780123c5be | ||
|
|
c4738ef26f | ||
|
|
2186f22999 | ||
|
|
aa15ded5c4 | ||
|
|
9f694531b2 | ||
|
|
1669939147 | ||
|
|
e3c7b3a9eb | ||
|
|
1e250f1a14 | ||
|
|
6f5079c193 | ||
|
|
0fa6a79a25 | ||
|
|
970bbca757 | ||
|
|
b9657155b2 | ||
|
|
f58caef16d | ||
|
|
c0797d115a | ||
|
|
744ff2f876 | ||
|
|
4137d3cfc0 | ||
|
|
4a7875bb38 | ||
|
|
14c2bb6ff2 | ||
|
|
44df20e1f3 | ||
|
|
4ffbdde578 | ||
|
|
1d3d9b5983 | ||
|
|
5d995c05a2 | ||
|
|
d9d87410e2 | ||
|
|
fa1afa3e0c | ||
|
|
ad53f2ce34 | ||
|
|
3d2fd8a020 | ||
|
|
668fceb048 | ||
|
|
5114689a34 | ||
|
|
eae4b49966 | ||
|
|
d70dded366 | ||
|
|
864e1eeedc | ||
|
|
73ea4dfe3b | ||
|
|
c0bf19fc44 | ||
|
|
bc26e979c5 | ||
|
|
8f352bd840 | ||
|
|
d465c3d2f1 | ||
|
|
840e9e873f | ||
|
|
5c1bb93068 | ||
|
|
2533ea6661 | ||
|
|
a67910ec00 | ||
|
|
825d434c66 | ||
|
|
5d924ecc53 | ||
|
|
a77b6e4f8b | ||
|
|
c8181dee1b | ||
|
|
4ea51fc98d | ||
|
|
cba584bb18 | ||
|
|
159f5d6185 | ||
|
|
a9c5d5a953 | ||
|
|
cf4c157141 | ||
|
|
9c1ea12d77 | ||
|
|
a705784673 | ||
|
|
2d3bcc7e91 | ||
|
|
e0cfd0b5ca | ||
|
|
6eba1bb24e |
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
|
||||
@@ -0,0 +1,8 @@
|
||||
language: go
|
||||
go:
|
||||
- 1.16.x
|
||||
services:
|
||||
- docker
|
||||
script:
|
||||
- make test
|
||||
- make security-scan
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
FROM golang:1.15.5 AS build
|
||||
WORKDIR /go/src/github.com/zricethezav/gitleaks
|
||||
ARG ldflags
|
||||
COPY . .
|
||||
RUN GO111MODULE=on CGO_ENABLED=0 go build -o bin/gitleaks -ldflags "-X="${ldflags} *.go
|
||||
|
||||
FROM alpine:3.11
|
||||
RUN apk add --no-cache bash git openssh
|
||||
COPY --from=build /go/src/github.com/zricethezav/gitleaks/bin/* /usr/bin/
|
||||
ENTRYPOINT ["gitleaks"]
|
||||
|
||||
# How to use me :
|
||||
|
||||
# docker build -t gitleaks .
|
||||
# docker run --rm --name=gitleaks gitleaks --repo=https://github.com/zricethezav/gitleaks
|
||||
|
||||
# This will check for secrets in https://github.com/zricethezav/gitleaks
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 Zachary Rice
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -0,0 +1,49 @@
|
||||
.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/v7/version.Version=$(VERSION)"
|
||||
_LDFLAGS="github.com/zricethezav/gitleaks/v7/version.Version=$(VERSION)"
|
||||
COVER=--cover --coverprofile=cover.out
|
||||
|
||||
test-cover:
|
||||
go test ./... --race $(COVER) $(PKG) -v
|
||||
go tool cover -html=cover.out
|
||||
|
||||
test:
|
||||
go get golang.org/x/lint/golint
|
||||
go fmt ./...
|
||||
go vet ./...
|
||||
golint ./...
|
||||
go test ./... --race $(PKG) -v
|
||||
|
||||
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 --build-arg ldflags=$(_LDFLAGS) -f Dockerfile -t zricethezav/gitleaks:latest -t zricethezav/gitleaks:$(VERSION) .
|
||||
echo "Pushing zricethezav/gitleaks:$(VERSION) and zricethezav/gitleaks:latest"
|
||||
docker push zricethezav/gitleaks
|
||||
|
||||
dockerbuild:
|
||||
docker build --build-arg ldflags=$(_LDFLAGS) -f Dockerfile -t zricethezav/gitleaks:latest -t zricethezav/gitleaks:$(VERSION) .
|
||||
@@ -1,26 +1,273 @@
|
||||
# GitLeaks
|
||||
#### Check git repos for secrets and keys
|
||||
<p align="center">
|
||||
<img alt="gitleaks" src="https://raw.githubusercontent.com/zricethezav/gifs/master/gitleakslogo.png" height="70" />
|
||||
<p align="center">
|
||||
<a href="https://travis-ci.org/zricethezav/gitleaks"><img alt="Travis" src="https://img.shields.io/travis/zricethezav/gitleaks/master.svg?style=flat-square"></a>
|
||||
<a href="https://gitter.im/gitleaks/gitleaks"><img alt="Travis" src="https://badges.gitter.im/gitleaks/gitleaks.svg?style=flat-square"></a>
|
||||
</p>
|
||||
</p>
|
||||
|
||||
##### Features:
|
||||
* Search all commits on all branches in topological order
|
||||
* Regex/Entropy checks
|
||||
Gitleaks is a SAST tool for detecting hardcoded secrets like passwords, api keys, and tokens in git repos. Gitleaks is an **easy-to-use, all-in-one solution** for finding secrets, past or present, in your code.
|
||||
|
||||
### Introduction Video
|
||||
<p align="left">
|
||||
<a href="https://www.youtube.com/watch?v=VUq2eII20S4"><img alt="intro" src="https://img.youtube.com/vi/VUq2eII20S4/maxresdefault.jpg" height="200"></a>
|
||||
</p>
|
||||
|
||||
### Features:
|
||||
- Scan for [commited](https://github.com/zricethezav/gitleaks#Scanning) secrets
|
||||
- Scan for [unstaged](https://github.com/zricethezav/gitleaks#scan-unstaged-changes) secrets to shift security left
|
||||
- Scan [directories and files](https://github.com/zricethezav/gitleaks#scan-local-directory)
|
||||
- Run [Gitleaks Action](https://github.com/marketplace/actions/gitleaks) in your CI/CD pipeline
|
||||
- [Custom rules](https://github.com/zricethezav/gitleaks#configuration) via toml configuration
|
||||
- Increased performance using [go-git](https://github.com/go-git/go-git)
|
||||
- JSON, SARIF, and CSV reporting
|
||||
- Private repo scans using key or password based authentication
|
||||
|
||||
|
||||
### Installation
|
||||
Gitleaks can be installed using Homebrew, Docker, or Go. Gitleaks is also available in binary form for many popular platforms and OS types on the [releases page](https://github.com/zricethezav/gitleaks/releases).
|
||||
|
||||
##### MacOS
|
||||
|
||||
##### Installing:
|
||||
```
|
||||
$ go get github.com/zricethezav/gitleaks
|
||||
brew install gitleaks
|
||||
```
|
||||
|
||||
##### Usage and Explanation:
|
||||

|
||||
##### Docker
|
||||
|
||||
```bash
|
||||
docker pull zricethezav/gitleaks
|
||||
```
|
||||
$ ./gitleaks {git url}
|
||||
|
||||
##### Go
|
||||
```bash
|
||||
GO111MODULE=on go get github.com/zricethezav/gitleaks/v7
|
||||
```
|
||||
|
||||
### Usage and Options
|
||||
```
|
||||
Usage:
|
||||
gitleaks [OPTIONS]
|
||||
|
||||
Application Options:
|
||||
-v, --verbose Show verbose output from scan
|
||||
-q, --quiet Sets log level to error and only output leaks, one json object per line
|
||||
-r, --repo-url= Repository URL
|
||||
-p, --path= Path to directory (repo if contains .git) or file
|
||||
-c, --config-path= Path to config
|
||||
--repo-config-path= Path to gitleaks config relative to repo root
|
||||
--version Version number
|
||||
--username= Username for git repo
|
||||
--password= Password for git repo
|
||||
--access-token= Access token for git repo
|
||||
--threads= Maximum number of threads gitleaks spawns
|
||||
--ssh-key= Path to ssh key used for auth
|
||||
--unstaged Run gitleaks on unstaged code
|
||||
--branch= Branch to scan
|
||||
--redact Redact secrets from log messages and leaks
|
||||
--debug Log debug messages
|
||||
--leaks-exit-code= Exit code when leaks have been encountered (default: 1)
|
||||
--no-git Treat git repos as plain directories and scan those
|
||||
files
|
||||
-o, --report= Report output path
|
||||
-f, --format= JSON, CSV, SARIF (default: json)
|
||||
--files-at-commit= Sha of commit to scan all files at commit
|
||||
--commit= Sha of commit to scan or "latest" to scan the last
|
||||
commit of the repository
|
||||
--commits= Comma separated list of a commits to scan
|
||||
--commits-file= Path to file of line separated list of commits to scan
|
||||
--commit-from= Commit to start scan from
|
||||
--commit-to= Commit to stop scan
|
||||
--commit-since= Scan commits more recent than a specific date. Ex:
|
||||
'2006-01-02' or '2006-01-02T15:04:05-0700' format.
|
||||
--commit-until= Scan commits older than a specific date. Ex:
|
||||
'2006-01-02' or '2006-01-02T15:04:05-0700' format.
|
||||
--depth= Number of commits to scan
|
||||
|
||||
Help Options:
|
||||
-h, --help Show this help message
|
||||
```
|
||||
This will clone the target `{git url}` and run a diff on all commits. A report will be output to `{repo_name}.json`
|
||||
Gitleaks scans all lines of all commit diffs and checks if there are any regular expression matches. The regexs are defined in `main.go`. For example if a line in a commit diff like `AWS_KEY='AKAI...'` exists then the value after the assignment operator will be checked for entropy. If the value is above a certain entropy threshold then we assume that the line contains a key/secret. Work largely based on https://people.eecs.berkeley.edu/~rohanpadhye/files/key_leaks-msr15.pdf
|
||||
|
||||
|
||||
#### TODO
|
||||
- Specify a target branch
|
||||
- Support for custom regex
|
||||
- Filter regex
|
||||
- Modify entropy cutoff
|
||||
### [Scanning](https://www.youtube.com/watch?v=WUzpRL8mKCk)
|
||||
|
||||
#### Basic repo-url scan:
|
||||
This scans the entire history of tests/secrets and logs leaks as they are encountered `-v`/`--verbose` being set.
|
||||
```
|
||||
gitleaks --repo-url=https://github.com/my-insecure/repo -v
|
||||
```
|
||||
|
||||
|
||||
#### Basic repo-url scan output to a report:
|
||||
If you want the report in sarif or csv you can set the `-f/--format` option
|
||||
```
|
||||
gitleaks --repo-url=https://github.com/my-insecure/repo -v --report=my-report.json
|
||||
```
|
||||
|
||||
#### Scan specific commit:
|
||||
```
|
||||
gitleaks --repo-url=https://github.com/my-insecure/repo --commit=commit-sha -v
|
||||
```
|
||||
|
||||
#### Scan local repo:
|
||||
```
|
||||
gitleaks --path=path/to/local/repo -v
|
||||
```
|
||||
|
||||
#### Scan repos contained in a parent directory:
|
||||
If you have `repo1`, `repo2`, `repo3` all under `path/to/local`, gitleaks will discover and scan those repos.
|
||||
```
|
||||
gitleaks --path=path/to/local/ -v
|
||||
```
|
||||
|
||||
#### Scan local directory:
|
||||
If you want to scan the current contents of a repo, ignoring git alltogether. You can use the `--no-git` option to do this.
|
||||
```
|
||||
gitleaks --path=path/to/local/repo -v --no-git
|
||||
```
|
||||
|
||||
#### Scan a file:
|
||||
Or if you want to scan a single file using gitleaks rules. You can do this by specifying the file in `--path` and including the `--no-git` option.
|
||||
```
|
||||
gitleaks --path=path/to/local/repo/main.go -v --no-git
|
||||
```
|
||||
|
||||
#### Scan unstaged changes:
|
||||
If you have unstaged changes are are currently at the root of the repo, you can run `gitleaks` with no `--path` or `--repo-url` specified which will run a scan on your uncommitted changes. Or if you want to specify a
|
||||
path, you can run:
|
||||
```
|
||||
gitleaks --path=path/to/local/repo -v --unstaged
|
||||
```
|
||||
|
||||
|
||||
### Configuration
|
||||
Provide your own gitleaks configurations with `--config-path` or `--repo-config-path`. `--config-path` loads a local gitleaks configuration whereas `--repo-config-path` will load a configuration present just in the repo you want to scan. For example, `gitleaks --repo-config-path=".github/gitleaks.config"`.
|
||||
The default configuration Gitleaks uses is located [here](https://github.com/zricethezav/gitleaks/blob/master/config/default.go). More configuration examples can be seen [here](https://github.com/zricethezav/gitleaks/tree/master/examples). Configuration files will contain a few different toml tables. Further explanation is provided below.
|
||||
|
||||
### Rules summary
|
||||
|
||||
The rules are written in [TOML](https://github.com/toml-lang/toml) as defined in [TomlLoader struct](https://github.com/zricethezav/gitleaks/blob/master/config/config.go#L57-L87), and can be summarized as:
|
||||
|
||||
```
|
||||
|
||||
|
||||
[[rules]]
|
||||
description = "a string describing one of many rule in this config"
|
||||
regex = '''one-go-style-regex-for-this-rule'''
|
||||
file = '''a-file-name-regex'''
|
||||
path = '''a-file-path-regex'''
|
||||
tags = ["tag","another tag"]
|
||||
[[rules.entropies]] # note these are strings, not floats
|
||||
Min = "3.5"
|
||||
Max = "4.5"
|
||||
Group = "1"
|
||||
[rules.allowlist]
|
||||
description = "a string"
|
||||
files = ['''one-file-name-regex''']
|
||||
commits = [ "commit-A", "commit-B"]
|
||||
paths = ['''one-file-path-regex''']
|
||||
regexes = ['''one-regex-within-the-already-matched-regex''']
|
||||
|
||||
[allowlist]
|
||||
description = "a description string for a global allowlist config"
|
||||
commits = [ "commit-A", "commit-B"]
|
||||
files = [ '''file-regex-a''', '''file-regex-b''']
|
||||
paths = [ '''path-regex-a''', '''path-regex-b''']
|
||||
repos = [ '''repo-regex-a''', '''repo-regex-b''']
|
||||
regexes = ['''one-regex-within-the-already-matched-regex''']
|
||||
```
|
||||
|
||||
Regular expressions are _NOT_ the full Perl set, so there are no look-aheads or look-behinds.
|
||||
|
||||
|
||||
### Examples
|
||||
#### Example 1
|
||||
The first and most commonly edited array of tables is `[[rules]]`. This is where you can define your own custom rules for Gitleaks to use while scanning repos. Example keys/values within the `[[rules]]` table:
|
||||
```
|
||||
[[rules]]
|
||||
description = "generic secret regex"
|
||||
regex = '''secret(.{0,20})([0-9a-zA-Z-._{}$\/\+=]{20,120})'''
|
||||
tags = ["secret", "example"]
|
||||
```
|
||||
#### Example 2
|
||||
We can also **combine** regular expressions AND entropy:
|
||||
```
|
||||
[[rules]]
|
||||
description = "entropy and regex example"
|
||||
regex = '''secret(.{0,20})['|"]([0-9a-zA-Z-._{}$\/\+=]{20,120})['|"]'''
|
||||
[[rules.Entropies]]
|
||||
Min = "4.5"
|
||||
Max = "4.7"
|
||||
```
|
||||
Translating this rule to English, this rule states: "if we encounter a line of code that matches *regex* AND the line falls within the bounds of a [Shannon entropy](https://en.wikipedia.org/wiki/Entropy_(information_theory)) of 4.5 to 4.7, then the line must be a leak"
|
||||
|
||||
#### Example 3
|
||||
Let's compare two lines of code:
|
||||
```
|
||||
aws_secret='ABCDEF+c2L7yXeGvUyrPgYsDnWRRC1AYEXAMPLE'
|
||||
```
|
||||
and
|
||||
```
|
||||
aws_secret=os.getenv('AWS_SECRET_ACCESS_KEY')
|
||||
|
||||
```
|
||||
The first line of code is an example of a hardcoded secret being assigned to the variable `aws_secret`. The second line of code is an example of a secret being assigned via env variables to `aws_secret`. Both would be caught by the rule defined in *example 2* but only the first line is actually a leak. Let's define a new rule that will capture only the first line of code. We can do this by combining regular expression **groups** and entropy.
|
||||
```
|
||||
[[rules]]
|
||||
description = "entropy and regex example"
|
||||
regex = '''secret(.{0,20})['|"]([0-9a-zA-Z-._{}$\/\+=]{20,120})['|"]'''
|
||||
[[rules.Entropies]]
|
||||
Min = "4.5"
|
||||
Max = "4.7"
|
||||
Group = "2"
|
||||
```
|
||||
Notice how we added `Group = "2"` to this rule. We can translate this rule to English: "if we encounter a line of code that matches regex AND the entropy of the *second regex group* falls within the bounds of a [Shannon entropy](https://en.wikipedia.org/wiki/Entropy_(information_theory)) of 4.5 to 4.7, then the line must be a leak"
|
||||
|
||||
### Example 4: Using allowlist regex
|
||||
|
||||
The proper Perl regex for AWS secret keys is
|
||||
`(?<![A-Za-z0-9\\+])[A-Za-z0-9\\+=]{40}(?![A-Za-z0-9\\+=])`
|
||||
but the Go library doesn't do lookahead/lookbehind, so
|
||||
we'll look for 40 base64 characters, then allowlist
|
||||
if they're embedded in a string of 41 base64 characters, that is,
|
||||
without any delimiters. This will make a false negative for, say:
|
||||
```
|
||||
foo=+awsSecretAccessKeyisBase64=40characters
|
||||
```
|
||||
So you can use the following to effectively create the proper Perl regex:
|
||||
```
|
||||
[[rules]]
|
||||
description = "AWS secret key regardless of labeling"
|
||||
regex = '''.?[A-Za-z0-9\\+=]{40}.?'''
|
||||
[rules.allowlist]
|
||||
description = "41 base64 characters is not an AWS secret key"
|
||||
regexes = ['''[A-Za-z0-9\\+=]{41}''']
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Exit Codes
|
||||
You can always set the exit code when leaves are encountered with the `--leaks-exit-code` flag. Default exit codes below:
|
||||
```
|
||||
0 - no leaks present
|
||||
1 - leaks or error encountered
|
||||
```
|
||||
|
||||
### Sponsors ❤️
|
||||
#### Corporate Sponsors
|
||||
[](https://gammanet.com/?utm_source=gitleaks&utm_medium=homepage&utm_campaign=gitleaks_promotion)
|
||||
|
||||
Gamma proactively detects and remediates data leaks across cloud apps. Scan your public repos for secret leaks with [Gamma](https://gammanet.com/github-demo?utm_source=gitleaks&utm_medium=homepage&utm_campaign=gitleaks_promotion)
|
||||
|
||||
#### Individual Sponsors
|
||||
These users are [sponsors](https://github.com/sponsors/zricethezav) of gitleaks:
|
||||
|
||||
[](https://github.com/adamdecaf) |
|
||||
---|
|
||||
----
|
||||
|
||||
|
||||
#### Logo Attribution
|
||||
The Gitleaks logo uses the Git Logo created <a href="https://twitter.com/jasonlong">Jason Long</a> is licensed under the <a href="https://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution 3.0 Unported License</a>.
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/nbutton23/zxcvbn-go"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// check each line of a diff and see if there are any potential secrets
|
||||
// [1] https://people.eecs.berkeley.edu/~rohanpadhye/files/key_leaks-msr15.pdf
|
||||
func checkRegex(diff string) []string {
|
||||
var match string
|
||||
var results []string
|
||||
lines := strings.Split(diff, "\n")
|
||||
for _, line := range lines {
|
||||
// doubtful a leak would be on a line > 120 characters
|
||||
if len(line) == 0 || len(line) > 120 {
|
||||
continue
|
||||
}
|
||||
for _, re := range regexes {
|
||||
match = re.FindString(line)
|
||||
if len(match) == 0 {
|
||||
continue
|
||||
}
|
||||
results = append(results, line)
|
||||
}
|
||||
}
|
||||
return results
|
||||
}
|
||||
|
||||
// checkEntropy determines whether target contains enough
|
||||
// entropy for a hash
|
||||
// TODO remove stop words:
|
||||
// setting(s), config(s), property(s), etc
|
||||
func checkEntropy(target string) bool {
|
||||
index := assignRegex.FindStringIndex(target)
|
||||
if len(index) == 0 {
|
||||
return false
|
||||
}
|
||||
|
||||
// TODO check for stop words here
|
||||
target = strings.Trim(target[index[1]:len(target)], " ")
|
||||
|
||||
if len(target) > 70 {
|
||||
return false
|
||||
}
|
||||
|
||||
entropy := zxcvbn.PasswordStrength(target, nil).Entropy
|
||||
|
||||
// tune this/make option
|
||||
if entropy > 70 {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCheckRegex(t *testing.T) {
|
||||
var secretsPresent bool
|
||||
var results []string
|
||||
checks := map[string]bool{
|
||||
"github.com": false,
|
||||
"github.com/user/": false,
|
||||
"github.com/user -- Sys": false,
|
||||
"github_api_client = \"sample key\"": true,
|
||||
"aws=\"afewafewafewafewaf\"": true,
|
||||
"aws\"afewafewafewafewaf\"": false,
|
||||
"heroku := \"afewafewafewafewaf\"": true,
|
||||
"heroku_client_secret := \"afewafewafewafewaf\"": true,
|
||||
"reddit_api_secreit = \"Fwe4fa431FgklreF\"": true,
|
||||
}
|
||||
|
||||
for k, v := range checks {
|
||||
results, secretsPresent = checkRegex(k)
|
||||
if v != secretsPresent {
|
||||
t.Errorf("regexCheck failed on string %s. Expected secretsPresent: %t, got %t, %v", k, v, secretsPresent, results)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestEntropy(t *testing.T) {
|
||||
var enoughEntropy bool
|
||||
checks := map[string]bool{
|
||||
"heroku_client_secret = settings.HEROKU_CLIENT": false,
|
||||
"heroku_client_secret = conf.heroku": false,
|
||||
"reddit_secret = settings.REDDIT_API": false,
|
||||
"reddit_api_secret = \"Fwe4fa431FgklreF\"": true,
|
||||
"aws_secret= \"AKIAIMNOJVGFDXXXE4OA\"": true,
|
||||
}
|
||||
for k, v := range checks {
|
||||
enoughEntropy = checkEntropy(k)
|
||||
if v != enoughEntropy {
|
||||
t.Errorf("checkEntropy failed for %s. Expected %t, got %t", k, v, enoughEntropy)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
)
|
||||
|
||||
// used for ignoring .git directories when the --no-git flag is set
|
||||
// related issue: https://github.com/zricethezav/gitleaks/issues/486
|
||||
const dotGit = `/\.git/`
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
// CommitAllowed checks if a commit is allowlisted
|
||||
func (a *AllowList) CommitAllowed(commit string) bool {
|
||||
for _, hash := range a.Commits {
|
||||
if commit == hash {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// FileAllowed checks if a file is allowlisted
|
||||
func (a *AllowList) FileAllowed(fileName string) bool {
|
||||
return anyRegexMatch(fileName, a.Files)
|
||||
}
|
||||
|
||||
// PathAllowed checks if a path is allowlisted
|
||||
func (a *AllowList) PathAllowed(filePath string) bool {
|
||||
return anyRegexMatch(filePath, a.Paths)
|
||||
}
|
||||
|
||||
// RegexAllowed checks if a regex is allowlisted
|
||||
func (a *AllowList) RegexAllowed(content string) bool {
|
||||
return anyRegexMatch(content, a.Regexes)
|
||||
}
|
||||
|
||||
// RepoAllowed checks if a regex is allowlisted
|
||||
func (a *AllowList) RepoAllowed(repo string) bool {
|
||||
return anyRegexMatch(repo, a.Repos)
|
||||
}
|
||||
|
||||
// IgnoreDotGit appends a `\.git` rule to ignore all .git paths. This is used for --no-git scans
|
||||
func (a *AllowList) IgnoreDotGit() error {
|
||||
re, err := regexp.Compile(dotGit)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
a.Paths = append(a.Paths, re)
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,319 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strconv"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v7/options"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
"github.com/go-git/go-git/v5"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
// Entropy represents an entropy range
|
||||
type Entropy struct {
|
||||
Min float64
|
||||
Max float64
|
||||
Group int
|
||||
}
|
||||
|
||||
// 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
|
||||
ReportGroup int
|
||||
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.ConfigPath != "" {
|
||||
_, err = toml.DecodeFile(options.ConfigPath, &tomlLoader)
|
||||
// append a allowlist rule for allowlisting the config
|
||||
tomlLoader.AllowList.Files = append(tomlLoader.AllowList.Files, path.Base(options.ConfigPath))
|
||||
} 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
|
||||
|
||||
allowList.Description = rule.AllowList.Description
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
||||
// rule specific commits
|
||||
allowList.Commits = rule.AllowList.Commits
|
||||
|
||||
var entropies []Entropy
|
||||
for _, e := range rule.Entropies {
|
||||
min, err := strconv.ParseFloat(e.Min, 64)
|
||||
if err != nil {
|
||||
return cfg, err
|
||||
}
|
||||
max, err := strconv.ParseFloat(e.Max, 64)
|
||||
if err != nil {
|
||||
return cfg, err
|
||||
}
|
||||
if e.Group == "" {
|
||||
e.Group = "0"
|
||||
}
|
||||
group, err := strconv.ParseInt(e.Group, 10, 64)
|
||||
if err != nil {
|
||||
return cfg, err
|
||||
} else if int(group) >= len(re.SubexpNames()) {
|
||||
return cfg, fmt.Errorf("problem loading config: group cannot be higher than number of groups in regexp")
|
||||
} else if group < 0 {
|
||||
return cfg, fmt.Errorf("problem loading config: group cannot be lower than 0")
|
||||
} else if min > 8.0 || min < 0.0 || max > 8.0 || max < 0.0 {
|
||||
return cfg, fmt.Errorf("problem loading config: invalid entropy ranges, must be within 0.0-8.0")
|
||||
} else if min > max {
|
||||
return cfg, fmt.Errorf("problem loading config: entropy Min value cannot be higher than Max value")
|
||||
}
|
||||
|
||||
entropies = append(entropies, Entropy{Min: min, Max: max, Group: int(group)})
|
||||
}
|
||||
|
||||
r := Rule{
|
||||
Description: rule.Description,
|
||||
Regex: re,
|
||||
File: fileNameRe,
|
||||
Path: filePathRe,
|
||||
ReportGroup: rule.ReportGroup,
|
||||
Tags: rule.Tags,
|
||||
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
|
||||
}
|
||||
|
||||
// LoadRepoConfig accepts a repo and config path related to the target repo's root.
|
||||
func LoadRepoConfig(repo *git.Repository, repoConfig string) (Config, error) {
|
||||
gitRepoConfig, err := repo.Config()
|
||||
if err != nil {
|
||||
return Config{}, err
|
||||
}
|
||||
if !gitRepoConfig.Core.IsBare {
|
||||
wt, err := repo.Worktree()
|
||||
if err != nil {
|
||||
return Config{}, err
|
||||
}
|
||||
_, err = wt.Filesystem.Stat(repoConfig)
|
||||
if err != nil {
|
||||
return Config{}, err
|
||||
}
|
||||
r, err := wt.Filesystem.Open(repoConfig)
|
||||
if err != nil {
|
||||
return Config{}, err
|
||||
}
|
||||
return parseTomlFile(r)
|
||||
}
|
||||
|
||||
log.Debug("attempting to load repo config from bare worktree, this may use an old config")
|
||||
ref, err := repo.Head()
|
||||
if err != nil {
|
||||
return Config{}, err
|
||||
}
|
||||
|
||||
c, err := repo.CommitObject(ref.Hash())
|
||||
if err != nil {
|
||||
return Config{}, err
|
||||
}
|
||||
|
||||
f, err := c.File(repoConfig)
|
||||
if err != nil {
|
||||
return Config{}, err
|
||||
}
|
||||
|
||||
r, err := f.Reader()
|
||||
|
||||
if err != nil {
|
||||
return Config{}, err
|
||||
}
|
||||
|
||||
return parseTomlFile(r)
|
||||
}
|
||||
|
||||
// LoadAdditionalConfig Accepts a path to a gitleaks config and returns a Config struct
|
||||
func LoadAdditionalConfig(repoConfig string) (Config, error) {
|
||||
file, err := os.Open(filepath.Clean(repoConfig))
|
||||
if err != nil {
|
||||
return Config{}, err
|
||||
}
|
||||
|
||||
return parseTomlFile(file)
|
||||
}
|
||||
|
||||
// AppendConfig Accepts a Config struct and will append those fields to this Config Struct's fields
|
||||
func (config *Config) AppendConfig(configToBeAppended Config) Config {
|
||||
newAllowList := AllowList{
|
||||
Description: "Appended Configuration",
|
||||
Commits: append(config.Allowlist.Commits, configToBeAppended.Allowlist.Commits...),
|
||||
Files: append(config.Allowlist.Files, configToBeAppended.Allowlist.Files...),
|
||||
Paths: append(config.Allowlist.Paths, configToBeAppended.Allowlist.Paths...),
|
||||
Regexes: append(config.Allowlist.Regexes, configToBeAppended.Allowlist.Regexes...),
|
||||
Repos: append(config.Allowlist.Repos, configToBeAppended.Allowlist.Repos...),
|
||||
}
|
||||
|
||||
return Config{
|
||||
Rules: append(config.Rules, configToBeAppended.Rules...),
|
||||
Allowlist: newAllowList,
|
||||
}
|
||||
}
|
||||
|
||||
// takes a File, makes sure it is a valid config, and parses it
|
||||
func parseTomlFile(f io.Reader) (Config, error) {
|
||||
var tomlLoader TomlLoader
|
||||
_, err := toml.DecodeReader(f, &tomlLoader)
|
||||
if err != nil {
|
||||
log.Errorf("Unable to read gitleaks config. Using defaults. Error: %s", err)
|
||||
return Config{}, err
|
||||
}
|
||||
return tomlLoader.Parse()
|
||||
}
|
||||
@@ -0,0 +1,283 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"regexp"
|
||||
"testing"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v7/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{
|
||||
ConfigPath: "../test_data/test_configs/aws_key.toml",
|
||||
},
|
||||
},
|
||||
{
|
||||
description: "test bad toml",
|
||||
opts: options.Options{
|
||||
ConfigPath: "../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{
|
||||
ConfigPath: "../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{
|
||||
ConfigPath: "../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{
|
||||
ConfigPath: "../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{
|
||||
ConfigPath: "../test_data/test_configs/large.toml",
|
||||
},
|
||||
},
|
||||
{
|
||||
description: "test load entropy",
|
||||
opts: options.Options{
|
||||
ConfigPath: "../test_data/test_configs/entropy.toml",
|
||||
},
|
||||
},
|
||||
{
|
||||
description: "test entropy bad range",
|
||||
opts: options.Options{
|
||||
ConfigPath: "../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{
|
||||
ConfigPath: "../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{
|
||||
ConfigPath: "../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{
|
||||
ConfigPath: "../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{
|
||||
ConfigPath: "../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{
|
||||
ConfigPath: "../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{
|
||||
ConfigPath: "../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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestParseFields will test that fields are properly parsed from a config. As fields are added, then please
|
||||
// add tests here.
|
||||
func TestParseFields(t *testing.T) {
|
||||
tomlConfig := `
|
||||
[[rules]]
|
||||
description = "Some Groups without a reportGroup"
|
||||
regex = '(.)(.)'
|
||||
|
||||
[[rules]]
|
||||
description = "Some Groups"
|
||||
regex = '(.)(.)'
|
||||
reportGroup = 1
|
||||
`
|
||||
configPath, err := writeTestConfig(tomlConfig)
|
||||
defer os.Remove(configPath)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
config, err := NewConfig(options.Options{ConfigPath: configPath})
|
||||
if err != nil {
|
||||
t.Fatalf("Couldn't parse config: %v", err)
|
||||
}
|
||||
|
||||
expectedRuleFields := []struct {
|
||||
Description string
|
||||
ReportGroup int
|
||||
}{
|
||||
{
|
||||
Description: "Some Groups without a reportGroup",
|
||||
ReportGroup: 0,
|
||||
},
|
||||
{
|
||||
Description: "Some Groups",
|
||||
ReportGroup: 1,
|
||||
},
|
||||
}
|
||||
|
||||
if len(config.Rules) != len(expectedRuleFields) {
|
||||
t.Fatalf("expected %v rules", len(expectedRuleFields))
|
||||
}
|
||||
|
||||
for _, expected := range expectedRuleFields {
|
||||
rule, err := findRuleByDescription(config.Rules, expected.Description)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if rule.ReportGroup != expected.ReportGroup {
|
||||
t.Errorf("expected the rule with description '%v' to have a ReportGroup of %v", expected.Description, expected.ReportGroup)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func findRuleByDescription(rules []Rule, description string) (*Rule, error) {
|
||||
for _, rule := range rules {
|
||||
if rule.Description == description {
|
||||
return &rule, nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("Couldn't find rule with the description: %s", description)
|
||||
}
|
||||
|
||||
func writeTestConfig(toml string) (string, error) {
|
||||
tmpfile, err := ioutil.TempFile("", "testConfig")
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("Couldn't create test config got: %w", err)
|
||||
}
|
||||
|
||||
if _, err := tmpfile.Write([]byte(toml)); err != nil {
|
||||
return "", fmt.Errorf("Couldn't create test config got: %w", err)
|
||||
}
|
||||
|
||||
if err := tmpfile.Close(); err != nil {
|
||||
return "", fmt.Errorf("Couldn't create test config got: %w", err)
|
||||
}
|
||||
|
||||
return tmpfile.Name(), nil
|
||||
}
|
||||
|
||||
func TestAppendingConfiguration(t *testing.T) {
|
||||
testRegexA, _ := regexp.Compile("a")
|
||||
testRegexB, _ := regexp.Compile("b")
|
||||
|
||||
allowListA := AllowList{
|
||||
Description: "Test Description",
|
||||
Commits: []string{"a"},
|
||||
Files: []*regexp.Regexp{testRegexA},
|
||||
Paths: []*regexp.Regexp{testRegexA},
|
||||
Regexes: []*regexp.Regexp{testRegexA},
|
||||
Repos: []*regexp.Regexp{testRegexA},
|
||||
}
|
||||
|
||||
allowListB := AllowList{
|
||||
Description: "Test Description",
|
||||
Commits: []string{"b"},
|
||||
Files: []*regexp.Regexp{testRegexB},
|
||||
Paths: []*regexp.Regexp{testRegexB},
|
||||
Regexes: []*regexp.Regexp{testRegexB},
|
||||
Repos: []*regexp.Regexp{testRegexB},
|
||||
}
|
||||
|
||||
ruleA := Rule{Description: "a"}
|
||||
ruleB := Rule{Description: "b"}
|
||||
|
||||
rulesA := []Rule{ruleA}
|
||||
rulesB := []Rule{ruleB}
|
||||
|
||||
cfgA := Config{
|
||||
Rules: rulesA,
|
||||
Allowlist: allowListA,
|
||||
}
|
||||
|
||||
cfgB := Config{
|
||||
Rules: rulesB,
|
||||
Allowlist: allowListB,
|
||||
}
|
||||
|
||||
cfgAppended := cfgA.AppendConfig(cfgB)
|
||||
|
||||
if !(len(cfgAppended.Rules) == 2) {
|
||||
t.Errorf("Length of Appended Rules = %d; want 2", len(cfgAppended.Rules))
|
||||
}
|
||||
|
||||
if !(len(cfgAppended.Allowlist.Commits) == 2) {
|
||||
t.Errorf("Length of Appended Allowed Commits = %d; want 2", len(cfgAppended.Allowlist.Commits))
|
||||
}
|
||||
|
||||
if !(len(cfgAppended.Allowlist.Files) == 2) {
|
||||
t.Errorf("Length of Appended Allowed Files = %d; want 2", len(cfgAppended.Allowlist.Files))
|
||||
}
|
||||
|
||||
if !(len(cfgAppended.Allowlist.Paths) == 2) {
|
||||
t.Errorf("Length of Appended Allowed Paths = %d; want 2", len(cfgAppended.Allowlist.Paths))
|
||||
}
|
||||
|
||||
if !(len(cfgAppended.Allowlist.Regexes) == 2) {
|
||||
t.Errorf("Length of Appended Allowed Regexes = %d; want 2", len(cfgAppended.Allowlist.Regexes))
|
||||
}
|
||||
|
||||
if !(len(cfgAppended.Allowlist.Repos) == 2) {
|
||||
t.Errorf("Length of Appended Allowed Repos = %d; want 2", len(cfgAppended.Allowlist.Repos))
|
||||
}
|
||||
|
||||
if cfgAppended.Allowlist.Description != "Appended Configuration" {
|
||||
t.Errorf("Allow List Description is = \"%s\"; want \"Appended Configuration\"", cfgAppended.Allowlist.Description)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
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 Access Key"
|
||||
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,3}((?i)token|api|key).{0,10}?(?-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,12}/[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"]
|
||||
|
||||
[[rules]]
|
||||
description = "Dynatrace ttoken"
|
||||
regex = '''dt0[a-zA-Z]{1}[0-9]{2}\.[A-Z0-9]{24}\.[A-Z0-9]{64}'''
|
||||
tags = ["key", "Dynatrace"]
|
||||
|
||||
[[rules]]
|
||||
description = "Shopify shared secret"
|
||||
regex = '''shpss_[a-fA-F0-9]{32}'''
|
||||
tags = ["key", "Shopify"]
|
||||
|
||||
[[rules]]
|
||||
description = "Shopify access token"
|
||||
regex = '''shpat_[a-fA-F0-9]{32}'''
|
||||
tags = ["key", "Shopify"]
|
||||
|
||||
[[rules]]
|
||||
description = "Shopify custom app access token"
|
||||
regex = '''shpca_[a-fA-F0-9]{32}'''
|
||||
tags = ["key", "Shopify"]
|
||||
|
||||
[[rules]]
|
||||
description = "Shopify private app access token"
|
||||
regex = '''shppa_[a-fA-F0-9]{32}'''
|
||||
tags = ["key", "Shopify"]
|
||||
|
||||
[allowlist]
|
||||
description = "Allowlisted files"
|
||||
files = ['''^\.?gitleaks.toml$''',
|
||||
'''(.*?)(png|jpg|gif|doc|docx|pdf|bin|xls|pyc|zip)$''',
|
||||
'''(go.mod|go.sum)$''']
|
||||
`
|
||||
+143
@@ -0,0 +1,143 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"math"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
// 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
|
||||
ReportGroup int
|
||||
Tags []string
|
||||
AllowList AllowList
|
||||
Entropies []Entropy
|
||||
}
|
||||
|
||||
// Inspect checks the content of a line for a leak
|
||||
func (r *Rule) Inspect(line string) string {
|
||||
offender := r.Regex.FindString(line)
|
||||
if offender == "" {
|
||||
return ""
|
||||
}
|
||||
|
||||
// check if offender is allowed
|
||||
if r.RegexAllowed(line) {
|
||||
return ""
|
||||
}
|
||||
|
||||
// check entropy
|
||||
groups := r.Regex.FindStringSubmatch(offender)
|
||||
if len(r.Entropies) != 0 && !r.ContainsEntropyLeak(groups) {
|
||||
return ""
|
||||
}
|
||||
|
||||
// 0 is a match for the full regex pattern
|
||||
if 0 < r.ReportGroup && r.ReportGroup < len(groups) {
|
||||
offender = groups[r.ReportGroup]
|
||||
}
|
||||
return offender
|
||||
}
|
||||
|
||||
// RegexAllowed checks if the content is allowlisted
|
||||
func (r *Rule) RegexAllowed(content string) bool {
|
||||
return anyRegexMatch(content, r.AllowList.Regexes)
|
||||
}
|
||||
|
||||
// CommitAllowed checks if a commit is allowlisted
|
||||
func (r *Rule) CommitAllowed(commit string) bool {
|
||||
return r.AllowList.CommitAllowed(commit)
|
||||
}
|
||||
|
||||
// ContainsEntropyLeak checks if there is an entropy leak
|
||||
func (r *Rule) ContainsEntropyLeak(groups []string) bool {
|
||||
for _, e := range r.Entropies {
|
||||
if len(groups) > e.Group {
|
||||
entropy := shannonEntropy(groups[e.Group])
|
||||
if entropy >= e.Min && entropy <= e.Max {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// HasFileOrPathLeakOnly first checks if there are no entropy/regex rules, then checks if
|
||||
// there are any file/path leaks
|
||||
func (r *Rule) HasFileOrPathLeakOnly(filePath string) bool {
|
||||
if r.Regex.String() != "" {
|
||||
return false
|
||||
}
|
||||
if len(r.Entropies) != 0 {
|
||||
return false
|
||||
}
|
||||
if r.AllowList.FileAllowed(filepath.Base(filePath)) || r.AllowList.PathAllowed(filePath) {
|
||||
return false
|
||||
}
|
||||
return r.HasFileLeak(filepath.Base(filePath)) || r.HasFilePathLeak(filePath)
|
||||
}
|
||||
|
||||
// HasFileLeak checks if there is a file leak
|
||||
func (r *Rule) HasFileLeak(fileName string) bool {
|
||||
return regexMatched(fileName, r.File)
|
||||
}
|
||||
|
||||
// HasFilePathLeak checks if there is a path leak
|
||||
func (r *Rule) HasFilePathLeak(filePath string) bool {
|
||||
return regexMatched(filePath, r.Path)
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
// 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 string, re *regexp.Regexp) bool {
|
||||
if re == nil {
|
||||
return false
|
||||
}
|
||||
if re.FindString(f) != "" {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// anyRegexMatch matched an interface to a regular expression. The interface f can
|
||||
// be a string type or go-git *object.File type.
|
||||
func anyRegexMatch(f string, res []*regexp.Regexp) bool {
|
||||
for _, re := range res {
|
||||
if regexMatched(f, re) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
title = "gitleaks config"
|
||||
|
||||
[[rules]]
|
||||
description = "AWS Access Key"
|
||||
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 Access Key"
|
||||
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 Access Key"
|
||||
regex = '''(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}'''
|
||||
tags = ["key", "AWS"]
|
||||
@@ -0,0 +1,17 @@
|
||||
module github.com/zricethezav/gitleaks/v7
|
||||
|
||||
go 1.16
|
||||
|
||||
replace github.com/go-git/go-git/v5 => github.com/zricethezav/go-git/v5 v5.2.2
|
||||
|
||||
require (
|
||||
github.com/BurntSushi/toml v0.3.1
|
||||
github.com/go-git/go-git/v5 v5.2.0
|
||||
github.com/google/go-cmp v0.4.0 // indirect
|
||||
github.com/hako/durafmt v0.0.0-20191009132224-3f39dc1ed9f4
|
||||
github.com/jessevdk/go-flags v1.4.0
|
||||
github.com/sergi/go-diff v1.1.0
|
||||
github.com/sirupsen/logrus v1.4.2
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9
|
||||
gopkg.in/yaml.v2 v2.2.8 // indirect
|
||||
)
|
||||
@@ -0,0 +1,96 @@
|
||||
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.2-0.20200613231340-f56387b50c12 h1:PbKy9zOy4aAKrJ5pibIRpVO2BXnK1Tlcg+caKI7Ox5M=
|
||||
github.com/go-git/go-git-fixtures/v4 v4.0.2-0.20200613231340-f56387b50c12/go.mod h1:m+ICp2rF3jDhFgEZ/8yziagdT1C+ZpZcrJjappBCDSw=
|
||||
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/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/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
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/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/ssh-agent v0.2.1 h1:TCbipTQL2JiiCprBWx9frJ2eJlCYT00NmctrHxVAr70=
|
||||
github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4=
|
||||
github.com/zricethezav/go-git/v5 v5.2.2 h1:VOVijF5OpIiHvFZXX94AJezdJ0b0kTyRyVNZ4yaqCRU=
|
||||
github.com/zricethezav/go-git/v5 v5.2.2/go.mod h1:kh02eMX+wdqqxgNMEyq8YgwlIOsDOa9homkUq1PoTMs=
|
||||
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-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/sync v0.0.0-20201020160332-67f06af15bc9 h1:SQFwaSi55rU7vdNs9Yr0Z324VNlrF+0wMqRXT4St8ck=
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/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-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=
|
||||
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/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
@@ -1,119 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"os/signal"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
type LeakElem struct {
|
||||
Line string `json:"line"`
|
||||
Commit string `json:"commit"`
|
||||
}
|
||||
|
||||
func start(opts *Options, repoUrl string) {
|
||||
c := make(chan os.Signal, 2)
|
||||
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
|
||||
|
||||
err := exec.Command("git", "clone", repoUrl).Run()
|
||||
if err != nil {
|
||||
log.Fatalf("failed to clone repo %v", err)
|
||||
}
|
||||
repoName := strings.Split(repoUrl, "/")[4]
|
||||
if err := os.Chdir(repoName); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
go func() {
|
||||
<-c
|
||||
cleanup(repoName)
|
||||
os.Exit(1)
|
||||
}()
|
||||
|
||||
report := getLeaks(repoName)
|
||||
cleanup(repoName)
|
||||
reportJson, _ := json.MarshalIndent(report, "", "\t")
|
||||
err = ioutil.WriteFile(fmt.Sprintf("%s_leaks.json", repoName), reportJson, 0644)
|
||||
}
|
||||
|
||||
func cleanup(repoName string) {
|
||||
if err := os.Chdir(appRoot); err != nil {
|
||||
log.Fatalf("failed cleaning up repo. Does the repo exist? %v", err)
|
||||
}
|
||||
err := exec.Command("rm", "-rf", repoName).Run()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func getLeaks(repoName string) []LeakElem {
|
||||
var (
|
||||
out []byte
|
||||
err error
|
||||
commitWG sync.WaitGroup
|
||||
gitLeakReceiverWG sync.WaitGroup
|
||||
concurrent = 100
|
||||
semaphoreChan = make(chan struct{}, concurrent)
|
||||
gitLeaks = make(chan LeakElem)
|
||||
report []LeakElem
|
||||
)
|
||||
|
||||
go func(commitWG *sync.WaitGroup, gitLeakReceiverWG *sync.WaitGroup) {
|
||||
for gitLeak := range gitLeaks {
|
||||
fmt.Println(gitLeak)
|
||||
report = append(report, gitLeak)
|
||||
gitLeakReceiverWG.Done()
|
||||
}
|
||||
}(&commitWG, &gitLeakReceiverWG)
|
||||
|
||||
out, err = exec.Command("git", "rev-list", "--all", "--remotes", "--topo-order").Output()
|
||||
if err != nil {
|
||||
log.Fatalf("error retrieving commits%v\n", err)
|
||||
}
|
||||
|
||||
commits := bytes.Split(out, []byte("\n"))
|
||||
commitWG.Add(len(commits))
|
||||
for _, currCommitB := range commits {
|
||||
currCommit := string(currCommitB)
|
||||
go func(currCommit string, repoName string, commitWG *sync.WaitGroup, gitLeakReceiverWG *sync.WaitGroup) {
|
||||
defer commitWG.Done()
|
||||
var leakPrs bool
|
||||
|
||||
if err := os.Chdir(fmt.Sprintf("%s/%s", appRoot, repoName)); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
commitCmp := fmt.Sprintf("%s^!", currCommit)
|
||||
semaphoreChan <- struct{}{}
|
||||
out, err := exec.Command("git", "diff", commitCmp).Output()
|
||||
<-semaphoreChan
|
||||
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
lines := checkRegex(string(out))
|
||||
if len(lines) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
for _, line := range lines {
|
||||
leakPrs = checkEntropy(line)
|
||||
if leakPrs {
|
||||
gitLeakReceiverWG.Add(1)
|
||||
gitLeaks <- LeakElem{line, currCommit}
|
||||
}
|
||||
}
|
||||
}(currCommit, repoName, &commitWG, &gitLeakReceiverWG)
|
||||
}
|
||||
|
||||
commitWG.Wait()
|
||||
gitLeakReceiverWG.Wait()
|
||||
return report
|
||||
}
|
||||
@@ -2,35 +2,73 @@ package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"regexp"
|
||||
)
|
||||
"os/signal"
|
||||
"time"
|
||||
|
||||
var (
|
||||
appRoot string
|
||||
regexes map[string]*regexp.Regexp
|
||||
assignRegex *regexp.Regexp
|
||||
)
|
||||
"github.com/zricethezav/gitleaks/v7/config"
|
||||
"github.com/zricethezav/gitleaks/v7/options"
|
||||
"github.com/zricethezav/gitleaks/v7/scan"
|
||||
|
||||
func init() {
|
||||
appRoot, _ = os.Getwd()
|
||||
// TODO update regex to look for things like:
|
||||
// TODO ability to add/filter regex
|
||||
// client("AKAI32fJ334...",
|
||||
regexes = map[string]*regexp.Regexp{
|
||||
"github": regexp.MustCompile(`[g|G][i|I][t|T][h|H][u|U][b|B].*(=|:|:=|<-).*\w+.*`),
|
||||
"aws": regexp.MustCompile(`[a|A][w|W][s|S].*(=|:=|:|<-).*\w+.*`),
|
||||
"heroku": regexp.MustCompile(`[h|H][e|E][r|R][o|O][k|K][u|U].*(=|:=|:|<-).*\w+.*`),
|
||||
"facebook": regexp.MustCompile(`[f|F][a|A][c|C][e|E][b|B][o|O][o|O][k|K].*(=|:=|:|<-).*\w+.*`),
|
||||
"twitter": regexp.MustCompile(`[t|T][w|W][i|I][t|T][t|T][e|E][r|R].*(=|:=|:|<-).*\w+.*`),
|
||||
"reddit": regexp.MustCompile(`[r|R][e|E][d|D][d|D][i|I][t|T].*(=|:=|:|<-).*\w+.*`),
|
||||
"twilio": regexp.MustCompile(`[t|T][w|W][i|I][l|L][i|I][o|O].*(=|:=|:|<-).*\w+.*`),
|
||||
}
|
||||
assignRegex = regexp.MustCompile(`(=|:|:=|<-)`)
|
||||
}
|
||||
"github.com/hako/durafmt"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func main() {
|
||||
args := os.Args[2:]
|
||||
repoUrl := os.Args[1]
|
||||
opts := parseOptions(args, repoUrl)
|
||||
start(opts, repoUrl)
|
||||
// this block sets up a go routine to listen for an interrupt signal
|
||||
// which will immediately exit gitleaks
|
||||
stopChan := make(chan os.Signal, 1)
|
||||
signal.Notify(stopChan, os.Interrupt)
|
||||
go listenForInterrupt(stopChan)
|
||||
|
||||
// setup options
|
||||
opts, err := options.ParseOptions()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
err = opts.Guard()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// setup configs
|
||||
cfg, err := config.NewConfig(opts)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// setup scanner
|
||||
scanner, err := scan.NewScanner(opts, cfg)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// run and time the scan
|
||||
start := time.Now()
|
||||
scannerReport, err := scanner.Scan()
|
||||
log.Info("scan time: ", durafmt.Parse(time.Now().Sub(start)))
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// report scan
|
||||
if err := scan.WriteReport(scannerReport, opts, cfg); err != nil {
|
||||
log.Error(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if len(scannerReport.Leaks) != 0 {
|
||||
os.Exit(opts.CodeOnLeak)
|
||||
}
|
||||
}
|
||||
|
||||
func listenForInterrupt(stopScan chan os.Signal) {
|
||||
<-stopScan
|
||||
log.Warn("halting gitleaks scan")
|
||||
os.Exit(1)
|
||||
}
|
||||
-69
@@ -1,69 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// TODO regex on type.. user/organization can be treated as the same:
|
||||
// hittps://github.com/<user or org>
|
||||
// hittps://github.com/<user or org>/repo
|
||||
const usage = `usage: gitleaks [git link] [options]
|
||||
|
||||
Options:
|
||||
-c Concurrency factor (potential number of git files open)
|
||||
-h --help Display this message
|
||||
`
|
||||
|
||||
type Options struct {
|
||||
Concurrency int
|
||||
}
|
||||
|
||||
func help() {
|
||||
os.Stderr.WriteString(usage)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
func optionsNextInt(args []string, i *int) int {
|
||||
if len(args) > *i+1 {
|
||||
*i++
|
||||
} else {
|
||||
help()
|
||||
}
|
||||
argInt, err := strconv.Atoi(args[*i])
|
||||
if err != nil {
|
||||
fmt.Printf("Invalid %s option: %s\n", args[*i-1], args[*i])
|
||||
help()
|
||||
}
|
||||
return argInt
|
||||
}
|
||||
|
||||
func optionsNextString(args []string, i *int) string {
|
||||
if len(args) > *i+1 {
|
||||
*i++
|
||||
} else {
|
||||
help()
|
||||
}
|
||||
return args[*i]
|
||||
}
|
||||
|
||||
func parseOptions(args []string, repoUrl string) *Options {
|
||||
opts := &Options{}
|
||||
for i := 0; i < len(args); i++ {
|
||||
arg := args[i]
|
||||
switch arg {
|
||||
case "-c":
|
||||
opts.Concurrency = optionsNextInt(args, &i)
|
||||
case "-h", "--help":
|
||||
help()
|
||||
return nil
|
||||
default:
|
||||
fmt.Printf("Uknown option %s\n\n", arg)
|
||||
help()
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
return opts
|
||||
}
|
||||
@@ -0,0 +1,218 @@
|
||||
package options
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/user"
|
||||
"strings"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v7/version"
|
||||
|
||||
"github.com/go-git/go-git/v5"
|
||||
"github.com/go-git/go-git/v5/plumbing"
|
||||
"github.com/go-git/go-git/v5/plumbing/transport"
|
||||
"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"
|
||||
)
|
||||
|
||||
// Options stores values of command line options
|
||||
type Options struct {
|
||||
Verbose bool `short:"v" long:"verbose" description:"Show verbose output from scan"`
|
||||
Quiet bool `short:"q" long:"quiet" description:"Sets log level to error and only output leaks, one json object per line"`
|
||||
RepoURL string `short:"r" long:"repo-url" description:"Repository URL"`
|
||||
Path string `short:"p" long:"path" description:"Path to directory (repo if contains .git) or file"`
|
||||
ConfigPath string `short:"c" long:"config-path" description:"Path to config"`
|
||||
RepoConfigPath string `long:"repo-config-path" description:"Path to gitleaks config relative to repo root"`
|
||||
ClonePath string `long:"clone-path" description:"Path to clone repo 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"`
|
||||
Threads int `long:"threads" description:"Maximum number of threads gitleaks spawns"`
|
||||
SSH string `long:"ssh-key" description:"Path to ssh key used for auth"`
|
||||
Unstaged bool `long:"unstaged" description:"Run gitleaks on unstaged code"`
|
||||
Branch string `long:"branch" description:"Branch to scan"`
|
||||
Redact bool `long:"redact" description:"Redact secrets from log messages and leaks"`
|
||||
Debug bool `long:"debug" description:"Log debug messages"`
|
||||
NoGit bool `long:"no-git" description:"Treat git repos as plain directories and scan those files"`
|
||||
CodeOnLeak int `long:"leaks-exit-code" default:"1" description:"Exit code when leaks have been encountered"`
|
||||
AppendRepoConfig bool `long:"append-repo-config" description:"Append the provided or default config with the repo config."`
|
||||
AdditionalConfig string `long:"additional-config" description:"Path to an additional gitleaks config to append with an existing config. Can be used with --append-repo-config to append up to three configurations"`
|
||||
|
||||
// Report Options
|
||||
Report string `short:"o" long:"report" description:"Report output path"`
|
||||
ReportFormat string `short:"f" long:"format" default:"json" description:"JSON, CSV, SARIF"`
|
||||
|
||||
// Commit Options
|
||||
FilesAtCommit string `long:"files-at-commit" description:"Sha of commit to scan all files at commit"`
|
||||
Commit string `long:"commit" description:"Sha of commit to scan or \"latest\" to scan the last commit of the repository"`
|
||||
Commits string `long:"commits" description:"Comma separated list of a commits to scan"`
|
||||
CommitsFile string `long:"commits-file" description:"Path to file of line separated list of commits to scan"`
|
||||
CommitFrom string `long:"commit-from" description:"Commit to start scan from"`
|
||||
CommitTo string `long:"commit-to" description:"Commit to stop scan"`
|
||||
CommitSince string `long:"commit-since" description:"Scan commits more recent than a specific date. Ex: '2006-01-02' or '2006-01-02T15:04:05-0700' format."`
|
||||
CommitUntil string `long:"commit-until" description:"Scan commits older than a specific date. Ex: '2006-01-02' or '2006-01-02T15:04:05-0700' format."`
|
||||
Depth int `long:"depth" description:"Number of commits to scan"`
|
||||
}
|
||||
|
||||
// ParseOptions is responsible for parsing options passed in by cli. An Options struct
|
||||
// is returned if successful. This struct is passed around the program
|
||||
// and will determine how the program executes. If err, an err message or help message
|
||||
// will be displayed and the program will exit with code 0.
|
||||
func ParseOptions() (Options, error) {
|
||||
var opts Options
|
||||
parser := flags.NewParser(&opts, flags.Default)
|
||||
_, err := parser.Parse()
|
||||
|
||||
if err != nil {
|
||||
if flagsErr, ok := err.(*flags.Error); ok && flagsErr.Type != flags.ErrHelp {
|
||||
parser.WriteHelp(os.Stdout)
|
||||
}
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
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(0)
|
||||
}
|
||||
|
||||
if opts.Debug {
|
||||
log.SetLevel(log.DebugLevel)
|
||||
}
|
||||
if opts.Quiet {
|
||||
log.SetLevel(log.ErrorLevel)
|
||||
}
|
||||
|
||||
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.RepoURL, opts.Path) {
|
||||
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) {
|
||||
var err error
|
||||
progress := ioutil.Discard
|
||||
if opts.Verbose {
|
||||
progress = os.Stdout
|
||||
}
|
||||
|
||||
cloneOpts := &git.CloneOptions{
|
||||
URL: opts.RepoURL,
|
||||
Progress: progress,
|
||||
}
|
||||
if opts.Depth != 0 {
|
||||
cloneOpts.Depth = opts.Depth
|
||||
}
|
||||
if opts.Branch != "" {
|
||||
cloneOpts.ReferenceName = plumbing.NewBranchReferenceName(opts.Branch)
|
||||
}
|
||||
|
||||
var auth transport.AuthMethod
|
||||
|
||||
if strings.HasPrefix(opts.RepoURL, "git") {
|
||||
// using git protocol so needs ssh auth
|
||||
auth, err = SSHAuth(opts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else if opts.Password != "" && opts.Username != "" {
|
||||
// auth using username and password
|
||||
auth = &http.BasicAuth{
|
||||
Username: opts.Username,
|
||||
Password: opts.Password,
|
||||
}
|
||||
} else if opts.AccessToken != "" {
|
||||
auth = &http.BasicAuth{
|
||||
Username: "gitleaks_user",
|
||||
Password: opts.AccessToken,
|
||||
}
|
||||
} else if os.Getenv("GITLEAKS_ACCESS_TOKEN") != "" {
|
||||
auth = &http.BasicAuth{
|
||||
Username: "gitleaks_user",
|
||||
Password: os.Getenv("GITLEAKS_ACCESS_TOKEN"),
|
||||
}
|
||||
}
|
||||
if auth != nil {
|
||||
cloneOpts.Auth = auth
|
||||
}
|
||||
return cloneOpts, 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.Unstaged || opts.Path != "" || opts.RepoURL == "" {
|
||||
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.Unstaged {
|
||||
return true
|
||||
}
|
||||
if opts == (Options{}) {
|
||||
return true
|
||||
}
|
||||
if opts.RepoURL != "" {
|
||||
return false
|
||||
}
|
||||
if opts.Path != "" {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
package options
|
||||
+158
@@ -0,0 +1,158 @@
|
||||
package scan
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v7/config"
|
||||
"github.com/zricethezav/gitleaks/v7/options"
|
||||
|
||||
"github.com/go-git/go-git/v5"
|
||||
fdiff "github.com/go-git/go-git/v5/plumbing/format/diff"
|
||||
"github.com/go-git/go-git/v5/plumbing/object"
|
||||
)
|
||||
|
||||
// CommitScanner is a commit scanner
|
||||
type CommitScanner struct {
|
||||
cfg config.Config
|
||||
opts options.Options
|
||||
repo *git.Repository
|
||||
repoName string
|
||||
commit *object.Commit
|
||||
}
|
||||
|
||||
// NewCommitScanner creates and returns a commit scanner
|
||||
func NewCommitScanner(opts options.Options, cfg config.Config, repo *git.Repository, commit *object.Commit) *CommitScanner {
|
||||
cs := &CommitScanner{
|
||||
cfg: cfg,
|
||||
opts: opts,
|
||||
repo: repo,
|
||||
commit: commit,
|
||||
repoName: getRepoName(opts),
|
||||
}
|
||||
return cs
|
||||
}
|
||||
|
||||
// SetRepoName sets the repo name of the scanner.
|
||||
func (cs *CommitScanner) SetRepoName(repoName string) {
|
||||
cs.repoName = repoName
|
||||
}
|
||||
|
||||
// Scan kicks off a CommitScanner Scan
|
||||
func (cs *CommitScanner) Scan() (Report, error) {
|
||||
var scannerReport Report
|
||||
|
||||
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.
|
||||
return
|
||||
}
|
||||
}()
|
||||
|
||||
if cs.cfg.Allowlist.CommitAllowed(cs.commit.Hash.String()) {
|
||||
return scannerReport, nil
|
||||
}
|
||||
|
||||
if len(cs.commit.ParentHashes) == 0 {
|
||||
facScanner := NewFilesAtCommitScanner(cs.opts, cs.cfg, cs.repo, cs.commit)
|
||||
return facScanner.Scan()
|
||||
}
|
||||
|
||||
parent, err := cs.commit.Parent(0)
|
||||
if err != nil {
|
||||
return scannerReport, err
|
||||
}
|
||||
|
||||
if parent == nil {
|
||||
return scannerReport, nil
|
||||
}
|
||||
|
||||
patch, err := parent.Patch(cs.commit)
|
||||
if err != nil || patch == nil {
|
||||
return scannerReport, fmt.Errorf("could not generate Patch")
|
||||
}
|
||||
|
||||
patchContent := patch.String()
|
||||
|
||||
for _, f := range patch.FilePatches() {
|
||||
if f.IsBinary() {
|
||||
continue
|
||||
}
|
||||
for _, chunk := range f.Chunks() {
|
||||
if chunk.Type() == fdiff.Add {
|
||||
_, to := f.Files()
|
||||
if cs.cfg.Allowlist.FileAllowed(filepath.Base(to.Path())) ||
|
||||
cs.cfg.Allowlist.PathAllowed(to.Path()) {
|
||||
continue
|
||||
}
|
||||
|
||||
// Check individual file path ONLY rules
|
||||
for _, rule := range cs.cfg.Rules {
|
||||
if rule.CommitAllowed(cs.commit.Hash.String()) {
|
||||
continue
|
||||
}
|
||||
|
||||
if rule.HasFileOrPathLeakOnly(to.Path()) {
|
||||
leak := NewLeak("", "Filename or path offender: "+to.Path(), defaultLineNumber).WithCommit(cs.commit)
|
||||
leak.Repo = cs.repoName
|
||||
leak.File = to.Path()
|
||||
leak.RepoURL = cs.opts.RepoURL
|
||||
leak.LeakURL = leak.URL()
|
||||
leak.Rule = rule.Description
|
||||
leak.Tags = strings.Join(rule.Tags, ", ")
|
||||
|
||||
leak.Log(cs.opts)
|
||||
|
||||
scannerReport.Leaks = append(scannerReport.Leaks, leak)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
lineLookup := make(map[string]bool)
|
||||
|
||||
// Check the actual content
|
||||
for _, line := range strings.Split(chunk.Content(), "\n") {
|
||||
for _, rule := range cs.cfg.Rules {
|
||||
if rule.AllowList.FileAllowed(filepath.Base(to.Path())) ||
|
||||
rule.AllowList.PathAllowed(to.Path()) ||
|
||||
rule.AllowList.CommitAllowed(cs.commit.Hash.String()) {
|
||||
continue
|
||||
}
|
||||
offender := rule.Inspect(line)
|
||||
if offender == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
if cs.cfg.Allowlist.RegexAllowed(line) {
|
||||
continue
|
||||
}
|
||||
|
||||
if rule.File.String() != "" && !rule.HasFileLeak(filepath.Base(to.Path())) {
|
||||
continue
|
||||
}
|
||||
if rule.Path.String() != "" && !rule.HasFilePathLeak(to.Path()) {
|
||||
continue
|
||||
}
|
||||
|
||||
leak := NewLeak(line, offender, defaultLineNumber).WithCommit(cs.commit)
|
||||
leak.File = to.Path()
|
||||
leak.LineNumber = extractLine(patchContent, leak, lineLookup)
|
||||
leak.RepoURL = cs.opts.RepoURL
|
||||
leak.Repo = cs.repoName
|
||||
leak.LeakURL = leak.URL()
|
||||
leak.Rule = rule.Description
|
||||
leak.Tags = strings.Join(rule.Tags, ", ")
|
||||
|
||||
leak.Log(cs.opts)
|
||||
|
||||
scannerReport.Leaks = append(scannerReport.Leaks, leak)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
scannerReport.Commits = 1
|
||||
return scannerReport, nil
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package scan
|
||||
|
||||
import (
|
||||
"github.com/go-git/go-git/v5"
|
||||
"github.com/zricethezav/gitleaks/v7/config"
|
||||
"github.com/zricethezav/gitleaks/v7/options"
|
||||
)
|
||||
|
||||
// CommitsScanner is a commit scanner
|
||||
type CommitsScanner struct {
|
||||
opts options.Options
|
||||
cfg config.Config
|
||||
|
||||
repo *git.Repository
|
||||
repoName string
|
||||
commits []string
|
||||
}
|
||||
|
||||
// NewCommitsScanner creates and returns a commits scanner, notice the 's' in commits
|
||||
func NewCommitsScanner(opts options.Options, cfg config.Config, repo *git.Repository, commits []string) *CommitsScanner {
|
||||
return &CommitsScanner{
|
||||
opts: opts,
|
||||
cfg: cfg,
|
||||
repo: repo,
|
||||
commits: commits,
|
||||
repoName: getRepoName(opts),
|
||||
}
|
||||
}
|
||||
|
||||
// Scan kicks off a CommitsScanner Scan
|
||||
func (css *CommitsScanner) Scan() (Report, error) {
|
||||
var scannerReport Report
|
||||
for _, c := range css.commits {
|
||||
c, err := obtainCommit(css.repo, c)
|
||||
if err != nil {
|
||||
return scannerReport, nil
|
||||
}
|
||||
cs := NewCommitScanner(css.opts, css.cfg, css.repo, c)
|
||||
commitReport, err := cs.Scan()
|
||||
if err != nil {
|
||||
return scannerReport, err
|
||||
}
|
||||
scannerReport.Leaks = append(scannerReport.Leaks, commitReport.Leaks...)
|
||||
scannerReport.Commits++
|
||||
}
|
||||
return scannerReport, nil
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
package scan
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v7/config"
|
||||
"github.com/zricethezav/gitleaks/v7/options"
|
||||
|
||||
"github.com/go-git/go-git/v5"
|
||||
"github.com/go-git/go-git/v5/plumbing/object"
|
||||
)
|
||||
|
||||
// FilesAtCommitScanner is a files at commit scanner. This differs from CommitScanner
|
||||
// as CommitScanner generates patches that are scanned. FilesAtCommitScanner instead looks at
|
||||
// files available at a commit's worktree and scans the entire content of said files.
|
||||
// Apologies for the awful struct name...
|
||||
type FilesAtCommitScanner struct {
|
||||
opts options.Options
|
||||
cfg config.Config
|
||||
repo *git.Repository
|
||||
commit *object.Commit
|
||||
repoName string
|
||||
}
|
||||
|
||||
// NewFilesAtCommitScanner creates and returns a files at commit scanner
|
||||
func NewFilesAtCommitScanner(opts options.Options, cfg config.Config, repo *git.Repository, commit *object.Commit) *FilesAtCommitScanner {
|
||||
fs := &FilesAtCommitScanner{
|
||||
opts: opts,
|
||||
cfg: cfg,
|
||||
repo: repo,
|
||||
commit: commit,
|
||||
repoName: getRepoName(opts),
|
||||
}
|
||||
return fs
|
||||
}
|
||||
|
||||
// Scan kicks off a FilesAtCommitScanner Scan
|
||||
func (fs *FilesAtCommitScanner) Scan() (Report, error) {
|
||||
var scannerReport Report
|
||||
|
||||
if fs.cfg.Allowlist.CommitAllowed(fs.commit.Hash.String()) {
|
||||
return scannerReport, nil
|
||||
}
|
||||
|
||||
fIter, err := fs.commit.Files()
|
||||
if err != nil {
|
||||
return scannerReport, err
|
||||
}
|
||||
|
||||
err = fIter.ForEach(func(f *object.File) error {
|
||||
bin, err := f.IsBinary()
|
||||
if bin {
|
||||
return nil
|
||||
} else if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if fs.cfg.Allowlist.FileAllowed(filepath.Base(f.Name)) ||
|
||||
fs.cfg.Allowlist.PathAllowed(f.Name) {
|
||||
return nil
|
||||
}
|
||||
|
||||
content, err := f.Contents()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Check individual file path ONLY rules
|
||||
for _, rule := range fs.cfg.Rules {
|
||||
if rule.CommitAllowed(fs.commit.Hash.String()) {
|
||||
continue
|
||||
}
|
||||
|
||||
if rule.HasFileOrPathLeakOnly(f.Name) {
|
||||
leak := NewLeak("", "Filename or path offender: "+f.Name, defaultLineNumber).WithCommit(fs.commit)
|
||||
leak.Repo = fs.repoName
|
||||
leak.File = f.Name
|
||||
leak.RepoURL = fs.opts.RepoURL
|
||||
leak.LeakURL = leak.URL()
|
||||
leak.Rule = rule.Description
|
||||
leak.Tags = strings.Join(rule.Tags, ", ")
|
||||
|
||||
leak.Log(fs.opts)
|
||||
|
||||
scannerReport.Leaks = append(scannerReport.Leaks, leak)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
for i, line := range strings.Split(content, "\n") {
|
||||
for _, rule := range fs.cfg.Rules {
|
||||
if rule.AllowList.FileAllowed(filepath.Base(f.Name)) ||
|
||||
rule.AllowList.PathAllowed(f.Name) ||
|
||||
rule.AllowList.CommitAllowed(fs.commit.Hash.String()) {
|
||||
continue
|
||||
}
|
||||
|
||||
offender := rule.Inspect(line)
|
||||
|
||||
if offender == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
if fs.cfg.Allowlist.RegexAllowed(line) {
|
||||
continue
|
||||
}
|
||||
|
||||
if rule.File.String() != "" && !rule.HasFileLeak(filepath.Base(f.Name)) {
|
||||
continue
|
||||
}
|
||||
if rule.Path.String() != "" && !rule.HasFilePathLeak(f.Name) {
|
||||
continue
|
||||
}
|
||||
|
||||
leak := NewLeak(line, offender, defaultLineNumber).WithCommit(fs.commit)
|
||||
leak.File = f.Name
|
||||
leak.LineNumber = i + 1
|
||||
leak.RepoURL = fs.opts.RepoURL
|
||||
leak.Repo = fs.repoName
|
||||
leak.LeakURL = leak.URL()
|
||||
leak.Rule = rule.Description
|
||||
leak.Tags = strings.Join(rule.Tags, ", ")
|
||||
|
||||
leak.Log(fs.opts)
|
||||
|
||||
scannerReport.Leaks = append(scannerReport.Leaks, leak)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
scannerReport.Commits = 1
|
||||
return scannerReport, err
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package scan
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v7/options"
|
||||
|
||||
"github.com/go-git/go-git/v5/plumbing/object"
|
||||
)
|
||||
|
||||
// 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"`
|
||||
RepoURL string `json:"repoURL"`
|
||||
LeakURL string `json:"leakURL"`
|
||||
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"`
|
||||
}
|
||||
|
||||
// RedactLeak will replace the offending string with "REDACTED" in both
|
||||
// the offender and line field of the leak which.
|
||||
func RedactLeak(leak Leak) Leak {
|
||||
leak.Line = strings.Replace(leak.Line, leak.Offender, "REDACTED", -1)
|
||||
leak.Offender = "REDACTED"
|
||||
return leak
|
||||
}
|
||||
|
||||
// NewLeak creates a new leak from common data all leaks must have, line, offender, linenumber
|
||||
func NewLeak(line string, offender string, lineNumber int) Leak {
|
||||
return Leak{
|
||||
Line: line,
|
||||
Offender: offender,
|
||||
LineNumber: lineNumber,
|
||||
}
|
||||
}
|
||||
|
||||
// WithCommit adds commit data to the leak
|
||||
func (leak Leak) WithCommit(commit *object.Commit) Leak {
|
||||
leak.Commit = commit.Hash.String()
|
||||
leak.Author = commit.Author.Name
|
||||
leak.Email = commit.Author.Email
|
||||
leak.Message = commit.Message
|
||||
leak.Date = commit.Author.When
|
||||
return leak
|
||||
}
|
||||
|
||||
// Log logs a leak and redacts if necessary
|
||||
func (leak Leak) Log(opts options.Options) {
|
||||
if !opts.Quiet && !opts.Verbose {
|
||||
return
|
||||
}
|
||||
if opts.Redact {
|
||||
leak = RedactLeak(leak)
|
||||
}
|
||||
if opts.Quiet {
|
||||
var b []byte
|
||||
b, _ = json.Marshal(leak)
|
||||
fmt.Println(string(b))
|
||||
} else {
|
||||
var b []byte
|
||||
b, _ = json.MarshalIndent(leak, "", " ")
|
||||
fmt.Println(string(b))
|
||||
}
|
||||
}
|
||||
|
||||
// URL generates a url to the leak if leak.RepoURL is set
|
||||
func (leak Leak) URL() string {
|
||||
if leak.RepoURL != "" {
|
||||
return fmt.Sprintf("%s/blob/%s/%s#L%d", leak.RepoURL, leak.Commit, leak.File, leak.LineNumber)
|
||||
}
|
||||
return ""
|
||||
}
|
||||
+154
@@ -0,0 +1,154 @@
|
||||
package scan
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"context"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v7/config"
|
||||
"github.com/zricethezav/gitleaks/v7/options"
|
||||
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
|
||||
// NoGitScanner is a scanner that absolutely despises git
|
||||
type NoGitScanner struct {
|
||||
opts options.Options
|
||||
cfg config.Config
|
||||
}
|
||||
|
||||
// NewNoGitScanner creates and returns a nogit scanner. This is used for scanning files and directories
|
||||
func NewNoGitScanner(opts options.Options, cfg config.Config) *NoGitScanner {
|
||||
ngs := &NoGitScanner{
|
||||
opts: opts,
|
||||
cfg: cfg,
|
||||
}
|
||||
|
||||
// no-git scans should ignore .git folders by default
|
||||
// issue: https://github.com/zricethezav/gitleaks/issues/474
|
||||
// ngs.cfg.Allowlist
|
||||
err := ngs.cfg.Allowlist.IgnoreDotGit()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return nil
|
||||
}
|
||||
return ngs
|
||||
}
|
||||
|
||||
// Scan kicks off a NoGitScanner Scan
|
||||
func (ngs *NoGitScanner) Scan() (Report, error) {
|
||||
var scannerReport Report
|
||||
|
||||
g, _ := errgroup.WithContext(context.Background())
|
||||
paths := make(chan string, 100)
|
||||
|
||||
g.Go(func() error {
|
||||
defer close(paths)
|
||||
return filepath.Walk(ngs.opts.Path,
|
||||
func(path string, fInfo os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if fInfo.Mode().IsRegular() {
|
||||
paths <- path
|
||||
}
|
||||
return nil
|
||||
})
|
||||
})
|
||||
|
||||
leaks := make(chan Leak, 100)
|
||||
|
||||
for path := range paths {
|
||||
p := path
|
||||
g.Go(func() error {
|
||||
if ngs.cfg.Allowlist.FileAllowed(filepath.Base(p)) ||
|
||||
ngs.cfg.Allowlist.PathAllowed(p) {
|
||||
return nil
|
||||
}
|
||||
|
||||
for _, rule := range ngs.cfg.Rules {
|
||||
if rule.HasFileOrPathLeakOnly(p) {
|
||||
leak := NewLeak("", "Filename or path offender: "+p, defaultLineNumber)
|
||||
relPath, err := filepath.Rel(ngs.opts.Path, p)
|
||||
if err != nil {
|
||||
leak.File = p
|
||||
} else {
|
||||
leak.File = relPath
|
||||
}
|
||||
leak.Rule = rule.Description
|
||||
leak.Tags = strings.Join(rule.Tags, ", ")
|
||||
|
||||
leak.Log(ngs.opts)
|
||||
|
||||
leaks <- leak
|
||||
}
|
||||
}
|
||||
|
||||
f, err := os.Open(p) // #nosec
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
scanner := bufio.NewScanner(f)
|
||||
lineNumber := 0
|
||||
for scanner.Scan() {
|
||||
lineNumber++
|
||||
for _, rule := range ngs.cfg.Rules {
|
||||
line := scanner.Text()
|
||||
|
||||
if rule.AllowList.FileAllowed(filepath.Base(p)) ||
|
||||
rule.AllowList.PathAllowed(p) {
|
||||
continue
|
||||
}
|
||||
|
||||
offender := rule.Inspect(line)
|
||||
if offender == "" {
|
||||
continue
|
||||
}
|
||||
if ngs.cfg.Allowlist.RegexAllowed(line) {
|
||||
continue
|
||||
}
|
||||
|
||||
if rule.File.String() != "" && !rule.HasFileLeak(filepath.Base(p)) {
|
||||
continue
|
||||
}
|
||||
if rule.Path.String() != "" && !rule.HasFilePathLeak(p) {
|
||||
continue
|
||||
}
|
||||
|
||||
leak := NewLeak(line, offender, defaultLineNumber)
|
||||
relPath, err := filepath.Rel(ngs.opts.Path, p)
|
||||
if err != nil {
|
||||
leak.File = p
|
||||
} else {
|
||||
leak.File = relPath
|
||||
}
|
||||
leak.LineNumber = lineNumber
|
||||
leak.Rule = rule.Description
|
||||
leak.Tags = strings.Join(rule.Tags, ", ")
|
||||
|
||||
leak.Log(ngs.opts)
|
||||
|
||||
leaks <- leak
|
||||
}
|
||||
}
|
||||
return f.Close()
|
||||
})
|
||||
}
|
||||
|
||||
go func() {
|
||||
if err := g.Wait(); err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
close(leaks)
|
||||
}()
|
||||
|
||||
for leak := range leaks {
|
||||
scannerReport.Leaks = append(scannerReport.Leaks, leak)
|
||||
}
|
||||
|
||||
return scannerReport, g.Wait()
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package scan
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v7/options"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v7/config"
|
||||
|
||||
"github.com/go-git/go-git/v5"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// ParentScanner is a parent directory scanner
|
||||
type ParentScanner struct {
|
||||
cfg config.Config
|
||||
opts options.Options
|
||||
}
|
||||
|
||||
// NewParentScanner creates and returns a directory scanner
|
||||
func NewParentScanner(opts options.Options, cfg config.Config) *ParentScanner {
|
||||
ds := &ParentScanner{
|
||||
opts: opts,
|
||||
cfg: cfg,
|
||||
}
|
||||
return ds
|
||||
}
|
||||
|
||||
// Scan kicks off a ParentScanner scan. This uses the directory from --path to discovery repos
|
||||
func (ds *ParentScanner) Scan() (Report, error) {
|
||||
var scannerReport Report
|
||||
log.Debugf("scanning repos in %s\n", ds.opts.Path)
|
||||
|
||||
files, err := ioutil.ReadDir(ds.opts.Path)
|
||||
if err != nil {
|
||||
return scannerReport, err
|
||||
}
|
||||
for _, f := range files {
|
||||
if !f.IsDir() {
|
||||
continue
|
||||
}
|
||||
|
||||
repo, err := git.PlainOpen(filepath.Join(ds.opts.Path, f.Name()))
|
||||
if err != nil {
|
||||
if err.Error() == "repository does not exist" {
|
||||
log.Debugf("%s is not a git repository", f.Name())
|
||||
continue
|
||||
}
|
||||
return scannerReport, err
|
||||
}
|
||||
if ds.cfg.Allowlist.RepoAllowed(f.Name()) {
|
||||
continue
|
||||
}
|
||||
|
||||
if ds.opts.RepoConfigPath != "" {
|
||||
cfg, err := config.LoadRepoConfig(repo, ds.opts.RepoConfigPath)
|
||||
if err != nil {
|
||||
log.Warn(err)
|
||||
} else {
|
||||
ds.cfg = cfg
|
||||
}
|
||||
}
|
||||
|
||||
rs := NewRepoScanner(ds.opts, ds.cfg, repo)
|
||||
rs.repoName = f.Name()
|
||||
repoReport, err := rs.Scan()
|
||||
if err != nil {
|
||||
return scannerReport, err
|
||||
}
|
||||
scannerReport.Leaks = append(scannerReport.Leaks, repoReport.Leaks...)
|
||||
scannerReport.Commits += repoReport.Commits
|
||||
}
|
||||
return scannerReport, nil
|
||||
}
|
||||
+118
@@ -0,0 +1,118 @@
|
||||
package scan
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"golang.org/x/sync/errgroup"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v7/config"
|
||||
"github.com/zricethezav/gitleaks/v7/options"
|
||||
|
||||
"github.com/go-git/go-git/v5"
|
||||
"github.com/go-git/go-git/v5/plumbing/object"
|
||||
"github.com/go-git/go-git/v5/plumbing/storer"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// RepoScanner is a repo scanner
|
||||
type RepoScanner struct {
|
||||
opts options.Options
|
||||
cfg config.Config
|
||||
repo *git.Repository
|
||||
throttle *Throttle
|
||||
repoName string
|
||||
}
|
||||
|
||||
// NewRepoScanner returns a new repo scanner (go figure). This function also
|
||||
// sets up the leak listener for multi-threaded awesomeness.
|
||||
func NewRepoScanner(opts options.Options, cfg config.Config, repo *git.Repository) *RepoScanner {
|
||||
rs := &RepoScanner{
|
||||
opts: opts,
|
||||
cfg: cfg,
|
||||
repo: repo,
|
||||
throttle: NewThrottle(opts),
|
||||
repoName: getRepoName(opts),
|
||||
}
|
||||
|
||||
return rs
|
||||
}
|
||||
|
||||
// Scan kicks of a repo scan
|
||||
func (rs *RepoScanner) Scan() (Report, error) {
|
||||
var (
|
||||
scannerReport Report
|
||||
commits chan *object.Commit
|
||||
)
|
||||
logOpts, err := logOptions(rs.repo, rs.opts)
|
||||
if err != nil {
|
||||
return scannerReport, err
|
||||
}
|
||||
cIter, err := rs.repo.Log(logOpts)
|
||||
if err != nil {
|
||||
return scannerReport, err
|
||||
}
|
||||
|
||||
g, _ := errgroup.WithContext(context.Background())
|
||||
commits = make(chan *object.Commit)
|
||||
leaks := make(chan Leak)
|
||||
|
||||
commitNum := 0
|
||||
g.Go(func() error {
|
||||
defer close(commits)
|
||||
err = cIter.ForEach(func(c *object.Commit) error {
|
||||
if c == nil || depthReached(commitNum, rs.opts) {
|
||||
return storer.ErrStop
|
||||
}
|
||||
|
||||
if rs.cfg.Allowlist.CommitAllowed(c.Hash.String()) {
|
||||
return nil
|
||||
}
|
||||
commitNum++
|
||||
commits <- c
|
||||
if c.Hash.String() == rs.opts.CommitTo {
|
||||
return storer.ErrStop
|
||||
}
|
||||
|
||||
return err
|
||||
})
|
||||
cIter.Close()
|
||||
return nil
|
||||
})
|
||||
|
||||
for commit := range commits {
|
||||
c := commit
|
||||
rs.throttle.Limit()
|
||||
g.Go(func() error {
|
||||
commitScanner := NewCommitScanner(rs.opts, rs.cfg, rs.repo, c)
|
||||
commitScanner.SetRepoName(rs.repoName)
|
||||
report, err := commitScanner.Scan()
|
||||
rs.throttle.Release()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
for _, leak := range report.Leaks {
|
||||
leaks <- leak
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
go func() {
|
||||
if err := g.Wait(); err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
close(leaks)
|
||||
}()
|
||||
|
||||
for leak := range leaks {
|
||||
scannerReport.Leaks = append(scannerReport.Leaks, leak)
|
||||
}
|
||||
|
||||
scannerReport.Commits = commitNum
|
||||
return scannerReport, g.Wait()
|
||||
}
|
||||
|
||||
// SetRepoName sets the repo name
|
||||
func (rs *RepoScanner) SetRepoName(repoName string) {
|
||||
rs.repoName = repoName
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package scan
|
||||
|
||||
import (
|
||||
"encoding/csv"
|
||||
"encoding/json"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/zricethezav/gitleaks/v7/config"
|
||||
"github.com/zricethezav/gitleaks/v7/options"
|
||||
"github.com/zricethezav/gitleaks/v7/version"
|
||||
)
|
||||
|
||||
// Report is a container for leaks and number of commits scanned
|
||||
type Report struct {
|
||||
Leaks []Leak
|
||||
Commits int
|
||||
}
|
||||
|
||||
// WriteReport accepts a report and options and will write a report if --report has been set
|
||||
func WriteReport(report Report, opts options.Options, cfg config.Config) error {
|
||||
if !(opts.NoGit || opts.CheckUncommitted()) {
|
||||
logrus.Info("commits scanned: ", report.Commits)
|
||||
}
|
||||
if len(report.Leaks) != 0 {
|
||||
logrus.Warn("leaks found: ", len(report.Leaks))
|
||||
} else {
|
||||
logrus.Info("No leaks found")
|
||||
}
|
||||
|
||||
if opts.Report == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
if opts.Redact {
|
||||
var redactedLeaks []Leak
|
||||
for _, leak := range report.Leaks {
|
||||
redactedLeaks = append(redactedLeaks, RedactLeak(leak))
|
||||
}
|
||||
report.Leaks = redactedLeaks
|
||||
}
|
||||
|
||||
file, err := os.Create(opts.Report)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer rable(file.Close)
|
||||
|
||||
if opts.Report != "" {
|
||||
switch opts.ReportFormat {
|
||||
case "json":
|
||||
encoder := json.NewEncoder(file)
|
||||
encoder.SetIndent("", " ")
|
||||
err = encoder.Encode(report.Leaks)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
case "csv":
|
||||
w := csv.NewWriter(file)
|
||||
err = w.Write([]string{"repo", "line", "commit", "offender", "leakURL", "rule", "tags", "commitMsg", "author", "email", "file", "date"})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, leak := range report.Leaks {
|
||||
err := w.Write([]string{leak.Repo, leak.Line, leak.Commit, leak.Offender, leak.LeakURL, leak.Rule, leak.Tags, leak.Message, leak.Author, leak.Email, leak.File, leak.Date.Format(time.RFC3339)})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
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: configToRules(cfg),
|
||||
},
|
||||
},
|
||||
Results: leaksToResults(report.Leaks),
|
||||
},
|
||||
},
|
||||
}
|
||||
encoder := json.NewEncoder(file)
|
||||
encoder.SetIndent("", " ")
|
||||
err = encoder.Encode(s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
+156
@@ -0,0 +1,156 @@
|
||||
package scan
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v7/config"
|
||||
)
|
||||
|
||||
//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"`
|
||||
Repo string `json:"repo"`
|
||||
}
|
||||
|
||||
//Runs ...
|
||||
type Runs struct {
|
||||
Tool Tool `json:"tool"`
|
||||
Results []Results `json:"results"`
|
||||
}
|
||||
|
||||
func configToRules(cfg config.Config) []Rules {
|
||||
var rules []Rules
|
||||
for _, rule := range cfg.Rules {
|
||||
rules = append(rules, Rules{
|
||||
ID: rule.Description,
|
||||
Name: rule.Description,
|
||||
})
|
||||
}
|
||||
return rules
|
||||
}
|
||||
|
||||
func leaksToResults(leaks []Leak) []Results {
|
||||
results := make([]Results, 0)
|
||||
|
||||
for _, leak := range 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,
|
||||
Repo: leak.Repo,
|
||||
},
|
||||
Locations: leakToLocation(leak),
|
||||
})
|
||||
}
|
||||
|
||||
return results
|
||||
}
|
||||
|
||||
func leakToLocation(leak Leak) []Locations {
|
||||
uri := leak.File
|
||||
if leak.LeakURL != "" {
|
||||
uri = leak.LeakURL
|
||||
}
|
||||
return []Locations{
|
||||
{
|
||||
PhysicalLocation: PhysicalLocation{
|
||||
ArtifactLocation: ArtifactLocation{
|
||||
URI: uri,
|
||||
},
|
||||
Region: Region{
|
||||
StartLine: leak.LineNumber,
|
||||
Snippet: Snippet{
|
||||
Text: leak.Line,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
+164
@@ -0,0 +1,164 @@
|
||||
package scan
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/go-git/go-git/v5"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v7/config"
|
||||
"github.com/zricethezav/gitleaks/v7/options"
|
||||
)
|
||||
|
||||
// Scanner abstracts unique scanner internals while exposing the Scan function which
|
||||
// returns a report.
|
||||
type Scanner interface {
|
||||
Scan() (Report, error)
|
||||
}
|
||||
|
||||
// ScannerType is the scanner type which is determined based on program arguments
|
||||
type ScannerType int
|
||||
|
||||
const (
|
||||
typeRepoScanner ScannerType = iota + 1
|
||||
typeDirScanner
|
||||
typeCommitScanner
|
||||
typeCommitsScanner
|
||||
typeUnstagedScanner
|
||||
typeFilesAtCommitScanner
|
||||
typeNoGitScanner
|
||||
typeEmpty
|
||||
)
|
||||
|
||||
// NewScanner accepts options and a config which will be used to determine and create a
|
||||
// new scanner which is then returned.
|
||||
func NewScanner(opts options.Options, cfg config.Config) (Scanner, error) {
|
||||
var (
|
||||
repo *git.Repository
|
||||
err error
|
||||
)
|
||||
|
||||
// We want to return a dir scanner immediately since if the scan type is a directory scan
|
||||
// we don't want to clone/open a repo until inside ParentScanner.Scan
|
||||
st, err := scanType(opts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if st == typeDirScanner {
|
||||
if opts.AdditionalConfig != "" {
|
||||
additionalCfg, err := config.LoadAdditionalConfig(opts.AdditionalConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cfg = cfg.AppendConfig(additionalCfg)
|
||||
}
|
||||
return NewParentScanner(opts, cfg), nil
|
||||
}
|
||||
|
||||
// Clone or open a repo if we need it
|
||||
if needsRepo(st) {
|
||||
repo, err = getRepo(opts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
// load up alternative config if possible, if not use default/specified config. Will append if AppendRepoConfig is true
|
||||
if opts.RepoConfigPath != "" && !opts.NoGit {
|
||||
repoCfg, err := config.LoadRepoConfig(repo, opts.RepoConfigPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if opts.AppendRepoConfig {
|
||||
cfg = cfg.AppendConfig(repoCfg)
|
||||
} else {
|
||||
cfg = repoCfg
|
||||
}
|
||||
}
|
||||
|
||||
// append additional config with the rest of the config
|
||||
if opts.AdditionalConfig != "" {
|
||||
additionalCfg, err := config.LoadAdditionalConfig(opts.AdditionalConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cfg = cfg.AppendConfig(additionalCfg)
|
||||
}
|
||||
|
||||
switch st {
|
||||
case typeCommitScanner:
|
||||
c, err := obtainCommit(repo, opts.Commit)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return NewCommitScanner(opts, cfg, repo, c), nil
|
||||
case typeCommitsScanner:
|
||||
commits, err := optsToCommits(opts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return NewCommitsScanner(opts, cfg, repo, commits), nil
|
||||
case typeFilesAtCommitScanner:
|
||||
c, err := obtainCommit(repo, opts.FilesAtCommit)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return NewFilesAtCommitScanner(opts, cfg, repo, c), nil
|
||||
case typeUnstagedScanner:
|
||||
return NewUnstagedScanner(opts, cfg, repo), nil
|
||||
case typeDirScanner:
|
||||
return NewParentScanner(opts, cfg), nil
|
||||
case typeNoGitScanner:
|
||||
return NewNoGitScanner(opts, cfg), nil
|
||||
default:
|
||||
return NewRepoScanner(opts, cfg, repo), nil
|
||||
}
|
||||
}
|
||||
|
||||
func scanType(opts options.Options) (ScannerType, error) {
|
||||
if opts.Commit != "" {
|
||||
return typeCommitScanner, nil
|
||||
}
|
||||
if opts.Commits != "" || opts.CommitsFile != "" {
|
||||
return typeCommitsScanner, nil
|
||||
}
|
||||
if opts.FilesAtCommit != "" {
|
||||
return typeFilesAtCommitScanner, nil
|
||||
}
|
||||
if opts.Path != "" && !opts.NoGit {
|
||||
if opts.CheckUncommitted() {
|
||||
return typeUnstagedScanner, nil
|
||||
}
|
||||
_, err := os.Stat(filepath.Join(opts.Path))
|
||||
if err != nil {
|
||||
return typeEmpty, err
|
||||
}
|
||||
// check if path/.git exists, if it does, this is a repo scan
|
||||
// if not this is a multi-repo scan
|
||||
_, err = os.Stat(filepath.Join(opts.Path, ".git"))
|
||||
if os.IsNotExist(err) {
|
||||
return typeDirScanner, nil
|
||||
}
|
||||
return typeRepoScanner, nil
|
||||
}
|
||||
if opts.Path != "" && opts.NoGit {
|
||||
_, err := os.Stat(filepath.Join(opts.Path))
|
||||
if err != nil {
|
||||
return typeEmpty, err
|
||||
}
|
||||
return typeNoGitScanner, nil
|
||||
}
|
||||
if opts.CheckUncommitted() {
|
||||
return typeUnstagedScanner, nil
|
||||
}
|
||||
|
||||
// default to the most commonly used scanner, RepoScanner
|
||||
return typeRepoScanner, nil
|
||||
}
|
||||
|
||||
func needsRepo(st ScannerType) bool {
|
||||
if !(st == typeDirScanner || st == typeNoGitScanner) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -0,0 +1,843 @@
|
||||
package scan
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"runtime"
|
||||
"testing"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v7/config"
|
||||
"github.com/zricethezav/gitleaks/v7/options"
|
||||
)
|
||||
|
||||
const testRepoBase = "../test_data/test_repos/"
|
||||
|
||||
func TestScan(t *testing.T) {
|
||||
err := moveDotGit("dotGit", ".git")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer moveDotGit(".git", "dotGit")
|
||||
tests := []struct {
|
||||
description string
|
||||
opts options.Options
|
||||
wantPath string
|
||||
wantErr error
|
||||
wantScanErr error
|
||||
emptyRepo bool
|
||||
wantEmpty bool
|
||||
}{
|
||||
{
|
||||
description: "test local repo one aws leak",
|
||||
opts: options.Options{
|
||||
Path: "../test_data/test_repos/test_repo_1",
|
||||
Report: "../test_data/test_local_repo_one_aws_leak.json.got",
|
||||
ReportFormat: "json",
|
||||
Threads: runtime.GOMAXPROCS(0),
|
||||
},
|
||||
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),
|
||||
Path: "../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{
|
||||
Path: "../test_data/test_repos/no_repo_here",
|
||||
ReportFormat: "json",
|
||||
},
|
||||
wantErr: fmt.Errorf("stat ../test_data/test_repos/no_repo_here: no such file or directory"),
|
||||
emptyRepo: true,
|
||||
},
|
||||
{
|
||||
description: "test local repo one aws leak allowlisted",
|
||||
opts: options.Options{
|
||||
Path: "../test_data/test_repos/test_repo_1",
|
||||
ReportFormat: "json",
|
||||
ConfigPath: "../test_data/test_configs/aws_key_allowlist_python_files.toml",
|
||||
},
|
||||
wantEmpty: true,
|
||||
},
|
||||
{
|
||||
description: "test local repo two leaks",
|
||||
opts: options.Options{
|
||||
Path: "../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{
|
||||
Path: "../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{
|
||||
Path: "../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 to from Commit",
|
||||
opts: options.Options{
|
||||
Path: "../test_data/test_repos/test_repo_2",
|
||||
Report: "../test_data/test_local_repo_two_leaks_commit_to_from.json.got",
|
||||
ReportFormat: "json",
|
||||
CommitFrom: "d8ac0b73aeeb45843319cdc5ce506516eb49bf7a",
|
||||
CommitTo: "51f6dcf6b89b93f4075ba92c400b075631a6cc93",
|
||||
},
|
||||
wantPath: "../test_data/test_local_repo_two_leaks_commit_to_from.json",
|
||||
},
|
||||
{
|
||||
description: "test local repo two leaks list Commits",
|
||||
opts: options.Options{
|
||||
Path: "../test_data/test_repos/test_repo_2",
|
||||
Report: "../test_data/test_local_repo_two_leaks_commit_range.json.got",
|
||||
ReportFormat: "json",
|
||||
Commits: "d8ac0b73aeeb45843319cdc5ce506516eb49bf7a,996865bb912f3bc45898a370a13aadb315014b55,17471a5fda722a9e423f1a0d3f0d267ea009d41c,51f6dcf6b89b93f4075ba92c400b075631a6cc93,b10b3e2cb320a8c211fda94c4567299d37de7776",
|
||||
},
|
||||
wantPath: "../test_data/test_local_repo_two_leaks_commit_range.json",
|
||||
},
|
||||
{
|
||||
description: "test local repo two leaks file list commits",
|
||||
opts: options.Options{
|
||||
Path: "../test_data/test_repos/test_repo_2",
|
||||
Report: "../test_data/test_local_repo_two_leaks_file_commit_range.json.got",
|
||||
ReportFormat: "json",
|
||||
CommitsFile: "../test_data/test_options/test_local_repo_commits.txt",
|
||||
Threads: runtime.GOMAXPROCS(0),
|
||||
},
|
||||
wantPath: "../test_data/test_local_repo_two_leaks_file_commit_range.json",
|
||||
},
|
||||
{
|
||||
description: "test local repo two leaks globally allowlisted",
|
||||
opts: options.Options{
|
||||
Path: "../test_data/test_repos/test_repo_2",
|
||||
ConfigPath: "../test_data/test_configs/aws_key_global_allowlist_file.toml",
|
||||
ReportFormat: "json",
|
||||
},
|
||||
wantEmpty: true,
|
||||
},
|
||||
{
|
||||
description: "test local repo two leaks allowlisted",
|
||||
opts: options.Options{
|
||||
Path: "../test_data/test_repos/test_repo_2",
|
||||
ConfigPath: "../test_data/test_configs/aws_key_allowlist_files.toml",
|
||||
ReportFormat: "json",
|
||||
},
|
||||
wantEmpty: true,
|
||||
},
|
||||
{
|
||||
description: "test local repo three leaks dev branch with reportGroup set",
|
||||
opts: options.Options{
|
||||
Path: "../test_data/test_repos/test_repo_3",
|
||||
Report: "../test_data/test_local_repo_three_leaks_with_report_groups.json.got",
|
||||
ConfigPath: "../test_data/test_configs/aws_key_with_report_groups.toml",
|
||||
Branch: "dev",
|
||||
ReportFormat: "json",
|
||||
},
|
||||
wantPath: "../test_data/test_local_repo_three_leaks_with_report_groups.json",
|
||||
},
|
||||
{
|
||||
description: "test local repo three leaks dev branch",
|
||||
opts: options.Options{
|
||||
Path: "../test_data/test_repos/test_repo_3",
|
||||
Report: "../test_data/test_local_repo_three_leaks.json.got",
|
||||
ConfigPath: "../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{
|
||||
Path: "../test_data/test_repos/test_repo_3",
|
||||
Branch: "nobranch",
|
||||
ReportFormat: "json",
|
||||
},
|
||||
wantScanErr: fmt.Errorf("could not find branch nobranch"),
|
||||
},
|
||||
{
|
||||
description: "test local repo one aws leak single Commit",
|
||||
opts: options.Options{
|
||||
Path: "../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{
|
||||
Path: "../test_data/test_repos/test_repo_1",
|
||||
Report: "../test_data/test_local_repo_one_aws_leak_and_file_leak.json.got",
|
||||
ConfigPath: "../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{
|
||||
Path: "../test_data/test_repos/",
|
||||
Report: "../test_data/test_local_owner_aws_leak.json.got",
|
||||
ReportFormat: "json",
|
||||
Threads: runtime.GOMAXPROCS(0),
|
||||
},
|
||||
wantPath: "../test_data/test_local_owner_aws_leak.json",
|
||||
},
|
||||
{
|
||||
description: "test owner path allowlist repo",
|
||||
opts: options.Options{
|
||||
Path: "../test_data/test_repos/",
|
||||
Report: "../test_data/test_local_owner_aws_leak_allowlist_repo.json.got",
|
||||
ReportFormat: "json",
|
||||
ConfigPath: "../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{
|
||||
Path: "../test_data/test_repos/test_repo_1",
|
||||
Report: "../test_data/test_regex_entropy.json.got",
|
||||
ConfigPath: "../test_data/test_configs/regex_entropy.toml",
|
||||
ReportFormat: "json",
|
||||
Threads: runtime.GOMAXPROCS(0),
|
||||
},
|
||||
wantPath: "../test_data/test_regex_entropy.json",
|
||||
},
|
||||
{
|
||||
description: "test local repo four entropy alternative config",
|
||||
opts: options.Options{
|
||||
Path: "../test_data/test_repos/test_repo_4",
|
||||
Report: "../test_data/test_local_repo_four_alt_config_entropy.json.got",
|
||||
RepoConfigPath: "gitleaks.toml",
|
||||
ReportFormat: "json",
|
||||
},
|
||||
wantPath: "../test_data/test_local_repo_four_alt_config_entropy.json",
|
||||
},
|
||||
{
|
||||
description: "test local repo four entropy alternative config",
|
||||
opts: options.Options{
|
||||
Path: "../test_data/test_repos/test_repo_1",
|
||||
Report: "../test_data/test_regex_allowlist.json.got",
|
||||
ConfigPath: "../test_data/test_configs/aws_key_aws_allowlisted.toml",
|
||||
ReportFormat: "json",
|
||||
},
|
||||
wantEmpty: true,
|
||||
},
|
||||
{
|
||||
description: "test owner path depth=2",
|
||||
opts: options.Options{
|
||||
Path: "../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{
|
||||
Path: "../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{
|
||||
Path: "../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{
|
||||
Path: "../test_data/test_repos/test_repo_5",
|
||||
Report: "../test_data/test_local_repo_five_commit.json.got",
|
||||
Commit: "a4c9fb737d5552fd96fce5cc7eedb23353ba9ed0",
|
||||
ReportFormat: "json",
|
||||
ConfigPath: "../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{
|
||||
Path: "../test_data/test_repos/test_repo_5",
|
||||
Report: "../test_data/test_local_repo_five_at_latest_commit.json.got",
|
||||
Commit: "latest",
|
||||
ReportFormat: "json",
|
||||
ConfigPath: "../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{
|
||||
Path: "../test_data/test_repos/test_repo_6",
|
||||
Report: "../test_data/test_local_repo_six_filename.json.got",
|
||||
ConfigPath: "../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{
|
||||
Path: "../test_data/test_repos/test_repo_6",
|
||||
Report: "../test_data/test_local_repo_six_filepath.json.got",
|
||||
ConfigPath: "../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{
|
||||
Path: "../test_data/test_repos/test_repo_6",
|
||||
Report: "../test_data/test_local_repo_six_filepath_filename.json.got",
|
||||
ConfigPath: "../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{
|
||||
Path: "../test_data/test_repos/test_repo_6",
|
||||
Report: "../test_data/test_local_repo_six_path_globally_allowlisted.json.got",
|
||||
ConfigPath: "../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{
|
||||
Path: "../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{
|
||||
Path: "../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{
|
||||
Path: "../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{
|
||||
Path: "../test_data/test_repos/test_repo_2",
|
||||
Report: "../test_data/test_local_repo_two_allowlist_commits.json.got",
|
||||
ConfigPath: "../test_data/test_configs/allowlist_commit.toml",
|
||||
ReportFormat: "json",
|
||||
},
|
||||
wantPath: "../test_data/test_local_repo_two_allowlist_commits.json",
|
||||
},
|
||||
{
|
||||
description: "test local repo eight (merges)",
|
||||
opts: options.Options{
|
||||
Path: "../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{
|
||||
Path: "../test_data/test_repos/test_repo_9",
|
||||
Report: "../test_data/test_local_repo_nine_aws_leak.json.got",
|
||||
ConfigPath: "../test_data/test_configs/large_with_global_allowlist_regex.toml",
|
||||
ReportFormat: "json",
|
||||
},
|
||||
wantPath: "../test_data/test_local_repo_nine_aws_leak.json",
|
||||
},
|
||||
{
|
||||
description: "test dir one no git",
|
||||
opts: options.Options{
|
||||
Path: "../test_data/test_repos/test_dir_1",
|
||||
Report: "../test_data/test_dir1_aws_leak.json.got",
|
||||
ReportFormat: "json",
|
||||
NoGit: true,
|
||||
},
|
||||
wantPath: "../test_data/test_dir1_aws_leak.json",
|
||||
},
|
||||
{
|
||||
description: "test file with leak no git",
|
||||
opts: options.Options{
|
||||
Path: "../test_data/test_repos/test_dir_1/server.test.py",
|
||||
Report: "../test_data/test_file1_aws_leak.json.got",
|
||||
ReportFormat: "json",
|
||||
NoGit: true,
|
||||
},
|
||||
wantPath: "../test_data/test_file1_aws_leak.json",
|
||||
},
|
||||
{
|
||||
description: "test only md files no git",
|
||||
opts: options.Options{
|
||||
Path: "../test_data/test_repos/",
|
||||
Report: "../test_data/test_only_files_no_git.json.got",
|
||||
ReportFormat: "json",
|
||||
ConfigPath: "../test_data/test_configs/onlyFiles.toml",
|
||||
NoGit: true,
|
||||
},
|
||||
wantPath: "../test_data/test_only_files_no_git.json",
|
||||
},
|
||||
{
|
||||
description: "test allowlist files",
|
||||
opts: options.Options{
|
||||
Path: "../test_data/test_repos/test_repo_10",
|
||||
Report: "../test_data/test_allow_list_file.json.got",
|
||||
ReportFormat: "json",
|
||||
ConfigPath: "../test_data/test_configs/allowlist_files.toml",
|
||||
},
|
||||
wantPath: "../test_data/test_allow_list_file.json",
|
||||
},
|
||||
{
|
||||
description: "test allowlist files",
|
||||
opts: options.Options{
|
||||
Path: "../test_data/test_repos/test_repo_10",
|
||||
Report: "../test_data/test_allow_list_file.json.got",
|
||||
ReportFormat: "json",
|
||||
ConfigPath: "../test_data/test_configs/allowlist_files.toml",
|
||||
},
|
||||
wantPath: "../test_data/test_allow_list_file.json",
|
||||
},
|
||||
{
|
||||
description: "test allowlist files no-git",
|
||||
opts: options.Options{
|
||||
Path: "../test_data/test_repos/test_repo_10",
|
||||
Report: "../test_data/test_allow_list_file_no_git.json.got",
|
||||
ReportFormat: "json",
|
||||
ConfigPath: "../test_data/test_configs/allowlist_files.toml",
|
||||
NoGit: true,
|
||||
},
|
||||
wantPath: "../test_data/test_allow_list_file_no_git.json",
|
||||
},
|
||||
{
|
||||
description: "test allowlist docx no-git",
|
||||
opts: options.Options{
|
||||
Path: "../test_data/test_repos/test_repo_10",
|
||||
Report: "../test_data/test_allow_list_docx_no_git.json.got",
|
||||
ReportFormat: "json",
|
||||
ConfigPath: "../test_data/test_configs/allowlist_docx.toml",
|
||||
NoGit: true,
|
||||
},
|
||||
wantPath: "../test_data/test_allow_list_docx_no_git.json",
|
||||
},
|
||||
{
|
||||
description: "test append repo config",
|
||||
opts: options.Options{
|
||||
Path: "../test_data/test_repos/test_repo_10",
|
||||
Report: "../test_data/test_append_repo.json.got",
|
||||
ReportFormat: "json",
|
||||
ConfigPath: "../test_data/test_configs/nozips.toml",
|
||||
RepoConfigPath: ".gitleaks.toml",
|
||||
AppendRepoConfig: true,
|
||||
},
|
||||
wantPath: "../test_data/test_append_repo.json",
|
||||
},
|
||||
{
|
||||
description: "test additional config",
|
||||
opts: options.Options{
|
||||
Path: "../test_data/test_repos/test_repo_10",
|
||||
Report: "../test_data/test_additional_config.json.got",
|
||||
ReportFormat: "json",
|
||||
ConfigPath: "../test_data/test_configs/nozips.toml",
|
||||
AdditionalConfig: "../test_data/test_repos/test_repo_10/.gitleaks.toml",
|
||||
},
|
||||
wantPath: "../test_data/test_additional_config.json",
|
||||
},
|
||||
{
|
||||
description: "test append repo config with additional config",
|
||||
opts: options.Options{
|
||||
Path: "../test_data/test_repos/test_repo_10",
|
||||
Report: "../test_data/test_append_repo_additional_config.json.got",
|
||||
ReportFormat: "json",
|
||||
ConfigPath: "../test_data/test_configs/nozips.toml",
|
||||
RepoConfigPath: ".gitleaks.toml",
|
||||
AppendRepoConfig: true,
|
||||
AdditionalConfig: "../test_data/test_configs/allowlist_bad_docx_10.toml",
|
||||
},
|
||||
wantEmpty: true,
|
||||
},
|
||||
{
|
||||
description: "test append repo config with additional config",
|
||||
opts: options.Options{
|
||||
Path: "../test_data/test_repos/test_repo_10",
|
||||
Report: "../test_data/test_append_repo_additional_config.json.got",
|
||||
ReportFormat: "json",
|
||||
ConfigPath: "../test_data/test_configs/nozips.toml",
|
||||
RepoConfigPath: ".gitleaks.toml",
|
||||
AppendRepoConfig: true,
|
||||
AdditionalConfig: "../test_data/test_configs/allowlist_bad_docx_10.toml",
|
||||
},
|
||||
wantEmpty: true,
|
||||
},
|
||||
{
|
||||
description: "test file with no leak due to additional config no git",
|
||||
opts: options.Options{
|
||||
Path: "../test_data/test_repos/test_dir_1",
|
||||
Report: "../test_data/fail.json.got",
|
||||
ReportFormat: "json",
|
||||
NoGit: false,
|
||||
AdditionalConfig: "../test_data/test_configs/allowlist_allow_all_repo_1.toml",
|
||||
},
|
||||
wantEmpty: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
fmt.Println(test.description)
|
||||
cfg, err := config.NewConfig(test.opts)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
scanner, err := NewScanner(test.opts, cfg)
|
||||
if test.wantErr != nil {
|
||||
if err == nil {
|
||||
t.Fatalf("did not receive wantErr: %v", test.wantErr)
|
||||
}
|
||||
if err.Error() != test.wantErr.Error() {
|
||||
t.Fatalf("wantErr does not equal err received: %v", err.Error())
|
||||
}
|
||||
continue
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
scannerReport, err := scanner.Scan()
|
||||
|
||||
if test.wantScanErr != nil {
|
||||
if err == nil {
|
||||
t.Fatalf("did not receive wantErr: %v", test.wantScanErr)
|
||||
}
|
||||
if err.Error() != test.wantScanErr.Error() {
|
||||
t.Fatalf("wantErr does not equal err received: %v", err.Error())
|
||||
}
|
||||
continue
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
err = WriteReport(scannerReport, test.opts, cfg)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if test.wantEmpty {
|
||||
if len(scannerReport.Leaks) != 0 {
|
||||
t.Errorf("wanted no leaks but got some instead: %+v", scannerReport.Leaks)
|
||||
}
|
||||
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
|
||||
wantScanErr error
|
||||
emptyRepo bool
|
||||
wantEmpty bool
|
||||
fileToChange string
|
||||
addition string
|
||||
}{
|
||||
{
|
||||
description: "test scan local one leak",
|
||||
opts: options.Options{
|
||||
Path: "../test_data/test_repos/test_repo_1",
|
||||
Report: "../test_data/test_local_repo_one_aws_leak_uncommitted.json.got",
|
||||
Unstaged: 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{
|
||||
Path: "../test_data/test_repos/test_repo_1",
|
||||
Unstaged: true,
|
||||
ReportFormat: "json",
|
||||
},
|
||||
wantEmpty: true,
|
||||
fileToChange: "server.test.py",
|
||||
addition: "nothing bad",
|
||||
},
|
||||
{
|
||||
description: "test scan repo with no commits",
|
||||
opts: options.Options{
|
||||
Path: "../test_data/test_repos/test_repo_7",
|
||||
Report: "../test_data/test_local_repo_seven_aws_leak_uncommitted.json.got",
|
||||
Unstaged: 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.Path, test.fileToChange))
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
altered, err := os.OpenFile(fmt.Sprintf("%s/%s", test.opts.Path, 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)
|
||||
}
|
||||
scanner, err := NewScanner(test.opts, cfg)
|
||||
if test.wantErr != nil {
|
||||
if err == nil {
|
||||
t.Fatalf("did not receive wantErr: %v", test.wantErr)
|
||||
}
|
||||
if err.Error() != test.wantErr.Error() {
|
||||
t.Fatalf("wantErr does not equal err received: %v", err.Error())
|
||||
}
|
||||
continue
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
scannerReport, err := scanner.Scan()
|
||||
|
||||
if test.wantScanErr != nil {
|
||||
if err == nil {
|
||||
t.Fatalf("did not receive wantErr: %v", test.wantScanErr)
|
||||
}
|
||||
if err.Error() != test.wantScanErr.Error() {
|
||||
t.Fatalf("wantErr does not equal err received: %v", err.Error())
|
||||
}
|
||||
continue
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
err = WriteReport(scannerReport, test.opts, cfg)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if test.fileToChange != "" {
|
||||
err = ioutil.WriteFile(fmt.Sprintf("%s/%s", test.opts.Path, 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 []Leak
|
||||
wantLeaks []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 err
|
||||
}
|
||||
|
||||
if len(wantLeaks) != len(gotLeaks) {
|
||||
return fmt.Errorf("got %d leaks, want %d leaks", len(gotLeaks), len(wantLeaks))
|
||||
}
|
||||
|
||||
for _, wantLeak := range wantLeaks {
|
||||
found := false
|
||||
for _, gotLeak := range gotLeaks {
|
||||
if same(gotLeak, wantLeak) {
|
||||
found = true
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
return fmt.Errorf("unable to find %+v in got leaks", wantLeak)
|
||||
}
|
||||
}
|
||||
|
||||
if err := os.Remove(gotPath); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func same(l1, l2 Leak) bool {
|
||||
if l1.Commit != l2.Commit {
|
||||
return false
|
||||
}
|
||||
|
||||
if l1.Offender != l2.Offender {
|
||||
return false
|
||||
}
|
||||
|
||||
if l1.Line != l2.Line {
|
||||
return false
|
||||
}
|
||||
|
||||
if l1.Tags != l2.Tags {
|
||||
return false
|
||||
}
|
||||
|
||||
if l1.LineNumber != l2.LineNumber {
|
||||
return false
|
||||
}
|
||||
|
||||
if l1.Author != l2.Author {
|
||||
return false
|
||||
}
|
||||
|
||||
if l1.LeakURL != l2.LeakURL {
|
||||
return false
|
||||
}
|
||||
|
||||
if l1.RepoURL != l2.RepoURL {
|
||||
return false
|
||||
}
|
||||
|
||||
if l1.Repo != l2.Repo {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
|
||||
}
|
||||
|
||||
func moveDotGit(from, to string) error {
|
||||
repoDirs, err := ioutil.ReadDir("../test_data/test_repos")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, dir := range repoDirs {
|
||||
if to == ".git" {
|
||||
_, err := os.Stat(fmt.Sprintf("%s/%s/%s", testRepoBase, dir.Name(), "dotGit"))
|
||||
if os.IsNotExist(err) {
|
||||
// dont want to delete the only copy of .git accidentally
|
||||
continue
|
||||
}
|
||||
os.RemoveAll(fmt.Sprintf("%s/%s/%s", testRepoBase, dir.Name(), ".git"))
|
||||
}
|
||||
if !dir.IsDir() {
|
||||
continue
|
||||
}
|
||||
_, err := os.Stat(fmt.Sprintf("%s/%s/%s", testRepoBase, dir.Name(), from))
|
||||
if os.IsNotExist(err) {
|
||||
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
|
||||
}
|
||||
// fmt.Println("RENAMED")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package scan
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v7/options"
|
||||
)
|
||||
|
||||
const (
|
||||
singleThreadCommitBuffer = 1
|
||||
multiThreadCommitBufferMultiplier = 10
|
||||
)
|
||||
|
||||
// Throttle is a struct that limits the number of concurrent goroutines and sets the
|
||||
// number of threads available for gitleaks to use via GOMAXPROCS.
|
||||
type Throttle struct {
|
||||
throttle chan bool
|
||||
}
|
||||
|
||||
// NewThrottle accepts some options and returns a throttle for scanners to use
|
||||
func NewThrottle(opts options.Options) *Throttle {
|
||||
t := Throttle{}
|
||||
if opts.Threads <= 1 {
|
||||
runtime.GOMAXPROCS(1)
|
||||
t.throttle = make(chan bool, singleThreadCommitBuffer)
|
||||
return &t
|
||||
}
|
||||
|
||||
runtime.GOMAXPROCS(opts.Threads)
|
||||
t.throttle = make(chan bool, multiThreadCommitBufferMultiplier*opts.Threads)
|
||||
return &t
|
||||
|
||||
}
|
||||
|
||||
// Limit blocks new goroutines from spinning up if throttle is at capacity
|
||||
func (t *Throttle) Limit() {
|
||||
t.throttle <- true
|
||||
}
|
||||
|
||||
// Release releases the hold on the throttle, allowing more goroutines to be spun up
|
||||
func (t *Throttle) Release() {
|
||||
<-t.throttle
|
||||
}
|
||||
@@ -0,0 +1,286 @@
|
||||
package scan
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v7/config"
|
||||
"github.com/zricethezav/gitleaks/v7/options"
|
||||
|
||||
"github.com/go-git/go-git/v5"
|
||||
"github.com/go-git/go-git/v5/plumbing"
|
||||
"github.com/sergi/go-diff/diffmatchpatch"
|
||||
)
|
||||
|
||||
// UnstagedScanner is an unstaged scanner. This is the scanner used when you don't provide program arguments
|
||||
// which will then scan your PWD. This scans unstaged changes in your repo.
|
||||
type UnstagedScanner struct {
|
||||
opts options.Options
|
||||
cfg config.Config
|
||||
repo *git.Repository
|
||||
repoName string
|
||||
}
|
||||
|
||||
// NewUnstagedScanner returns an unstaged scanner
|
||||
func NewUnstagedScanner(opts options.Options, cfg config.Config, repo *git.Repository) *UnstagedScanner {
|
||||
us := &UnstagedScanner{
|
||||
opts: opts,
|
||||
cfg: cfg,
|
||||
repo: repo,
|
||||
repoName: getRepoName(opts),
|
||||
}
|
||||
return us
|
||||
}
|
||||
|
||||
// Scan kicks off an unstaged scan. This will attempt to determine unstaged changes which are then scanned.
|
||||
func (us *UnstagedScanner) Scan() (Report, error) {
|
||||
var scannerReport Report
|
||||
r, err := us.repo.Head()
|
||||
if err == plumbing.ErrReferenceNotFound {
|
||||
wt, err := us.repo.Worktree()
|
||||
if err != nil {
|
||||
return scannerReport, err
|
||||
}
|
||||
|
||||
status, err := wt.Status()
|
||||
if err != nil {
|
||||
return scannerReport, err
|
||||
}
|
||||
for fn := range status {
|
||||
workTreeBuf := bytes.NewBuffer(nil)
|
||||
workTreeFile, err := wt.Filesystem.Open(fn)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
// Check if file is allow listed
|
||||
if us.cfg.Allowlist.FileAllowed(filepath.Base(fn)) ||
|
||||
us.cfg.Allowlist.PathAllowed(fn) {
|
||||
continue
|
||||
}
|
||||
// Check individual file path ONLY rules
|
||||
for _, rule := range us.cfg.Rules {
|
||||
if rule.HasFileOrPathLeakOnly(fn) {
|
||||
leak := NewLeak("", "Filename or path offender: "+fn, defaultLineNumber)
|
||||
leak.Repo = us.repoName
|
||||
leak.File = fn
|
||||
leak.RepoURL = us.opts.RepoURL
|
||||
leak.LeakURL = leak.URL()
|
||||
leak.Rule = rule.Description
|
||||
leak.Tags = strings.Join(rule.Tags, ", ")
|
||||
leak.Log(us.opts)
|
||||
scannerReport.Leaks = append(scannerReport.Leaks, leak)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
if _, err := io.Copy(workTreeBuf, workTreeFile); err != nil {
|
||||
return scannerReport, err
|
||||
}
|
||||
lineNumber := 0
|
||||
for _, line := range strings.Split(workTreeBuf.String(), "\n") {
|
||||
lineNumber++
|
||||
for _, rule := range us.cfg.Rules {
|
||||
offender := rule.Inspect(line)
|
||||
if offender == "" {
|
||||
continue
|
||||
}
|
||||
if us.cfg.Allowlist.RegexAllowed(line) ||
|
||||
rule.AllowList.FileAllowed(filepath.Base(workTreeFile.Name())) ||
|
||||
rule.AllowList.PathAllowed(workTreeFile.Name()) {
|
||||
continue
|
||||
}
|
||||
if rule.File.String() != "" && !rule.HasFileLeak(filepath.Base(workTreeFile.Name())) {
|
||||
continue
|
||||
}
|
||||
if rule.Path.String() != "" && !rule.HasFilePathLeak(filepath.Base(workTreeFile.Name())) {
|
||||
continue
|
||||
}
|
||||
leak := NewLeak(line, offender, defaultLineNumber).WithCommit(emptyCommit())
|
||||
leak.File = workTreeFile.Name()
|
||||
leak.LineNumber = lineNumber
|
||||
leak.Repo = us.repoName
|
||||
leak.Rule = rule.Description
|
||||
leak.Tags = strings.Join(rule.Tags, ", ")
|
||||
if us.opts.Verbose {
|
||||
leak.Log(us.opts)
|
||||
}
|
||||
scannerReport.Leaks = append(scannerReport.Leaks, leak)
|
||||
}
|
||||
}
|
||||
}
|
||||
return scannerReport, nil
|
||||
} else if err != nil {
|
||||
return scannerReport, err
|
||||
}
|
||||
|
||||
c, err := us.repo.CommitObject(r.Hash())
|
||||
if err != nil {
|
||||
return scannerReport, err
|
||||
}
|
||||
|
||||
// Staged change so the Commit details do not yet exist. Insert empty defaults.
|
||||
c.Hash = plumbing.Hash{}
|
||||
c.Message = ""
|
||||
c.Author.Name = ""
|
||||
c.Author.Email = ""
|
||||
c.Author.When = time.Unix(0, 0).UTC()
|
||||
|
||||
prevTree, err := c.Tree()
|
||||
if err != nil {
|
||||
return scannerReport, err
|
||||
}
|
||||
wt, err := us.repo.Worktree()
|
||||
if err != nil {
|
||||
return scannerReport, err
|
||||
}
|
||||
|
||||
status, err := gitStatus(wt)
|
||||
if err != nil {
|
||||
return scannerReport, err
|
||||
}
|
||||
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 scannerReport, 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 scannerReport, err
|
||||
}
|
||||
if filename == "" {
|
||||
filename = prevFile.Name
|
||||
}
|
||||
}
|
||||
|
||||
dmp := diffmatchpatch.New()
|
||||
diffs := dmp.DiffMain(prevFileContents, currFileContents, false)
|
||||
prettyDiff := diffPrettyText(diffs)
|
||||
|
||||
var diffContents string
|
||||
for _, d := range diffs {
|
||||
if d.Type == diffmatchpatch.DiffInsert {
|
||||
diffContents += fmt.Sprintf("%s\n", d.Text)
|
||||
}
|
||||
}
|
||||
|
||||
lineLookup := make(map[string]bool)
|
||||
|
||||
for _, line := range strings.Split(diffContents, "\n") {
|
||||
for _, rule := range us.cfg.Rules {
|
||||
offender := rule.Inspect(line)
|
||||
if offender == "" {
|
||||
continue
|
||||
}
|
||||
if us.cfg.Allowlist.RegexAllowed(line) ||
|
||||
rule.AllowList.FileAllowed(filepath.Base(filename)) ||
|
||||
rule.AllowList.PathAllowed(filename) {
|
||||
continue
|
||||
}
|
||||
if rule.File.String() != "" && !rule.HasFileLeak(filepath.Base(filename)) {
|
||||
continue
|
||||
}
|
||||
if rule.Path.String() != "" && !rule.HasFilePathLeak(filepath.Base(filename)) {
|
||||
continue
|
||||
}
|
||||
leak := NewLeak(line, offender, defaultLineNumber).WithCommit(emptyCommit())
|
||||
leak.File = filename
|
||||
leak.LineNumber = extractLine(prettyDiff, leak, lineLookup) + 1
|
||||
leak.Repo = us.repoName
|
||||
leak.Rule = rule.Description
|
||||
leak.Tags = strings.Join(rule.Tags, ", ")
|
||||
|
||||
leak.Log(us.opts)
|
||||
|
||||
scannerReport.Leaks = append(scannerReport.Leaks, leak)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return scannerReport, err
|
||||
}
|
||||
|
||||
// DiffPrettyText converts a []Diff into a colored text report.
|
||||
// TODO open PR for this
|
||||
func diffPrettyText(diffs []diffmatchpatch.Diff) string {
|
||||
var buff bytes.Buffer
|
||||
for _, diff := range diffs {
|
||||
text := diff.Text
|
||||
|
||||
switch diff.Type {
|
||||
case diffmatchpatch.DiffInsert:
|
||||
_, _ = buff.WriteString("+")
|
||||
_, _ = buff.WriteString(text)
|
||||
case diffmatchpatch.DiffDelete:
|
||||
_, _ = buff.WriteString("-")
|
||||
_, _ = buff.WriteString(text)
|
||||
case diffmatchpatch.DiffEqual:
|
||||
_, _ = buff.WriteString(" ")
|
||||
_, _ = buff.WriteString(text)
|
||||
}
|
||||
}
|
||||
return buff.String()
|
||||
}
|
||||
|
||||
// gitStatus returns the status of modified files in the worktree. It will attempt to execute 'git status'
|
||||
// and will fall back to git.Worktree.Status() if that fails.
|
||||
func gitStatus(wt *git.Worktree) (git.Status, error) {
|
||||
c := exec.Command("git", "status", "--porcelain", "-z")
|
||||
c.Dir = wt.Filesystem.Root()
|
||||
output, err := c.Output()
|
||||
if err != nil {
|
||||
stat, err := wt.Status()
|
||||
return stat, err
|
||||
}
|
||||
|
||||
lines := strings.Split(string(output), "\000")
|
||||
stat := make(map[string]*git.FileStatus, len(lines))
|
||||
for _, line := range lines {
|
||||
if len(line) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
// For copy/rename the output looks like
|
||||
// R destination\000source
|
||||
// Which means we can split on space and ignore anything with only one result
|
||||
parts := strings.SplitN(strings.TrimLeft(line, " "), " ", 2)
|
||||
if len(parts) == 2 {
|
||||
stat[strings.Trim(parts[1], " ")] = &git.FileStatus{
|
||||
Staging: git.StatusCode([]byte(parts[0])[0]),
|
||||
}
|
||||
}
|
||||
}
|
||||
return stat, err
|
||||
}
|
||||
+227
@@ -0,0 +1,227 @@
|
||||
package scan
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v7/options"
|
||||
|
||||
"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/storage/memory"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
const (
|
||||
diffAddPrefix = "+"
|
||||
diffDelPrefix = "-"
|
||||
diffLineSignature = " @@"
|
||||
defaultLineNumber = 1
|
||||
)
|
||||
|
||||
func obtainCommit(repo *git.Repository, commitSha string) (*object.Commit, error) {
|
||||
if commitSha == "latest" {
|
||||
ref, err := repo.Head()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
commitSha = ref.Hash().String()
|
||||
}
|
||||
return repo.CommitObject(plumbing.NewHash(commitSha))
|
||||
}
|
||||
|
||||
func getRepoName(opts options.Options) string {
|
||||
if opts.RepoURL != "" {
|
||||
return filepath.Base(opts.RepoURL)
|
||||
}
|
||||
if opts.Path != "" {
|
||||
return filepath.Base(opts.Path)
|
||||
}
|
||||
if opts.CheckUncommitted() {
|
||||
dir, _ := os.Getwd()
|
||||
return filepath.Base(dir)
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func getRepo(opts options.Options) (*git.Repository, error) {
|
||||
if opts.OpenLocal() {
|
||||
if opts.Path != "" {
|
||||
log.Infof("opening %s\n", opts.Path)
|
||||
} else {
|
||||
log.Info("opening .")
|
||||
}
|
||||
return git.PlainOpen(opts.Path)
|
||||
}
|
||||
if opts.CheckUncommitted() {
|
||||
// open git repo from PWD
|
||||
dir, err := os.Getwd()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.Debugf("opening %s as a repo\n", dir)
|
||||
return git.PlainOpen(dir)
|
||||
}
|
||||
return cloneRepo(opts)
|
||||
}
|
||||
|
||||
func cloneRepo(opts options.Options) (*git.Repository, error) {
|
||||
cloneOpts, err := opts.CloneOptions()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if opts.ClonePath != "" {
|
||||
log.Infof("cloning... %s to %s", cloneOpts.URL, opts.ClonePath)
|
||||
return git.PlainClone(opts.ClonePath, false, cloneOpts)
|
||||
}
|
||||
log.Infof("cloning... %s", cloneOpts.URL)
|
||||
return git.Clone(memory.NewStorage(), nil, cloneOpts)
|
||||
}
|
||||
|
||||
// depthReached checks if i meets the depth (--depth=) if set
|
||||
func depthReached(i int, opts options.Options) bool {
|
||||
if opts.Depth != 0 && 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: "",
|
||||
Author: object.Signature{
|
||||
Name: "",
|
||||
Email: "",
|
||||
When: time.Unix(0, 0).UTC(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// 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 logOptions(repo *git.Repository, opts options.Options) (*git.LogOptions, error) {
|
||||
var logOpts git.LogOptions
|
||||
const dateformat string = "2006-01-02"
|
||||
const timeformat string = "2006-01-02T15:04:05-0700"
|
||||
if opts.CommitFrom != "" {
|
||||
logOpts.From = plumbing.NewHash(opts.CommitFrom)
|
||||
}
|
||||
if opts.CommitSince != "" {
|
||||
if t, err := time.Parse(timeformat, opts.CommitSince); err == nil {
|
||||
logOpts.Since = &t
|
||||
} else if t, err := time.Parse(dateformat, opts.CommitSince); err == nil {
|
||||
logOpts.Since = &t
|
||||
} else {
|
||||
return nil, err
|
||||
}
|
||||
logOpts.All = true
|
||||
}
|
||||
if opts.CommitUntil != "" {
|
||||
if t, err := time.Parse(timeformat, opts.CommitUntil); err == nil {
|
||||
logOpts.Until = &t
|
||||
} else if t, err := time.Parse(dateformat, opts.CommitUntil); err == nil {
|
||||
logOpts.Until = &t
|
||||
} else {
|
||||
return nil, err
|
||||
}
|
||||
logOpts.All = true
|
||||
}
|
||||
if opts.Branch != "" {
|
||||
ref, err := repo.Storer.Reference(plumbing.NewBranchReferenceName(opts.Branch))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not find branch %s", opts.Branch)
|
||||
}
|
||||
logOpts = git.LogOptions{
|
||||
From: ref.Hash(),
|
||||
}
|
||||
|
||||
if logOpts.From.IsZero() {
|
||||
return nil, fmt.Errorf("could not find branch %s", opts.Branch)
|
||||
}
|
||||
return &logOpts, nil
|
||||
}
|
||||
if !logOpts.From.IsZero() || logOpts.Since != nil || logOpts.Until != nil {
|
||||
return &logOpts, nil
|
||||
}
|
||||
return &git.LogOptions{All: true}, nil
|
||||
}
|
||||
|
||||
func optsToCommits(opts options.Options) ([]string, error) {
|
||||
if opts.Commits != "" {
|
||||
return strings.Split(opts.Commits, ","), nil
|
||||
}
|
||||
file, err := os.Open(opts.CommitsFile)
|
||||
if err != nil {
|
||||
return []string{}, err
|
||||
}
|
||||
defer rable(file.Close)
|
||||
|
||||
scanner := bufio.NewScanner(file)
|
||||
var commits []string
|
||||
for scanner.Scan() {
|
||||
commits = append(commits, scanner.Text())
|
||||
}
|
||||
return commits, nil
|
||||
}
|
||||
|
||||
func extractLine(patchContent string, leak Leak, lineLookup map[string]bool) int {
|
||||
i := strings.Index(patchContent, fmt.Sprintf("\n+++ b/%s", leak.File))
|
||||
filePatchContent := patchContent[i+1:]
|
||||
i = strings.Index(filePatchContent, "diff --git")
|
||||
if i != -1 {
|
||||
filePatchContent = filePatchContent[:i]
|
||||
}
|
||||
chunkStartLine := 0
|
||||
currLine := 0
|
||||
for _, patchLine := range strings.Split(filePatchContent, "\n") {
|
||||
if strings.HasPrefix(patchLine, "@@") {
|
||||
i := strings.Index(patchLine, diffAddPrefix)
|
||||
pairs := strings.Split(strings.Split(patchLine[i+1:], diffLineSignature)[0], ",")
|
||||
chunkStartLine, _ = strconv.Atoi(pairs[0])
|
||||
currLine = -1
|
||||
}
|
||||
if strings.HasPrefix(patchLine, diffDelPrefix) {
|
||||
currLine--
|
||||
}
|
||||
if strings.HasPrefix(patchLine, diffAddPrefix) && strings.Contains(patchLine, leak.Line) {
|
||||
lineNumber := chunkStartLine + currLine
|
||||
if _, ok := lineLookup[fmt.Sprintf("%s%s%d%s", leak.Offender, leak.Line, lineNumber, leak.File)]; !ok {
|
||||
lineLookup[fmt.Sprintf("%s%s%d%s", leak.Offender, leak.Line, lineNumber, leak.File)] = true
|
||||
return lineNumber
|
||||
}
|
||||
}
|
||||
currLine++
|
||||
}
|
||||
return defaultLineNumber
|
||||
}
|
||||
|
||||
// rable is the second half of deferrable... mainly used for defer file.Close()
|
||||
func rable(f func() error) {
|
||||
if err := f(); err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
[
|
||||
{
|
||||
"line": "",
|
||||
"lineNumber": 1,
|
||||
"offender": "Filename or path offender: tmp/bad.docx",
|
||||
"commit": "b0f9b62dfe12e4e10de180359c6b9276472494f8",
|
||||
"repo": "test_repo_10",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "Block dangerous filetypes",
|
||||
"commitMessage": "Create bad.docx",
|
||||
"author": "Zachary Rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "tmp/bad.docx",
|
||||
"date": "2020-12-09T11:02:10-05:00",
|
||||
"tags": "key, extensions"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,82 @@
|
||||
[
|
||||
{
|
||||
"line": "",
|
||||
"lineNumber": 1,
|
||||
"offender": "Filename or path offender: ../test_data/test_repos/test_repo_10/.gitignore",
|
||||
"commit": "",
|
||||
"repo": "",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "Block dangerous filetypes",
|
||||
"commitMessage": "",
|
||||
"author": "",
|
||||
"email": "",
|
||||
"file": "../test_data/test_repos/test_repo_10/.gitignore",
|
||||
"date": "0001-01-01T00:00:00Z",
|
||||
"tags": "key, extensions"
|
||||
},
|
||||
{
|
||||
"line": "",
|
||||
"lineNumber": 1,
|
||||
"offender": "Filename or path offender: ../test_data/test_repos/test_repo_10/bad.zip",
|
||||
"commit": "",
|
||||
"repo": "",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "Block dangerous filetypes",
|
||||
"commitMessage": "",
|
||||
"author": "",
|
||||
"email": "",
|
||||
"file": "../test_data/test_repos/test_repo_10/bad.zip",
|
||||
"date": "0001-01-01T00:00:00Z",
|
||||
"tags": "key, extensions"
|
||||
},
|
||||
{
|
||||
"line": "",
|
||||
"lineNumber": 1,
|
||||
"offender": "Filename or path offender: ../test_data/test_repos/test_repo_10/gitfile.txt",
|
||||
"commit": "",
|
||||
"repo": "",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "Block dangerous filetypes",
|
||||
"commitMessage": "",
|
||||
"author": "",
|
||||
"email": "",
|
||||
"file": "../test_data/test_repos/test_repo_10/gitfile.txt",
|
||||
"date": "0001-01-01T00:00:00Z",
|
||||
"tags": "key, extensions"
|
||||
},
|
||||
{
|
||||
"line": "",
|
||||
"lineNumber": 1,
|
||||
"offender": "Filename or path offender: ../test_data/test_repos/test_repo_10/creds.git",
|
||||
"commit": "",
|
||||
"repo": "",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "Block dangerous filetypes",
|
||||
"commitMessage": "",
|
||||
"author": "",
|
||||
"email": "",
|
||||
"file": "../test_data/test_repos/test_repo_10/creds.git",
|
||||
"date": "0001-01-01T00:00:00Z",
|
||||
"tags": "key, extensions"
|
||||
},
|
||||
{
|
||||
"line": "",
|
||||
"lineNumber": 1,
|
||||
"offender": "Filename or path offender: ../test_data/test_repos/test_repo_10/somedir.git/secret.key",
|
||||
"commit": "",
|
||||
"repo": "",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "Block dangerous filetypes",
|
||||
"commitMessage": "",
|
||||
"author": "",
|
||||
"email": "",
|
||||
"file": "../test_data/test_repos/test_repo_10/somedir.git/secret.key",
|
||||
"date": "0001-01-01T00:00:00Z",
|
||||
"tags": "key, extensions"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,18 @@
|
||||
[
|
||||
{
|
||||
"line": "",
|
||||
"lineNumber": 1,
|
||||
"offender": "Filename or path offender: tmp/bad.docx",
|
||||
"commit": "b0f9b62dfe12e4e10de180359c6b9276472494f8",
|
||||
"repo": "test_repo_10",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "Block dangerous filetypes",
|
||||
"commitMessage": "Create bad.docx",
|
||||
"author": "Zachary Rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "tmp/bad.docx",
|
||||
"date": "2020-12-09T11:02:10-05:00",
|
||||
"tags": "key, extensions"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,34 @@
|
||||
[
|
||||
{
|
||||
"line": "",
|
||||
"lineNumber": 1,
|
||||
"offender": "Filename or path offender: ../test_data/test_repos/test_repo_10/somedir.git/secret.key",
|
||||
"commit": "",
|
||||
"repo": "",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "Block dangerous filetypes",
|
||||
"commitMessage": "",
|
||||
"author": "",
|
||||
"email": "",
|
||||
"file": "../test_data/test_repos/test_repo_10/somedir.git/secret.key",
|
||||
"date": "0001-01-01T00:00:00Z",
|
||||
"tags": "key, extensions"
|
||||
},
|
||||
{
|
||||
"line": "",
|
||||
"lineNumber": 1,
|
||||
"offender": "Filename or path offender: ../test_data/test_repos/test_repo_10/tmp/bad.docx",
|
||||
"commit": "",
|
||||
"repo": "",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "Block dangerous filetypes",
|
||||
"commitMessage": "",
|
||||
"author": "",
|
||||
"email": "",
|
||||
"file": "../test_data/test_repos/test_repo_10/tmp/bad.docx",
|
||||
"date": "0001-01-01T00:00:00Z",
|
||||
"tags": "key, extensions"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,18 @@
|
||||
[
|
||||
{
|
||||
"line": "",
|
||||
"lineNumber": 1,
|
||||
"offender": "Filename or path offender: tmp/bad.docx",
|
||||
"commit": "b0f9b62dfe12e4e10de180359c6b9276472494f8",
|
||||
"repo": "test_repo_10",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "Block dangerous filetypes",
|
||||
"commitMessage": "Create bad.docx",
|
||||
"author": "Zachary Rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "tmp/bad.docx",
|
||||
"date": "2020-12-09T11:02:10-05:00",
|
||||
"tags": "key, extensions"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,3 @@
|
||||
[allowlist]
|
||||
description = "Allowlisted files"
|
||||
files = [ '''server.test.py''','''server.test2.py''']
|
||||
@@ -0,0 +1,3 @@
|
||||
[allowlist]
|
||||
description = "Allowlisted files"
|
||||
files = [ '''bad.docx''']
|
||||
@@ -0,0 +1,15 @@
|
||||
[[rules]]
|
||||
description = "AWS Access Key"
|
||||
regex = '''(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}'''
|
||||
tags = ["key", "AWS"]
|
||||
[rules.allowlist]
|
||||
description = "if we encounter this commit for this rule, skip it"
|
||||
commits = ["b10b3e2cb320a8c211fda94c4567299d37de7776"]
|
||||
|
||||
|
||||
[allowlist]
|
||||
commits = [
|
||||
"17471a5fda722a9e423f1a0d3f0d267ea009d41c",
|
||||
"996865bb912f3bc45898a370a13aadb315014b55"
|
||||
]
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
[[rules]]
|
||||
description = "Block dangerous filetypes"
|
||||
file = '''(.*?)(creds.git|gitfile.txt|gitignore|pdf|doc|docx|zip|xls|tfplan|tfstate|tfvars|vault_pass|vagrant|pyc|key|cache)$'''
|
||||
tags = ["key", "extensions"]
|
||||
[rules.allowlist]
|
||||
paths = ['''.docx''']
|
||||
description = "ignore known locations and files"
|
||||
|
||||
#[allowlist]
|
||||
# description = "Allowlisted files"
|
||||
# paths = ['''.zip''']
|
||||
@@ -0,0 +1,11 @@
|
||||
[[rules]]
|
||||
description = "Block dangerous filetypes"
|
||||
file = '''(.*?)(pdf|doc|docx|zip|xls|tfplan|tfstate|tfvars|vault_pass|vagrant|pyc|key|cache)$'''
|
||||
tags = ["key", "extensions"]
|
||||
[rules.allowlist]
|
||||
paths = ['''.zip''']
|
||||
description = "ignore known locations and files"
|
||||
#
|
||||
#[allowlist]
|
||||
# description = "Allowlisted files"
|
||||
# paths = ['''.zip''']
|
||||
@@ -0,0 +1,9 @@
|
||||
[[rules]]
|
||||
description = "AWS Access Key"
|
||||
regex = '''(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}'''
|
||||
tags = ["key", "AWS"]
|
||||
|
||||
[allowlist]
|
||||
description = "Allowlisted files"
|
||||
paths = ['''.py''']
|
||||
files = ['''.md$''']
|
||||
@@ -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 Access Key"
|
||||
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 Access Key"
|
||||
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 Access Key"
|
||||
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 Access Key"
|
||||
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 Access Key"
|
||||
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 Access Key"
|
||||
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 Access Key"
|
||||
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 Access Key"
|
||||
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,10 @@
|
||||
[[rules]]
|
||||
description = "AWS Secret Key"
|
||||
regex = '''(?i)aws(.{0,20})?(?-i)['\"][0-9a-zA-Z\/+]{40}['\"]'''
|
||||
tags = ["key", "AWS"]
|
||||
|
||||
[[rules]]
|
||||
description = "AWS Access Key"
|
||||
regex = '''AWS secret: ("?)((A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16})("?)'''
|
||||
tags = ["key", "AWS"]
|
||||
reportGroup = 2
|
||||
@@ -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 Access Key"
|
||||
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 Access Key"
|
||||
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 Access Key"
|
||||
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 Access Key"
|
||||
regex = '''(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}'''
|
||||
tags = ["key", "AWS"]
|
||||
@@ -0,0 +1,16 @@
|
||||
title = "gitleaks config"
|
||||
|
||||
[[rules]]
|
||||
description = "Asymmetric Private Key"
|
||||
regex = '''-----BEGIN ((EC|PGP|DSA|RSA|OPENSSH) )?PRIVATE KEY( BLOCK)?-----'''
|
||||
tags = ["key", "AsymmetricPrivateKey"]
|
||||
|
||||
[[rules]]
|
||||
description = "Passwords"
|
||||
regex = '''(?i)password=(?i)'''
|
||||
tags = ["key", "Generic"]
|
||||
|
||||
[[rules]]
|
||||
description = "secret secret.com"
|
||||
regex = '''(?i)secret\.com'''
|
||||
tags = ["key", "custom"]
|
||||
@@ -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 Access Key"
|
||||
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 Access Key"
|
||||
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,4 @@
|
||||
|
||||
[[rules]]
|
||||
description = "No Zips"
|
||||
file = '''.*\.zip'''
|
||||
@@ -0,0 +1,4 @@
|
||||
[[rules]]
|
||||
description = "flag go"
|
||||
file = '''(.*?)(md)$'''
|
||||
tags = ["key", "extensions"]
|
||||
@@ -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 Access Key"
|
||||
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,34 @@
|
||||
[
|
||||
{
|
||||
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||
"lineNumber": 5,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "",
|
||||
"repo": "",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"commitMessage": "",
|
||||
"author": "",
|
||||
"email": "",
|
||||
"file": "../test_data/test_repos/test_dir_1/server.test.py",
|
||||
"date": "0001-01-01T00:00:00Z",
|
||||
"tags": "key, AWS"
|
||||
},
|
||||
{
|
||||
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||
"lineNumber": 5,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "",
|
||||
"repo": "",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"commitMessage": "",
|
||||
"author": "",
|
||||
"email": "",
|
||||
"file": "../test_data/test_repos/test_dir_1/server.test2.py",
|
||||
"date": "0001-01-01T00:00:00Z",
|
||||
"tags": "key, AWS"
|
||||
}
|
||||
]
|
||||
@@ -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,18 @@
|
||||
[
|
||||
{
|
||||
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||
"lineNumber": 5,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "",
|
||||
"repo": "",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"commitMessage": "",
|
||||
"author": "",
|
||||
"email": "",
|
||||
"file": "../test_data/test_repos/test_dir_1/server.test.py",
|
||||
"date": "0001-01-01T00:00:00Z",
|
||||
"tags": "key, AWS"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,370 @@
|
||||
[
|
||||
{
|
||||
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||
"lineNumber": 5,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "6557c92612d3b35979bd426d429255b3bf9fab74",
|
||||
"repo": "test_repos",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"commitMessage": "commit 1 with secrets\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "server.test.py",
|
||||
"date": "2019-10-24T09:29:27-04:00",
|
||||
"tags": "key, AWS"
|
||||
},
|
||||
{
|
||||
"line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"",
|
||||
"lineNumber": 3,
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c",
|
||||
"repo": "test_repo_2",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"commitMessage": "wait this is actually adding an aws secret\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:01:27-04:00",
|
||||
"tags": "key, AWS"
|
||||
},
|
||||
{
|
||||
"line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"",
|
||||
"lineNumber": 4,
|
||||
"offender": "AKIALALEMEL33243OLIB",
|
||||
"commit": "b2eb34a61c988afd9b4aaa9dd58c8dd7d5f14dba",
|
||||
"repo": "test_repo_2",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"commitMessage": "adding another one\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:12:08-04:00",
|
||||
"tags": "key, AWS"
|
||||
},
|
||||
{
|
||||
"line": "Here's an AWS secret: AKIALALEMEL33243OLIAE",
|
||||
"lineNumber": 3,
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "b10b3e2cb320a8c211fda94c4567299d37de7776",
|
||||
"repo": "test_repo_2",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"commitMessage": "adding aws key\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T12:58:39-04:00",
|
||||
"tags": "key, AWS"
|
||||
},
|
||||
{
|
||||
"line": "AWS secret: \"AKIALALEMEL33243OLIAE\"",
|
||||
"lineNumber": 5,
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "deea550dd6c7acaf0e59432600593533984a2125",
|
||||
"repo": "test_repo_3",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"commitMessage": "dev branch\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:35:03-04:00",
|
||||
"tags": "key, AWS"
|
||||
},
|
||||
{
|
||||
"line": "const AWSKEY = \"AKIALALEMEL33243OLIAE\"",
|
||||
"lineNumber": 3,
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "84ac4e80d4dbf2c968b64e9d4005f5079795bb81",
|
||||
"repo": "test_repo_3",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"commitMessage": "more secrets\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:54:08-04:00",
|
||||
"tags": "key, AWS"
|
||||
},
|
||||
{
|
||||
"line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"",
|
||||
"lineNumber": 3,
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c",
|
||||
"repo": "test_repo_3",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"commitMessage": "wait this is actually adding an aws secret\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:01:27-04:00",
|
||||
"tags": "key, AWS"
|
||||
},
|
||||
{
|
||||
"line": "Here's an AWS secret: AKIALALEMEL33243OLIAE",
|
||||
"lineNumber": 3,
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "b10b3e2cb320a8c211fda94c4567299d37de7776",
|
||||
"repo": "test_repo_3",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"commitMessage": "adding aws key\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T12:58:39-04:00",
|
||||
"tags": "key, AWS"
|
||||
},
|
||||
{
|
||||
"line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"",
|
||||
"lineNumber": 4,
|
||||
"offender": "AKIALALEMEL33243OLIB",
|
||||
"commit": "b2eb34a61c988afd9b4aaa9dd58c8dd7d5f14dba",
|
||||
"repo": "test_repo_3",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"commitMessage": "adding another one\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:12:08-04:00",
|
||||
"tags": "key, AWS"
|
||||
},
|
||||
{
|
||||
"line": "AWS secret: \"AKIALALEMEL33243OLIAE\"",
|
||||
"lineNumber": 5,
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "deea550dd6c7acaf0e59432600593533984a2125",
|
||||
"repo": "test_repo_4",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"commitMessage": "dev branch\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:35:03-04:00",
|
||||
"tags": "key, AWS"
|
||||
},
|
||||
{
|
||||
"line": "const AWSKEY = \"AKIALALEMEL33243OLIAE\"",
|
||||
"lineNumber": 3,
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "84ac4e80d4dbf2c968b64e9d4005f5079795bb81",
|
||||
"repo": "test_repo_4",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"commitMessage": "more secrets\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:54:08-04:00",
|
||||
"tags": "key, AWS"
|
||||
},
|
||||
{
|
||||
"line": "Here's an AWS secret: AKIALALEMEL33243OLIAE",
|
||||
"lineNumber": 3,
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "b10b3e2cb320a8c211fda94c4567299d37de7776",
|
||||
"repo": "test_repo_4",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"commitMessage": "adding aws key\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T12:58:39-04:00",
|
||||
"tags": "key, AWS"
|
||||
},
|
||||
{
|
||||
"line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"",
|
||||
"lineNumber": 4,
|
||||
"offender": "AKIALALEMEL33243OLIB",
|
||||
"commit": "b2eb34a61c988afd9b4aaa9dd58c8dd7d5f14dba",
|
||||
"repo": "test_repo_4",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"commitMessage": "adding another one\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:12:08-04:00",
|
||||
"tags": "key, AWS"
|
||||
},
|
||||
{
|
||||
"line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"",
|
||||
"lineNumber": 3,
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c",
|
||||
"repo": "test_repo_4",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"commitMessage": "wait this is actually adding an aws secret\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:01:27-04:00",
|
||||
"tags": "key, AWS"
|
||||
},
|
||||
{
|
||||
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPLE'",
|
||||
"lineNumber": 1,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "1f2a4abc47dabf991e6af6f9770867ce0ac1f360",
|
||||
"repo": "test_repo_5",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"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"
|
||||
},
|
||||
{
|
||||
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPL2'",
|
||||
"lineNumber": 4,
|
||||
"offender": "AKIAIO5FODNN7EXAMPL2",
|
||||
"commit": "ca71fcdeda15f25f0cc661d90e8785c255925c27",
|
||||
"repo": "test_repo_5",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"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"
|
||||
},
|
||||
{
|
||||
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||
"lineNumber": 5,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "6557c92612d3b35979bd426d429255b3bf9fab74",
|
||||
"repo": "test_repos",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"commitMessage": "commit 1 with secrets\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "server.test.py",
|
||||
"date": "2019-10-24T09:29:27-04:00",
|
||||
"tags": "key, AWS"
|
||||
},
|
||||
{
|
||||
"line": "aws_access_key_id=AKIAIO5FODNN7EXAMPLE",
|
||||
"lineNumber": 3,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "98b6c7cb3fb29a5993c4c95c56a2dc53050b9247",
|
||||
"repo": "test_repo_6",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"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"
|
||||
},
|
||||
{
|
||||
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||
"lineNumber": 2,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "ce7e8177bbf8a172c06b6a1e370a374d5c19f660",
|
||||
"repo": "test_repo_8",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"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"
|
||||
},
|
||||
{
|
||||
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||
"lineNumber": 6,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "9267bc86ec1497471cbc6f3308f3527f7ef34b9d",
|
||||
"repo": "test_repo_8",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"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"
|
||||
},
|
||||
{
|
||||
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||
"lineNumber": 6,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "748f11eaf2c38c3cf0ac6a22e44208777e79fa6f",
|
||||
"repo": "test_repo_8",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"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"
|
||||
},
|
||||
{
|
||||
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE', #gitleaks:allow",
|
||||
"lineNumber": 5,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "8d1fb60d2d80f0590f191ed5ace1e45ef780909a",
|
||||
"repo": "test_repo_9",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"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"
|
||||
},
|
||||
{
|
||||
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||
"lineNumber": 5,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "6557c92612d3b35979bd426d429255b3bf9fab74",
|
||||
"repo": "test_repos",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"commitMessage": "commit 1 with secrets\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "server.test.py",
|
||||
"date": "2019-10-24T09:29:27-04:00",
|
||||
"tags": "key, AWS"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,354 @@
|
||||
[
|
||||
{
|
||||
"line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"",
|
||||
"lineNumber": 4,
|
||||
"offender": "AKIALALEMEL33243OLIB",
|
||||
"commit": "b2eb34a61c988afd9b4aaa9dd58c8dd7d5f14dba",
|
||||
"repo": "test_repo_2",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"commitMessage": "adding another one\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:12:08-04:00",
|
||||
"tags": "key, AWS"
|
||||
},
|
||||
{
|
||||
"line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"",
|
||||
"lineNumber": 3,
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c",
|
||||
"repo": "test_repo_2",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"commitMessage": "wait this is actually adding an aws secret\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:01:27-04:00",
|
||||
"tags": "key, AWS"
|
||||
},
|
||||
{
|
||||
"line": "Here's an AWS secret: AKIALALEMEL33243OLIAE",
|
||||
"lineNumber": 3,
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "b10b3e2cb320a8c211fda94c4567299d37de7776",
|
||||
"repo": "test_repo_2",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"commitMessage": "adding aws key\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T12:58:39-04:00",
|
||||
"tags": "key, AWS"
|
||||
},
|
||||
{
|
||||
"line": "const AWSKEY = \"AKIALALEMEL33243OLIAE\"",
|
||||
"lineNumber": 3,
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "84ac4e80d4dbf2c968b64e9d4005f5079795bb81",
|
||||
"repo": "test_repo_3",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"commitMessage": "more secrets\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:54:08-04:00",
|
||||
"tags": "key, AWS"
|
||||
},
|
||||
{
|
||||
"line": "AWS secret: \"AKIALALEMEL33243OLIAE\"",
|
||||
"lineNumber": 5,
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "deea550dd6c7acaf0e59432600593533984a2125",
|
||||
"repo": "test_repo_3",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"commitMessage": "dev branch\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:35:03-04:00",
|
||||
"tags": "key, AWS"
|
||||
},
|
||||
{
|
||||
"line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"",
|
||||
"lineNumber": 4,
|
||||
"offender": "AKIALALEMEL33243OLIB",
|
||||
"commit": "b2eb34a61c988afd9b4aaa9dd58c8dd7d5f14dba",
|
||||
"repo": "test_repo_3",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"commitMessage": "adding another one\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:12:08-04:00",
|
||||
"tags": "key, AWS"
|
||||
},
|
||||
{
|
||||
"line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"",
|
||||
"lineNumber": 3,
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c",
|
||||
"repo": "test_repo_3",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"commitMessage": "wait this is actually adding an aws secret\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:01:27-04:00",
|
||||
"tags": "key, AWS"
|
||||
},
|
||||
{
|
||||
"line": "Here's an AWS secret: AKIALALEMEL33243OLIAE",
|
||||
"lineNumber": 3,
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "b10b3e2cb320a8c211fda94c4567299d37de7776",
|
||||
"repo": "test_repo_3",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"commitMessage": "adding aws key\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T12:58:39-04:00",
|
||||
"tags": "key, AWS"
|
||||
},
|
||||
{
|
||||
"line": "const AWSKEY = \"AKIALALEMEL33243OLIAE\"",
|
||||
"lineNumber": 3,
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "84ac4e80d4dbf2c968b64e9d4005f5079795bb81",
|
||||
"repo": "test_repo_4",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"commitMessage": "more secrets\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:54:08-04:00",
|
||||
"tags": "key, AWS"
|
||||
},
|
||||
{
|
||||
"line": "AWS secret: \"AKIALALEMEL33243OLIAE\"",
|
||||
"lineNumber": 5,
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "deea550dd6c7acaf0e59432600593533984a2125",
|
||||
"repo": "test_repo_4",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"commitMessage": "dev branch\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:35:03-04:00",
|
||||
"tags": "key, AWS"
|
||||
},
|
||||
{
|
||||
"line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"",
|
||||
"lineNumber": 4,
|
||||
"offender": "AKIALALEMEL33243OLIB",
|
||||
"commit": "b2eb34a61c988afd9b4aaa9dd58c8dd7d5f14dba",
|
||||
"repo": "test_repo_4",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"commitMessage": "adding another one\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:12:08-04:00",
|
||||
"tags": "key, AWS"
|
||||
},
|
||||
{
|
||||
"line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"",
|
||||
"lineNumber": 3,
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c",
|
||||
"repo": "test_repo_4",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"commitMessage": "wait this is actually adding an aws secret\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:01:27-04:00",
|
||||
"tags": "key, AWS"
|
||||
},
|
||||
{
|
||||
"line": "Here's an AWS secret: AKIALALEMEL33243OLIAE",
|
||||
"lineNumber": 3,
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "b10b3e2cb320a8c211fda94c4567299d37de7776",
|
||||
"repo": "test_repo_4",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"commitMessage": "adding aws key\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T12:58:39-04:00",
|
||||
"tags": "key, AWS"
|
||||
},
|
||||
{
|
||||
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPL2'",
|
||||
"lineNumber": 4,
|
||||
"offender": "AKIAIO5FODNN7EXAMPL2",
|
||||
"commit": "ca71fcdeda15f25f0cc661d90e8785c255925c27",
|
||||
"repo": "test_repo_5",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"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"
|
||||
},
|
||||
{
|
||||
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPLE'",
|
||||
"lineNumber": 1,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "1f2a4abc47dabf991e6af6f9770867ce0ac1f360",
|
||||
"repo": "test_repo_5",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"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"
|
||||
},
|
||||
{
|
||||
"line": "aws_access_key_id=AKIAIO5FODNN7EXAMPLE",
|
||||
"lineNumber": 3,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "98b6c7cb3fb29a5993c4c95c56a2dc53050b9247",
|
||||
"repo": "test_repo_6",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"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"
|
||||
},
|
||||
{
|
||||
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||
"lineNumber": 5,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "6557c92612d3b35979bd426d429255b3bf9fab74",
|
||||
"repo": "test_repos",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"commitMessage": "commit 1 with secrets\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "server.test.py",
|
||||
"date": "2019-10-24T09:29:27-04:00",
|
||||
"tags": "key, AWS"
|
||||
},
|
||||
{
|
||||
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||
"lineNumber": 6,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "748f11eaf2c38c3cf0ac6a22e44208777e79fa6f",
|
||||
"repo": "test_repo_8",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"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"
|
||||
},
|
||||
{
|
||||
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||
"lineNumber": 2,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "ce7e8177bbf8a172c06b6a1e370a374d5c19f660",
|
||||
"repo": "test_repo_8",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"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"
|
||||
},
|
||||
{
|
||||
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||
"lineNumber": 6,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "9267bc86ec1497471cbc6f3308f3527f7ef34b9d",
|
||||
"repo": "test_repo_8",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"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"
|
||||
},
|
||||
{
|
||||
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE', #gitleaks:allow",
|
||||
"lineNumber": 5,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "8d1fb60d2d80f0590f191ed5ace1e45ef780909a",
|
||||
"repo": "test_repo_9",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"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"
|
||||
},
|
||||
{
|
||||
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||
"lineNumber": 5,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "6557c92612d3b35979bd426d429255b3bf9fab74",
|
||||
"repo": "test_repos",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"commitMessage": "commit 1 with secrets\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "server.test.py",
|
||||
"date": "2019-10-24T09:29:27-04:00",
|
||||
"tags": "key, AWS"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,114 @@
|
||||
[
|
||||
{
|
||||
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||
"lineNumber": 5,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "6557c92612d3b35979bd426d429255b3bf9fab74",
|
||||
"repo": "test_repos",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"commitMessage": "commit 1 with secrets\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "server.test.py",
|
||||
"date": "2019-10-24T09:29:27-04:00",
|
||||
"tags": "key, AWS"
|
||||
},
|
||||
{
|
||||
"line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"",
|
||||
"lineNumber": 4,
|
||||
"offender": "AKIALALEMEL33243OLIB",
|
||||
"commit": "b2eb34a61c988afd9b4aaa9dd58c8dd7d5f14dba",
|
||||
"repo": "test_repo_2",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"commitMessage": "adding another one\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:12:08-04:00",
|
||||
"tags": "key, AWS"
|
||||
},
|
||||
{
|
||||
"line": "const AWSKEY = \"AKIALALEMEL33243OLIAE\"",
|
||||
"lineNumber": 3,
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "84ac4e80d4dbf2c968b64e9d4005f5079795bb81",
|
||||
"repo": "test_repo_3",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"commitMessage": "more secrets\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:54:08-04:00",
|
||||
"tags": "key, AWS"
|
||||
},
|
||||
{
|
||||
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPL2'",
|
||||
"lineNumber": 4,
|
||||
"offender": "AKIAIO5FODNN7EXAMPL2",
|
||||
"commit": "ca71fcdeda15f25f0cc661d90e8785c255925c27",
|
||||
"repo": "test_repo_5",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"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"
|
||||
},
|
||||
{
|
||||
"line": "aws_access_key_id=AKIAIO5FODNN7EXAMPLE",
|
||||
"lineNumber": 3,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "98b6c7cb3fb29a5993c4c95c56a2dc53050b9247",
|
||||
"repo": "test_repo_6",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"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"
|
||||
},
|
||||
{
|
||||
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||
"lineNumber": 6,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "748f11eaf2c38c3cf0ac6a22e44208777e79fa6f",
|
||||
"repo": "test_repo_8",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"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"
|
||||
},
|
||||
{
|
||||
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE', #gitleaks:allow",
|
||||
"lineNumber": 5,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "8d1fb60d2d80f0590f191ed5ace1e45ef780909a",
|
||||
"repo": "test_repo_9",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"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"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,50 @@
|
||||
[
|
||||
{
|
||||
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||
"lineNumber": 6,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "748f11eaf2c38c3cf0ac6a22e44208777e79fa6f",
|
||||
"repo": "test_repo_8",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"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"
|
||||
},
|
||||
{
|
||||
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||
"lineNumber": 2,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "ce7e8177bbf8a172c06b6a1e370a374d5c19f660",
|
||||
"repo": "test_repo_8",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"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"
|
||||
},
|
||||
{
|
||||
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||
"lineNumber": 6,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "9267bc86ec1497471cbc6f3308f3527f7ef34b9d",
|
||||
"repo": "test_repo_8",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"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"
|
||||
}
|
||||
]
|
||||
@@ -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 Access Key",
|
||||
"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 Access Key",
|
||||
"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 Access Key",
|
||||
"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 Access Key",
|
||||
"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,34 @@
|
||||
[
|
||||
{
|
||||
"line": "const AWSSECRET = \"99432bfewaf823ec3294e231\"",
|
||||
"lineNumber": 4,
|
||||
"offender": "\"99432bfewaf823ec3294e231\"",
|
||||
"commit": "84ac4e80d4dbf2c968b64e9d4005f5079795bb81",
|
||||
"repo": "test_repo_4",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"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"
|
||||
},
|
||||
{
|
||||
"line": " const AWSSECRET = \"99432bfewaf823ec3294e231\"",
|
||||
"lineNumber": 5,
|
||||
"offender": "\"99432bfewaf823ec3294e231\"",
|
||||
"commit": "b2eb34a61c988afd9b4aaa9dd58c8dd7d5f14dba",
|
||||
"repo": "test_repo_4",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"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"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,34 @@
|
||||
[
|
||||
{
|
||||
"line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"",
|
||||
"lineNumber": 4,
|
||||
"offender": "AKIALALEMEL33243OLIB",
|
||||
"commit": "b2eb34a61c988afd9b4aaa9dd58c8dd7d5f14dba",
|
||||
"repo": "test_repo_4",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"commitMessage": "adding another one\n",
|
||||
"author": "zach rice",
|
||||
"email": "zricer@protonmail.com",
|
||||
"file": "secrets.md",
|
||||
"date": "2019-10-25T13:12:08-04:00",
|
||||
"tags": "key, AWS"
|
||||
},
|
||||
{
|
||||
"line": "Here's an AWS secret: \"AKIALALEMEL33243OLIAE\"",
|
||||
"lineNumber": 3,
|
||||
"offender": "AKIALALEMEL33243OLIA",
|
||||
"commit": "17471a5fda722a9e423f1a0d3f0d267ea009d41c",
|
||||
"repo": "test_repo_4",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"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"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,17 @@
|
||||
[
|
||||
{
|
||||
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||
"lineNumber": 5,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "6557c92612d3b35979bd426d429255b3bf9fab74",
|
||||
"repo": "test_repo_9",
|
||||
"rule": "AWS Access Key",
|
||||
"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,18 @@
|
||||
[
|
||||
{
|
||||
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||
"lineNumber": 5,
|
||||
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||
"commit": "6557c92612d3b35979bd426d429255b3bf9fab74",
|
||||
"repo": "test_repo_1",
|
||||
"repoURL": "",
|
||||
"leakURL": "",
|
||||
"rule": "AWS Access Key",
|
||||
"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"
|
||||
}
|
||||
]
|
||||
Loaded 100 of 486 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user