mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-30 21:24:21 +01:00
Merge pull request #627 from w0rmr1d3r/update_documentation
Update documentation
This commit is contained in:
1 file changed
+12
-14
@@ -43,8 +43,9 @@ brew install gitleaks
|
|||||||
##### Docker
|
##### Docker
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker pull zricethezav/gitleaks
|
# To just pull the image
|
||||||
# or
|
docker pull zricethezav/gitleaks:latest
|
||||||
|
# To run it from your cloned repo
|
||||||
cd to/your/repo/
|
cd to/your/repo/
|
||||||
docker run -v ${PWD}:/my-repo zricethezav/gitleaks:latest --path="/my-repo" [OPTIONS]
|
docker run -v ${PWD}:/my-repo zricethezav/gitleaks:latest --path="/my-repo" [OPTIONS]
|
||||||
```
|
```
|
||||||
@@ -60,8 +61,11 @@ See [pre-commit](https://github.com/pre-commit/pre-commit) for instructions.
|
|||||||
Sample `.pre-commit-config.yaml`
|
Sample `.pre-commit-config.yaml`
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
|
# The revision doesn't get updated manually
|
||||||
|
# check this https://github.com/zricethezav/gitleaks/releases
|
||||||
|
# to see if there are newer versions
|
||||||
- repo: https://github.com/zricethezav/gitleaks
|
- repo: https://github.com/zricethezav/gitleaks
|
||||||
rev: v7.5.0
|
rev: v7.6.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: gitleaks
|
- id: gitleaks
|
||||||
```
|
```
|
||||||
@@ -167,9 +171,7 @@ The default configuration Gitleaks uses is located [here](https://github.com/zri
|
|||||||
|
|
||||||
The rules are written in [TOML](https://github.com/toml-lang/toml) as defined in [TomlLoader struct](https://github.com/zricethezav/gitleaks/blob/master/config/config.go#L57-L87), and can be summarized as:
|
The rules are written in [TOML](https://github.com/toml-lang/toml) as defined in [TomlLoader struct](https://github.com/zricethezav/gitleaks/blob/master/config/config.go#L57-L87), and can be summarized as:
|
||||||
|
|
||||||
```
|
```toml
|
||||||
|
|
||||||
|
|
||||||
[[rules]]
|
[[rules]]
|
||||||
description = "a string describing one of many rule in this config"
|
description = "a string describing one of many rule in this config"
|
||||||
regex = '''one-go-style-regex-for-this-rule'''
|
regex = '''one-go-style-regex-for-this-rule'''
|
||||||
@@ -202,7 +204,7 @@ Regular expressions are _NOT_ the full Perl set, so there are no look-aheads or
|
|||||||
### Examples
|
### Examples
|
||||||
#### Example 1
|
#### Example 1
|
||||||
The first and most commonly edited array of tables is `[[rules]]`. This is where you can define your own custom rules for Gitleaks to use while scanning repos. Example keys/values within the `[[rules]]` table:
|
The first and most commonly edited array of tables is `[[rules]]`. This is where you can define your own custom rules for Gitleaks to use while scanning repos. Example keys/values within the `[[rules]]` table:
|
||||||
```
|
```toml
|
||||||
[[rules]]
|
[[rules]]
|
||||||
description = "generic secret regex"
|
description = "generic secret regex"
|
||||||
regex = '''secret(.{0,20})([0-9a-zA-Z-._{}$\/\+=]{20,120})'''
|
regex = '''secret(.{0,20})([0-9a-zA-Z-._{}$\/\+=]{20,120})'''
|
||||||
@@ -210,7 +212,7 @@ The first and most commonly edited array of tables is `[[rules]]`. This is where
|
|||||||
```
|
```
|
||||||
#### Example 2
|
#### Example 2
|
||||||
We can also **combine** regular expressions AND entropy:
|
We can also **combine** regular expressions AND entropy:
|
||||||
```
|
```toml
|
||||||
[[rules]]
|
[[rules]]
|
||||||
description = "entropy and regex example"
|
description = "entropy and regex example"
|
||||||
regex = '''secret(.{0,20})['|"]([0-9a-zA-Z-._{}$\/\+=]{20,120})['|"]'''
|
regex = '''secret(.{0,20})['|"]([0-9a-zA-Z-._{}$\/\+=]{20,120})['|"]'''
|
||||||
@@ -228,10 +230,9 @@ aws_secret='ABCDEF+c2L7yXeGvUyrPgYsDnWRRC1AYEXAMPLE'
|
|||||||
and
|
and
|
||||||
```
|
```
|
||||||
aws_secret=os.getenv('AWS_SECRET_ACCESS_KEY')
|
aws_secret=os.getenv('AWS_SECRET_ACCESS_KEY')
|
||||||
|
|
||||||
```
|
```
|
||||||
The first line of code is an example of a hardcoded secret being assigned to the variable `aws_secret`. The second line of code is an example of a secret being assigned via env variables to `aws_secret`. Both would be caught by the rule defined in *example 2* but only the first line is actually a leak. Let's define a new rule that will capture only the first line of code. We can do this by combining regular expression **groups** and entropy.
|
The first line of code is an example of a hardcoded secret being assigned to the variable `aws_secret`. The second line of code is an example of a secret being assigned via env variables to `aws_secret`. Both would be caught by the rule defined in *example 2* but only the first line is actually a leak. Let's define a new rule that will capture only the first line of code. We can do this by combining regular expression **groups** and entropy.
|
||||||
```
|
```toml
|
||||||
[[rules]]
|
[[rules]]
|
||||||
description = "entropy and regex example"
|
description = "entropy and regex example"
|
||||||
regex = '''secret(.{0,20})['|"]([0-9a-zA-Z-._{}$\/\+=]{20,120})['|"]'''
|
regex = '''secret(.{0,20})['|"]([0-9a-zA-Z-._{}$\/\+=]{20,120})['|"]'''
|
||||||
@@ -254,18 +255,16 @@ without any delimiters. This will make a false negative for, say:
|
|||||||
foo=+awsSecretAccessKeyisBase64=40characters
|
foo=+awsSecretAccessKeyisBase64=40characters
|
||||||
```
|
```
|
||||||
So you can use the following to effectively create the proper Perl regex:
|
So you can use the following to effectively create the proper Perl regex:
|
||||||
```
|
```toml
|
||||||
[[rules]]
|
[[rules]]
|
||||||
description = "AWS secret key regardless of labeling"
|
description = "AWS secret key regardless of labeling"
|
||||||
regex = '''.?[A-Za-z0-9\\+=]{40}.?'''
|
regex = '''.?[A-Za-z0-9\\+=]{40}.?'''
|
||||||
[rules.allowlist]
|
[rules.allowlist]
|
||||||
description = "41 base64 characters is not an AWS secret key"
|
description = "41 base64 characters is not an AWS secret key"
|
||||||
regexes = ['''[A-Za-z0-9\\+=]{41}''']
|
regexes = ['''[A-Za-z0-9\\+=]{41}''']
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Exit Codes
|
### Exit Codes
|
||||||
You can always set the exit code when leaves are encountered with the `--leaks-exit-code` flag. Default exit codes below:
|
You can always set the exit code when leaves are encountered with the `--leaks-exit-code` flag. Default exit codes below:
|
||||||
```
|
```
|
||||||
@@ -285,6 +284,5 @@ These users are [sponsors](https://github.com/sponsors/zricethezav) of gitleaks:
|
|||||||
- [Ben "Ihavespoons"](https://github.com/ihavespoons)
|
- [Ben "Ihavespoons"](https://github.com/ihavespoons)
|
||||||
- [Henry Sachs](https://github.com/henrysachs)
|
- [Henry Sachs](https://github.com/henrysachs)
|
||||||
|
|
||||||
|
|
||||||
#### Logo Attribution
|
#### 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>.
|
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>.
|
||||||
Reference in new issue
Block a user