Skip to content

Secret Detection Patterns

greengate ships with 26 built-in regex patterns covering the most common cloud providers, SaaS platforms, and API services. All patterns are applied only to string literals (not comments or JSX text) when scanning JS/TS files.

Built-in patterns

Pattern nameWhat it detects
AWS Access KeyAKIA... access key IDs
AWS Secret Key40-character AWS secret access keys
AWS Session TokenTemporary STS session tokens
Azure Client SecretAzure AD application secrets
Azure Storage KeyAzure storage account keys
GCP API KeyGoogle Cloud AIza... API keys
GCP Service Account JSONEmbedded service account credential blocks
DigitalOcean Personal Access Tokendop_v1_... tokens
Alibaba Cloud Access KeyLTAI... access key IDs
GitHub Personal Access Tokenghp_..., github_pat_...
GitHub OAuth Tokengho_...
GitHub App Tokenghs_..., ghr_...
Stripe Secret Keysk_live_..., sk_test_...
Stripe Publishable Keypk_live_..., pk_test_...
Twilio Account SIDAC... SIDs
Twilio Auth Token32-hex Twilio auth tokens
Expo Access Tokenexpo_... tokens
Sentry Auth Tokensntrys_... tokens
Mapbox Tokenpk.eyJ1... tokens
Slack Bot Tokenxoxb-...
Slack User Tokenxoxp-...
Generic API KeyHigh-entropy values assigned to keys named api_key, apikey, api-key
Generic SecretHigh-entropy values assigned to keys named secret, password, passwd, pwd
Private Key-----BEGIN ... PRIVATE KEY----- blocks
Email Address (PII)RFC 5322-compliant email addresses
IPv4 Address (PII)Private-range IPv4 addresses in sensitive contexts

Adding custom patterns

toml
# .greengate.toml
[scan]
extra_patterns = [
  { name = "Internal Service Token", regex = "svc_[a-z0-9]{40}" },
  { name = "Legacy API Key", regex = "legacy_[A-Za-z0-9]{32}" },
]

Custom patterns are applied in addition to the built-ins (not instead of them).

Shannon entropy detection

Enable entropy-based detection to catch unrecognized high-entropy tokens (API keys, bearer tokens, random secrets) not covered by named patterns:

toml
[scan]
entropy = true
entropy_threshold = 4.5    # bits per character — lower = more sensitive
entropy_min_length = 20    # ignore tokens shorter than this

Excluding paths

toml
[scan]
exclude_patterns = [
  "tests/**",
  "*.test.ts",
  "fixtures/**",
  "vendor/**",
]

Suppressing individual findings

ts
const key = "AKIAIOSFODNN7EXAMPLE123"; // greengate: ignore

Released under the MIT License.