fix(rules): allowlist keyboard chord secrets in generic-api-key#2125
Open
obchain wants to merge 1 commit into
Open
fix(rules): allowlist keyboard chord secrets in generic-api-key#2125obchain wants to merge 1 commit into
obchain wants to merge 1 commit into
Conversation
`generic-api-key` flags VSCode/JetBrains keybinding entries like
`"key": "ctrl+shift+down"` because the chord string slips through the
`[a-z0-9][a-z0-9+/]{11,}` arm of the secret regex (gitleaks#1897).
Add a chord-shape regex to the first generic-api-key allowlist (target
= secret). It requires one or more known modifier prefixes
(`ctrl`, `cmd`, `shift`, `alt`, `opt`, `meta`, `super`, `win`, `fn`,
plus the long forms) joined by `+`, followed by a short word, F-key,
digit, or single punctuation character — anchored end-to-end so the
shape can't appear inside a real secret and over-allowlist.
Six new FPs lock the behavior in via `utils.Validate`.
Closes gitleaks#1897
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
generic-api-keyflags VSCode/JetBrains keybinding entries like:{ "key": "ctrl+shift+down", "command": "editor.action.moveSelectionDown" }The chord
ctrl+shift+downslips through the[a-z0-9][a-z0-9+/]{11,}branch of the secret regex because+is permitted there. Thekeyidentifier in front trips the semi-generic match and the chord is reported as a secret (#1897).Add a chord-shape regex to the first
generic-api-keyallowlist (RegexTarget = secret):It requires 1–5 known modifier prefixes joined by
+, then a short word, F-key, digit, or single punctuation character. Anchored end-to-end (^...$) so the shape can't appear inside a real secret and over-allowlist.Verification
Six new FPs lock the behavior in via
utils.Validate:Test plan
go generate ./...regeneratesconfig/gitleaks.tomlcleanly (Validate passes new FPs)go test ./...greenCloses #1897