diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f634115..f0a8f4c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -6,7 +6,7 @@ on: jobs: test: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 strategy: matrix: python-version: ["3.9", "3.13"] diff --git a/README.md b/README.md index a2c02e5..f22f351 100644 --- a/README.md +++ b/README.md @@ -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) | @@ -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`. + diff --git a/docs/README.tr.md b/docs/README.tr.md index abbe35f..a437517 100644 --- a/docs/README.tr.md +++ b/docs/README.tr.md @@ -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) | @@ -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. + diff --git a/repodx.py b/repodx.py index a4e7d89..2475d07 100644 --- a/repodx.py +++ b/repodx.py @@ -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]+"), @@ -1704,3 +1706,4 @@ def cli(): if __name__ == "__main__": cli() + diff --git a/tests/test_repodx.py b/tests/test_repodx.py index e6b3155..f3946d6 100644 --- a/tests/test_repodx.py +++ b/tests/test_repodx.py @@ -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"), @@ -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") @@ -1621,3 +1639,4 @@ def test_outside_a_git_repository(self): if __name__ == "__main__": unittest.main() +