Compare commits

...
445 Commits
Author SHA1 Message Date
zricethezav 81b3a6e279 Update readme 2020-12-02 17:11:47 -05:00
Zachary Rice c50906373c update to V7 (#469) 2020-12-02 17:07:31 -05:00
Zachary Rice 40545fb680 Need to include offender in line extraction memoization (#466) 2020-11-21 15:49:59 -05:00
Daniel Paul SearlesandDaniel Paul Searles 2acc34dfdf Add support for reportGroup (#456)
Why:

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

This change addresses the need by:

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

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

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

* more work

* more sarif work

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

* Update test configs

* adding test

* golint and change to allowlist

* fix race condition, this mistakenly got committed

* Updating tests and examples

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

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

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

* fix import fmt

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

* think i got it working

* we got em

* Updating tests

* fixing tests

* Better comments, more test fixing

* Bumping to v5

* Fixing golint messages

* Replacing usage of audit with scan in comments

* bumping go-git

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

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

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

* fixing SIGSEGV

* adding options for date and time format + tests

* Update repo.go

* Update github.go

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

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

* bumping go-git and adding repo whitelist

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

* updating readme

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

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

* audit before commit

* adding test

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

* Add more match cases to generic credential pattern

* Fix quotation for valid toml

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

Added option to scan files at latest commit

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

* fixing github private user auth and donate msg

* formatting

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

* Config tests

* Small fixes on entropy ranges

* Fix toml configs
Fix tests

* Start adding support for rules with filename regex

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

* File regex working

* Fixing tests and configs

* Implemented different regex for filename and filepath

* Fix comments

* Audit tests

* Config rename vars

* Fix audit tests

* Filename offender

* Indents and code styles

* Indents and code styles

* Removing bad test repo

* Adding test repo 6 for filename and filepath tests

* global whitelist path and fixes

* Fixes on tests and new test for global whitelisting paths

* Removing unused test

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

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

* Config tests

* Small fixes on entropy ranges

* Fix toml configs
Fix tests

* Indents and code styles
2020-02-24 13:44:38 -05:00
zricethezav e7fbcf5333 updating readme and comments 2020-02-01 16:48:05 -05:00
Zachary Rice 2810eccc82 Merge pull request #329 from zricethezav/bug/commit-scan
Bug/commit scan
2020-02-01 11:38:02 -05:00
zricethezav baff419091 removing hooks 2020-02-01 11:23:11 -05:00
zricethezav d13e0fdfde adding more tests 2020-02-01 11:18:27 -05:00
zricethezav 5a300c3c64 fixing --commit bug, adding --files-at-commit option 2020-01-30 20:08:01 -05:00
Zachary Rice d8ddb9630a Merge pull request #327 from zricethezav/bug/timeoutcancel
Adding timeout check in context select so we dont log erroneously
2020-01-24 18:16:59 -05:00
zricethezav 1537eeb5fa Adding timeout check in context select so we dont log erroneously 2020-01-24 18:07:16 -05:00
Zachary Rice 1a492537dd Merge pull request #325 from zricethezav/bug/timeoutcancel
defer cancel in audit
2020-01-23 18:52:56 -05:00
zricethezav bd4107b002 ensuring cancel is called after audit is complete so context can be dropped 2020-01-23 18:47:37 -05:00
Zach Rice 7b48cadf6d fixing version loading in makefile 2020-01-22 20:42:14 -05:00
Zachary Rice 6eab8a7a0a Update README.md 2020-01-22 20:00:27 -05:00
Zachary Rice c6d14e5b7d Merge pull request #323 from zricethezav/bug/fix-go-module
fixing modules, adding v3 in path
2020-01-22 18:10:23 -05:00
zricethezav ce95cafd54 fixing modules, adding v3 in path 2020-01-22 10:21:00 -05:00
Zachary Rice 4024faceab Merge pull request #322 from zricethezav/exclude-forks
exclude-forks gitlab and github
2020-01-19 12:41:07 -05:00
zricethezav 1afa931248 exclude-forks gitlab and github 2020-01-19 12:35:52 -05:00
Zachary Rice 2474c39311 Merge pull request #321 from zricethezav/depth
reimplementing depth feature
2020-01-19 12:17:42 -05:00
zricethezav f6460a7365 reimplementing depth feature 2020-01-19 12:14:14 -05:00
Zachary Rice b47e00858e Merge pull request #320 from zricethezav/bug/manager-ptr
bug/manager-ptr
2020-01-19 11:56:29 -05:00
zricethezav b200a13c8d bug fix: use manager pointers instead of value for gitleaks hosts... this was causing an issue with metadata logging 2020-01-19 11:51:52 -05:00
Zachary Rice e6fabdbb31 Merge pull request #319 from zricethezav/repo-timeout
Repo timeout
2020-01-19 11:48:57 -05:00
Zachary Rice cdd654eab7 pr template 2020-01-19 10:17:08 -05:00
zricethezav 2f07b96333 adding test, cancelfunc (for go vet) 2020-01-19 10:07:01 -05:00
zricethezav 62e74b2b18 let the repo handle timeouts... better for automating audits anyway 2020-01-19 09:26:06 -05:00
Zachary Rice e75693b131 Update feature_request.md 2020-01-12 12:22:54 -05:00
Zachary Rice 3cd14d4696 Update bug_report.md 2020-01-12 12:22:14 -05:00
Zachary Rice d29cc9892c Update bug_report.md 2020-01-12 12:21:33 -05:00
Zachary Rice d996882f4e Update bug_report.md 2020-01-12 12:20:44 -05:00
Zachary Rice 17b6aa856d Update issue templates 2020-01-12 11:07:45 -05:00
Zachary Rice c21a9cf121 Merge pull request #317 from zricethezav/feature/commit-range
Adding commit range feature via 'commit-to' and 'commit-from' options
2020-01-11 17:01:53 -05:00
zricethezav d3c4342c15 Updating README 2020-01-11 16:58:59 -05:00
zricethezav b4c2f8e69c cleaning up some comments 2020-01-11 16:54:09 -05:00
Zach Rice a0f72a4e35 Adding commit range feature via 'commit-to' and 'commit-from' options 2020-01-11 16:46:58 -05:00
Zachary Rice 24844002de Update README.md 2020-01-03 16:15:54 -05:00
Zachary Rice 593edeae21 Update README.md 2019-12-24 10:03:02 -06:00
Zachary Rice 6df770d261 Merge pull request #313 from zricethezav/bug/docker-update
adding docker push support again to Make and fixed a go vet nit
2019-12-24 09:13:01 -06:00
zach rice 4f0c9dcede adding docker push support again to Make and fixed a go vet nit 2019-12-17 20:44:20 -05:00
Zachary Rice 52425a8ca9 Merge pull request #307 from pegasd/add_pkcs8_key_support
Add support for PKCS8 key
2019-12-07 19:33:54 -05:00
Zachary Rice 454acebe5a Merge pull request #303 from petegallagher/host-base-url
Adding baseurl flag to allow self-hosted GitLab/GitHub servers
2019-12-05 10:32:52 -05:00
Peter Gallagher 6fcf91e934 Removing logging of git client errors as these are now returned in main.go 2019-12-05 15:22:18 +00:00
Peter Gallagher f89b8f2b29 Return errors for failed host clients 2019-12-05 12:11:46 +00:00
Zachary Rice 648a7ba577 Merge pull request #304 from chapeupreto/patch-1
fix typo
2019-12-04 14:47:12 -05:00
Zachary Rice 7c5594c39d Merge pull request #305 from zricethezav/limit-leak-len
Limit leak len
2019-12-04 14:46:36 -05:00
Zachary Rice 274e8212a6 adding license 2019-12-04 08:48:37 -05:00
Eugene Piven 36c6ddaf86 Add support for PKCS8 key 2019-12-03 20:24:33 +03:00
zach rice 15ed72bc09 updating test data 2019-12-01 21:33:40 -05:00
zach rice ace8de93a9 limit leak len to 200 characters 2019-12-01 21:30:40 -05:00
Rod Elias 45a4c0a284 fix typo 2019-12-01 17:10:26 -03:00
Peter Gallagher c5e1e8abc0 Adding baseurl flag to allow self-hosted GitLab/GitHub servers 2019-12-01 10:49:32 +00:00
Zachary Rice ef38b69c39 Merge pull request #302 from petegallagher/whitelist-gitleaks.toml
Update default whitelist to include gitleaks.toml
2019-11-30 09:44:23 -06:00
Zachary Rice ac6bde9996 Merge pull request #296 from petegallagher/private-key
Update asymmetric private key regex
2019-11-30 09:41:35 -06:00
Zachary Rice 23568cc0ba Merge pull request #295 from petegallagher/sendgrid
Adding regex for SendGrid API keys
2019-11-30 09:41:10 -06:00
Zachary Rice e61c2cfae7 Merge pull request #301 from petegallagher/AuditUncommitted
Fix repo-config and file whitelist for AuditUncommitted function
2019-11-30 09:40:24 -06:00
Peter Gallagher 38e0b11995 Fix test data for AuditUncommitted 2019-11-29 10:22:02 +00:00
Peter Gallagher 31903d1a80 Update default whitelist to include gitleaks.toml 2019-11-29 10:14:03 +00:00
Peter Gallagher 3655284b57 Fix test data for AuditUncommitted 2019-11-29 10:07:56 +00:00
Peter Gallagher db79a96118 Use Unix Epoch time for staged commit time 2019-11-29 10:07:27 +00:00
Peter Gallagher999 5152e1fc63 Reset commit values when auditing uncommitted changes 2019-11-28 23:13:59 +00:00
Peter Gallagher c04e137b28 Adding global file regex to AuditUncommitted 2019-11-28 22:53:08 +00:00
Peter Gallagher 9b3342fbff Allow use of --repo-config for AuditUncommitted function 2019-11-28 13:53:52 +00:00
Peter Gallagher d9a060a12d Honour file whitelist for AuditUncommitted function 2019-11-28 13:53:18 +00:00
Peter Gallagher 77f2fdd09a Update asymmetric private key regex 2019-11-25 15:59:40 +00:00
Peter Gallagher dba1ef6104 Adding regex for SendGrid API keys 2019-11-25 15:49:47 +00:00
Zachary Rice 725da55905 Merge pull request #289 from zricethezav/fix/3.0.2
recover on panic in patch generation, full filepath for report, versi…
2019-11-23 09:56:27 -05:00
zach rice cfac551ab8 recover on panic in patch generation, full filepath for report, version message if not built with LDFLAGS 2019-11-23 09:50:16 -05:00
Zachary Rice c559fdbf04 Merge pull request #287 from chenrui333/go-1.13.4
Bump golang and alpine to latest
2019-11-17 13:41:43 -06:00
Rui Chen e2ac47cd06 Bump alpine to v3.10 2019-11-17 14:37:04 -05:00
Rui Chen 8ef16d9efb Bump golang to v1.13.4 2019-11-17 14:36:37 -05:00
Zachary Rice b6f726654e Merge pull request #286 from zricethezav/v3.0.1
V3.0.1
2019-11-17 12:12:54 -06:00
zach rice 8cbb84c50f fixing tests 2019-11-17 11:56:16 -06:00
zach rice f3eac0c958 adding report-format to tests since we dont parse flags 2019-11-17 11:34:15 -06:00
zach rice 3211cfbbb1 fixing a bug, adding csv report option and leak caching 2019-11-17 11:13:34 -06:00
zach rice c6934f5eab updating readme 2019-11-15 13:52:05 -06:00
zach rice f8c054b879 gotta log the reponame on cloned repos 2019-11-15 13:35:34 -06:00
Zachary Rice ad2a64c82b Merge pull request #285 from zricethezav/v3
metadata sync
2019-11-15 13:26:46 -06:00
zach rice 9e0028fe73 Merge branch 'master' of github.com:zricethezav/gitleaks into v3 2019-11-15 13:22:18 -06:00
zach rice dfbd01a980 sync bug w/ timings 2019-11-15 13:22:03 -06:00
Zachary Rice 86737955de Merge pull request #281 from zricethezav/v3
V3
2019-11-14 07:38:34 -05:00
zach rice 7f0b027486 changing ret err to warning for owner-path scan 2019-11-13 20:03:51 -05:00
zach rice 4d04ea079f fixing test data 2019-11-12 22:32:15 -05:00
zach rice 6e1c41b536 more examples 2019-11-12 22:17:56 -05:00
zach rice 275232f8c8 examples and more tests 2019-11-12 20:08:17 -05:00
zach rice c8f9560aa3 adding pretty print option 2019-11-12 18:18:51 -05:00
zach rice 315ee56024 opts guard and removing severity 2019-11-12 15:18:13 -05:00
zach rice e446ba0738 fixing all golint and adding some more tests 2019-11-11 21:50:50 -05:00
zach rice 2ccd40677d adding alt config test 2019-11-10 19:28:02 -05:00
zach rice 41ef2a8cd2 rm hooks from test repos 2019-11-10 18:35:07 -05:00
zach rice d8acd1354f no more automatic deploys... doing it manually from now on 2019-11-10 17:18:52 -05:00
zach rice e28cfd1ad5 audit test import 2019-11-10 17:08:56 -05:00
zach rice e5f5e64cdb fixing module name, updating gitignore and travis 2019-11-10 17:05:36 -05:00
zach rice b55d88dc15 v3 work... lots of things 2019-11-10 13:30:43 -05:00
Zachary Rice f3360cbf66 Create FUNDING.yml 2019-10-13 10:39:08 -04:00
Zachary Rice 065b621604 Merge pull request #262 from siemens/feat/relax-repo-config
feat(repo-config): do not fail if no repo-config is available
2019-09-08 16:59:01 -04:00
Roger Meier fd87df475c feat(repo-config): do not fail if no repo-config is available 2019-09-08 20:49:29 +02:00
Zachary Rice c7b6792956 Merge pull request #261 from siemens/fix/sigsegv-repo-config
fix(repo-config): avoid SIGSEGV if there is no .gitleaks.toml
2019-09-08 08:57:49 -04:00
Roger Meier 1f2d11003d fix(repo-config): avoid SIGSEGV if there is no .gitleaks.toml 2019-09-08 13:07:17 +02:00
Zachary Rice 6432f11a6b Merge pull request #249 from siemens/bufferoverflow-patch-1
fix(gitleaks.toml): LinkedIn had a Twitter tag
2019-08-14 10:04:27 -04:00
Roger Meier 7d53fb5951 fix(gitleaks.toml): LinkedIn had a Twitter tag 2019-08-14 11:22:19 +02:00
Zachary Rice b9aa3ef97d readme 2019-08-13 08:54:33 -04:00
zach rice c271497ecb more generic api key regex 2019-08-02 17:16:20 -05:00
Zachary Rice e05c4645ac Merge pull request #246 from hughsaunders/regexes_in_sample
Regex whitelist example in sample config
2019-08-02 17:10:28 -05:00
Hugh Saunders 63d8e6e21b Regex whitelist example in sample config
Users looking to the sample config to discover possible options may
not notice that its possible to whitelist by regex. This commit adds
an example to aid discovery.

Related: conjurinc/ops#246
2019-08-02 21:15:15 +01:00
zach rice 5bd59b0d8c bump 2019-08-01 17:39:09 -05:00
zach rice 464e152783 rm vendor and changelog 2019-08-01 17:15:28 -05:00
Zachary Rice 91406b0c4c Merge pull request #184 from JCofman/feature/gitlabTokenSupport
Feature/gitlab token support
2019-08-01 17:13:44 -05:00
Zachary Rice 04e81270cb Merge pull request #244 from cfzlp/non-zero-exit-for-leaks
Return exit code 1 when leaks are found
2019-08-01 09:50:24 -05:00
Ixl123 69c6695765 resolve merge conflicts 2019-08-01 13:46:51 +02:00
Carlos Pereira 9e0e050f92 Return exit code 1 when leaks are found 2019-07-31 23:21:30 +02:00
Zachary Rice b2efcf36c8 Merge pull request #241 from manasmbellani/enhance_apikey_rule
constants.go(enhance): added an enhancement to include apikey without…
2019-07-15 21:54:16 -05:00
Manas Bellani ba39abfb19 constants.go(enhance): added an enhancement to include apikey without underscore as another detection for api keys that might be present in source code 2019-07-16 12:31:49 +10:00
zricethezav f47e1f71ee cleaner and bounded regex for generic keys and secrets 2019-07-14 15:16:46 -05:00
Zachary Rice 6d980b4eab Code cleaning (#240) 2019-07-10 10:32:51 -05:00
Zachary Rice ca18e8e2f6 Merge pull request #239 from cfzlp/fix-repo-config
Fix updating config from repo-config
2019-07-09 16:52:08 -05:00
Zachary Rice ec436d7b33 Merge pull request #230 from eargollo/windows-log
Fixed Windows output to be consistent with Linux output (colors)
2019-07-09 16:48:54 -05:00
Zachary Rice 38a511f6ba Merge pull request #236 from dorneanu/fix-commit-option
Implemented right way to scan for files in a commit (by using --commit)
2019-07-09 16:42:31 -05:00
Carlos Pereira 15ac1ffdd1 Fix updating config from repo-config 2019-07-07 14:57:57 +02:00
Victor Dorneanu eb977ba237 Differentiate between commits with parents and commits w/o parents 2019-06-19 14:28:10 +02:00
Victor Dorneanu 9a6b1c3bbb Implemented right way to scan for files in a commit (by using --commit) 2019-06-18 19:03:54 +02:00
Zachary Rice 95443e742c Merge pull request #231 from jesmg/master
Add new default rules
2019-06-18 07:56:55 -05:00
Jesús Marín 0c94db2d6b Improve rules 2019-06-18 10:27:50 +02:00
Jesús Marín 9808551eed Add new default rules 2019-06-17 15:04:33 +02:00
Eduardo Argollo b6fe5b08d3 Added colors to Windows output making it consistent with Linux one 2019-06-06 11:30:33 -07:00
Eduardo Argollo 5309811a09 Merge remote-tracking branch 'upstream/master' 2019-06-06 11:13:51 -07:00
zach rice 3b6c198715 fixing test 2019-06-02 20:55:24 -05:00
Zachary Rice 57bfa41b33 Merge pull request #224 from eargollo/overwrite-error
Solved bug on error being overwritten and not passed to postAudit, closes #223
2019-06-02 17:53:05 -05:00
Zachary Rice 474266c0b5 Merge pull request #226 from eargollo/windows-test
Adapt test message to run tests in Windows
2019-06-02 17:49:26 -05:00
Eduardo Argollo c891470344 Merge pull request #1 from eargollo/windows-test
Adapt test message to run tests in Windows
2019-05-31 09:56:44 -07:00
Eduardo Argollo e6004da801 Adapt test message to run tests in Windows 2019-05-31 09:52:21 -07:00
Eduardo Argollo e18b1a884a Updating expected error message 2019-05-30 15:11:37 -07:00
Eduardo Argollo faeb0914b2 Solving error on authentication 2019-05-30 15:09:45 -07:00
Eduardo Argollo d6578df998 Solved bug on error being overwritten and not passed to postAudit, closes #223 2019-05-28 15:35:10 -07:00
Zachary Rice f010513d17 Merge pull request #222 from martelo/modify-single-commit-audit
Modify single commit audit
2019-05-28 17:00:13 -05:00
Cassio Berra d4be9602e3 Removing other unnecessary references to opts.Commit 2019-05-18 01:24:18 +00:00
Cassio Berra 7676690697 Audit single commit without iterating through all commits 2019-05-18 01:02:46 +00:00
Zachary Rice f4b9b6d0b3 Merge pull request #204 from luispollo/fix-repo-path-logging
Fix logging of repo paths
2019-05-06 10:00:27 -05:00
Luis Pollo 7a3d155675 Fix logging of repo paths 2019-05-06 08:53:02 -05:00
Zachary Rice 68b6388ef7 Merge pull request #202 from MaxymVlasov/docs/improve_examples
Add more examples and improve README structure
2019-04-30 11:30:31 -05:00
MaxymVlasov 547e9768ec Add more examples and improve README structure 2019-04-30 18:08:58 +03:00
Zachary Rice 8608cf5b48 Merge pull request #198 from theoretick/patch-1
Update README - formatting fixes
2019-04-19 10:34:46 -05:00
Lucas Charles a08ddedb88 Update README - formatting fixes 2019-04-19 08:28:33 -07:00
Zachary Rice 398366a615 Merge pull request #196 from zricethezav/v2.0.0
V2.0.0
2019-04-16 19:00:12 -05:00
zach rice 7dfa3f2b48 last updates? 2019-04-16 18:13:24 -05:00
zach rice 2e7325ce03 adding some more tests during lunch 2019-04-16 12:04:00 -05:00
zach rice cb74386ef0 working on filetype filtering 2019-04-13 16:48:57 -05:00
zach rice 87d6c588a6 removing validating config, already handled 2019-04-13 14:09:16 -05:00
zach rice df8a2d35a8 cleaning up 2019-04-13 13:50:14 -05:00
zach rice c4da547503 fmt 2019-04-13 13:12:58 -05:00
zach rice 7bd55e33b5 working tests out 2019-04-13 12:30:00 -05:00
zach rice 256ace38d7 workin on new filters 2019-04-11 18:06:18 -05:00
zach rice 4c20d5d85c bumping version 2019-03-30 15:29:52 -05:00
Zachary Rice ac43c67a47 Merge pull request #190 from zricethezav/bug/singleCommit
Bug/single commit
2019-03-30 15:24:42 -05:00
zach rice d2d68a7e44 fixing commit target bug 2019-03-30 15:19:31 -05:00
zach rice 27aee19a35 Merge branch 'master' of github.com:zricethezav/gitleaks 2019-03-29 19:41:33 -05:00
Zachary Rice 2a6bd1636f Merge pull request #189 from zricethezav/debt/breakout
Debt/breakout
2019-03-29 19:27:54 -05:00
zach rice 7b82e29e7e updating readme 2019-03-29 19:23:28 -05:00
zach rice 4fd2f06a0d rm vendor and updating dockerfile 2019-03-29 19:12:28 -05:00
zach rice 8016dffe18 more travis 2019-03-29 18:52:38 -05:00
zach rice 10004da36f travis version 2019-03-29 18:46:45 -05:00
zach rice 633e06a7c7 updating travis 2019-03-29 18:39:52 -05:00
zach rice 660350c9b1 gofmt 2019-03-29 18:11:01 -05:00
zach rice 9122aa6cf4 updating changelog 2019-03-29 18:09:34 -05:00
zach rice 56c89866a2 spliting up email and author 2019-03-29 18:04:49 -05:00
zach rice f9be4e543a working on coverage 2019-03-29 15:54:42 -05:00
zach rice 042b82e2af more test work 2019-03-29 15:02:25 -05:00
zach rice 9176896742 getting testing there 2019-03-29 13:02:59 -05:00
zach rice 4ea0c66bec making good progress on tests 2019-03-28 21:28:16 -05:00
zach rice ae4542abf0 working on tests now 2019-03-28 13:13:26 -05:00
zach rice ac14d347de more refactoring 2019-03-28 10:42:43 -05:00
zach rice c2143c5843 repoDescriptor->repoInfo 2019-03-28 08:06:38 -05:00
zach rice e79ffc6ae8 go mod and even more work 2019-03-27 17:26:27 -05:00
zach rice a56c2341cf Merge branch 'master' of github.com:zricethezav/gitleaks 2019-03-26 16:11:12 -05:00
zach rice 1c14586cde main.go, need to work on tests next 2019-03-26 16:06:43 -05:00
zach rice 2b995fda44 init 2019-03-26 13:57:55 -05:00
Zachary Rice 5d68b48af3 Update README.md 2019-03-21 19:31:26 -05:00
Zachary Rice f90a00b564 Update README.md 2019-03-20 20:36:11 -05:00
Ixl123 4bc7c13310 Merge branch 'master' of https://github.com/zricethezav/gitleaks 2019-03-08 14:44:56 +01:00
Ixl123 771055fd59 add changelog and format go code 2019-03-08 14:38:47 +01:00
Jacob Cofman 75c70bf804 try this 2019-03-06 23:31:15 +01:00
Zachary Rice c5f34a6704 Update README.md 2019-03-06 08:45:30 -06:00
Zachary Rice 463871a307 Update README.md 2019-03-06 08:43:45 -06:00
Zachary Rice fa1080d066 Update README.md 2019-02-16 10:31:27 -06:00
Zachary Rice 52cfad1d08 Update CHANGELOG.md 2019-02-06 20:06:20 -06:00
Zachary Rice 9e294f5910 Merge pull request #179 from zricethezav/single-commit
Single commit
2019-02-06 20:04:54 -06:00
zach rice 9f8326de56 updating changelog and readme 2019-02-06 19:56:02 -06:00
zach rice 79c3f99165 fixing tests 2019-02-06 19:48:17 -06:00
zach rice d4925443c8 workin on tests 2019-02-06 19:20:52 -06:00
zach rice fa27d32bfe ref is not ordered... so the depth option is wack 2019-02-06 18:36:05 -06:00
zach rice 230a52e3e3 reworking logic 2019-02-06 17:50:55 -06:00
zach rice 15dedda59a single commit and bumping go-git version 2019-02-06 09:26:41 -06:00
Zachary Rice 3b45fb91e3 Update README.md 2019-01-21 18:18:57 +01:00
Zachary Rice f378319395 Merge pull request #174 from zricethezav/revert-169-add_support_for_branch
Revert "Add support for scanning single branch"
2019-01-13 17:17:49 -06:00
Zachary Rice 98173b3aa6 Revert "Add support for scanning single branch" 2019-01-13 17:13:36 -06:00
Zachary Rice 36340c8f2f Merge pull request #169 from AdamKobi/add_support_for_branch
Add support for scanning single branch
2019-01-13 10:20:37 -06:00
Adam Kobi 77b6d90a16 Merge branch 'master' into add_support_for_branch 2019-01-13 13:58:07 +02:00
Adam Kobi 6b3bd46fa8 added tests for scanning single branch and non-existing branch 2019-01-13 13:55:01 +02:00
Zachary Rice 8485f88158 Update README.md 2019-01-11 15:35:29 -06:00
Zachary Rice d2baa9e675 jk i am prepared. no more games 2019-01-06 19:57:46 -06:00
Zachary Rice 7fa9c802f5 u r not prepared 2019-01-06 18:47:43 -06:00
zach rice 8f1bc74e26 new logo 2019-01-06 18:29:02 -06:00
zach rice 8de38be418 bump version 2019-01-06 17:48:08 -06:00
Zachary Rice ec1ebd4686 Merge pull request #171 from milo-minderbinder/bugfix/report-memory
fix memory issue when writing json report (#168)
2019-01-06 08:58:43 -06:00
zach rice 81ddfbed88 dupe code 2019-01-06 08:52:31 -06:00
Zachary Rice 63814f1eaf Merge pull request #172 from zricethezav/repo-config
Repo config
2019-01-05 21:35:51 -06:00
zach rice 38a36add57 typo 2019-01-05 20:51:59 -06:00
zach rice 9e39927ac6 turning down logging, adding test 2019-01-05 20:50:17 -06:00
Milo Minderbinder 0ba9dda0f0 fix memory issue when writing json report (#168)
Previously, gitleaks.writeReport used json.MarshallIndent on the entire
set of leaks when writing json reports, which would cause failures due
to excessive memory consumption when a large number of leaks were
identified.

This PR addresses the problem by doing incremental marshalling and
writing of leaks to the report file, and reduces the memory footprint by
several GB in tests with >30k leaks.
2019-01-04 18:49:25 -05:00
zach rice a24f9a2c92 working on getting pinned config working 2019-01-04 16:31:33 -06:00
Zachary Rice f57158a893 Merge pull request #170 from syk0saje/master
Fix typo in recovery message
2019-01-04 09:45:13 -06:00
Pepe Bawagan 1e3bf42464 Fix typo in recovery message 2019-01-04 15:23:26 +08:00
Zachary Rice 9d6a75fbab Merge pull request #163 from milo-minderbinder/bugfix/whitelist-checks
fix file (#162) & line (#161) whitelist checks
2019-01-01 11:09:54 -06:00
Milo Minderbinder 6fa52ae7cc Merge remote-tracking branch 'upstream/master' into bugfix/whitelist-checks 2018-12-31 16:54:53 -05:00
Milo Minderbinder bb9c459a1a check whiteListFiles for root commit & GitHub PRs
add missing checks against `whiteListFiles` regexes for files in the
root/initial commit and in GitHub PRs (in `auditGithubPR` function)
2018-12-31 12:49:49 -05:00
Adam Kobi 432c76a9d9 added support for scanning only single remote branch 2018-12-29 13:10:39 +02:00
Adam Kobi 1cdf315bfa Merge pull request #1 from zricethezav/master
update upstream
2018-12-29 02:24:01 +02:00
Zachary Rice 777601a0ea Merge pull request #165 from camaya/update-report-creation
Write report only when leaks are found
2018-12-27 16:16:24 -06:00
Zachary Rice 35d170018e Merge pull request #166 from arbazkiraak/patch-1
Adding Stripe API Regex
2018-12-27 16:15:38 -06:00
Arbaz Hussain af2e99ef45 Adding Strip API Regex
```
→ printf '  Stripe.api_key = "Sk_test_41u0zAKbiWmTVhvHcS6gAjp9"
  Stripe.api_key = "sk_live_VhYCleaZwuUBGSFYFc7WUboz"
  STRIPE_PUBLIC_KEY= "pk_live_8sCPFZoLtW5pXuVHGrRKrROs"' | grep -P "(?i)(sk|pk)_(test|live)_[0-9a-zA-Z]{10,32}"
  Stripe.api_key = "Sk_test_41u0zAKbiWmTVhvHcS6gAjp9"
  Stripe.api_key = "sk_live_VhYCleaZwuUBGSFYFc7WUboz"
  STRIPE_PUBLIC_KEY= "pk_live_8sCPFZoLtW5pXuVHGrRKrROs"
```
2018-12-27 21:45:39 +05:30
Zachary Rice 734befb555 bad cops bad cops 2018-12-25 09:31:58 -06:00
Milo Minderbinder 64c8d618a2 fix file (#162) & line (#161) whitelist checks
* only check entropyRegexes and whiteListRegexes once per line, and only
  if regex or entropy leak type was found, since regex checks are expensive
* check whiteListFiles once for each FilePatch, instead of for
  every Chunk
2018-12-13 13:14:54 -05:00
Cristhian Amaya 92bb4ea6fc Write report only when leaks are found 2018-12-11 18:33:11 +01:00
zach rice 98b025da72 bumping versions 2018-12-10 09:48:48 -06:00
Zachary Rice af7717412f Merge pull request #159 from camaya/reduce-entropy-noise
Reduce noise when running entropy checks
2018-12-10 09:40:05 -06:00
Cristhian Amaya 68c2a18f6f Update entropy noise reduction
Instead of reducing noise by default, there's a new flag called
`--noise-reduction` to enable that.
2018-12-10 16:24:53 +01:00
Cristhian Amaya ea49078ffd Reduce noise when running entropy checks
When there's a word on a line with high entropy, we check if the line
matches any of the regex configured on the `lineregexes` element of the
`entropy` section. If so, it's marked as a leaked.

This has reduced the number of leaks found with entropy enabled up to
80%
2018-12-04 10:23:42 +01:00
Zachary Rice b902d7310a Merge pull request #158 from camaya/redact-only-secret-on-line
Change redacted behaviour on the line information
2018-11-30 08:55:22 -06:00
Zachary Rice 3591560b34 Merge pull request #157 from camaya/add-commit-date-prs
Add commit date to Github PRs checks
2018-11-30 08:54:56 -06:00
Cristhian Amaya 949029ca89 Change redacted behaviour on the line information
The line information sometimes contains useful context information so
instead of redacting the whole line, this change redacts only the
secret
2018-11-30 14:13:18 +01:00
Cristhian Amaya cde0894711 Add commit date to Github PRs checks 2018-11-30 13:37:18 +01:00
Zachary Rice 342e9f80db Merge pull request #152 from camaya/fix-github-pr-nilcheck
Fix Github PR checks error
2018-11-29 09:10:36 -06:00
Zachary Rice 96b0f4aab7 Merge pull request #153 from madblobfish/patch-1
Fix releases link in readme
2018-11-26 12:03:40 -06:00
madblobfish 3af6a546ac fix releases link in readme 2018-11-26 11:20:17 +01:00
Cristhian Amaya 6e086c4297 Fix Github PR checks error
When a commit contained a file without patch information like an added
empty file, there was a nil pointer dereference.
2018-11-23 11:56:49 +01:00
zricethezav db08fc0564 actually bump version in code >.< 2018-11-18 08:43:05 -06:00
zricethezav dbb6d4cc5f including camayas changes in version bump 2018-11-18 08:42:32 -06:00
Zachary Rice d0f44da4c2 Merge pull request #151 from AdamKobi/add_support_for_tokens
Add support for tokens
2018-11-18 08:39:17 -06:00
Zachary Rice cb6b01cc5d Merge pull request #149 from camaya/fix-files-whitelist-github-prs
Fix files whitelisting when checking Github PRs
2018-11-18 08:36:47 -06:00
Adam Kobi 392d79b9e2 added changes to changelog 2018-11-15 19:04:51 +02:00
Adam Kobi f8e609d4bf added case for when using oauth token for both listing and cloning repos 2018-11-15 17:58:54 +02:00
Zachary Rice 573bf46fd1 grammar not my best subject 2018-11-13 20:01:44 -06:00
Zachary Rice d65592bbcc Update to readme 2018-11-13 19:57:52 -06:00
Cristhian Amaya 169a137e7f Fix files whitelisting when checking Github PRs
Files whitelisting code was not executed when running the tool against a
Github PR so the config was ignored.

To avoid duplication, the whitelist files check has been moved to the `inspect`
function which is always executed.
2018-11-13 11:54:25 +01:00
Zachary Rice bd61f2d2f7 Merge pull request #148 from zricethezav/gitlab-support
bumping version, format, changelog, uhhhhhh, test... a single test
2018-11-12 21:45:35 -06:00
zricethezav 793bbc793f bumping version, format, changelog, uhhhhhh, test... a single test 2018-11-12 21:42:45 -06:00
Zachary Rice 4aa7be2dbf Merge pull request #120 from denwwer/115-gitlab
115 gitlab
2018-11-12 21:30:06 -06:00
Zachary Rice 35531233d9 Merge pull request #147 from zricethezav/fix/first-commit
fixing commit count
2018-11-07 19:39:52 -06:00
zach rice 54949bd62a fixing commit count 2018-11-07 19:33:39 -06:00
Zachary Rice e95a8a7158 Merge pull request #146 from zricethezav/fix/first-commit
Fix/first commit
2018-11-06 22:35:26 -06:00
zach rice de0a70a835 changelog 2018-11-06 22:27:52 -06:00
zach rice 9f8feca926 gotta check the root 2018-11-06 22:20:42 -06:00
Zachary Rice c50187559b Merge pull request #145 from camaya/update-report-commit-message
Remove break lines in commit messages
2018-11-06 08:31:49 -06:00
boris c2cf6327c2 adjusted perPage; minor fixes 2018-11-06 15:29:10 +02:00
boris 1ea773ddfb support self hosted GitLab server 2018-11-06 15:10:12 +02:00
boris 79a8983bac support GitLab 2018-11-06 15:10:09 +02:00
Cristhian Amaya 7d5ed837a4 Remove break lines in commit messages
Breaklines in a csv report caused issues when importing the data to an
spreadsheet application like LibreOffice Calc or Microsoft Excel.
2018-11-06 11:41:38 +01:00
Zachary Rice 60267523e9 Merge pull request #144 from zricethezav/fix/files
readding default whitelist
2018-11-05 18:18:36 -06:00
zach rice 8153da6e9c readding default whitelist 2018-11-05 18:13:50 -06:00
Zachary Rice 5f6fb388ec Merge pull request #141 from zricethezav/feature/default-all
removing branch from report
2018-11-03 11:37:21 -05:00
zach rice ba49396755 updating tests 2018-11-03 11:34:07 -05:00
zach rice 40240cb5ee removing branch from report 2018-11-03 11:31:18 -05:00
Zachary Rice bba926693e Merge pull request #140 from zricethezav/feature/default-all
Feature/default all
2018-11-03 11:29:20 -05:00
zach rice 9103834503 tests, readme, bumping version 2018-11-03 11:11:50 -05:00
zach rice 7e3c740592 audit all branches by default, memoize commits, smarter regexes 2018-11-02 21:58:09 -05:00
Zachary Rice 35a59746df Merge pull request #135 from camaya/add-commit-date-to-leaks
Add commit date to leaks
2018-10-28 12:21:45 -05:00
Cristhian Amaya 23b5ce3264 Add commit date to leaks 2018-10-28 17:13:59 +01:00
zach rice 03c53d2978 version again, pushing to master because thats what we do here 2018-10-27 19:30:58 -05:00
Zachary Rice 695449d73d Merge pull request #134 from zricethezav/fix/threads
Fix/threads
2018-10-27 19:25:40 -05:00
zach rice 6bad1e7194 updating readme 2018-10-27 19:20:11 -05:00
zach rice 77dec1461b better language 2018-10-27 19:19:07 -05:00
Zachary Rice 14d77f59d4 Merge pull request #133 from akerl/fix/slack-tokens
fix slack token format
2018-10-27 16:13:17 -05:00
Les Aker afb598cf15 update defaultConfig with new Slack regex 2018-10-27 14:29:25 -04:00
Les Aker b4c6fe92e0 fix slack token format 2018-10-27 10:56:41 -04:00
Zachary Rice f50577be1c Merge pull request #131 from zricethezav/feature/default-regex
Feature/default regex
2018-10-26 14:04:15 -05:00
zach rice c358ae9310 changelog 2018-10-26 13:53:16 -05:00
zach rice 9554258d02 adding some more defaults 2018-10-26 13:48:14 -05:00
Zachary Rice 95ee2cc30e Merge pull request #128 from r--w/patch-1
Telegram bot API token
2018-10-26 13:26:08 -05:00
Zachary Rice 79a35f0c27 Merge branch 'master' into patch-1 2018-10-26 13:25:58 -05:00
Zachary Rice 7a021cda9e Merge pull request #129 from harston/patch-1
Add PGP header
2018-10-26 13:25:23 -05:00
Zachary Rice 447f7a04cb Merge branch 'master' into patch-1 2018-10-26 13:24:55 -05:00
Zachary Rice e5b62cbc7c Merge pull request #130 from harston/patch-2
Add slack token
2018-10-26 13:24:01 -05:00
Paweł Gawinek 6739a34f74 Add slack token
Add Slack token from https://api.slack.com/docs/token-types 

#hactoberfest #greywizard
2018-10-26 10:36:04 +02:00
Paweł Gawinek e502bf29de Add PGP header
Add PGP private key header 

#hactoberfest #greywizard
2018-10-26 10:23:26 +02:00
Radoslaw Wesolowski 51b504bf99 Telegram bot API token
Format is described here: https://core.telegram.org/bots/api#authorizing-your-bot

#hactoberfest #greywizard
2018-10-26 09:22:18 +02:00
Zachary Rice 107d582e7b Merge pull request #127 from zricethezav/fix/ssh-logic
fixing default ssh logic
2018-10-25 12:38:14 -05:00
zach rice ea42ed406f fixing default ssh logic 2018-10-25 12:27:50 -05:00
Zachary Rice c869812875 Merge pull request #125 from ziyaddin/patch-1
Fix typos in docs
2018-10-24 17:06:43 -05:00
Zachary Rice 4f7ce9c195 Merge pull request #126 from zricethezav/fix/concurrency
Fix/concurrency
2018-10-24 16:56:01 -05:00
zach rice 847687a637 fixing test. travis doesnt have rsa id 2018-10-24 16:48:34 -05:00
zach rice 94389137e8 removing private opts 2018-10-24 16:00:15 -05:00
zach rice 98e6ba9378 better ssh handling 2018-10-24 15:49:53 -05:00
zach rice e288db29a8 fixing tests 2018-10-24 12:40:05 -05:00
zach rice 98aeee9b1d fixing everything 2018-10-24 12:28:54 -05:00
Ziyaddin Sadigov 45a2aa8495 Fix typos in changelog 2018-10-24 21:19:40 +04:00
Ziyaddin Sadigov 4b350987a1 Fix typos in contributing.md 2018-10-24 21:11:29 +04:00
Ziyaddin Sadigov 3b2b754fe5 Fix typos in readme 2018-10-24 21:06:08 +04:00
zach rice 64e7afea98 updating version 2018-10-24 09:58:39 -05:00
zach rice 16765c19cf adding go routines does not help performance much.... posting benchmarks soon 2018-10-24 09:38:36 -05:00
Zachary Rice 87d916fc24 Merge pull request #123 from zricethezav/update/whitelist-repo
whitelist repo update
2018-10-23 16:38:17 -05:00
zach rice 21b59fab5d whitelist repo update 2018-10-23 16:34:36 -05:00
Zachary Rice 9272e1e556 Merge pull request #122 from zricethezav/feature/entropy-range
entropy ranges
2018-10-22 18:55:51 -05:00
zach rice 0a51dabb17 entropy ranges 2018-10-22 18:51:01 -05:00
Zachary Rice 8c1cee4e00 Merge pull request #116 from keirans/documentation_updates
Documentation enhancements
2018-10-21 10:23:48 -05:00
Keiran Sweet 4d5315e2ca Documentation updates 2018-10-21 17:12:00 +11:00
zach rice 88cc9bb363 committing to master nbd.... stupid version 2018-10-20 17:28:42 -05:00
Zachary Rice 80e41ee14c Merge pull request #118 from zricethezav/feature/github-pr
Feature/GitHub pr
2018-10-20 18:27:27 -04:00
zach rice 23489f3f18 updating changelog, readme, some other things 2018-10-20 17:16:35 -05:00
zach rice a998ddc9d4 adding github.go, pagination working 2018-10-20 16:31:52 -05:00
zach rice 833963c1c1 refactoring 2018-10-19 19:53:10 -05:00
zach rice 4b11f87f80 poc seems to work fine w token auth 2018-10-19 15:58:25 -04:00
Zachary Rice 923dcf0311 Merge pull request #117 from camaya/update-help-option
Update help option
2018-10-17 08:42:20 -04:00
Cristhian Amaya 8896cf66cd Update help option
* Show program usage when no arguments are provided
* Exit program after the -h or --help options are used
2018-10-15 17:10:44 +02:00
zach rice df133ccaf8 version boss strikes AGAIN 2018-10-12 19:01:42 -05:00
Zachary Rice 23cd693d71 Merge pull request #114 from zricethezav/report
report filetype enforcement, time to audit
2018-10-12 18:53:38 -05:00
zach rice 524d81fde9 durafmt 2018-10-12 18:43:03 -05:00
zach rice d387f528c4 update lint 2018-10-12 18:22:33 -05:00
zach rice dcda26578b report filetype enforcement, time to audit 2018-10-12 17:01:24 -05:00
Zachary Rice 28639d3a49 Merge pull request #112 from zricethezav/wl-commit
look at prev commit too
2018-10-10 12:19:21 -05:00
zach rice 19e23c9cbe look at prev commit too 2018-10-10 12:16:31 -05:00
Zachary Rice 160015b872 Merge pull request #111 from zricethezav/fix-wl-commit
rm commit count log
2018-10-10 09:50:28 -05:00
zach rice abdf2c47f0 cl update 2018-10-10 09:43:01 -05:00
zach rice 8536f16ceb rm commit count log 2018-10-10 09:41:49 -05:00
Zachary Rice 6862c13bf7 Merge pull request #109 from zricethezav/depth
Depth
2018-10-09 21:13:29 -05:00
zach rice 9939c638ec better log 2018-10-09 21:07:49 -05:00
zach rice ed3a512b4b commit depth option 2018-10-09 21:01:56 -05:00
Zachary Rice 7c988c927d Merge pull request #107 from camaya/feature/add-entropy-checks
Add option to check string entropy
2018-10-09 18:46:21 -05:00
zach rice bde9af44ea merging, adding comments, updating flag description 2018-10-09 18:42:09 -05:00
Zachary Rice eee4d05642 Merge pull request #108 from camaya/fix-commit-option
Fix commit option
2018-10-09 16:18:54 -05:00
Cristhian Amaya 9144594d77 Fix commit option
The --commit option was being ignored becase the Close() function doesn't stop
the iterator.
According to the documentation:
https://godoc.org/gopkg.in/src-d/go-git.v4/plumbing/object#FileIter.ForEach
an ErrStop error should be send to stop it.
2018-10-09 16:49:16 +02:00
Cristhian Amaya 1cb15242fd Add option to check string entropy
Strings with high entropy have a good probability of being a secret.
2018-10-08 16:08:04 +02:00
Zachary Rice 08498600d1 Merge pull request #106 from zricethezav/exclude-fork
exclude fork
2018-10-07 18:42:42 -05:00
zach rice 88c0c7779b exclude fork 2018-10-07 18:39:17 -05:00
Zachary Rice 67454d109e Merge pull request #105 from zricethezav/wlrepo
Wlrepo
2018-10-07 18:26:18 -05:00
zach rice ce603c73b4 sample config opt 2018-10-07 18:19:43 -05:00
zach rice 55218fc8f8 whitelist repos 2018-10-07 18:09:10 -05:00
Zachary Rice 5d81c650e8 Merge pull request #104 from zricethezav/comments
Comments
2018-10-06 19:31:14 -05:00
zach rice 0726209172 maintenance 2018-10-06 19:27:54 -05:00
zach rice bfec8aca51 working on better comments 2018-10-05 22:55:19 -05:00
Zachary Rice a9b30edb06 Resource fix (#103)
* bumping version
2018-10-04 10:11:52 -05:00
Zachary Rice cc6d698e63 Resource fix (#102)
* no more dangling goroutines
2018-10-04 09:47:18 -05:00
Zachary Rice 2ba97d0fa3 fixing audit repo bug (#101)
* fixing audit repo bug

* bumping version
2018-10-02 12:34:05 -05:00
Zachary Rice d299b5aa7f Exitcode (#100)
* additional exit code, some more cleaning

* bump version
2018-10-02 09:52:18 -05:00
Zachary Rice 0a209b60a5 typo 2018-10-02 07:59:11 -05:00
Zachary Rice fe8c6271f2 panic plan (#99) 2018-10-01 22:44:25 -05:00
zach rice 42fb085684 pls contribute 2018-10-01 21:54:31 -05:00
Zachary Rice 3faec00bf9 Max go (#98)
* default max go, cleaning up for orgs

* bump changelog

* bumping version
2018-10-01 21:21:19 -05:00
Zachary Rice 93669f1ee8 Csv (#96)
* refactoring github audits, adding csv support

* working on tests

* test passing

* bumping version

* updating readme
2018-09-29 22:11:40 -05:00
Zachary Rice fad98cbde2 Single commit repo (#95)
* supporting repos with one commit
2018-09-26 14:28:22 -05:00
Zachary Rice 8eb28cbb4c Merge pull request #91 from zricethezav/audit_branch
test branch opt, bump changelog
2018-09-12 19:33:46 -05:00
zach rice 9dc9a8e62a bump version 2018-09-12 19:23:20 -05:00
zach rice e6caef0d94 test branch opt, bump changelog 2018-09-12 19:17:04 -05:00
Zachary Rice 5e289ed0cc Merge pull request #88 from Fabse333/master
Added Support for branches
2018-09-12 12:41:00 -05:00
Fabian Helfert d99588fe19 Fixed failure when Branch option is ommited 2018-08-23 14:07:25 +02:00
Fabian Helfert a7ccb7a9d1 Added Support for branches 2018-08-23 13:50:32 +02:00
Zachary Rice f32abb921d Merge pull request #87 from nenadstojanovikj/patch-1
Update description to reflect regex
2018-08-22 09:41:28 -05:00
Nenad Stojanovikj e8851c1f99 Update description to reflect regex 2018-08-21 21:08:44 +02:00
Zachary Rice f3a8359ac0 Merge pull request #86 from zricethezav/patch-err-check
Patch err check
2018-08-11 15:33:39 -04:00
zach rice 829e8fed8c up check to warning msg 2018-08-11 14:30:34 -05:00
zach rice c7e3605bff bump patch 2018-08-11 14:29:23 -05:00
zach rice c1774b1596 err check on patch 2018-08-11 14:27:51 -05:00
Zachary Rice 35710a7428 Merge pull request #85 from eripa/github-enterprise-support
GitHub Enterprise support + improved error handling. Fixes #84
2018-08-10 15:59:52 -04:00
Eric Ripa c7ba4d8bbf Update README and CHANGELOG with GitHub URL/Enterprise support detailed 2018-08-10 06:59:04 -07:00
Eric Ripa 5585e10933 Change error handling in getRepo functions
Instead of returning an empty list of repositories
and an error if any cloning operation fails, simply
store the error in the Repo instance and always
return all repos.

Then later on check for errors during the audit step.

By having this approach we don't prematurely exit
the scanning if there are problems during cloning,
such as if a repository is empty and fails to clone.
2018-08-09 11:31:29 -07:00
Eric Ripa 23d5bf0b51 Add simply TCP check during optsGuard to verify the given github URL 2018-08-09 11:30:55 -07:00
Eric Ripa b1c7a84fae Add initial support for GitHub Enterprise custom URLs 2018-08-09 10:04:41 -07:00
Zachary Rice 60801b336a Opt version (#80)
* version opt

* change-log
2018-07-22 20:16:09 -05:00
Zachary Rice 851ea3df3c anime 2018-07-22 10:03:01 -05:00
Zachary Rice d482577e47 copyleft 2018-07-21 14:19:28 -05:00
zricethezav 94e7a25b5b removing log formatting 2018-07-21 14:01:39 -05:00
zricethezav 45d94fa013 fixing commit patch order and report commit 2018-07-21 14:00:33 -05:00
zricethezav b4e69ecd37 clone and results logs, some additional comments 2018-07-21 13:29:32 -05:00
zricethezav 1c2820b4f1 Merge branch 'master' of github.com:zricethezav/gitleaks 2018-07-21 11:15:19 -05:00
zricethezav 215c3f6623 Simple slogan 2018-07-21 11:15:05 -05:00
Zachary Rice 39b162cadf Merge pull request #78 from zricethezav/default_mem
Updating Makefile, making in-memory default, adding disk option
2018-07-21 10:34:58 -05:00
zricethezav e0c717c3a3 Updating Makefile, making in-memory default, adding disk option 2018-07-21 09:09:39 -05:00
zricethezav ebb9be999f update sample docker cmd 2018-07-20 21:51:56 -05:00
Zachary Rice 5fbb15be62 Merge pull request #77 from arjunyel/patch-2
Twitter typo
2018-07-20 21:46:53 -05:00
Zachary Rice 8922546a00 Merge pull request #76 from arjunyel/patch-1
Update Go docker version
2018-07-20 21:45:59 -05:00
arjunyel 38b7fc3cfb Twitter typo 2018-07-20 21:34:00 -05:00
arjunyel 8a76e0af27 Update Go docker version 2018-07-20 21:17:49 -05:00
1314 changed files with 6771 additions and 323588 deletions

No files matched your search

+4
View File
@@ -0,0 +1,4 @@
# These are supported funding model platforms
github: [zricethezav]
custom: ["https://www.paypal.me/zricethezav"]
+29
View File
@@ -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
+22
View File
@@ -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
+8
View File
@@ -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
View File
@@ -0,0 +1,13 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
*.DS_STORE
*.idea
gitleaks
build
# Test binary
*.out
+2 -13
View File
@@ -1,19 +1,8 @@
sudo: required
language: go
go:
- 1.9
- 1.14.x
services:
- docker
script:
- make test
after_success:
- export REPO=zricethezav/gitleaks
- export TAG=`if [ "$TRAVIS_BRANCH" == "master" ]; then echo "latest"; else echo $TRAVIS_BRANCH;
fi`
- if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then make deploy; fi
env:
global:
- secure: kUjq6Jgnm57V+ikDoYJ4IrFu4bLMHkaBb9uLtbQj0A545zZt4Dbooarnwqbfz2efqqMDZ9TXP6kN6677yWm0DyvFOCYx/Xq2innnVbBJczQciEUb5PI/9fcmLOfTe/QgGNi0GZOCdIOGlki2sbKxob6tTOUsm52ugRSJU92cXkX8w+Gzc6pC6fAb4moLE2QpwK1xWDHm2sHiZYExpBOH8eidSH5VPGVdNE9QmUA/FwwJ9NFGsZ8BgWCJPy7IJreyixsv2nNpiZNHoj0UgKe4wylzceu4sG/yQDIYk3fLVWBXSm/nSA17QYIjVMzQFjSAVC5dRqzq8HzFYiAYLKzkoOtrbBqEGtXzYZMN6yC8zEedk9gX6P6mvGpWYBy280uumcpGl6eoKYj5ke2H6kfcCUhMNTGZP17nmnTa1KFLAz1nxB1jfJwwO6v1l+xdytju5yAhm049Af7VyDM5GmE2x5ha48uKvK7wHtv+IKiZbbcR9ExsXvm21+7NVjQvRPzAw4/Sor9SG/yjoA/Sf7e4evy1w3fALv4WlaSisj5Yalmv7mzeeFZaIB7EIq6OryeRld2Rr1MZwwhZgIs7+SWwpjKfwhkfLVEUvSWCdnS2tnTydK6R6OFxfG5TGfR/WHooXLHEv5gMuKhUu/CqnbLyvI+8IOH2ybz2AtZWjf5n7oY=
- secure: cIxKSkBNkPFAn243eHtwHJb8z6Uty1cZ43ZK/UABjwJoSrhu/roK4soqdZLwdVRA/0QswAlp6AC25Zs3ngLKGxxFHoeB8Tx6VLanE1zoi8OT0I2KbT92FdrLV4HlcRshKZtTFoTCfgVKPnWNKC+hil97CQzQPGRpZLBSfNefk5uCMnQiAzaJ5lyWPx+sjLHzpVlGA6aQx9ZeBQqngQJoDHKc0K3hKwug4h9mkkhyaYE3kgxtsdOYlHvOtQgVk+Zih5uW7ABOQCyAOaQVipXBC+uiuNf2DeAuGDaX69DTRKqPzuIasbhwyGqlfsr2JeofEWgZGmTaWGKMi03hnIY+U9+lHjygBW1qqVglODboouUrV3LwER9kqrT+ZFTM5Ca8VB+Gx5khkknbjWd06jpzRQxNXdukYN89kEaAHkBH844G99pMDqcZ32lHK7lpCu8n1H/Liz3ygoV6ScJXnYAP6y9rrd3bb9KEmnKhmFacVLRIAUw1vN/cgspJpl/Mk6s5rvGwsbQih1OxGyooOLxGjEGWqVDFgHFtyiwX9s9kT+hNTwKgbhp7Ragk/QuDYUPZ3Vum7HoiNPS9KpQNstLvDckdtd8h13JIw6nX+xdWbNKjjdYbAZRstJHUROQtNq3XdWNQ9YjqbCoybaxCOwOUTwOiTSWNKXjTFbFI5mR/ZO0=
- COMMIT=${TRAVIS_COMMIT::8}
- secure: o6uPX071qGRKgOQmitxiDr1j+KRW8W6ru0wmKNBFuUlZvQudwCUZMnVfk6OeofT1IgLCHmLS8ST81cTyeXqOQhYVZrlxTmEUpDHHRTu6dOj3eqRzdJow1LIWNpw5xfOaqXUdQ8+SQ47ZeSFapsmaY9oeRDvSJ8zLS4qUdgUylvZFJWjSrjzi2xemJa1l3MDdZRhEaNkfMliDGCv2vuUFp7tYz0QtyqBkBMORQl53dzgrcQcsRjDSE274WJl9CUg1l0pNMFsAbVCUGwUqCmKace9LXZ9JV00TRdg4EpryDsUCi23q0THnwstvRffwyJrw+xbhY/X3GKC4zOKqiCLJ4MTPQEIKlpVJQ9e9lWJ8FYhpUrl3QaHfEPINJ0taUfGhCyNzi5QBkSWbTcWVmRMmu+QIy7moW9crcz2xmVEUey7AaGwZT2Kk6JGw26w5q9IUy1Z9mwaljmHrUTqZrOX4Hj3UblpkHN+mGkoia/ipta5KhN5lTTIs4N3V+El7O2R2GggBrVHNiSualfydo+RX8k/S6PM1/C88IQO3Y2utoJrr415CznncvhF9Sc6tncZcShcNQj1iEOSsGxY2noW265eHzTMKJ/xuN6Bp9OXVK+8iOcUsz1T7F0UqwY3xnD8F7fBZ7IGG41DsXBDIcPmb+SIYbhv0uJjm3BEuv4TzIU0=
- make security-scan
+5 -4
View File
@@ -1,9 +1,10 @@
FROM golang:1.10.0 AS build
FROM golang:1.15.5 AS build
WORKDIR /go/src/github.com/zricethezav/gitleaks
ARG ldflags
COPY . .
RUN CGO_ENABLED=0 go build -o bin/gitleaks *.go
RUN GO111MODULE=on CGO_ENABLED=0 go build -o bin/gitleaks -ldflags "-X="${ldflags} *.go
FROM alpine:3.7
FROM alpine:3.11
RUN apk add --no-cache bash git openssh
COPY --from=build /go/src/github.com/zricethezav/gitleaks/bin/* /usr/bin/
ENTRYPOINT ["gitleaks"]
@@ -11,6 +12,6 @@ ENTRYPOINT ["gitleaks"]
# How to use me :
# docker build -t gitleaks .
# docker run --rm --name=gitleaks gitleaks https://github.com/zricethezav/gitleaks
# docker run --rm --name=gitleaks gitleaks --repo=https://github.com/zricethezav/gitleaks
# This will check for secrets in https://github.com/zricethezav/gitleaks
Generated
-153
View File
@@ -1,153 +0,0 @@
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
[[projects]]
name = "github.com/BurntSushi/toml"
packages = ["."]
revision = "b26d9c308763d68093482582cea63d69be07a0f0"
version = "v0.3.0"
[[projects]]
name = "github.com/emirpasic/gods"
packages = ["containers","lists","lists/arraylist","trees","trees/binaryheap","utils"]
revision = "f6c17b524822278a87e3b3bd809fec33b51f5b46"
version = "v1.9.0"
[[projects]]
name = "github.com/franela/goblin"
packages = ["."]
revision = "cd5d08fb4ede9eaac1812fdb513552e7404eae2e"
version = "0.0.2"
[[projects]]
name = "github.com/golang/protobuf"
packages = ["proto"]
revision = "b4deda0973fb4c70b50d226b1af49f3da59f5265"
version = "v1.1.0"
[[projects]]
name = "github.com/google/go-github"
packages = ["github"]
revision = "e48060a28fac52d0f1cb758bc8b87c07bac4a87d"
version = "v15.0.0"
[[projects]]
branch = "master"
name = "github.com/google/go-querystring"
packages = ["query"]
revision = "53e6ce116135b80d037921a7fdd5138cf32d7a8a"
[[projects]]
branch = "master"
name = "github.com/jbenet/go-context"
packages = ["io"]
revision = "d14ea06fba99483203c19d92cfcd13ebe73135f4"
[[projects]]
name = "github.com/jessevdk/go-flags"
packages = ["."]
revision = "c6ca198ec95c841fdb89fc0de7496fed11ab854e"
version = "v1.4.0"
[[projects]]
name = "github.com/kevinburke/ssh_config"
packages = ["."]
revision = "9fc7bb800b555d63157c65a904c86a2cc7b4e795"
version = "0.4"
[[projects]]
branch = "master"
name = "github.com/mitchellh/go-homedir"
packages = ["."]
revision = "3864e76763d94a6df2f9960b16a20a33da9f9a66"
[[projects]]
name = "github.com/pelletier/go-buffruneio"
packages = ["."]
revision = "c37440a7cf42ac63b919c752ca73a85067e05992"
version = "v0.2.0"
[[projects]]
name = "github.com/sergi/go-diff"
packages = ["diffmatchpatch"]
revision = "1744e2970ca51c86172c8190fadad617561ed6e7"
version = "v1.0.0"
[[projects]]
name = "github.com/sirupsen/logrus"
packages = ["."]
revision = "c155da19408a8799da419ed3eeb0cb5db0ad5dbc"
version = "v1.0.5"
[[projects]]
name = "github.com/src-d/gcfg"
packages = [".","scanner","token","types"]
revision = "f187355171c936ac84a82793659ebb4936bc1c23"
version = "v1.3.0"
[[projects]]
name = "github.com/xanzy/ssh-agent"
packages = ["."]
revision = "640f0ab560aeb89d523bb6ac322b1244d5c3796c"
version = "v0.2.0"
[[projects]]
branch = "master"
name = "golang.org/x/crypto"
packages = ["cast5","curve25519","ed25519","ed25519/internal/edwards25519","internal/chacha20","internal/subtle","openpgp","openpgp/armor","openpgp/elgamal","openpgp/errors","openpgp/packet","openpgp/s2k","poly1305","ssh","ssh/agent","ssh/knownhosts","ssh/terminal"]
revision = "a49355c7e3f8fe157a85be2f77e6e269a0f89602"
[[projects]]
branch = "master"
name = "golang.org/x/net"
packages = ["context","context/ctxhttp"]
revision = "d0887baf81f4598189d4e12a37c6da86f0bba4d0"
[[projects]]
branch = "master"
name = "golang.org/x/oauth2"
packages = [".","internal"]
revision = "ef147856a6ddbb60760db74283d2424e98c87bff"
[[projects]]
branch = "master"
name = "golang.org/x/sys"
packages = ["unix","windows"]
revision = "ac767d655b305d4e9612f5f6e33120b9176c4ad4"
[[projects]]
name = "golang.org/x/text"
packages = ["internal/gen","internal/triegen","internal/ucd","transform","unicode/cldr","unicode/norm"]
revision = "f21a4dfb5e38f5895301dc265a8def02365cc3d0"
version = "v0.3.0"
[[projects]]
name = "google.golang.org/appengine"
packages = ["internal","internal/base","internal/datastore","internal/log","internal/remote_api","internal/urlfetch","urlfetch"]
revision = "b1f26356af11148e710935ed1ac8a7f5702c7612"
version = "v1.1.0"
[[projects]]
name = "gopkg.in/src-d/go-billy.v4"
packages = [".","helper/chroot","helper/polyfill","osfs","util"]
revision = "83cf655d40b15b427014d7875d10850f96edba14"
version = "v4.2.0"
[[projects]]
name = "gopkg.in/src-d/go-git.v4"
packages = [".","config","internal/revision","plumbing","plumbing/cache","plumbing/filemode","plumbing/format/config","plumbing/format/diff","plumbing/format/gitignore","plumbing/format/idxfile","plumbing/format/index","plumbing/format/objfile","plumbing/format/packfile","plumbing/format/pktline","plumbing/object","plumbing/protocol/packp","plumbing/protocol/packp/capability","plumbing/protocol/packp/sideband","plumbing/revlist","plumbing/storer","plumbing/transport","plumbing/transport/client","plumbing/transport/file","plumbing/transport/git","plumbing/transport/http","plumbing/transport/internal/common","plumbing/transport/server","plumbing/transport/ssh","storage","storage/filesystem","storage/filesystem/dotgit","storage/memory","utils/binary","utils/diff","utils/ioutil","utils/merkletrie","utils/merkletrie/filesystem","utils/merkletrie/index","utils/merkletrie/internal/frame","utils/merkletrie/noder"]
revision = "3bd5e82b2512d85becae9677fa06b5a973fd4cfb"
version = "v4.5.0"
[[projects]]
name = "gopkg.in/warnings.v0"
packages = ["."]
revision = "ec4a0fea49c7b46c2aeb0b51aac55779c607e52b"
version = "v0.1.2"
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "5af7c639081bd99afc4a673e96079d2ed9e76d0e1bf0d2cc5ad9c71274beaa86"
solver-name = "gps-cdcl"
solver-version = 1
-58
View File
@@ -1,58 +0,0 @@
# Gopkg.toml example
#
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"
#
# [prune]
# non-go = false
# go-tests = true
# unused-packages = true
[[constraint]]
name = "github.com/BurntSushi/toml"
version = "0.3.0"
[[constraint]]
name = "github.com/franela/goblin"
version = "0.0.2"
[[constraint]]
name = "github.com/google/go-github"
version = "15.0.0"
[[constraint]]
name = "github.com/jessevdk/go-flags"
version = "1.4.0"
[[constraint]]
name = "github.com/sirupsen/logrus"
version = "1.0.5"
[[constraint]]
branch = "master"
name = "golang.org/x/oauth2"
[[constraint]]
name = "gopkg.in/src-d/go-git.v4"
version = "4.5.0"
[prune]
go-tests = true
unused-packages = true
@@ -1,6 +1,6 @@
The MIT License (MIT)
MIT License
Copyright (c) 2014 Simon Eskildsen
Copyright (c) 2019 Zachary Rice
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -9,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+44 -16
View File
@@ -1,21 +1,49 @@
.PHONY: test build-all release
.PHONY: test test-cover build release-builds
VERSION := `git fetch --tags && git tag | sort -V | tail -1`
PKG=github.com/zricethezav/gitleaks
LDFLAGS=-ldflags "-X=github.com/zricethezav/gitleaks/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 github.com/golang/lint/golint
go fmt
golint
go test --race -cover
go get golang.org/x/lint/golint
go fmt ./...
go vet ./...
golint ./...
go test ./... --race $(PKG) -v
build:
go fmt ./...
golint ./...
go vet ./...
go mod tidy
go build $(LDFLAGS)
security-scan:
go get github.com/securego/gosec/cmd/gosec
gosec -no-fail ./...
release-builds:
rm -rf build
mkdir build
env GOOS="windows" GOARCH="amd64" go build -o "build/gitleaks-windows-amd64.exe" $(LDFLAGS)
env GOOS="windows" GOARCH="386" go build -o "build/gitleaks-windows-386.exe" $(LDFLAGS)
env GOOS="linux" GOARCH="amd64" go build -o "build/gitleaks-linux-amd64" $(LDFLAGS)
env GOOS="linux" GOARCH="arm" go build -o "build/gitleaks-linux-arm" $(LDFLAGS)
env GOOS="linux" GOARCH="mips" go build -o "build/gitleaks-linux-mips" $(LDFLAGS)
env GOOS="linux" GOARCH="mips" go build -o "build/gitleaks-linux-mips" $(LDFLAGS)
env GOOS="darwin" GOARCH="amd64" go build -o "build/gitleaks-darwin-amd64" $(LDFLAGS)
deploy:
@echo "$(DOCKER_PASSWORD)" | docker login -u "$(DOCKER_USERNAME)" --password-stdin
docker build -f Dockerfile -t $(REPO):$(TAG) .
echo "Pushing $(REPO):$(COMMIT) $(REPO):$(TAG)"
docker push $(REPO)
docker build --build-arg ldflags=$(_LDFLAGS) -f Dockerfile -t zricethezav/gitleaks:latest -t zricethezav/gitleaks:$(VERSION) .
echo "Pushing zricethezav/gitleaks:$(VERSION) and zricethezav/gitleaks:latest"
docker push zricethezav/gitleaks
build-all:
mkdir build
env GOOS="windows" GOARCH="amd64" go build -o "build/gitleaks-windows-amd64.exe"
env GOOS="windows" GOARCH="386" go build -o "build/gitleaks-windows-386.exe"
env GOOS="linux" GOARCH="amd64" go build -o "build/gitleaks-linux-amd64"
env GOOS="linux" GOARCH="arm" go build -o "build/gitleaks-linux-arm"
env GOOS="linux" GOARCH="mips" go build -o "build/gitleaks-linux-mips"
env GOOS="linux" GOARCH="mips" go build -o "build/gitleaks-linux-mips"
dockerbuild:
docker build --build-arg ldflags=$(_LDFLAGS) -f Dockerfile -t zricethezav/gitleaks:latest -t zricethezav/gitleaks:$(VERSION) .
+79 -36
View File
@@ -1,59 +1,102 @@
<p align="center">
<img alt="gitleaks" src="https://raw.githubusercontent.com/zricethezav/gifs/master/gitleaks5.png" height="140" />
<img alt="gitleaks" src="https://raw.githubusercontent.com/zricethezav/gifs/master/gitleakslogo.png" height="70" />
<p align="center">
<a href="https://travis-ci.org/zricethezav/gitleaks"><img alt="Travis" src="https://img.shields.io/travis/zricethezav/gitleaks/master.svg?style=flat-square"></a>
</p>
</p>
## Audit git repos for secrets, keys, and whatever.
### Powered by src-d's [go-git](https://github.com/src-d/go-git)
Gitleaks is a SAST tool for detecting hardcoded secrets like passwords, api keys, and tokens in git repos. Gitleaks aims to be the **easy-to-use, all-in-one solution** for finding secrets, past or present, in your code.
### Features:
- Scan for [commited](https://github.com/zricethezav/gitleaks/wiki/Scanning) secrets
- Scan for [uncommitted](https://github.com/zricethezav/gitleaks/wiki/Scanning#uncommitted-changes-scan) secrets as part of shifting security left
- Scan for entire directories and files
- Available [Github Action](https://github.com/marketplace/actions/gitleaks)
- [Custom rules](https://github.com/zricethezav/gitleaks/wiki/Configuration) via toml configuration
- High performance using [go-git](https://github.com/go-git/go-git)
- JSON, SARIF, and CSV reporting
- Private repo scans using key or password based authentication
#### Installing
### Installation
Written in Go, gitleaks is available in binary form for many popular platforms and OS types from the [releases page](https://github.com/zricethezav/gitleaks/releases). Alternatively, executed via Docker or it can be installed using Go directly.
##### MacOS
```
brew install gitleaks
```
##### Docker
```bash
go get -u github.com/zricethezav/gitleaks
docker pull zricethezav/gitleaks
```
Or download from release binaries [here](https://github.com/zricethezav/gitleaks/releases)
##### Go
```bash
GO111MODULE=on go get github.com/zricethezav/gitleaks/v7
```
#### Usage and Options
### Usage and Options
```
Usage:
gitleaks [OPTIONS]
Application Options:
-r, --repo= Repo url to audit
--github-user= User url to audit
--github-org= Organization url to audit
-p, --private Include private repos in audit
-c, --commit= sha of commit to stop at
--repo-path= Path to repo
--owner-path= Path to owner directory (repos discovered)
--max-go= Maximum number of concurrent go-routines gitleaks spawns
-m, --in-memory Run gitleaks in memory
--all-refs run audit on all refs
--single-search= single regular expression to search for
--config= path to gitleaks config
--ssh-key= path to ssh key
-l, --log= log level
-v, --verbose Show verbose output from gitleaks audit
--report= path to write report file
--redact redact secrets from log messages and report
-v, --verbose Show verbose output from scan
-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
--clone-path= Path to clone repo to disk
--clone-cleanup= Deletes cloned repo after scan
--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
--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
```
#### Exit Codes
```
1: leaks present
0: no leaks
-h, --help Show this help message
```
#### Additional Examples and Explanations
Check the wiki [here](https://github.com/zricethezav/gitleaks/wiki)
### If you find a valid leak in a repo
Please read this [Github article on removing sensitive data from a repository](https://help.github.com/articles/removing-sensitive-data-from-a-repository/) to remove the sensitive information from your history.
### Sponsors ❤️
#### Corporate Sponsors
[![gammanet](https://gammanet.com/assets/images/new-design/gamma-logo.png)](https://gammanet.com/?utm_source=gitleaks&utm_medium=homepage&utm_campaign=gitleaks_promotion)
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:
[![Adam Shannon](https://github.com/adamdecaf.png?size=50)](https://github.com/adamdecaf) |
---|
----
#### Logo Attribution
The Gitleaks logo uses the Git Logo created <a href="https://twitter.com/jasonlong">Jason Long</a> is licensed under the <a href="https://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution 3.0 Unported License</a>.
### Run me with docker
Simply run `docker run --rm --name=gitleaks zricethezav/gitleaks https://github.com/zricethezav/gitleaks`
+315
View File
@@ -0,0 +1,315 @@
package config
import (
"fmt"
"path"
"regexp"
"strconv"
"github.com/zricethezav/gitleaks/v7/options"
"github.com/BurntSushi/toml"
"github.com/go-git/go-git/v5"
log "github.com/sirupsen/logrus"
)
// AllowList is struct containing items that if encountered will allowlist
// a commit/line of code that would be considered a leak.
type AllowList struct {
Description string
Regexes []*regexp.Regexp
Commits []string
Files []*regexp.Regexp
Paths []*regexp.Regexp
Repos []*regexp.Regexp
}
// Entropy represents an entropy range
type Entropy struct {
Min float64
Max float64
Group int
}
// Rule is a struct that contains information that is loaded from a gitleaks config.
// This struct is used in the Config struct as an array of Rules and is iterated
// over during an scan. Each rule will be checked. If a regex match is found AND
// that match is not allowlisted (globally or locally), then a leak will be appended
// to the final scan report.
type Rule struct {
Description string
Regex *regexp.Regexp
File *regexp.Regexp
Path *regexp.Regexp
ReportGroup int
Tags []string
AllowList AllowList
Entropies []Entropy
}
// Config is a composite struct of Rules and Allowlists
// Each Rule contains a description, regular expression, tags, and allowlists if available
type Config struct {
Rules []Rule
Allowlist AllowList
}
// TomlAllowList is a struct used in the TomlLoader that loads in allowlists from
// specific rules or globally at the top level config
type TomlAllowList struct {
Description string
Regexes []string
Commits []string
Files []string
Paths []string
Repos []string
}
// TomlLoader gets loaded with the values from a gitleaks toml config
// see the config in config/defaults.go for an example. TomlLoader is used
// to generate Config values (compiling regexes, etc).
type TomlLoader struct {
AllowList TomlAllowList
Rules []struct {
Description string
Regex string
File string
Path string
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
}
var tomlLoader TomlLoader
_, err = toml.DecodeReader(r, &tomlLoader)
if err != nil {
return Config{}, err
}
return tomlLoader.Parse()
}
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
}
var tomlLoader TomlLoader
r, err := f.Reader()
if err != nil {
return Config{}, err
}
_, err = toml.DecodeReader(r, &tomlLoader)
if err != nil {
return Config{}, err
}
return tomlLoader.Parse()
}
+213
View File
@@ -0,0 +1,213 @@
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
}
+164
View File
@@ -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,20})?(?-i)[0-9a-zA-Z]{35,40}'''
tags = ["key", "Github"]
[[rules]]
description = "LinkedIn Client ID"
regex = '''(?i)linkedin(.{0,20})?(?-i)[0-9a-z]{12}'''
tags = ["client", "LinkedIn"]
[[rules]]
description = "LinkedIn Secret Key"
regex = '''(?i)linkedin(.{0,20})?[0-9a-z]{16}'''
tags = ["secret", "LinkedIn"]
[[rules]]
description = "Slack"
regex = '''xox[baprs]-([0-9a-zA-Z]{10,48})?'''
tags = ["key", "Slack"]
[[rules]]
description = "Asymmetric Private Key"
regex = '''-----BEGIN ((EC|PGP|DSA|RSA|OPENSSH) )?PRIVATE KEY( BLOCK)?-----'''
tags = ["key", "AsymmetricPrivateKey"]
[[rules]]
description = "Google API key"
regex = '''AIza[0-9A-Za-z\\-_]{35}'''
tags = ["key", "Google"]
[[rules]]
description = "Google (GCP) Service Account"
regex = '''"type": "service_account"'''
tags = ["key", "Google"]
[[rules]]
description = "Heroku API key"
regex = '''(?i)heroku(.{0,20})?[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'''
tags = ["key", "Heroku"]
[[rules]]
description = "MailChimp API key"
regex = '''(?i)(mailchimp|mc)(.{0,20})?[0-9a-f]{32}-us[0-9]{1,2}'''
tags = ["key", "Mailchimp"]
[[rules]]
description = "Mailgun API key"
regex = '''((?i)(mailgun|mg)(.{0,20})?)?key-[0-9a-z]{32}'''
tags = ["key", "Mailgun"]
[[rules]]
description = "PayPal Braintree access token"
regex = '''access_token\$production\$[0-9a-z]{16}\$[0-9a-f]{32}'''
tags = ["key", "Paypal"]
[[rules]]
description = "Picatic API key"
regex = '''sk_live_[0-9a-z]{32}'''
tags = ["key", "Picatic"]
[[rules]]
description = "SendGrid API Key"
regex = '''SG\.[\w_]{16,32}\.[\w_]{16,64}'''
tags = ["key", "SendGrid"]
[[rules]]
description = "Slack Webhook"
regex = '''https://hooks.slack.com/services/T[a-zA-Z0-9_]{8}/B[a-zA-Z0-9_]{8}/[a-zA-Z0-9_]{24}'''
tags = ["key", "slack"]
[[rules]]
description = "Stripe API key"
regex = '''(?i)stripe(.{0,20})?[sr]k_live_[0-9a-zA-Z]{24}'''
tags = ["key", "Stripe"]
[[rules]]
description = "Square access token"
regex = '''sq0atp-[0-9A-Za-z\-_]{22}'''
tags = ["key", "square"]
[[rules]]
description = "Square OAuth secret"
regex = '''sq0csp-[0-9A-Za-z\\-_]{43}'''
tags = ["key", "square"]
[[rules]]
description = "Twilio API key"
regex = '''(?i)twilio(.{0,20})?SK[0-9a-f]{32}'''
tags = ["key", "twilio"]
[[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$''',
'''(.*?)(jpg|gif|doc|pdf|bin)$''',
'''(go.mod|go.sum)$''']
`
+195
View File
@@ -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)$''']
+19
View File
@@ -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
+17
View File
@@ -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"
+6
View File
@@ -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"]
-30
View File
@@ -1,30 +0,0 @@
title = "gitleaks config"
[[regexes]]
description = "AWS"
regex = '''AKIA[0-9A-Z]{16}'''
[[regexes]]
description = "RKCS8"
regex = '''-----BEGIN PRIVATE KEY-----'''
[[regexes]]
description = "RSA"
regex = '''-----BEGIN RSA PRIVATE KEY-----'''
[[regexes]]
description = "Github"
regex = '''(?i)github.*['\"][0-9a-zA-Z]{35,40}['\"]'''
[[regexes]]
description = "SSH"
regex = '''-----BEGIN OPENSSH PRIVATE KEY-----'''
[[regexes]]
description = "Facebook"
regex = '''(?i)facebook.*['\"][0-9a-f]{32}['\"]'''
[[regexes]]
description = "Facebook"
regex = '''(?i)twitter.*['\"][0-9a-zA-Z]{35,44}['\"]'''
[whitelist]
regexes = [
"AKIA.*",
]
files = [
"(.*?)(jpg|gif|doc|pdf|bin|go)$"
]
-650
View File
@@ -1,650 +0,0 @@
package main
import (
"fmt"
"io/ioutil"
"os"
"path"
"regexp"
"strings"
"testing"
"github.com/franela/goblin"
git "gopkg.in/src-d/go-git.v4"
"gopkg.in/src-d/go-git.v4/storage/memory"
)
const testWhitelistCommit = `
[[regexes]]
description = "AWS"
regex = '''AKIA[0-9A-Z]{16}'''
[whitelist]
commits = [
"eaeffdc65b4c73ccb67e75d96bd8743be2c85973",
]
`
const testWhitelistFile = `
[[regexes]]
description = "AWS"
regex = '''AKIA[0-9A-Z]{16}'''
[whitelist]
files = [
".go",
]
`
const testWhitelistBranch = `
[[regexes]]
description = "AWS"
regex = '''AKIA[0-9A-Z]{16}'''
[whitelist]
branches = [
"origin/master",
]
`
const testWhitelistRegex = `
[[regexes]]
description = "AWS"
regex = '''AKIA[0-9A-Z]{16}'''
[whitelist]
regexes= [
"AKIA",
]
`
func TestGetRepo(t *testing.T) {
var err error
dir, err = ioutil.TempDir("", "gitleaksTestRepo")
defer os.RemoveAll(dir)
if err != nil {
panic(err)
}
_, err = git.PlainClone(dir, false, &git.CloneOptions{
URL: "https://github.com/gitleakstest/gronit",
})
if err != nil {
panic(err)
}
var tests = []struct {
testOpts Options
description string
expectedErrMsg string
}{
{
testOpts: Options{
Repo: "https://github.com/gitleakstest/gronit",
},
description: "test plain clone remote repo",
expectedErrMsg: "",
},
{
testOpts: Options{
Repo: "https://github.com/gitleakstest/gronit",
InMem: true,
},
description: "test inmem clone remote repo",
expectedErrMsg: "",
},
{
testOpts: Options{
RepoPath: dir,
},
description: "test local clone repo",
expectedErrMsg: "",
},
{
testOpts: Options{
Repo: "https://github.com/gitleakstest/nope",
},
description: "test no repo",
expectedErrMsg: "authentication required",
},
{
testOpts: Options{
Repo: "https://github.com/gitleakstest/private",
IncludePrivate: true,
},
description: "test private repo",
expectedErrMsg: "invalid auth method",
},
{
testOpts: Options{
Repo: "https://github.com/gitleakstest/private",
IncludePrivate: true,
InMem: true,
},
description: "test private repo",
expectedErrMsg: "invalid auth method",
},
}
g := goblin.Goblin(t)
for _, test := range tests {
g.Describe("TestGetRepo", func() {
g.It(test.description, func() {
opts = test.testOpts
_, err := getRepo()
if err != nil {
g.Assert(err.Error()).Equal(test.expectedErrMsg)
}
})
})
}
}
func TestGetOwnerRepo(t *testing.T) {
var err error
dir, err = ioutil.TempDir("", "gitleaksTestOwner")
defer os.RemoveAll(dir)
if err != nil {
panic(err)
}
git.PlainClone(dir+"/gronit", false, &git.CloneOptions{
URL: "https://github.com/gitleakstest/gronit",
})
git.PlainClone(dir+"/h1domains", false, &git.CloneOptions{
URL: "https://github.com/gitleakstest/h1domains",
})
var tests = []struct {
testOpts Options
description string
expectedErrMsg string
numRepos int
}{
{
testOpts: Options{
GithubUser: "gitleakstest",
},
description: "test github user",
numRepos: 2,
expectedErrMsg: "",
},
{
testOpts: Options{
GithubUser: "gitleakstest",
InMem: true,
},
description: "test github user in mem",
numRepos: 2,
expectedErrMsg: "",
},
{
testOpts: Options{
GithubOrg: "gitleakstestorg",
},
description: "test github org",
numRepos: 2,
expectedErrMsg: "",
},
{
testOpts: Options{
OwnerPath: dir,
},
description: "test plain clone remote repo",
numRepos: 2,
expectedErrMsg: "",
},
{
testOpts: Options{
GithubOrg: "gitleakstestorg",
IncludePrivate: true,
},
description: "test private org no ssh",
numRepos: 0,
expectedErrMsg: "no ssh auth available",
},
{
testOpts: Options{
GithubOrg: "gitleakstestorg",
InMem: true,
},
description: "test org in mem",
numRepos: 2,
expectedErrMsg: "",
},
{
testOpts: Options{
GithubOrg: "gitleakstestorg",
IncludePrivate: true,
InMem: true,
},
description: "test private org in mem no ssh",
numRepos: 0,
expectedErrMsg: "no ssh auth available",
},
}
g := goblin.Goblin(t)
for _, test := range tests {
g.Describe("TestGetOwnerRepo", func() {
g.It(test.description, func() {
opts = test.testOpts
repos, err := getOwnerRepos()
if err != nil {
g.Assert(err.Error()).Equal(test.expectedErrMsg)
}
g.Assert(len(repos)).Equal(test.numRepos)
})
})
}
}
func TestWriteReport(t *testing.T) {
tmpDir, _ := ioutil.TempDir("", "reportDir")
reportFile := path.Join(tmpDir, "report.json")
defer os.RemoveAll(tmpDir)
leaks := []Leak{
{
Line: "eat",
Commit: "your",
Offender: "veggies",
Type: "and",
Message: "get",
Author: "some",
File: "sleep",
Branch: "thxu",
},
}
var tests = []struct {
leaks []Leak
reportFile string
fileName string
description string
testOpts Options
}{
{
leaks: leaks,
reportFile: reportFile,
fileName: "report.json",
description: "can we write a file",
testOpts: Options{
Report: reportFile,
},
},
}
g := goblin.Goblin(t)
for _, test := range tests {
g.Describe("TestWriteReport", func() {
g.It(test.description, func() {
opts = test.testOpts
writeReport(test.leaks)
f, _ := os.Stat(test.reportFile)
g.Assert(f.Name()).Equal(test.fileName)
})
})
}
}
func testTomlLoader() string {
tmpDir, _ := ioutil.TempDir("", "whiteListConfigs")
ioutil.WriteFile(path.Join(tmpDir, "regex"), []byte(testWhitelistRegex), 0644)
ioutil.WriteFile(path.Join(tmpDir, "branch"), []byte(testWhitelistBranch), 0644)
ioutil.WriteFile(path.Join(tmpDir, "commit"), []byte(testWhitelistCommit), 0644)
ioutil.WriteFile(path.Join(tmpDir, "file"), []byte(testWhitelistFile), 0644)
return tmpDir
}
func TestAuditRepo(t *testing.T) {
var leaks []Leak
err := loadToml()
configsDir := testTomlLoader()
defer os.RemoveAll(configsDir)
if err != nil {
panic(err)
}
leaksRepo, err := git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
URL: "https://github.com/gitleakstest/gronit.git",
})
if err != nil {
panic(err)
}
cleanRepo, err := git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
URL: "https://github.com/gitleakstest/h1domains.git",
})
if err != nil {
panic(err)
}
var tests = []struct {
testOpts Options
description string
expectedErrMsg string
numLeaks int
repo *git.Repository
whiteListFiles []*regexp.Regexp
whiteListCommits map[string]bool
whiteListBranches []string
whiteListRegexes []*regexp.Regexp
configPath string
}{
{
repo: leaksRepo,
description: "two leaks present",
numLeaks: 2,
},
{
repo: leaksRepo,
description: "two leaks present limit goroutines",
numLeaks: 2,
testOpts: Options{
MaxGoRoutines: 2,
},
},
{
repo: leaksRepo,
description: "audit all branch",
numLeaks: 6,
testOpts: Options{
AuditAllRefs: true,
},
},
{
repo: leaksRepo,
description: "audit all branch whitelist 1",
numLeaks: 4,
testOpts: Options{
AuditAllRefs: true,
},
whiteListBranches: []string{
"origin/master",
},
},
{
repo: leaksRepo,
description: "two leaks present whitelist AWS.. no leaks",
whiteListRegexes: []*regexp.Regexp{
regexp.MustCompile("AKIA"),
},
numLeaks: 0,
},
{
repo: leaksRepo,
description: "two leaks present limit goroutines",
numLeaks: 2,
},
{
repo: cleanRepo,
description: "no leaks present",
numLeaks: 0,
},
{
repo: leaksRepo,
description: "two leaks present whitelist go files",
whiteListFiles: []*regexp.Regexp{
regexp.MustCompile(".go"),
},
numLeaks: 0,
},
{
repo: leaksRepo,
description: "two leaks present whitelist bad commit",
whiteListCommits: map[string]bool{
"eaeffdc65b4c73ccb67e75d96bd8743be2c85973": true,
},
numLeaks: 1,
},
{
repo: leaksRepo,
description: "redact",
testOpts: Options{
Redact: true,
},
numLeaks: 2,
},
{
repo: leaksRepo,
description: "toml whitelist regex",
configPath: path.Join(configsDir, "regex"),
numLeaks: 0,
},
{
repo: leaksRepo,
description: "toml whitelist branch",
configPath: path.Join(configsDir, "branch"),
testOpts: Options{
AuditAllRefs: true,
},
numLeaks: 4,
},
{
repo: leaksRepo,
description: "toml whitelist file",
configPath: path.Join(configsDir, "file"),
numLeaks: 0,
},
{
repo: leaksRepo,
description: "toml whitelist commit",
configPath: path.Join(configsDir, "commit"),
numLeaks: 1,
},
}
whiteListCommits = make(map[string]bool)
g := goblin.Goblin(t)
for _, test := range tests {
g.Describe("TestAuditRepo", func() {
g.It(test.description, func() {
opts = test.testOpts
// settin da globs
if test.whiteListFiles != nil {
whiteListFiles = test.whiteListFiles
} else {
whiteListFiles = nil
}
if test.whiteListCommits != nil {
whiteListCommits = test.whiteListCommits
} else {
whiteListCommits = nil
}
if test.whiteListBranches != nil {
whiteListBranches = test.whiteListBranches
} else {
whiteListBranches = nil
}
if test.whiteListRegexes != nil {
whiteListRegexes = test.whiteListRegexes
} else {
whiteListRegexes = nil
}
// config paths
if test.configPath != "" {
os.Setenv("GITLEAKS_CONFIG", test.configPath)
loadToml()
}
leaks, err = auditRepo(test.repo)
if opts.Redact {
g.Assert(leaks[0].Offender).Equal("REDACTED")
}
g.Assert(len(leaks)).Equal(test.numLeaks)
})
})
}
}
func TestOptionGuard(t *testing.T) {
var tests = []struct {
testOpts Options
githubToken bool
description string
expectedErrMsg string
expectedErrMsgFuzzy string
}{
{
testOpts: Options{},
description: "default no opts",
expectedErrMsg: "",
},
{
testOpts: Options{
IncludePrivate: true,
GithubOrg: "fakeOrg",
},
description: "private org no githubtoken",
expectedErrMsg: "user/organization private repos require env var GITHUB_TOKEN to be set",
githubToken: false,
},
{
testOpts: Options{
IncludePrivate: true,
GithubUser: "fakeUser",
},
description: "private user no githubtoken",
expectedErrMsg: "user/organization private repos require env var GITHUB_TOKEN to be set",
githubToken: false,
},
{
testOpts: Options{
IncludePrivate: true,
GithubUser: "fakeUser",
GithubOrg: "fakeOrg",
},
description: "double owner",
expectedErrMsg: "github user and organization set",
},
{
testOpts: Options{
IncludePrivate: true,
GithubOrg: "fakeOrg",
OwnerPath: "/dev/null",
},
description: "local and remote target",
expectedErrMsg: "github organization set and local owner path",
},
{
testOpts: Options{
IncludePrivate: true,
GithubUser: "fakeUser",
OwnerPath: "/dev/null",
},
description: "local and remote target",
expectedErrMsg: "github user set and local owner path",
},
{
testOpts: Options{
GithubUser: "fakeUser",
SingleSearch: "*/./....",
},
description: "single search invalid regex gaurd",
expectedErrMsgFuzzy: "unable to compile regex: */./...., ",
},
{
testOpts: Options{
GithubUser: "fakeUser",
SingleSearch: "mystring",
},
description: "single search regex gaurd",
expectedErrMsg: "",
},
}
g := goblin.Goblin(t)
for _, test := range tests {
g.Describe("Test Option Gaurd", func() {
g.It(test.description, func() {
os.Clearenv()
opts = test.testOpts
if test.githubToken {
os.Setenv("GITHUB_TOKEN", "fakeToken")
}
err := optsGuard()
if err != nil {
if test.expectedErrMsgFuzzy != "" {
g.Assert(strings.Contains(err.Error(), test.expectedErrMsgFuzzy)).Equal(true)
} else {
g.Assert(err.Error()).Equal(test.expectedErrMsg)
}
} else {
g.Assert("").Equal(test.expectedErrMsg)
}
})
})
}
}
func TestLoadToml(t *testing.T) {
tmpDir, _ := ioutil.TempDir("", "gitleaksTestConfigDir")
defer os.RemoveAll(tmpDir)
err := ioutil.WriteFile(path.Join(tmpDir, "gitleaksConfig"), []byte(defaultConfig), 0644)
if err != nil {
panic(err)
}
configPath := path.Join(tmpDir, "gitleaksConfig")
noConfigPath := path.Join(tmpDir, "gitleaksConfigNope")
var tests = []struct {
testOpts Options
description string
configPath string
expectedErrMsg string
singleSearch bool
}{
{
testOpts: Options{
ConfigPath: configPath,
},
description: "path to config",
},
{
testOpts: Options{},
description: "env var path to no config",
singleSearch: true,
},
{
testOpts: Options{
ConfigPath: noConfigPath,
},
description: "no path to config",
expectedErrMsg: fmt.Sprintf("no gitleaks config at %s", noConfigPath),
},
{
testOpts: Options{},
description: "env var path to config",
configPath: configPath,
expectedErrMsg: "",
},
{
testOpts: Options{},
description: "env var path to no config",
configPath: noConfigPath,
expectedErrMsg: fmt.Sprintf("problem loading config: open %s: no such file or directory", noConfigPath),
},
}
g := goblin.Goblin(t)
for _, test := range tests {
g.Describe("TestLoadToml", func() {
g.It(test.description, func() {
opts = test.testOpts
if test.singleSearch {
singleSearchRegex = regexp.MustCompile("test")
} else {
singleSearchRegex = nil
}
if test.configPath != "" {
os.Setenv("GITLEAKS_CONFIG", test.configPath)
} else {
os.Clearenv()
}
err := loadToml()
if err != nil {
g.Assert(err.Error()).Equal(test.expectedErrMsg)
} else {
g.Assert("").Equal(test.expectedErrMsg)
}
})
})
}
}
+16
View File
@@ -0,0 +1,16 @@
module github.com/zricethezav/gitleaks/v7
go 1.15
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/lint v0.0.0-20200302205851-738671d3881b // indirect
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9
gopkg.in/yaml.v2 v2.2.8 // indirect
)
+110
View File
@@ -0,0 +1,110 @@
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/go-git/go-git/v5 v5.2.0 h1:YPBLG/3UK1we1ohRkncLjaXWLW+HKp5QNM/jTli2JgI=
github.com/go-git/go-git/v5 v5.2.0/go.mod h1:kh02eMX+wdqqxgNMEyq8YgwlIOsDOa9homkUq1PoTMs=
github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/hako/durafmt v0.0.0-20191009132224-3f39dc1ed9f4 h1:60gBOooTSmNtrqNaRvrDbi8VAne0REaek2agjnITKSw=
github.com/hako/durafmt v0.0.0-20191009132224-3f39dc1ed9f4/go.mod h1:5Scbynm8dF1XAPwIwkGPqzkM/shndPm79Jd1003hTjE=
github.com/imdario/mergo v0.3.9 h1:UauaLniWCFHWd+Jp9oCEkTBj8VO/9DKg3PV3VCNMDIg=
github.com/imdario/mergo v0.3.9/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
github.com/jessevdk/go-flags v1.4.0 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGARJA=
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd h1:Coekwdh0v2wtGp9Gmz1Ze3eVRAWJMLokvN3QjdzCHLY=
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/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=
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-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073 h1:xMPOj6Pz6UipU1wXLkrtqpHbR0AVFnyPEQq/wRWz9lM=
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/lint v0.0.0-20200302205851-738671d3881b h1:Wh+f8QHJXR411sJR8/vRBTZ7YapZaRvUcLFFJhusH0k=
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-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-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
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/tools v0.0.0-20200130002326-2f3ba24bd6e7 h1:EBZoQjiKKPaLbPrbpssUfuHtwM6KV/vb4U85g/cigFY=
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
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 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+42 -780
View File
@@ -1,810 +1,72 @@
package main
import (
"context"
"crypto/md5"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"os"
"os/user"
"path"
"regexp"
"strings"
"sync"
"os/signal"
"time"
"gopkg.in/src-d/go-git.v4/plumbing"
"github.com/zricethezav/gitleaks/v7/report"
"golang.org/x/oauth2"
"gopkg.in/src-d/go-git.v4/plumbing/object"
"gopkg.in/src-d/go-git.v4/plumbing/transport/ssh"
"gopkg.in/src-d/go-git.v4/storage/memory"
"github.com/zricethezav/gitleaks/v7/config"
"github.com/zricethezav/gitleaks/v7/options"
"github.com/zricethezav/gitleaks/v7/scan"
"github.com/BurntSushi/toml"
"github.com/google/go-github/github"
flags "github.com/jessevdk/go-flags"
"github.com/hako/durafmt"
log "github.com/sirupsen/logrus"
git "gopkg.in/src-d/go-git.v4"
)
// Leak represents a leaked secret or regex match. This will be output to stdout and/or the report
type Leak struct {
Line string `json:"line"`
Commit string `json:"commit"`
Offender string `json:"offender"`
Type string `json:"reason"`
Message string `json:"commitMsg"`
Author string `json:"author"`
File string `json:"file"`
Branch string `json:"branch"`
}
// Repo contains the actual git repository and meta data about the repo
type Repo struct {
path string
url string
name string
leaks []Leak
repository *git.Repository
}
// Owner contains a collection of repos. This could represent an org or user.
type Owner struct {
path string
url string
repos []Repo
}
// Options for gitleaks
type Options struct {
// remote target options
Repo string `short:"r" long:"repo" description:"Repo url to audit"`
GithubUser string `long:"github-user" description:"User url to audit"`
GithubOrg string `long:"github-org" description:"Organization url to audit"`
IncludePrivate bool `short:"p" long:"private" description:"Include private repos in audit"`
/*
TODO:
GitLabUser string `long:"gitlab-user" description:"User url to audit"`
GitLabOrg string `long:"gitlab-org" description:"Organization url to audit"`
*/
Branch string `short:"b" long:"branch" description:"branch name to audit (defaults to HEAD)"`
Commit string `short:"c" long:"commit" description:"sha of commit to stop at"`
// local target option
RepoPath string `long:"repo-path" description:"Path to repo"`
OwnerPath string `long:"owner-path" description:"Path to owner directory (repos discovered)"`
// Process options
MaxGoRoutines int `long:"max-go" description:"Maximum number of concurrent go-routines gitleaks spawns"`
InMem bool `short:"m" long:"in-memory" description:"Run gitleaks in memory"`
AuditAllRefs bool `long:"all-refs" description:"run audit on all refs"`
SingleSearch string `long:"single-search" description:"single regular expression to search for"`
ConfigPath string `long:"config" description:"path to gitleaks config"`
SSHKey string `long:"ssh-key" description:"path to ssh key"`
// TODO: IncludeMessages string `long:"messages" description:"include commit messages in audit"`
// Output options
Log string `short:"l" long:"log" description:"log level"`
Verbose bool `short:"v" long:"verbose" description:"Show verbose output from gitleaks audit"`
Report string `long:"report" description:"path to write report file"`
Redact bool `long:"redact" description:"redact secrets from log messages and report"`
}
// Config struct for regexes matching and whitelisting
type Config struct {
Regexes []struct {
Description string
Regex string
}
Whitelist struct {
Files []string
Regexes []string
Commits []string
Branches []string
}
}
const defaultConfig = `
title = "gitleaks config"
# add regexes to the regex table
[[regexes]]
description = "AWS"
regex = '''AKIA[0-9A-Z]{16}'''
[[regexes]]
description = "RKCS8"
regex = '''-----BEGIN PRIVATE KEY-----'''
[[regexes]]
description = "RSA"
regex = '''-----BEGIN RSA PRIVATE KEY-----'''
[[regexes]]
description = "Github"
regex = '''(?i)github.*['\"][0-9a-zA-Z]{35,40}['\"]'''
[[regexes]]
description = "SSH"
regex = '''-----BEGIN OPENSSH PRIVATE KEY-----'''
[[regexes]]
description = "Facebook"
regex = '''(?i)facebook.*['\"][0-9a-f]{32}['\"]'''
[[regexes]]
description = "Facebook"
regex = '''(?i)twitter.*['\"][0-9a-zA-Z]{35,44}['\"]'''
[whitelist]
#regexes = [
# "AKAIMYFAKEAWKKEY",
#]
#files = [
# "(.*?)(jpg|gif|doc|pdf|bin)$"
#]
#commits = [
# "BADHA5H1",
# "BADHA5H2",
#]
#branches = [
# "dev/STUPDIFKNFEATURE"
#]
`
var (
opts Options
regexes map[string]*regexp.Regexp
singleSearchRegex *regexp.Regexp
whiteListRegexes []*regexp.Regexp
whiteListFiles []*regexp.Regexp
whiteListCommits map[string]bool
whiteListBranches []string
fileDiffRegex *regexp.Regexp
sshAuth *ssh.PublicKeys
dir string
)
func init() {
log.SetOutput(os.Stdout)
regexes = make(map[string]*regexp.Regexp)
whiteListCommits = make(map[string]bool)
}
func main() {
var (
leaks []Leak
repos []Repo
)
_, err := flags.Parse(&opts)
// 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)
}
setLogLevel()
err = optsGuard()
err = opts.Guard()
if err != nil {
log.Fatal(err)
log.Error(err)
os.Exit(1)
}
err = loadToml()
// setup configs
cfg, err := config.NewConfig(opts)
if err != nil {
log.Fatal(err)
log.Error(err)
os.Exit(1)
}
if opts.IncludePrivate {
// if including private repos use ssh as authentication
sshAuth, err = getSSHAuth()
if err != nil {
log.Fatal(err)
}
// setup scanner
scanner, err := scan.NewScanner(opts, cfg)
if err != nil {
log.Error(err)
os.Exit(1)
}
if !opts.InMem {
// temporary directory where all the gitleaks plain clones will reside
dir, err = ioutil.TempDir("", "gitleaks")
defer os.RemoveAll(dir)
if err != nil {
log.Fatal(err)
}
// 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)
}
// start audits
if opts.Repo != "" || opts.RepoPath != "" {
r, err := getRepo()
if err != nil {
log.Fatal(err)
}
repos = append(repos, r)
} else if ownerTarget() {
repos, err = getOwnerRepos()
}
for _, r := range repos {
l, err := auditRepo(r.repository)
if err != nil {
log.Fatal(err)
}
leaks = append(leaks, l...)
}
if opts.Report != "" {
writeReport(leaks)
}
if len(leaks) != 0 {
log.Debug("leaks detected")
// report scan
if err := report.WriteReport(scannerReport, opts, cfg); err != nil {
log.Error(err)
os.Exit(1)
}
}
// writeReport writes a report to opts.Report in JSON.
// TODO support yaml
func writeReport(leaks []Leak) error {
log.Info("writing report to %s", opts.Report)
reportJSON, _ := json.MarshalIndent(leaks, "", "\t")
err := ioutil.WriteFile(opts.Report, reportJSON, 0644)
return err
}
// getRepo is responsible for cloning a repo in-memory or to disk, or opening a local repo and creating
// a repo object
func getRepo() (Repo, error) {
var (
err error
r *git.Repository
)
if opts.InMem {
if opts.IncludePrivate {
r, err = git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
URL: opts.Repo,
Progress: os.Stdout,
Auth: sshAuth,
})
} else {
r, err = git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
URL: opts.Repo,
Progress: os.Stdout,
})
}
} else if opts.RepoPath != "" {
// use existing repo
r, err = git.PlainOpen(opts.RepoPath)
} else {
cloneTarget := fmt.Sprintf("%s/%x", dir, md5.Sum([]byte(fmt.Sprintf("%s%s", opts.GithubUser, opts.Repo))))
if opts.IncludePrivate {
r, err = git.PlainClone(cloneTarget, false, &git.CloneOptions{
URL: opts.Repo,
Progress: os.Stdout,
Auth: sshAuth,
})
} else {
r, err = git.PlainClone(cloneTarget, false, &git.CloneOptions{
URL: opts.Repo,
Progress: os.Stdout,
})
}
}
if err != nil {
return Repo{}, err
}
return Repo{
repository: r,
path: opts.RepoPath,
url: opts.Repo,
}, nil
}
// auditRef audits a git reference
// TODO: need to add a layer of parallelism here and a cache for parent+child commits so we don't
// double dip
func auditRef(r *git.Repository, ref *plumbing.Reference, commitWg *sync.WaitGroup, commitChan chan []Leak) error {
var (
err error
// prevTree *object.Tree
prevCommit *object.Commit
limitGoRoutines bool
semaphore chan bool
)
// goroutine limiting
if opts.MaxGoRoutines != 0 {
semaphore = make(chan bool, opts.MaxGoRoutines)
limitGoRoutines = true
}
cIter, err := r.Log(&git.LogOptions{From: ref.Hash()})
if err != nil {
return err
}
err = cIter.ForEach(func(c *object.Commit) error {
if c.Hash.String() == opts.Commit {
cIter.Close()
}
if whiteListCommits[c.Hash.String()] {
log.Infof("skipping commit: %s\n", c.Hash.String())
return nil
}
if limitGoRoutines {
semaphore <- true
}
if prevCommit == nil {
prevCommit = c
}
commitWg.Add(1)
go func(c *object.Commit, prevCommit *object.Commit) {
var (
leaks []Leak
filePath string
skipFile bool
)
patch, _ := c.Patch(prevCommit)
for _, f := range patch.FilePatches() {
skipFile = false
from, to := f.Files()
filePath = "???"
if from != nil {
filePath = from.Path()
} else if to != nil {
filePath = to.Path()
}
for _, re := range whiteListFiles {
if re.FindString(filePath) != "" {
skipFile = true
break
}
}
if skipFile {
continue
}
chunks := f.Chunks()
for _, chunk := range chunks {
if chunk.Type() == 1 || chunk.Type() == 2 {
// only check if adding or removing
leaks = append(leaks, checkDiff(chunk.Content(), c, filePath, string(ref.Name()))...)
}
}
}
if limitGoRoutines {
<-semaphore
}
commitChan <- leaks
}(c, prevCommit)
prevCommit = c
return nil
})
return nil
}
// auditRepo performs an audit on a repository checking for regex matching and ignoring
// files and regexes that are whitelisted
func auditRepo(r *git.Repository) ([]Leak, error) {
var (
err error
leaks []Leak
commitWg sync.WaitGroup
)
ref, err := r.Head()
if err != nil {
return leaks, err
}
// leak messaging
commitChan := make(chan []Leak, 1)
if opts.AuditAllRefs {
skipBranch := false
refs, err := r.Storer.IterReferences()
if err != nil {
return leaks, err
}
err = refs.ForEach(func(ref *plumbing.Reference) error {
for _, b := range whiteListBranches {
if strings.HasSuffix(string(ref.Name()), b) {
skipBranch = true
}
}
if skipBranch {
skipBranch = false
return nil
}
auditRef(r, ref, &commitWg, commitChan)
return nil
})
} else {
auditRef(r, ref, &commitWg, commitChan)
}
go func() {
for commitLeaks := range commitChan {
if commitLeaks != nil {
for _, leak := range commitLeaks {
leaks = append(leaks, leak)
}
}
commitWg.Done()
}
}()
commitWg.Wait()
return leaks, err
}
// checkDiff accepts a string diff and commit object then performs a
// regex check
func checkDiff(diff string, commit *object.Commit, filePath string, branch string) []Leak {
lines := strings.Split(diff, "\n")
var (
leaks []Leak
skipLine bool
)
for _, line := range lines {
skipLine = false
for leakType, re := range regexes {
match := re.FindString(line)
if match == "" {
continue
}
// whitelists
for _, wRe := range whiteListRegexes {
whitelistMatch := wRe.FindString(line)
if whitelistMatch != "" {
skipLine = true
break
}
}
if skipLine {
break
}
leak := Leak{
Line: line,
Commit: commit.Hash.String(),
Offender: match,
Type: leakType,
Message: commit.Message,
Author: commit.Author.String(),
File: filePath,
Branch: branch,
}
if opts.Verbose {
leak.log()
}
if opts.Redact {
leak.Offender = "REDACTED"
}
leaks = append(leaks, leak)
}
}
return leaks
}
// auditOwner audits all of the owner's(user or org) repos
func getOwnerRepos() ([]Repo, error) {
var (
err error
repos []Repo
)
ctx := context.Background()
if opts.OwnerPath != "" {
repos, err = discoverRepos(opts.OwnerPath)
} else if opts.GithubOrg != "" {
githubClient := github.NewClient(githubToken())
githubOptions := github.RepositoryListByOrgOptions{
ListOptions: github.ListOptions{PerPage: 10},
}
repos, err = getOrgGithubRepos(ctx, &githubOptions, githubClient)
} else if opts.GithubUser != "" {
githubClient := github.NewClient(githubToken())
githubOptions := github.RepositoryListOptions{
Affiliation: "owner",
ListOptions: github.ListOptions{
PerPage: 10,
},
}
repos, err = getUserGithubRepos(ctx, &githubOptions, githubClient)
}
return repos, err
}
// getUserGithubRepos
func getUserGithubRepos(ctx context.Context, listOpts *github.RepositoryListOptions, client *github.Client) ([]Repo, error) {
var (
err error
repos []Repo
r *git.Repository
rs []*github.Repository
resp *github.Response
)
for {
if opts.IncludePrivate {
rs, resp, err = client.Repositories.List(ctx, "", listOpts)
} else {
rs, resp, err = client.Repositories.List(ctx, opts.GithubUser, listOpts)
}
for _, rDesc := range rs {
log.Debugf("Cloning: %s from %s", *rDesc.Name, *rDesc.SSHURL)
if opts.InMem {
if opts.IncludePrivate {
r, err = git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
URL: *rDesc.SSHURL,
Auth: sshAuth,
})
} else {
r, err = git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
URL: *rDesc.CloneURL,
})
}
} else {
ownerDir, err := ioutil.TempDir(dir, opts.GithubUser)
if err != nil {
return repos, fmt.Errorf("unable to generater owner temp dir: %v", err)
}
if opts.IncludePrivate {
r, err = git.PlainClone(fmt.Sprintf("%s/%s", ownerDir, *rDesc.Name), false, &git.CloneOptions{
URL: *rDesc.SSHURL,
Auth: sshAuth,
})
} else {
r, err = git.PlainClone(fmt.Sprintf("%s/%s", ownerDir, *rDesc.Name), false, &git.CloneOptions{
URL: *rDesc.CloneURL,
})
}
}
if err != nil {
return repos, fmt.Errorf("problem cloning %s -- %v", *rDesc.Name, err)
}
repos = append(repos, Repo{
name: *rDesc.Name,
url: *rDesc.SSHURL,
repository: r,
})
}
if resp.NextPage == 0 {
break
}
listOpts.Page = resp.NextPage
}
return repos, err
}
// getOrgGithubRepos
func getOrgGithubRepos(ctx context.Context, listOpts *github.RepositoryListByOrgOptions, client *github.Client) ([]Repo, error) {
var (
err error
repos []Repo
r *git.Repository
ownerDir string
)
for {
rs, resp, err := client.Repositories.ListByOrg(ctx, opts.GithubOrg, listOpts)
for _, rDesc := range rs {
log.Debugf("Cloning: %s from %s", *rDesc.Name, *rDesc.SSHURL)
if opts.InMem {
if opts.IncludePrivate {
if sshAuth == nil {
return nil, fmt.Errorf("no ssh auth available")
}
r, err = git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
URL: *rDesc.SSHURL,
Auth: sshAuth,
})
} else {
r, err = git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
URL: *rDesc.CloneURL,
})
}
} else {
ownerDir, err = ioutil.TempDir(dir, opts.GithubUser)
if err != nil {
return repos, fmt.Errorf("unable to generater owner temp dir: %v", err)
}
if opts.IncludePrivate {
if sshAuth == nil {
return nil, fmt.Errorf("no ssh auth available")
}
r, err = git.PlainClone(fmt.Sprintf("%s/%s", ownerDir, *rDesc.Name), false, &git.CloneOptions{
URL: *rDesc.SSHURL,
Auth: sshAuth,
})
} else {
r, err = git.PlainClone(fmt.Sprintf("%s/%s", ownerDir, *rDesc.Name), false, &git.CloneOptions{
URL: *rDesc.CloneURL,
})
}
}
if err != nil {
return nil, err
}
repos = append(repos, Repo{
url: *rDesc.SSHURL,
name: *rDesc.Name,
repository: r,
})
}
if err != nil {
return nil, err
} else if resp.NextPage == 0 {
break
}
listOpts.Page = resp.NextPage
}
return repos, err
}
func githubToken() *http.Client {
githubToken := os.Getenv("GITHUB_TOKEN")
if githubToken == "" {
return nil
}
ts := oauth2.StaticTokenSource(
&oauth2.Token{AccessToken: githubToken},
)
return oauth2.NewClient(context.Background(), ts)
}
// discoverRepos walks all the children of `path`. If a child directory
// contain a .git file then that repo will be added
func discoverRepos(ownerPath string) ([]Repo, error) {
var (
err error
repos []Repo
)
files, err := ioutil.ReadDir(ownerPath)
if err != nil {
return repos, err
}
for _, f := range files {
if f.IsDir() {
repoPath := path.Join(ownerPath, f.Name())
r, err := git.PlainOpen(repoPath)
if err != nil {
continue
}
repos = append(repos, Repo{
repository: r,
name: f.Name(),
path: repoPath,
})
}
}
return repos, err
}
// setLogLevel sets log level for gitleaks. Default is Warning
func setLogLevel() {
switch opts.Log {
case "info":
log.SetLevel(log.InfoLevel)
case "debug":
log.SetLevel(log.DebugLevel)
case "warn":
log.SetLevel(log.WarnLevel)
default:
log.SetLevel(log.WarnLevel)
}
}
// optsGuard prevents invalid options
func optsGuard() error {
var err error
if opts.GithubOrg != "" && opts.GithubUser != "" {
return fmt.Errorf("github user and organization set")
} else if opts.GithubOrg != "" && opts.OwnerPath != "" {
return fmt.Errorf("github organization set and local owner path")
} else if opts.GithubUser != "" && opts.OwnerPath != "" {
return fmt.Errorf("github user set and local owner path")
} else if opts.IncludePrivate && os.Getenv("GITHUB_TOKEN") == "" && (opts.GithubOrg != "" || opts.GithubUser != "") {
return fmt.Errorf("user/organization private repos require env var GITHUB_TOKEN to be set")
}
if opts.SingleSearch != "" {
singleSearchRegex, err = regexp.Compile(opts.SingleSearch)
if err != nil {
return fmt.Errorf("unable to compile regex: %s, %v", opts.SingleSearch, err)
}
}
return nil
}
// loadToml loads of the toml config containing regexes.
// 1. look for config path
// 2. two, look for gitleaks config env var
func loadToml() error {
var (
config Config
configPath string
)
if opts.ConfigPath != "" {
configPath = opts.ConfigPath
_, err := os.Stat(configPath)
if err != nil {
return fmt.Errorf("no gitleaks config at %s", configPath)
}
} else {
configPath = os.Getenv("GITLEAKS_CONFIG")
}
if configPath != "" {
if _, err := toml.DecodeFile(configPath, &config); err != nil {
return fmt.Errorf("problem loading config: %v", err)
}
} else {
_, err := toml.Decode(defaultConfig, &config)
if err != nil {
return fmt.Errorf("problem loading default config: %v", err)
}
}
// load up regexes
if singleSearchRegex != nil {
// single search takes precedence over default regex
regexes["singleSearch"] = singleSearchRegex
} else {
for _, regex := range config.Regexes {
regexes[regex.Description] = regexp.MustCompile(regex.Regex)
}
}
whiteListBranches = config.Whitelist.Branches
whiteListCommits = make(map[string]bool)
for _, commit := range config.Whitelist.Commits {
whiteListCommits[commit] = true
}
for _, regex := range config.Whitelist.Files {
whiteListFiles = append(whiteListFiles, regexp.MustCompile(regex))
}
for _, regex := range config.Whitelist.Regexes {
whiteListRegexes = append(whiteListRegexes, regexp.MustCompile(regex))
}
return nil
}
// ownerTarget checks if we are dealing with a remote owner
func ownerTarget() bool {
if opts.GithubOrg != "" ||
opts.GithubUser != "" ||
opts.OwnerPath != "" {
return true
}
return false
}
// getSSHAuth generates ssh auth
func getSSHAuth() (*ssh.PublicKeys, error) {
var (
sshKeyPath string
)
if opts.SSHKey != "" {
sshKeyPath = opts.SSHKey
} else {
c, _ := user.Current()
sshKeyPath = fmt.Sprintf("%s/.ssh/id_rsa", c.HomeDir)
}
sshAuth, err := ssh.NewPublicKeysFromFile("git", sshKeyPath, "")
if err != nil {
return nil, fmt.Errorf("unable to generate ssh key: %v", err)
}
return sshAuth, err
}
func (leak *Leak) log() {
b, _ := json.MarshalIndent(leak, "", " ")
fmt.Println(string(b))
func listenForInterrupt(stopScan chan os.Signal) {
<-stopScan
log.Warn("halting gitleaks scan")
os.Exit(1)
}
+212
View File
@@ -0,0 +1,212 @@
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"`
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"`
CleanUp string `long:"clone-cleanup" description:"Deletes cloned repo after scan"`
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"`
// 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(0)
}
if opts.Version {
if version.Version == "" {
fmt.Println("Gitleaks uses LDFLAGS to pull most recent version. Build with 'make build' for version")
} else {
fmt.Printf("%s\n", version.Version)
}
os.Exit(0)
}
if opts.Debug {
log.SetLevel(log.DebugLevel)
}
return opts, nil
}
// Guard checks to makes sure there are no invalid options set.
// If invalid sets of options are present, a descriptive error will return
// else nil is returned
func (opts Options) Guard() error {
if !oneOrNoneSet(opts.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
}
+1
View File
@@ -0,0 +1 @@
package options
+33
View File
@@ -0,0 +1,33 @@
package report
import (
"strings"
"time"
)
// 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
}
+95
View File
@@ -0,0 +1,95 @@
package report
import (
"encoding/csv"
"encoding/json"
"os"
"time"
"github.com/zricethezav/gitleaks/v7/config"
"github.com/zricethezav/gitleaks/v7/options"
"github.com/zricethezav/gitleaks/v7/version"
log "github.com/sirupsen/logrus"
)
// 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()) {
log.Info("commits scanned: ", report.Commits)
}
if len(report.Leaks) != 0 {
log.Warn("leaks found: ", len(report.Leaks))
} else {
log.Info("No leaks found")
return nil
}
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 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)
_ = w.Write([]string{"repo", "line", "commit", "offender", "leakURL", "rule", "tags", "commitMsg", "author", "email", "file", "date"})
for _, leak := range report.Leaks {
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)})
}
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
}
+155
View File
@@ -0,0 +1,155 @@
package report
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 {
var results []Results
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,
},
},
},
},
}
}
+86
View File
@@ -0,0 +1,86 @@
package scan
import (
"fmt"
"github.com/zricethezav/gitleaks/v7/report"
"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 {
BaseScanner
repo *git.Repository
repoName string
commit *object.Commit
}
// NewCommitScanner creates and returns a commit scanner
func NewCommitScanner(base BaseScanner, repo *git.Repository, commit *object.Commit) *CommitScanner {
cs := &CommitScanner{
BaseScanner: base,
repo: repo,
commit: commit,
repoName: getRepoName(base.opts),
}
cs.scannerType = typeCommitScanner
return cs
}
// Scan kicks off a CommitScanner Scan
func (cs *CommitScanner) Scan() (report.Report, error) {
var scannerReport report.Report
if len(cs.commit.ParentHashes) == 0 {
facScanner := NewFilesAtCommitScanner(cs.BaseScanner, cs.repo, cs.commit)
return facScanner.Scan()
}
err := cs.commit.Parents().ForEach(func(parent *object.Commit) error {
defer func() {
if err := recover(); err != nil {
// sometimes the Patch generation will fail due to a known bug in
// sergi's go-diff: https://github.com/sergi/go-diff/issues/89.
// Once a fix has been merged I will remove this recover.
return
}
}()
if parent == nil {
return nil
}
patch, err := parent.Patch(cs.commit)
if err != nil {
return 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()
leaks := checkRules(cs.BaseScanner, cs.commit, cs.repoName, to.Path(), chunk.Content())
lineLookup := make(map[string]bool)
for _, leak := range leaks {
leak.LineNumber = extractLine(patchContent, leak, lineLookup)
leak.LeakURL = leakURL(leak)
scannerReport.Leaks = append(scannerReport.Leaks, leak)
if cs.opts.Verbose {
logLeak(leak, cs.opts.Redact)
}
}
}
}
}
return nil
})
scannerReport.Commits = 1
return scannerReport, err
}
+44
View File
@@ -0,0 +1,44 @@
package scan
import (
"github.com/go-git/go-git/v5"
"github.com/zricethezav/gitleaks/v7/report"
)
// CommitsScanner is a commit scanner
type CommitsScanner struct {
BaseScanner
repo *git.Repository
repoName string
commits []string
}
// NewCommitsScanner creates and returns a commits scanner, notice the 's' in commits
func NewCommitsScanner(base BaseScanner, repo *git.Repository, commits []string) *CommitsScanner {
return &CommitsScanner{
BaseScanner: base,
repo: repo,
commits: commits,
repoName: getRepoName(base.opts),
}
}
// Scan kicks off a CommitsScanner Scan
func (css *CommitsScanner) Scan() (report.Report, error) {
var scannerReport report.Report
for _, c := range css.commits {
c, err := obtainCommit(css.repo, c)
if err != nil {
return scannerReport, nil
}
cs := NewCommitScanner(css.BaseScanner, 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
}
+60
View File
@@ -0,0 +1,60 @@
package scan
import (
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing/object"
"github.com/zricethezav/gitleaks/v7/report"
)
// 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 {
BaseScanner
repo *git.Repository
commit *object.Commit
repoName string
}
// NewFilesAtCommitScanner creates and returns a files at commit scanner
func NewFilesAtCommitScanner(base BaseScanner, repo *git.Repository, commit *object.Commit) *FilesAtCommitScanner {
fs := &FilesAtCommitScanner{
BaseScanner: base,
repo: repo,
commit: commit,
repoName: getRepoName(base.opts),
}
fs.scannerType = typeFilesAtCommitScanner
return fs
}
// Scan kicks off a FilesAtCommitScanner Scan
func (fs *FilesAtCommitScanner) Scan() (report.Report, error) {
var scannerReport report.Report
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
}
content, err := f.Contents()
if err != nil {
return err
}
scannerReport.Leaks = append(scannerReport.Leaks, checkRules(fs.BaseScanner, fs.commit, fs.repoName, f.Name, content)...)
return nil
})
scannerReport.Commits = 1
return scannerReport, err
}
+103
View File
@@ -0,0 +1,103 @@
package scan
import (
"bufio"
"context"
"os"
"path/filepath"
"sync"
"github.com/zricethezav/gitleaks/v7/report"
"golang.org/x/sync/errgroup"
)
// NoGitScanner is a scanner that absolutely despises git
type NoGitScanner struct {
BaseScanner
leakChan chan report.Leak
leakWG *sync.WaitGroup
leaks []report.Leak
}
// NewNoGitScanner creates and returns a nogit scanner. This is used for scanning files and directories
func NewNoGitScanner(base BaseScanner) *NoGitScanner {
ngs := &NoGitScanner{
BaseScanner: base,
leakChan: make(chan report.Leak),
leakWG: &sync.WaitGroup{},
}
go ngs.receiveLeaks()
ngs.scannerType = typeNoGitScanner
return ngs
}
// Scan kicks off a NoGitScanner Scan
func (ngs *NoGitScanner) Scan() (report.Report, error) {
var scannerReport report.Report
g, _ := errgroup.WithContext(context.Background())
paths := make(chan string)
semaphore := make(chan bool, howManyThreads(ngs.opts.Threads))
wg := sync.WaitGroup{}
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
})
})
for path := range paths {
p := path
wg.Add(1)
semaphore <- true
g.Go(func() error {
defer func() {
<-semaphore
wg.Done()
}()
f, err := os.Open(p)
if err != nil {
return err
}
scanner := bufio.NewScanner(f)
line := 0
for scanner.Scan() {
line++
leaks := checkRules(ngs.BaseScanner, emptyCommit(), "", f.Name(), scanner.Text())
for _, leak := range leaks {
leak.LineNumber = line
if ngs.opts.Verbose {
logLeak(leak, ngs.opts.Redact)
}
ngs.leakWG.Add(1)
ngs.leakChan <- leak
}
}
return f.Close()
})
}
wg.Wait()
ngs.leakWG.Wait()
scannerReport.Leaks = ngs.leaks
return scannerReport, nil
}
func (ngs *NoGitScanner) receiveLeaks() {
for leak := range ngs.leakChan {
ngs.leaks = append(ngs.leaks, leak)
ngs.leakWG.Done()
}
}
+69
View File
@@ -0,0 +1,69 @@
package scan
import (
"io/ioutil"
"path/filepath"
"github.com/zricethezav/gitleaks/v7/report"
"github.com/go-git/go-git/v5"
log "github.com/sirupsen/logrus"
)
// ParentScanner is a parent directory scanner
type ParentScanner struct {
BaseScanner
}
// NewParentScanner creates and returns a directory scanner
func NewParentScanner(base BaseScanner) *ParentScanner {
ds := &ParentScanner{
BaseScanner: base,
}
ds.scannerType = typeDirScanner
return ds
}
// Scan kicks off a ParentScanner scan. This uses the directory from --path to discovery repos
func (ds *ParentScanner) Scan() (report.Report, error) {
var scannerReport report.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
}
skip := false
for _, allowListedRepo := range ds.cfg.Allowlist.Repos {
if regexMatched(f.Name(), allowListedRepo) {
skip = true
}
}
if skip {
continue
}
rs := NewRepoScanner(ds.BaseScanner, 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
}
+163
View File
@@ -0,0 +1,163 @@
package scan
import (
"sync"
"github.com/zricethezav/gitleaks/v7/report"
"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"
"github.com/go-git/go-git/v5/plumbing/storer"
log "github.com/sirupsen/logrus"
)
// RepoScanner is a repo scanner
type RepoScanner struct {
BaseScanner
repo *git.Repository
repoName string
leakChan chan report.Leak
leakWG *sync.WaitGroup
leakCache map[string]bool
leaks []report.Leak
}
// NewRepoScanner returns a new repo scanner (go figure). This function also
// sets up the leak listener for multi-threaded awesomeness.
func NewRepoScanner(base BaseScanner, repo *git.Repository) *RepoScanner {
rs := &RepoScanner{
BaseScanner: base,
repo: repo,
leakChan: make(chan report.Leak),
leakWG: &sync.WaitGroup{},
leakCache: make(map[string]bool),
repoName: getRepoName(base.opts),
}
rs.scannerType = typeRepoScanner
go rs.receiveLeaks()
return rs
}
// Scan kicks of a repo scan
func (rs *RepoScanner) Scan() (report.Report, error) {
var scannerReport report.Report
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
}
semaphore := make(chan bool, howManyThreads(rs.opts.Threads))
wg := sync.WaitGroup{}
err = cIter.ForEach(func(c *object.Commit) error {
if c == nil || depthReached(scannerReport.Commits, rs.opts) {
return storer.ErrStop
}
// Check if Commit is allowlisted
if isCommitAllowListed(c.Hash.String(), rs.cfg.Allowlist.Commits) {
return nil
}
// Check if at root
if len(c.ParentHashes) == 0 {
scannerReport.Commits++
facScanner := NewFilesAtCommitScanner(rs.BaseScanner, rs.repo, c)
facScanner.repoName = rs.repoName
facReport, err := facScanner.Scan()
if err != nil {
return err
}
scannerReport.Leaks = append(scannerReport.Leaks, facReport.Leaks...)
return nil
}
// inspect first parent only as all other parents will be eventually reached
// (they exist as the tip of other branches, etc)
// See https://github.com/zricethezav/gitleaks/issues/413 for details
parent, err := c.Parent(0)
if err != nil {
return err
}
defer func() {
if err := recover(); err != nil {
// sometimes the Patch generation will fail due to a known bug in
// sergi's go-diff: https://github.com/sergi/go-diff/issues/89.
// Once a fix has been merged I will remove this recover.
return
}
}()
if parent == nil {
// shouldn't reach this point but just in case
return nil
}
// start := time.Now()
patch, err := parent.Patch(c)
if err != nil {
log.Errorf("could not generate Patch")
}
scannerReport.Commits++
wg.Add(1)
semaphore <- true
go func(c *object.Commit, patch *object.Patch) {
defer func() {
<-semaphore
wg.Done()
}()
// patchContent is used for searching for leak line number
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()
lineLookup := make(map[string]bool)
for _, leak := range checkRules(rs.BaseScanner, c, rs.repoName, to.Path(), chunk.Content()) {
leak.LineNumber = extractLine(patchContent, leak, lineLookup)
leak.LeakURL = leakURL(leak)
if rs.opts.Verbose {
logLeak(leak, rs.opts.Redact)
}
rs.leakWG.Add(1)
rs.leakChan <- leak
}
}
}
}
}(c, patch)
if c.Hash.String() == rs.opts.CommitTo {
return storer.ErrStop
}
return nil
})
wg.Wait()
rs.leakWG.Wait()
scannerReport.Leaks = append(scannerReport.Leaks, rs.leaks...)
return scannerReport, nil
}
func (rs *RepoScanner) receiveLeaks() {
for leak := range rs.leakChan {
rs.leaks = append(rs.leaks, leak)
rs.leakWG.Done()
}
}
+168
View File
@@ -0,0 +1,168 @@
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"
"github.com/zricethezav/gitleaks/v7/report"
)
// Scanner abstracts unique scanner internals while exposing the Scan function which
// returns a report.
type Scanner interface {
Scan() (report.Report, error)
}
// BaseScanner is a container for common data each scanner needs.
type BaseScanner struct {
opts options.Options
cfg config.Config
stopChan chan os.Signal
scannerType ScannerType
}
// 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
)
// TODO move this block to config parsing?
for _, allowListedRepo := range cfg.Allowlist.Repos {
if regexMatched(opts.Path, allowListedRepo) {
return nil, nil
}
if regexMatched(opts.RepoURL, allowListedRepo) {
return nil, nil
}
}
base := BaseScanner{
opts: opts,
cfg: cfg,
}
// 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 {
return NewParentScanner(base), nil
}
// Clone or open a repo if we need it
if needsRepo(st) {
repo, err = getRepo(base.opts)
if err != nil {
return nil, err
}
}
// load up alternative config if possible, if not use manager's config
if opts.RepoConfigPath != "" {
base.cfg, err = config.LoadRepoConfig(repo, opts.RepoConfigPath)
if err != nil {
return nil, err
}
}
switch st {
case typeCommitScanner:
c, err := obtainCommit(repo, opts.Commit)
if err != nil {
return nil, err
}
return NewCommitScanner(base, repo, c), nil
case typeCommitsScanner:
commits, err := optsToCommits(opts)
if err != nil {
return nil, err
}
return NewCommitsScanner(base, repo, commits), nil
case typeFilesAtCommitScanner:
c, err := obtainCommit(repo, opts.FilesAtCommit)
if err != nil {
return nil, err
}
return NewFilesAtCommitScanner(base, repo, c), nil
case typeUnstagedScanner:
return NewUnstagedScanner(base, repo), nil
case typeDirScanner:
return NewParentScanner(base), nil
case typeNoGitScanner:
return NewNoGitScanner(base), nil
default:
return NewRepoScanner(base, repo), nil
}
}
func scanType(opts options.Options) (ScannerType, error) {
//if opts.OwnerPath != "" {
// return typeDirScanner
//}
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
}
+672
View File
@@ -0,0 +1,672 @@
package scan
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"reflect"
"runtime"
"sort"
"testing"
"github.com/zricethezav/gitleaks/v7/report"
"github.com/zricethezav/gitleaks/v7/config"
"github.com/zricethezav/gitleaks/v7/options"
"github.com/sergi/go-diff/diffmatchpatch"
)
const testRepoBase = "../test_data/test_repos/"
func TestScan(t *testing.T) {
moveDotGit("dotGit", ".git")
defer moveDotGit(".git", "dotGit")
tests := []struct {
description string
opts options.Options
wantPath string
wantErr error
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",
},
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",
},
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",
},
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",
},
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",
},
}
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 = report.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 = report.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 []report.Leak
wantLeaks []report.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
}
sort.Slice(gotLeaks, func(i, j int) bool { return (gotLeaks)[i].Commit < (gotLeaks)[j].Commit })
sort.Slice(wantLeaks, func(i, j int) bool { return (wantLeaks)[i].Commit < (wantLeaks)[j].Commit })
if !reflect.DeepEqual(gotLeaks, wantLeaks) {
dmp := diffmatchpatch.New()
diffs := dmp.DiffMain(string(want), string(got), false)
return fmt.Errorf("%s does not equal %s: %s", wantPath, gotPath, dmp.DiffPrettyText(diffs))
}
if err := os.Remove(gotPath); err != nil {
return err
}
return nil
}
func moveDotGit(from, to string) error {
repoDirs, err := ioutil.ReadDir("../test_data/test_repos")
if err != nil {
return err
}
for _, dir := range repoDirs {
if !dir.IsDir() {
continue
}
_, err := os.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
}
}
return nil
}
+190
View File
@@ -0,0 +1,190 @@
package scan
import (
"bytes"
"fmt"
"io"
"strings"
"time"
"github.com/zricethezav/gitleaks/v7/report"
"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 {
BaseScanner
repo *git.Repository
repoName string
}
// NewUnstagedScanner returns an unstaged scanner
func NewUnstagedScanner(base BaseScanner, repo *git.Repository) *UnstagedScanner {
us := &UnstagedScanner{
BaseScanner: base,
repo: repo,
repoName: getRepoName(base.opts),
}
us.scannerType = typeUnstagedScanner
return us
}
// Scan kicks off an unstaged scan. This will attempt to determine unstaged changes which are then scanned.
func (us *UnstagedScanner) Scan() (report.Report, error) {
var scannerReport report.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
}
if _, err := io.Copy(workTreeBuf, workTreeFile); err != nil {
return scannerReport, err
}
leaks := checkRules(us.BaseScanner, emptyCommit(), us.repoName, workTreeFile.Name(), workTreeBuf.String())
for _, leak := range leaks {
if us.opts.Verbose {
logLeak(leak, us.opts.Redact)
}
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 := wt.Status()
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)
}
}
leaks := checkRules(us.BaseScanner, c, us.repoName, filename, diffContents)
lineLookup := make(map[string]bool)
for _, leak := range leaks {
for lineNumber, line := range strings.Split(prettyDiff, "\n") {
if strings.HasPrefix(line, diffAddPrefix) && strings.Contains(line, leak.Line) {
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
leak.LineNumber = lineNumber + 1
if us.opts.Verbose {
logLeak(leak, us.opts.Redact)
}
scannerReport.Leaks = append(scannerReport.Leaks, leak)
break
}
}
}
}
}
}
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(text)
}
}
return buff.String()
}
+510
View File
@@ -0,0 +1,510 @@
package scan
import (
"bufio"
"encoding/json"
"fmt"
"math"
"os"
"path/filepath"
"regexp"
"runtime"
"strconv"
"strings"
"time"
"github.com/zricethezav/gitleaks/v7/report"
"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/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
maxLineLen = 200
)
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
}
func shouldLog(scanner BaseScanner) bool {
if scanner.opts.Verbose && scanner.scannerType != typeRepoScanner &&
scanner.scannerType != typeCommitScanner &&
scanner.scannerType != typeUnstagedScanner &&
scanner.scannerType != typeNoGitScanner {
return true
}
return false
}
func checkRules(scanner BaseScanner, commit *object.Commit, repoName, filePath, content string) []report.Leak {
filename := filepath.Base(filePath)
path := filepath.Dir(filePath)
var leaks []report.Leak
skipRuleLookup := make(map[string]bool)
// First do simple rule checks based on filename
if skipCheck(scanner.cfg, filename, path) {
return leaks
}
for _, rule := range scanner.cfg.Rules {
if isCommitAllowListed(commit.Hash.String(), rule.AllowList.Commits) {
continue
}
if skipRule(rule, filename, filePath, commit.Hash.String()) {
skipRuleLookup[rule.Description] = true
continue
}
// If it doesnt contain a Content regex then it is a filename regex match
if !ruleContainRegex(rule) {
leak := report.Leak{
LineNumber: defaultLineNumber,
Line: "",
Offender: limitLen("Filename/path offender: " + filename),
Commit: commit.Hash.String(),
Repo: repoName,
RepoURL: scanner.opts.RepoURL,
Message: limitLen(commit.Message),
Rule: rule.Description,
Author: commit.Author.Name,
Email: commit.Author.Email,
Date: commit.Author.When,
Tags: strings.Join(rule.Tags, ", "),
File: filePath,
// Operation: diffOpToString(bundle.Operation),
}
leak.LeakURL = leakURL(leak)
if shouldLog(scanner) {
logLeak(leak, scanner.opts.Redact)
}
leaks = append(leaks, leak)
}
}
lineNumber := 1
for _, line := range strings.Split(content, "\n") {
for _, rule := range scanner.cfg.Rules {
if isCommitAllowListed(commit.Hash.String(), rule.AllowList.Commits) {
break
}
if _, ok := skipRuleLookup[rule.Description]; ok {
continue
}
offender := rule.Regex.FindString(line)
if offender == "" {
continue
}
// check entropy
groups := rule.Regex.FindStringSubmatch(offender)
if isAllowListed(line, append(rule.AllowList.Regexes, scanner.cfg.Allowlist.Regexes...)) {
continue
}
if len(rule.Entropies) != 0 && !trippedEntropy(groups, rule) {
continue
}
// 0 is a match for the full regex pattern
if 0 < rule.ReportGroup && rule.ReportGroup < len(groups) {
offender = groups[rule.ReportGroup]
}
leak := report.Leak{
LineNumber: lineNumber,
Line: limitLen(line),
Offender: limitLen(offender),
Commit: commit.Hash.String(),
Repo: repoName,
RepoURL: scanner.opts.RepoURL,
Message: limitLen(commit.Message),
Rule: rule.Description,
Author: commit.Author.Name,
Email: commit.Author.Email,
Date: commit.Author.When,
Tags: strings.Join(rule.Tags, ", "),
File: filePath,
}
leak.LeakURL = leakURL(leak)
if shouldLog(scanner) {
logLeak(leak, scanner.opts.Redact)
}
leaks = append(leaks, leak)
}
lineNumber++
}
return leaks
}
func limitLen(str string) string {
if len(str) > 200 {
return str[0:maxLineLen-1] + "..."
}
return str
}
func logLeak(leak report.Leak, redact bool) {
if redact {
leak = report.RedactLeak(leak)
}
var b []byte
b, _ = json.MarshalIndent(leak, "", " ")
fmt.Println(string(b))
}
// 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 skipCheck(cfg config.Config, filename string, path string) bool {
// We want to check if there is a allowlist for this file
if len(cfg.Allowlist.Files) != 0 {
for _, reFileName := range cfg.Allowlist.Files {
if regexMatched(filename, reFileName) {
log.Debugf("allowlisted file found, skipping scan of file: %s", filename)
return true
}
}
}
// We want to check if there is a allowlist for this path
if len(cfg.Allowlist.Paths) != 0 {
for _, reFilePath := range cfg.Allowlist.Paths {
if regexMatched(path, reFilePath) {
log.Debugf("file in allowlisted path found, skipping scan of file: %s", filename)
return true
}
}
}
return false
}
func skipRule(rule config.Rule, filename, path, commitSha string) bool {
// For each rule we want to check filename allowlists
if isAllowListed(filename, rule.AllowList.Files) || isAllowListed(path, rule.AllowList.Paths) {
return true
}
// If it has fileNameRegex and it doesnt match we continue to next rule
if ruleContainFileRegex(rule) && !regexMatched(filename, rule.File) {
return true
}
// If it has filePathRegex and it doesnt match we continue to next rule
if ruleContainPathRegex(rule) && !regexMatched(path, rule.Path) {
return true
}
return false
}
// 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
}
// trippedEntropy checks if a given capture group or offender falls in between entropy ranges
// supplied by a custom gitleaks configuration. Gitleaks do not check entropy by default.
func trippedEntropy(groups []string, rule config.Rule) bool {
for _, e := range rule.Entropies {
if len(groups) > e.Group {
entropy := shannonEntropy(groups[e.Group])
if entropy >= e.Min && entropy <= e.Max {
return true
}
}
}
return false
}
// shannonEntropy calculates the entropy of data using the formula defined here:
// https://en.wiktionary.org/wiki/Shannon_entropy
// Another way to think about what this is doing is calculating the number of bits
// needed to on average encode the data. So, the higher the entropy, the more random the data, the
// more bits needed to encode that data.
func shannonEntropy(data string) (entropy float64) {
if data == "" {
return 0
}
charCounts := make(map[rune]int)
for _, char := range data {
charCounts[char]++
}
invLength := 1.0 / float64(len(data))
for _, count := range charCounts {
freq := float64(count) * invLength
entropy -= freq * math.Log2(freq)
}
return entropy
}
// Checks if the given rule has a regex
func ruleContainRegex(rule config.Rule) bool {
if rule.Regex == nil {
return false
}
if rule.Regex.String() == "" {
return false
}
return true
}
// Checks if the given rule has a file name regex
func ruleContainFileRegex(rule config.Rule) bool {
if rule.File == nil {
return false
}
if rule.File.String() == "" {
return false
}
return true
}
// Checks if the given rule has a file path regex
func ruleContainPathRegex(rule config.Rule) bool {
if rule.Path == nil {
return false
}
if rule.Path.String() == "" {
return false
}
return true
}
func isCommitAllowListed(commitHash string, allowlistedCommits []string) bool {
for _, hash := range allowlistedCommits {
if commitHash == hash {
return true
}
}
return false
}
func isAllowListed(target string, allowList []*regexp.Regexp) bool {
if len(allowList) != 0 {
for _, re := range allowList {
if re.FindString(target) != "" {
return true
}
}
}
return false
}
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 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 report.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
}
func leakURL(leak report.Leak) string {
if leak.RepoURL != "" {
return fmt.Sprintf("%s/blob/%s/%s#L%d", leak.RepoURL, leak.Commit, leak.File, leak.LineNumber)
}
return ""
}
@@ -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"
]
+9
View File
@@ -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
+9
View File
@@ -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"]
+16
View File
@@ -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"]
+11
View File
@@ -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"
+4
View File
@@ -0,0 +1,4 @@
[[rules]]
description = "Generic Credential"
regex = '''(?i)(api_key|apikey|secret|password|pass|pw|key)(.{0,20})?[0-9a-zA-Z]{16,45}'''
tags = ["key", "API", "generic"]
+148
View File
@@ -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'''
]
+14
View File
@@ -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"]
+30
View File
@@ -0,0 +1,30 @@
[
{
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
"lineNumber": 5,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "0000000000000000000000000000000000000000",
"repo": "",
"rule": "AWS Access Key",
"commitMessage": "",
"author": "",
"email": "",
"file": "../test_data/test_repos/test_dir_1/server.test.py",
"date": "1970-01-01T00:00:00Z",
"tags": "key, AWS"
},
{
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
"lineNumber": 5,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "0000000000000000000000000000000000000000",
"repo": "",
"rule": "AWS Access Key",
"commitMessage": "",
"author": "",
"email": "",
"file": "../test_data/test_repos/test_dir_1/server.test2.py",
"date": "1970-01-01T00:00:00Z",
"tags": "key, AWS"
}
]
+15
View File
@@ -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"
}
]
+16
View File
@@ -0,0 +1,16 @@
[
{
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
"lineNumber": 5,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "0000000000000000000000000000000000000000",
"repo": "",
"rule": "AWS Access Key",
"commitMessage": "",
"author": "",
"email": "",
"file": "../test_data/test_repos/test_dir_1/server.test.py",
"date": "1970-01-01T00:00:00Z",
"tags": "key, AWS"
}
]
+370
View File
@@ -0,0 +1,370 @@
[
{
"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"
},
{
"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": 5,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "6557c92612d3b35979bd426d429255b3bf9fab74",
"repo": "test_repo_6",
"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": 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',",
"lineNumber": 5,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "6557c92612d3b35979bd426d429255b3bf9fab74",
"repo": "test_repo_9",
"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', #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,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": 5,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "6557c92612d3b35979bd426d429255b3bf9fab74",
"repo": "test_repo_6",
"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": 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',",
"lineNumber": 5,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "6557c92612d3b35979bd426d429255b3bf9fab74",
"repo": "test_repo_9",
"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', #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,114 @@
[
{
"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"
},
{
"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"
}
]
+47
View File
@@ -0,0 +1,47 @@
[
{
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
"lineNumber": 6,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "748f11eaf2c38c3cf0ac6a22e44208777e79fa6f",
"repo": "test_repo_8",
"rule": "AWS 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",
"operation": "addition"
},
{
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
"lineNumber": 2,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "ce7e8177bbf8a172c06b6a1e370a374d5c19f660",
"repo": "test_repo_8",
"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",
"operation": "addition"
},
{
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
"lineNumber": 6,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "9267bc86ec1497471cbc6f3308f3527f7ef34b9d",
"repo": "test_repo_8",
"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",
"operation": "addition"
}
]
@@ -0,0 +1,17 @@
[
{
"line": "more_secrets = '99432bfewaf823ec3294e231'",
"lineNumber": 7,
"offender": "secrets = '99432bfewaf823ec3294e231",
"commit": "a4c9fb737d5552fd96fce5cc7eedb23353ba9ed0",
"repo": "test_repo_5",
"rule": "Generic Credential",
"commitMessage": "even more secrets\n",
"author": "Zach Rice",
"email": "zrice@gitlab.com",
"file": "secrets.py",
"date": "2020-02-01T10:30:22-05:00",
"tags": "key, API, generic",
"operation": "addition"
}
]
@@ -0,0 +1,17 @@
[
{
"line": "more_secrets = '99432bfewaf823ec3294e231'",
"lineNumber": 7,
"offender": "secrets = '99432bfewaf823ec3294e231",
"commit": "a4c9fb737d5552fd96fce5cc7eedb23353ba9ed0",
"repo": "test_repo_5",
"rule": "Generic Credential",
"commitMessage": "even more secrets\n",
"author": "Zach Rice",
"email": "zrice@gitlab.com",
"file": "secrets.py",
"date": "2020-02-01T10:30:22-05:00",
"tags": "key, API, generic",
"operation": "addition"
}
]
@@ -0,0 +1,32 @@
[
{
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPLE'",
"lineNumber": 1,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "a4c9fb737d5552fd96fce5cc7eedb23353ba9ed0",
"repo": "test_repo_5",
"rule": "AWS 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,17 @@
[
{
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
"lineNumber": 5,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "6557c92612d3b35979bd426d429255b3bf9fab74",
"repo": "test_repo_1",
"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,17 @@
[
{
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
"lineNumber": 5,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "6557c92612d3b35979bd426d429255b3bf9fab74",
"repo": "test_repo_1",
"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,17 @@
[
{
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
"lineNumber": 5,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "6557c92612d3b35979bd426d429255b3bf9fab74",
"repo": "test_repo_1",
"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='AKIAIO5FODNN7DXAMPLE'",
"lineNumber": 10,
"offender": "AKIAIO5FODNN7DXAMPLE",
"commit": "0000000000000000000000000000000000000000",
"repo": "test_repo_1",
"repoURL": "",
"leakURL": "",
"rule": "AWS Access Key",
"commitMessage": "",
"author": "",
"email": "",
"file": "server.test.py",
"date": "1970-01-01T00:00:00Z",
"tags": "key, AWS"
}
]
@@ -0,0 +1,17 @@
[
{
"line": "AKIAIO5FODNN7EXAMPLE",
"lineNumber": 5,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "0000000000000000000000000000000000000000",
"repo": "test_repo_7",
"rule": "AWS Access Key",
"commitMessage": "",
"author": "",
"email": "",
"file": "file",
"date": "1970-01-01T00:00:00Z",
"tags": "key, AWS",
"operation": "equal"
}
]
+44
View File
@@ -0,0 +1,44 @@
[
{
"line": "api_token: exampleSecretPassword",
"lineNumber": 3,
"offender": "token: exampleSecretPassword",
"commit": "e7bf376f855ae9bc6e3bb27b5f9d65c57eba799d",
"repo": "test_repo_6",
"rule": "Generic password",
"commitMessage": "More secrets\n\n",
"author": "Noel Algora",
"email": "noealgigu@gmail.com",
"file": "config/config.yaml",
"date": "2020-02-19T04:08:26-05:00",
"tags": "key, Yml, Yaml"
},
{
"line": "db_password_token: exampleSecretPassword",
"lineNumber": 3,
"offender": "password_token: exampleSecretPassword",
"commit": "e7bf376f855ae9bc6e3bb27b5f9d65c57eba799d",
"repo": "test_repo_6",
"rule": "Generic password",
"commitMessage": "More secrets\n\n",
"author": "Noel Algora",
"email": "noealgigu@gmail.com",
"file": "config/config.yaml",
"date": "2020-02-19T04:08:26-05:00",
"tags": "key, Yml, Yaml"
},
{
"line": "aws_access_key_id=AKIAIO5FODNN7EXAMPLE",
"lineNumber": 1,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "95cf0237f8cdfc0686a29df08260d8635f46c9b0",
"repo": "test_repo_6",
"rule": "AWS Access Key",
"commitMessage": "AWS Key in properties\n\n",
"author": "Noel Algora",
"email": "noealgigu@gmail.com",
"file": "config/application.properties",
"date": "2020-02-19T04:04:15-05:00",
"tags": "key, AWS"
}
]
@@ -0,0 +1,32 @@
[
{
"line": "api_token: exampleSecretPassword",
"lineNumber": 2,
"offender": "token: exampleSecretPassword",
"commit": "98b6c7cb3fb29a5993c4c95c56a2dc53050b9247",
"repo": "test_repo_6",
"rule": "Generic password",
"commitMessage": "Adding some secrets in config folder\n\n",
"author": "Noel Algora",
"email": "noealgigu@gmail.com",
"file": "application.yaml",
"date": "2020-02-24T14:13:15-05:00",
"tags": "key, Yml, Yaml",
"operation": "addition"
},
{
"line": "db_password: verySecretProductionPassword",
"lineNumber": 3,
"offender": "password: verySecretProductionPassword",
"commit": "98b6c7cb3fb29a5993c4c95c56a2dc53050b9247",
"repo": "test_repo_6",
"rule": "Generic password",
"commitMessage": "Adding some secrets in config folder\n\n",
"author": "Noel Algora",
"email": "noealgigu@gmail.com",
"file": "application.yaml",
"date": "2020-02-24T14:13:15-05:00",
"tags": "key, Yml, Yaml",
"operation": "addition"
}
]
@@ -0,0 +1,17 @@
[
{
"line": "aws_access_key_id=AKIAIO5FODNN7EXAMPLE",
"lineNumber": 3,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "98b6c7cb3fb29a5993c4c95c56a2dc53050b9247",
"repo": "test_repo_6",
"rule": "AWS 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",
"operation": "addition"
}
]
@@ -0,0 +1,17 @@
[
{
"line": "apiToken=d41d8cd98f00b204e9800998ecf8427e",
"lineNumber": 2,
"offender": "Token=d41d8cd98f00b204e9800998ecf8427e",
"commit": "98b6c7cb3fb29a5993c4c95c56a2dc53050b9247",
"repo": "test_repo_6",
"rule": "Generic password",
"commitMessage": "Adding some secrets in config folder\n\n",
"author": "Noel Algora",
"email": "noealgigu@gmail.com",
"file": "config/application.properties",
"date": "2020-02-24T14:13:15-05:00",
"tags": "key, Yml, Yaml",
"operation": "addition"
}
]
@@ -0,0 +1,17 @@
[
{
"line": "aws_access_key_id=AKIAIO5FODNN7EXAMPLE",
"lineNumber": 3,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "98b6c7cb3fb29a5993c4c95c56a2dc53050b9247",
"repo": "test_repo_6",
"rule": "AWS 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",
"operation": "addition"
}
]
@@ -0,0 +1,17 @@
[
{
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
"lineNumber": 5,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "6557c92612d3b35979bd426d429255b3bf9fab74",
"repo": "test_repo_6",
"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,17 @@
[
{
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
"lineNumber": 5,
"offender": "AKIAIO5FODNN7EXAMPLE",
"commit": "6557c92612d3b35979bd426d429255b3bf9fab74",
"repo": "test_repo_6",
"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,66 @@
[
{
"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"
}
]
@@ -0,0 +1,50 @@
[
{
"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": "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"
}
]
@@ -0,0 +1,18 @@
[
{
"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"
}
]
+50
View File
@@ -0,0 +1,50 @@
[
{
"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"
}
]
Loaded 100 of 1314 files, more files were not shown because too many files have changed in this diff. Show more