Documentation
¶
Overview ¶
Package gitleaksrules scans unified diffs with the gitleaks default ruleset embedded in the gk binary, so secret scanning works without the gitleaks binary installed.
rules.json is generated by tools/genrules from a pinned gitleaks release (see `make gen-rules`). The engine mirrors the gitleaks detection steps that the default config relies on: keyword prefilter, regex, secret group, entropy, path rules, and global and per-rule allowlists.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GKRuleCount ¶ added in v0.158.0
func GKRuleCount() int
GKRuleCount returns the number of rules that gk adds to the gitleaks ruleset.
func MaskLines ¶ added in v0.167.0
MaskLines returns a copy of lines with every secret the ruleset finds masked in place, for callers that print source lines outside a scan report, such as `gk find`. path is the file the lines came from, or "" when they came from no file. The lines are scanned as one block, so a match that spans lines is found.
It is stricter than a scan in three ways. The rules run with no path, so the path allowlists, which a scan uses to skip test fixtures and lock files, do not apply: a line that is printed must not depend on where it came from. Only the rules that are limited to a path, such as the Terraform password rule, run with path. A secret found only in decoded text, such as a base64 value, cannot be located in the line, so the whole line is replaced. So is a line that is one opaque run of base64, such as a line of a PEM block: apart from the block around it, it matches no rule.
An encoded value folded over several lines, as in a YAML block, is not joined back: the decoder reads one line at a time, so only a piece that holds a whole secret or is an opaque run is masked. `gk find`, the one caller, prints one line of a diff at a time and passes each alone, so it never has the other pieces of such a value to join.
func ScanDiff ¶
ScanDiff scans the added lines of a unified diff (`git diff` or `git log -p` output) and returns one finding per matched secret.
Types ¶
This section is empty.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package codec decodes base64, hex, percent, and unicode escapes in place so the rules can run on the decoded text, and maps decoded matches back to their location in the original text.
|
Package codec decodes base64, hex, percent, and unicode escapes in place so the rules can run on the decoded text, and maps decoded matches back to their location in the original text. |