Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion repodx.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,8 @@ def check_readme(repo_path):
("Perplexity API key", r"\bpplx-[A-Za-z0-9]{40,}\b"),
("Replicate API token", r"\br8_[A-Za-z0-9]{37}\b"),
("SendGrid API key", r"\bSG\.[A-Za-z0-9_\-]{22}\.[A-Za-z0-9_\-]{43}\b"),
# Sentry DSNs are public by design; only the auth tokens carry the sntry prefix.
("Sentry auth token", r"\bsntry[su]_[A-Za-z0-9+/=_\-]{40,}"),
("Telegram bot token", r"\b\d{8,10}:AA[A-Za-z0-9_\-]{33}\b"),
("Discord webhook URL", r"https://(?:ptb\.|canary\.)?discord(?:app)?\.com/api/webhooks/\d+/[A-Za-z0-9_\-]+"),
]
Expand Down Expand Up @@ -429,7 +431,7 @@ def check_readme(repo_path):
CANDIDATE_LITERALS = [
"sk-", "AKIA", "ASIA", "ghp_", "gho_", "ghu_", "ghs_", "ghr_", "github_pat_", "glpat-", "_live_",
"glsa_", "sb_secret_", "xox", "hf_", "npm_", "gsk_", "pplx-", "r8_", "SG.", ":AA", "AIza", "eyJ", "://",
"shpat_", "shpca_", "shppa_", "shpss_", "dop_v1_", "doo_v1_", "pypi-",
"shpat_", "shpca_", "shppa_", "shpss_", "dop_v1_", "doo_v1_", "pypi-", "sntry",
]


Expand Down
16 changes: 16 additions & 0 deletions tests/test_repodx.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,9 @@ def test_detects_provider_keys(self):
"Stripe restricted key": fake("rk", "_live_", "A1b2C3d4E5f6G7h8I9j0K1"),
"Supabase secret key": fake("sb", "_secret_", "A1b2C3d4E5f6G7h8I9j0K1"),
"Perplexity API key": fake("pplx", "-", "Q7zT4mWx9Rb2Kd5Nf8Lp3Hs6Vc1Yj0GuE4tA9BnC7Xq2Zw5M"),
"Sentry auth token": fake(
"sntrys", "_", "Q7zT4mWx9Rb2Kd5Nf8Lp3Hs6Vc1Yj0GuE4tA9BnC7Xq2Zw5Mu6Ry3Kd8Nf2"
),
"Replicate API token": fake("r8", "_", "A1b2C3d4E5f6G7h8I9j0K1l2M3n4O5p6Q7r8S"),
"Discord webhook URL": fake(
"https://discord.com/api/webhooks/",
Expand Down Expand Up @@ -650,6 +653,19 @@ def test_ignores_placeholder_slack_webhook_url(self):

self.assertEqual(repodx.scan_line_for_secrets(line), [])

def test_ignores_sentry_dsn(self):
# A DSN is public by design and must not be reported as a leaked key.
line = fake("SENTRY_DSN=", "https://abc123@o123456.ingest.sentry.io/7890123")

self.assertEqual(repodx.scan_line_for_secrets(line), [])

def test_detects_sentry_user_token(self):
key = fake("sntryu", "_", "Q7zT4mWx9Rb2Kd5Nf8Lp3Hs6Vc1Yj0GuE4tA9BnC7Xq2Zw5Mu6Ry3Kd8Nf2")

hits = repodx.scan_line_for_secrets(f'SENTRY_AUTH_TOKEN="{key}"')

self.assertEqual([(hit[0], hit[1], hit[2]) for hit in hits], [("secret", "critical", "Sentry auth token")])

def test_ignores_documentation_placeholders(self):
lines = [
fake("aws_key = '", "AKIA", "IOSFODNN7EXAMPLE", "'"),
Expand Down
Loading