Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
Allowlist Regex Targets
Let's use the generic rule to demonstrate the new
regexTarget
allowlist optionexample.txt
will be our target and contain a single line with a fake secret:Running gitleaks on this file using the generic rule will return one finding:
We can add a allowlist
regexes
entry to include part of the secret. This will cause gitleaks to ignore the finding above.Note that by default gitleaks uses the Secret to compare against allowlist regexes.
Adding the following allowlist to the generic rule will cause gitleaks to ignore the finding:
But now say you don't want to use
Secret
to compare against your allowlist regexes. Well, now you can useregexTarget
and set the value as eitherline
ormatch
to compare against the line or regex match:and
will both result in the finding being ignored because
discord
is found in the generic rule regex match andvar
is in the line where the finding was found.In addition to rule allowlists, you can set
regexTarget
in the global allowlist:Checklist: