Skip to content

Commit 4fab46a

Browse files
authored
feat: detect hardcoded Anthropic (Claude) API keys (#20)
Adds a new security rule to detect hardcoded Anthropic (Claude) API keys. - Regex-based detection for `sk-ant-*` keys - High severity with remediation guidance - Includes an example file demonstrating detection This expands AI/LLM credential leakage coverage.
1 parent 8dfaa90 commit 4fab46a

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

src/pyspector/rules/built-in-rules.toml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2142,4 +2142,12 @@ severity = "Medium"
21422142
confidence = "Low"
21432143
remediation = "Validate format strings and use safe formatting methods."
21442144
ast_match = "Call(func.id=format)"
2145-
file_pattern = "*.py"
2145+
file_pattern = "*.py"
2146+
2147+
[[rule]]
2148+
id = "AI002"
2149+
description = "Hardcoded Anthropic (Claude) API key detected."
2150+
severity = "High"
2151+
remediation = "Remove hardcoded API keys and load them from environment variables or a secure secrets manager."
2152+
pattern = "(?i)sk-ant-api[0-9]*-[A-Za-z0-9_-]{20,}"
2153+
file_pattern = ".*\\.py"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
ANTHROPIC_API_KEY = "sk-ant-api03-FAKEKEYFORTESTING-ABCDEF1234567890"
2+
3+
def example():
4+
pass

0 commit comments

Comments
 (0)