You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Version 0.2.0 of Gitleaks is the first version update since this got relatively popular. Based on the issues raised it seems that folks want better support for integration into their pipelines. I hear ya. This is what this update tries to provide. So... what are the changes?
7
+
8
+
* Additionally regex checking
9
+
* $HOME/.gitleaks/ directory for clones and reports
10
+
* Clone into temp dir option
11
+
* Persistent repos for Orgs and Users (no more re-cloning)
12
+
* Pagination for Org/User list... no more partial repo lists
Copy file name to clipboardExpand all lines: README.md
+65-25
Original file line number
Diff line number
Diff line change
@@ -5,11 +5,6 @@
5
5
6
6
## Check git repos for secrets and keys
7
7
8
-
### Features
9
-
10
-
* Search all commits on all branches in topological order
11
-
* Regex/Entropy checks
12
-
13
8
#### Installing
14
9
15
10
```bash
@@ -24,34 +19,80 @@ go get -u github.com/zricethezav/gitleaks
24
19
./gitleaks {git url}
25
20
```
26
21
27
-
This example will clone the target `{git url}` and run a diff on all commits. A report will be outputted to `{repo_name}_leaks.json`
28
-
Gitleaks scans all lines of all commits and checks if there are any regular expression matches. The regexs are defined in `main.go`. Work largely based on [https://people.eecs.berkeley.edu/~rohanpadhye/files/key_leaks-msr15.pdf](https://people.eecs.berkeley.edu/~rohanpadhye/files/key_leaks-msr15.pdf) and regexes from https://github.com/dxa4481/truffleHog and https://github.com/anshumanbh/git-all-secrets.
29
-
30
-
##### gitLeaks User
31
-
```bash
32
-
./gitleaks -u {user git url}
22
+
Gitleaks will clone the target `<git url>` to `$HOME/.gitleaks/clones/<repo name>` and run a regex check against all diffs of all commits on all remotes in topological order. If any leaks are found gitleaks will output the leak in json, Ex:
Gitleaks will not re-clone repos unless the temporary flag is set (see Options section), instead gitleaks will `fetch` all new changes before the scan. This works for users and organization repos as well. Regex's for the scan are defined in `main.go`, feel free to open a PR and contribute if you have additional regex you want included. Work largely based on [https://people.eecs.berkeley.edu/~rohanpadhye/files/key_leaks-msr15.pdf](https://people.eecs.berkeley.edu/~rohanpadhye/files/key_leaks-msr15.pdf) and regexes from https://github.com/dxa4481/truffleHog and https://github.com/anshumanbh/git-all-secrets.
This will run gitleaks on one of my projects, gronit and create the following structure in `$HOME/.gitleaks`:
37
43
```
44
+
.
45
+
├── clones
46
+
│ └── zricethezav
47
+
│ └── gronit
48
+
│ ├── README.md
49
+
│ ├── main.go
50
+
│ ├── options.go
51
+
│ ├── server.go
52
+
│ └── utils.go
53
+
└── report
54
+
└── zricethezav
55
+
└── gronit_leaks.json
56
+
```
57
+
The clones directory contains the repo owner (me) and any repos gitleaks has scanned. Next time we run gitleaks on gronit again we will `fetch` gronit rather than `clone`. Reports are written out to `$HOME/.gitleaks/report/<owner>/<repo>_leaks.json`
38
58
39
-
#### Help
59
+
#### Options
40
60
```
41
61
usage: gitleaks [options] <url>
42
62
43
63
Options:
44
-
-c Concurrency factor (default is 10)
45
-
-u --user Git user url
46
-
-r --repo Git repo url
47
-
-o --org Git organization url
48
-
-s --since Scan until this commit (SHA)
49
-
-b --b64Entropy Base64 entropy cutoff (default is 70)
50
-
-x --hexEntropy Hex entropy cutoff (default is 40)
51
-
-e --entropy Enable entropy
52
-
--strict Enables stopwords
53
-
-h --help Display this message
64
+
-c --concurrency Upper bound on concurrent diffs
65
+
-u --user Git user url
66
+
-r --repo Git repo url
67
+
-o --org Git organization url
68
+
-s --since Commit to stop at
69
+
-b --b64Entropy Base64 entropy cutoff (default is 70)
70
+
-x --hexEntropy Hex entropy cutoff (default is 40)
71
+
-e --entropy Enable entropy
72
+
-j --json Output gitleaks report
73
+
--token Github API token
74
+
--strict Enables stopwords
75
+
-h --help Display this message
76
+
54
77
```
78
+
79
+
##### Options Explained
80
+
81
+
| Option | Explanation |
82
+
| ------------- | ------------- |
83
+
| -c --concurrency | Set the limit on the number of concurrent diffs. If unbounded, your system would throw a `too many open files` error. Tweak `ulimit` for quicker scans at your own risk. Ex: `gitleaks -c 100 <repo_url>`|
84
+
| -u --user | Target git user. Reports and clones are dumped to `$HOME/.gitleaks/clones/<user>/<user_repos>` and `$HOME/.gitleaks/reports/<user>/<gitleaks_reports>`. Ex: `gitleaks -u <user_git_url>`.
85
+
| -o --org | Target git organization. Reports and clones are dumped to `$HOME/.gitleaks/clones/<org>/<org_repos>` and `$HOME/.gitleaks/reports/<org>/<gitleaks_reports>`. Ex: `gitleaks -o <org_git_url>`
86
+
| -r --repo | Default behavior is to have gitleaks target a specific repo, so this option is unecessary, but... Target git repo. Reports and clones are dumped to `$HOME/.gitleaks/clones/<owner>/<repos>` and `$HOME/.gitleaks/reports/<owner>/<gitleaks_reports>`
87
+
| -s --since | Since argument accepts a commit hash and will scan the repo history up to and including this hash. Ex: `gitleaks -s <HASH> <repo_url>`
88
+
| -b --b64Entropy | Entropy cutoff for base 64 characters. Ex: `gitleaks -e -b 70 <repo_url>`|
| -t --temporary | Cloned repos will be cloned into a temp directory and removed after gitleaks exits. Ex: `gitleaks -t <repo_url>`|
93
+
| --token | NOTE: you should use env var `GITHUB_TOKEN` instead of this flag. Github API token needed for scanning private repos and pagination on repo fetching from github's api. |
NOTE: your mileage may vary so if you aren't getting the results you expected try updating the regexes to fit your needs or try tweaking the entropy cutoffs and stopwords. Entropy cutoff for base64 alphabets seemed to give good results around 70 and hex alphabets seemed to give good results around 40. Entropy is calculated using [Shannon entropy](http://www.bearcave.com/misl/misl_tech/wavelets/compression/shannon.html).
56
97
57
98
@@ -69,4 +110,3 @@ docker build -t gitleaks .
69
110
docker run --rm --name=gitleaks gitleaks https://github.com/zricethezav/gitleaks
0 commit comments