mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-30 05:04:22 +01:00
Add baseline (#975)
* Add baseline * Update doc, add error, move baseline to detect namespace, ignore findings instead of reactively filter them out * Update detect/detect.go Co-authored-by: Zachary Rice <zricezrice@gmail.com> * Update IsNew function (no check on tags - omit finger print check) * Update README.md Co-authored-by: Zachary Rice <zricezrice@gmail.com> * Update examples in readme to make it ensure it's clear that a baseline is indeed a gitleaks report * Fix test - updated tags doesn't make a finding new * Add missing err assignment * Allow scanner to continue without baseline if file is malformed * Fix typo in comment * Fix control flow err. (Real life testing) * Fix wording * Auto-ignore baseline path
This commit is contained in:
1 parent
62020539f4
commit
4f6ee2bcf1
9 files changed
+295
-1
No files matched your search
@@ -156,6 +156,7 @@ Flags:
|
||||
--redact redact secrets from logs and stdout
|
||||
-f, --report-format string output format (json, csv, sarif)
|
||||
-r, --report-path string report file
|
||||
-b, --baseline-path path to a previously generated report with known issues that gitleaks should ignore
|
||||
-s, --source string path to source (git repo, directory, file)
|
||||
-v, --verbose show verbose output from scan
|
||||
|
||||
@@ -190,6 +191,23 @@ as a pre-commit.
|
||||
|
||||
**NOTE**: the `protect` command can only be used on git repos, running `protect` on files or directories will result in an error message.
|
||||
|
||||
### Creating a baseline
|
||||
|
||||
When scanning large repositories or repositories with a long history, it can be convenient to use a baseline. When using a baseline,
|
||||
gitleaks will ignore any old findings that are present in the baseline. A baseline can be any gitleaks report. To create a gitleaks report, run gitleaks with the `--report-path` parameter.
|
||||
|
||||
```
|
||||
gitleaks detect --report-path gitleaks-report.json # This will save the report in a file called gitleaks-report.json
|
||||
```
|
||||
|
||||
Once as baseline is created it can be applied when running the detect command again:
|
||||
|
||||
```
|
||||
gitleaks detect --baseline-path gitleaks-report.json --report-path findings.json
|
||||
```
|
||||
|
||||
After running the detect command with the --baseline-path parameter, report output (findings.json) will only contain new issues.
|
||||
|
||||
### Verify Findings
|
||||
|
||||
You can verify a finding found by gitleaks using a `git log` command.
|
||||
|
||||
Reference in new issue
Block a user