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
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

jobs:
test:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: ["3.9", "3.13"]
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ Run `repodx --badge` and paste the output into your README:

| Severity | Check |
| --- | --- |
| critical | API keys and tokens: OpenAI, Anthropic, OpenRouter, Perplexity, Replicate, Groq, Hugging Face, AWS, GitHub, GitLab, Grafana, npm, PyPI, Stripe, Supabase secret keys, Shopify, DigitalOcean, Slack, SendGrid, Telegram bots, private keys |
| critical | API keys and tokens: OpenAI, Anthropic, OpenRouter, Perplexity, Replicate, Groq, Hugging Face, AWS, GitHub, GitLab, Grafana, npm, PyPI, Stripe, Clerk, Supabase secret keys, Shopify, DigitalOcean, Slack, SendGrid, Telegram bots, private keys |
| critical | Slack and Discord webhook URLs |
| critical / warning | Secret-looking variable names behind public prefixes that ship to the browser (`NEXT_PUBLIC_OPENAI_API_KEY`, `VITE_STRIPE_SECRET_KEY`, `EXPO_PUBLIC_..._SERVICE_ROLE_KEY`), even with an empty value |
| critical | Supabase `service_role` JWTs (the JWT is decoded to check its role; public `anon` keys are not reported) |
Expand Down Expand Up @@ -263,3 +263,4 @@ Adding a check:
2. Add its fix text to `FIXES`.
3. Call it from `build_report`.
4. Add a test in `tests/test_repodx.py`.

3 changes: 2 additions & 1 deletion docs/README.tr.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ repos:

| Önem | Kontrol |
| --- | --- |
| kritik | API anahtarları ve token'lar: OpenAI, Anthropic, OpenRouter, Perplexity, Replicate, Groq, Hugging Face, AWS, GitHub, GitLab, Grafana, npm, PyPI, Stripe, Supabase gizli anahtarları, Shopify, DigitalOcean, Slack, SendGrid, Telegram botları, özel anahtarlar (private key) |
| kritik | API anahtarları ve token'lar: OpenAI, Anthropic, OpenRouter, Perplexity, Replicate, Groq, Hugging Face, AWS, GitHub, GitLab, Grafana, npm, PyPI, Stripe, Clerk, Supabase gizli anahtarları, Shopify, DigitalOcean, Slack, SendGrid, Telegram botları, özel anahtarlar (private key) |
| kritik | Slack ve Discord webhook URL'leri |
| kritik / uyarı | Tarayıcıya giden public önekli, gizli anahtar gibi görünen değişken adları (`NEXT_PUBLIC_OPENAI_API_KEY`, `VITE_STRIPE_SECRET_KEY`, `EXPO_PUBLIC_..._SERVICE_ROLE_KEY`), değerleri boş olsa bile |
| kritik | Supabase `service_role` JWT'leri (rolü kontrol etmek için JWT çözülür; herkese açık `anon` anahtarları raporlanmaz) |
Expand Down Expand Up @@ -274,3 +274,4 @@ Yeni bir kontrol eklemek için:
2. Düzeltme metnini `FIXES` sözlüğüne ekle.
3. Fonksiyonu `build_report` içinden çağır.
4. `tests/test_repodx.py` içine bir test ekle.

5 changes: 4 additions & 1 deletion repodx.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,9 @@ def check_readme(repo_path):
("Shopify token", r"\bshp(?:at|ca|pa|ss)_[a-fA-F0-9]{32}\b"),
("DigitalOcean token", r"\bdo[op]_v1_[a-f0-9]{64}\b"),
("PyPI API token", r"\bpypi-AgEIcHlwaS5vcmc[A-Za-z0-9_\-]{50,}\b"),
("Stripe secret key", r"\b(?:sk|rk)_live_[A-Za-z0-9]{20,}\b"),
# Stripe and Clerk share the sk_live_ prefix without a documented unique suffix.
("Secret key (Stripe or Clerk)", r"\bsk_live_[A-Za-z0-9]{20,}\b"),
("Stripe restricted key", r"\brk_live_[A-Za-z0-9]{20,}\b"),
("Supabase secret key", r"\bsb_secret_[A-Za-z0-9_\-]{20,}"),
("Slack token", r"\bxox[abposr]-[A-Za-z0-9\-]{10,}"),
("Slack webhook URL", r"https://hooks\.slack\.com/services/T[A-Z0-9]+/B[A-Z0-9]+/[A-Za-z0-9]+"),
Expand Down Expand Up @@ -1704,3 +1706,4 @@ def cli():

if __name__ == "__main__":
cli()

21 changes: 20 additions & 1 deletion tests/test_repodx.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,8 @@ def test_detects_provider_keys(self):
"PyPI API token": fake(
"pypi-", "AgEIcHlwaS5vcmc", "q7ZT4mWx9Rb2Kd5Nf8Lp3Hs6Vc1Yj0GuE4tA_BnC7Xq2Zw5Mu6"
),
"Stripe secret key": fake("sk", "_live_", "A1b2C3d4E5f6G7h8I9j0K1"),
"Secret key (Stripe or Clerk)": fake("sk", "_live_", "A1b2C3d4E5f6G7h8I9j0K1"),
"Stripe restricted key": fake("rk", "_live_", "A1b2C3d4E5f6G7h8I9j0K1"),
"Supabase secret key": fake("sb", "_secret_", "A1b2C3d4E5f6G7h8I9j0K1"),
"Perplexity API key": fake("pplx", "-", "Q7zT4mWx9Rb2Kd5Nf8Lp3Hs6Vc1Yj0GuE4tA9BnC7Xq2Zw5M"),
"Replicate API token": fake("r8", "_", "A1b2C3d4E5f6G7h8I9j0K1l2M3n4O5p6Q7r8S"),
Expand All @@ -611,6 +612,23 @@ def test_detects_provider_keys(self):

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

def test_shared_stripe_clerk_prefix_has_one_neutral_finding(self):
for length in (20, 32, 48, 96):
with self.subTest(length=length):
suffix = ("Q7zT4mWx9Rb2Kd5Nf8Lp" * 5)[:length]
key = fake("sk", "_live_", suffix)
hits = repodx.scan_line_for_secrets(f'CLERK_SECRET_KEY="{key}"')
self.assertEqual(
[(hit[0], hit[1], hit[2]) for hit in hits],
[("secret", "critical", "Secret key (Stripe or Clerk)")],
)

def test_ignores_stripe_clerk_publishable_keys(self):
for mode in ("live", "test"):
with self.subTest(mode=mode):
key = fake("pk", "_", mode, "_", "Q7zT4mWx9Rb2Kd5Nf8Lp3Hs6Vc1Yj0Gu")
self.assertEqual(repodx.scan_line_for_secrets(f'key="{key}"'), [])

def test_detects_digitalocean_oauth_token(self):
key = fake("doo_v1_", "f1e2d3c4b5a69788796a5b4c3d2e1f0af9e8d7c6b5a49382716f0e1d2c3ba4b7")

Expand Down Expand Up @@ -1621,3 +1639,4 @@ def test_outside_a_git_repository(self):

if __name__ == "__main__":
unittest.main()

Loading