diff --git a/repodx.py b/repodx.py index 2475d07..56ab832 100644 --- a/repodx.py +++ b/repodx.py @@ -381,6 +381,7 @@ def check_readme(repo_path): ("Groq API key", r"\bgsk_[A-Za-z0-9]{48,}\b"), ("Perplexity API key", r"\bpplx-[A-Za-z0-9]{40,}\b"), ("Replicate API token", r"\br8_[A-Za-z0-9]{37}\b"), + ("Linear API key", r"\blin_api_[A-Za-z0-9]{40}\b"), ("SendGrid API key", r"\bSG\.[A-Za-z0-9_\-]{22}\.[A-Za-z0-9_\-]{43}\b"), ("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_\-]+"), @@ -429,7 +430,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-", "lin_api_", ] diff --git a/tests/test_repodx.py b/tests/test_repodx.py index f3946d6..4988299 100644 --- a/tests/test_repodx.py +++ b/tests/test_repodx.py @@ -593,6 +593,7 @@ def test_detects_provider_keys(self): "Supabase secret key": fake("sb", "_secret_", "A1b2C3d4E5f6G7h8I9j0K1"), "Perplexity API key": fake("pplx", "-", "Q7zT4mWx9Rb2Kd5Nf8Lp3Hs6Vc1Yj0GuE4tA9BnC7Xq2Zw5M"), "Replicate API token": fake("r8", "_", "A1b2C3d4E5f6G7h8I9j0K1l2M3n4O5p6Q7r8S"), + "Linear API key": fake("lin", "_api_", "Q7zT4mWx9Rb2Kd5Nf8Lp3Hs6Vc1Yj0GuE4tA9BnC"), "Discord webhook URL": fake( "https://discord.com/api/webhooks/", "908172635490817263/", @@ -612,6 +613,24 @@ def test_detects_provider_keys(self): self.assertEqual([(hit[0], hit[1], hit[2]) for hit in hits], [("secret", "critical", name)]) + def test_detects_linear_api_key_in_a_file(self): + key = fake("lin", "_api_", "Q7zT4mWx9Rb2Kd5Nf8Lp3Hs6Vc1Yj0GuE4tA9BnC") + + with tempfile.TemporaryDirectory() as temp_dir: + repo_path = make_repo(temp_dir, {"src/config.js": f"// setup\nconst LINEAR_KEY = '{key}';\n"}) + + result = findings_for(repo_path, "secret") + + self.assertEqual( + [(finding["severity"], finding["title"], finding["path"], finding["line"]) for finding in result], + [("critical", "Linear API key", "src/config.js", 2)], + ) + + def test_linear_api_key_needs_forty_characters(self): + key = fake("lin", "_api_", "Q7zT4mWx9Rb2Kd5Nf8Lp3Hs6Vc1Yj0GuE4tA9Bn") + + self.assertEqual(repodx.scan_line_for_secrets(f'const key = "{key}";'), []) + def test_shared_stripe_clerk_prefix_has_one_neutral_finding(self): for length in (20, 32, 48, 96): with self.subTest(length=length):