You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add DLP rules for Stripe and LLM-provider API keys #4
Agents frequently handle Stripe (sk_live_...) and LLM-provider keys (OpenAI sk-..., Anthropic sk-ant-...). These leaking into a tool call is exactly what DLP is for.
Task
Add rules to apps/orchestrator/agentmetry/policies/dlp/manifest.yaml for Stripe live/test keys ((?i)sk_(live|test)_[0-9a-z]{24,}) and a generic provider key (sk-[a-zA-Z0-9]{20,}). Category credentials, severity critical.
Acceptance criteria
Fires + near-miss tests in test_dlp_scanner.py with fake keys (gitleaks:allow).
Assigned — thanks for picking this up, and welcome.
Two things worth knowing before you start, both of which have bitten me in this
exact file.
1. The proposed generic pattern misses Anthropic keys.
sk-[a-zA-Z0-9]{20,} needs 20+ alphanumerics immediately after sk-. An
Anthropic key looks like sk-ant-api03-..., so the regex gets ant, hits the
hyphen, and stops. Three characters, no match — despite the issue naming
Anthropic explicitly. Worth handling sk-ant- as its own rule, or allowing
hyphens in the generic one. Your call which reads better; I'd lean toward a
separate anthropic_api_key rule, since a distinct rule id is more useful in a
detection than a generic one.
2. Patterns are matched against json.dumps(arguments), not raw text.
This is the trap. By the time the scanner sees your pattern, quotes have been
escaped, so a key inside a quoted shell command arrives as \"sk_live_...\".
That is why aws_secret_key in the manifest has \\\\? before each quote —
it survives the JSON escaping. If a rule works in a regex tester and not in the
test suite, this is almost always why.
Where things live
Rules: policies/dlp/manifest.yaml (see aws_access_key for the shape)
Run: cd apps/orchestrator && pytest tests/test_dlp_scanner.py -q
On the tests
Please write the near-miss alongside the positive. The aws_secret_key comment
in the manifest explains why: a bare 40-char pattern matched every git commit
SHA, so git checkout <sha> became a critical finding and, in block mode, a
denied tool call. A false positive in a security tool is not cosmetic — it is
how the feed gets muted. For these rules the near-misses I would want covered
are a Stripe-shaped string that is too short, and something like sk- followed
by a short word.
CI runs gitleaks, so mark your fake keys with a gitleaks:allow comment or the
secret scan will block the PR.
One admin note: there is a CLA to sign for first contributions. You
keep copyright; it grants permission to ship your work under Apache 2.0.
Shout if anything is unclear or the escaping fights you.
Nothing about the task changes, only the path. I have updated the issue body above.
Why it moved: those manifests are configuration the package needs in order to run, and pip install agentmetry was shipping without them. DLP scanning was silently inert for anyone who installed instead of cloning, which is close to the worst possible failure for a secret scanner. They now live inside the package so the wheel actually carries them.
If you already have a branch open, it was a plain git mv, so a rebase on master should carry your edits across:
git fetch origin && git rebase origin/master
The test file is unchanged at apps/orchestrator/tests/test_dlp_scanner.py, though the constant at the top of it now points at the new location.
Sorry for the churn, and thanks for picking this up.
Activity
hvadlamani1 commentedon Jul 28, 2026
Hello! Can I be assigned to this?
blitzcrieg1 commentedon Jul 28, 2026
Assigned — thanks for picking this up, and welcome.
Two things worth knowing before you start, both of which have bitten me in this
exact file.
1. The proposed generic pattern misses Anthropic keys.
sk-[a-zA-Z0-9]{20,}needs 20+ alphanumerics immediately aftersk-. AnAnthropic key looks like
sk-ant-api03-..., so the regex getsant, hits thehyphen, and stops. Three characters, no match — despite the issue naming
Anthropic explicitly. Worth handling
sk-ant-as its own rule, or allowinghyphens in the generic one. Your call which reads better; I'd lean toward a
separate
anthropic_api_keyrule, since a distinct rule id is more useful in adetection than a generic one.
2. Patterns are matched against
json.dumps(arguments), not raw text.This is the trap. By the time the scanner sees your pattern, quotes have been
escaped, so a key inside a quoted shell command arrives as
\"sk_live_...\".That is why
aws_secret_keyin the manifest has\\\\?before each quote —it survives the JSON escaping. If a rule works in a regex tester and not in the
test suite, this is almost always why.
Where things live
policies/dlp/manifest.yaml(seeaws_access_keyfor the shape)apps/orchestrator/tests/test_dlp_scanner.pycd apps/orchestrator && pytest tests/test_dlp_scanner.py -qOn the tests
Please write the near-miss alongside the positive. The
aws_secret_keycommentin the manifest explains why: a bare 40-char pattern matched every git commit
SHA, so
git checkout <sha>became a critical finding and, in block mode, adenied tool call. A false positive in a security tool is not cosmetic — it is
how the feed gets muted. For these rules the near-misses I would want covered
are a Stripe-shaped string that is too short, and something like
sk-followedby a short word.
CI runs gitleaks, so mark your fake keys with a
gitleaks:allowcomment or thesecret scan will block the PR.
One admin note: there is a CLA to sign for first contributions. You
keep copyright; it grants permission to ship your work under Apache 2.0.
Shout if anything is unclear or the escaping fights you.
blitzcrieg1 commentedon Aug 3, 2026
Heads up, the DLP manifest moved on
master:Nothing about the task changes, only the path. I have updated the issue body above.
Why it moved: those manifests are configuration the package needs in order to run, and
pip install agentmetrywas shipping without them. DLP scanning was silently inert for anyone who installed instead of cloning, which is close to the worst possible failure for a secret scanner. They now live inside the package so the wheel actually carries them.If you already have a branch open, it was a plain
git mv, so a rebase onmastershould carry your edits across:git fetch origin && git rebase origin/masterThe test file is unchanged at
apps/orchestrator/tests/test_dlp_scanner.py, though the constant at the top of it now points at the new location.Sorry for the churn, and thanks for picking this up.
hvadlamani1 commentedon Aug 27, 2026
@blitzcrieg1, any update on the PR?