Repository navigation
added 3 DLP rules - #126
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
|
recheck |
I have read the CLA Document and I hereby sign the CLA |
|
I have read the CLA Document and I hereby sign the CLA |
|
recheck |
|
Thanks for this. It is a better contribution than most: three rules, six tests, and three of those are near-misses. Your reasoning on the Anthropic rule is correct and I checked it rather than took it: The hyphen after One thing to fix before this landsThere is an existing DashScope rule in the manifest: pattern: "(?i)\bsk-[a-f0-9]{32}\b"Hex is a subset of alphanumeric and 32 is more than 20, so a DashScope token now matches your generic rule as well: Your rule description says the specific rules are handled "above", so I think you assumed first match wins. It does not. Not a false positive, both are real credential matches, but duplicate criticals are the same noise problem in a different coat. A negative lookahead on the generic pattern is enough: pattern: "(?i)\bsk-(?!ant-)(?![a-f0-9]{32}\b)[a-zA-Z0-9]{20,}\b"The Why the checks have not runThis is a fork PR from a first-time contributor, so GitHub is holding the workflows for maintainer approval. That is why only the CLA check has reported and the branch shows as blocked. Nothing to do with your change; it will be approved. Happy to take this either way: push the lookahead, or say the word and I will apply it on merge. |
|
Merged. Thanks. Two corrections to my review, both in your favour. The overlap is mostly not yours. I measured the regexes in isolation and said your generic rule "now produces two" matches on a DashScope key. Then I ran it against the real scanner on master, and the number is four: Three of those four overlapped before your PR. You added one to a pile that already existed rather than creating it, and your rules are the only ones in that list with near-miss tests. So I did not ask you to patch it. It is filed as #130 with the reproduction and four options, because a one-line lookahead on your rule would have hidden a wider problem behind a local fix. Your PR is what surfaced it. Every match is correct and none is a false positive; the problem is that a SOC gets four criticals for one secret, which is the alert-fatigue failure this project spent its last release fixing, in a different coat. Not urgent either way: DLP defaults to Your rules and all six tests are on master unchanged, and you are in CONTRIBUTORS.md. The entry names the near-miss tests specifically, because that is the part a reviewer skimming the diff would miss and it is the thing this project cares most about in a detection contribution. If you want #130, it is yours. Option 3 in that issue, deduplicating on the matched span, looks closest to right to me: two token rules hitting the same 35 characters is one finding reported twice, while |
Added three DLP rules to [manifest.yaml] all credentials / critical:
stripe_api_key — (?i)\bsk_(live|test)[0-9a-z]{24,}\b, exactly as the issue specified.
anthropic_api_key — a separate rule (per the assignee's stated preference), (?i)\bsk-ant-[a-zA-Z0-9-]{20,}, since the generic pattern's alnum-only run breaks at the hyphen after ant and never matches Anthropic keys.
generic_provider_api_key — (?i)\bsk-[a-zA-Z0-9]{20,}\b for OpenAI-shaped keys.
Added 6 test cases, a fire test each for Stripe live, Stripe test, Anthropic, and generic-provider, plus the two near-misses requested (a too-short Stripe-shaped string, and sk- followed by a short word like sk-test), etc.
All test cases successful. Closes #4