# PromptGate output-side pattern file
# Format: # signal: <name>  followed by one regex pattern per line
# All patterns are compiled as re.IGNORECASE | re.MULTILINE
# Blank lines and lines starting with # are ignored

# signal: secret_leak
# API keys and tokens — common formats used by major providers
sk-[a-zA-Z0-9]{20,}
sk-proj-[a-zA-Z0-9_-]{20,}
sk-live-[a-zA-Z0-9_-]{20,}
sk-test-[a-zA-Z0-9_-]{20,}
AKIA[0-9A-Z]{16}
ghp_[a-zA-Z0-9]{36}
gho_[a-zA-Z0-9]{36}
glpat-[a-zA-Z0-9_-]{20}
xox[bpas]-[0-9A-Za-z-]{10,}
EAACEdEose0cBA[0-9A-Za-z]+
AIza[0-9A-Za-z_-]{35}
SG\.[a-zA-Z0-9_-]{22,}\.[a-zA-Z0-9_-]{22,}
whsec_[a-zA-Z0-9_-]{20,}
[aA][pP][iI][-_]?[kK][eE][yY]\s*[:=]\s*['"]?[a-zA-Z0-9_\-]{16,}['"]?
[sS]ecret[-_]?[kK]ey\s*[:=]\s*['"]?[a-zA-Z0-9_\-]{16,}['"]?
[aA]ccess[-_]?[tT]oken\s*[:=]\s*['"]?[a-zA-Z0-9_\-]{16,}['"]?
[bB]earer\s+[a-zA-Z0-9_\-\.]{20,}
[pP]assword\s*[:=]\s*['"]?[a-zA-Z0-9!@#$%^&*_\-]{8,}['"]?
[dD]atabase[-_]?[uU][rR][lL]\s*[:=]\s*['"]?[a-zA-Z0-9+.\-]+://[^\s'"]{10,}['"]?
# Webhook secrets
whsec_[a-zA-Z0-9]{20,}
[sS]igning[-_]?[sS]ecret\s*[:=]\s*['"]?[a-zA-Z0-9_\-]{16,}['"]?
[wW]ebhook[-_]?[sS]ecret\s*[:=]\s*['"]?[a-zA-Z0-9_\-]{16,}['"]?
# Private keys / certificates
-----BEGIN (RSA |EC |DSA |OPENSSH |)?PRIVATE KEY-----
-----BEGIN CERTIFICATE-----
# Credential URLs (password embedded in URL)
[a-zA-Z][a-zA-Z0-9+\-.]*://[^:@\s]+:[^:@\s]{4,}@[a-zA-Z0-9.\-]+
# Environment variable credential dumps
(AWS_ACCESS_KEY_ID|AWS_SECRET_ACCESS_KEY|GITHUB_TOKEN|OPENAI_API_KEY|STRIPE_KEY|SENDGRID_KEY|SMTP_PASSWORD)\s*[:=]\s*[^\s]{8,}
# Auth headers
[aA]uthorization\s*:\s*[bB]earer\s+[a-zA-Z0-9_\-\.]{20,}
[aA]uthorization\s*:\s*[bB]asic\s+[a-zA-Z0-9+/=]{16,}
# Stripe-specific
sk_live_[a-zA-Z0-9]{24,}
sk_test_[a-zA-Z0-9]{24,}
rk_live_[a-zA-Z0-9]{24,}

# signal: system_prompt_echo
# Phrases an LLM commonly produces when echoing its system prompt
you are a helpful assistant (and|who|that)
my (core )?instructions (are|say|tell me) to
i (have been|was) (told|instructed|configured|programmed|initialized|set up) to
(according to|as per|based on) my (system |initial )?(prompt|instructions|directives|configuration)
my system prompt (says|states|specifies|is|tells me|begins with)
the (context|system message|initial message|setup) (says|tells me|states|specifies)
i('m| am) (operating|running|functioning) (under|with|according to) (the following )?(instructions|guidelines|rules|directives)
(here are|these are) my (system |core |base )?(instructions|guidelines|rules|directives|constraints)
my (initialization|initial) (instructions|prompt|configuration) (include|say|state|specify)
i (am|was) (configured|initialized|set up|programmed) (to|with|for)
my prompt (says|states|specifies|tells me|grants|gives me)

# signal: harmful_instruction_leak
# Patterns suggesting the LLM is outputting synthesized harmful how-to content.
# IMPORTANT: patterns must NOT match benign cooking/crafting instructions.
# Key discriminator: dangerous/illegal/harmful context words must be present,
# OR the specific dangerous substances/actions must be named.
(here('s| is)|step[- ]by[- ]step).*?how to (make|synthesize|create|build)\s+(a\s+)?(bomb|explosive|weapon|poison|drug|malware|ransomware|virus|trojan)
(step\s+1|first[,:]?\s+you('ll| will)?)\s*:.*?(dangerous|illegal|harmful|explosive|weapon|synthesize|detonate)
(the (materials|ingredients|chemicals|components) (you need|required|needed|to use) are).{0,50}(dangerous|illegal|explosive|chemical|precursor|accelerant)
(here is (a|the) (recipe|guide|method|process|procedure|tutorial) for).{0,80}(bomb|explosive|poison|drug|hack|malware|weapon|exploit|synthesiz)
(obtain|acquire).{0,30}(precursor|explosive|accelerant|chemical\s+compound).{0,30}(step|mix|combine|process)
(mix|combine|react).{0,50}(acetone|peroxide|sulfuric|nitric|ammonia|bleach).{0,50}(step|carefully|slowly|ratio)
(deploy|install|configure).{0,50}(malware|ransomware|payload|keylogger|botnet|c2|command.and.control)
(synthesize|manufacture|produce).{0,50}(methamphetamine|fentanyl|heroin|cocaine|mdma|lsd)
(bypass|evade|disable).{0,50}(security|antivirus|firewall|detection|monitoring).{0,30}(step|guide|how)