Find the holes before someone else does. A fast, 100% Rust vulnerability scanner: XSS, SQL injection, leaked secrets, dependency CVEs and AI agent setups.
Rust ai-agentsclaude-codeclaude-code-pluginclicodexcursordevsecopsmcposvowasprustsastsecret-scanningsecretssecuritysecurity-scannersql-injectionvulnerabilityvulnerability-scannerxss
Detect Telegram bot tokens (secret.telegram-bot-token) (#67)
Prashant25d75b639d9b
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 623af88..b056a5a 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -13,6 +13,7 @@- Secrets: new rule `secret.huggingface-token` (critical) for Hugging Face access tokens (`hf_` followed by 34 letters).- Secrets: new rule `secret.npm-token` (critical) for npm access tokens (`npm_` followed by 36 letters or digits).- Secrets: new rule `secret.mailgun-key` (critical) for Mailgun private API keys (`key-` followed by 32 lowercase hex characters).+- Secrets: new rule `secret.telegram-bot-token` (high) for Telegram bot tokens (8 to 10 digits, a colon, then 35 letters, digits, `_` or `-`).- Dependencies: `uv.lock` entries whose `source` is `editable`, `virtual` or `path` (the project itself or alocal package) are no longer counted or looked up on PyPI.- Secrets: `secret.url-credentials` skips a connection string whose password is an angle-bracket placeholderdiff --git a/README.md b/README.mdindex 040cf0b..025ac0c 100644--- a/README.md+++ b/README.md@@ -20,7 +20,7 @@ Every finding comes with the line, the reason and the fix.</p><a href="https://github.com/erkamyaman/safe-anything"><img src="https://img.shields.io/github/stars/erkamyaman/safe-anything?style=social" alt="GitHub stars"></a></p>-<p align="center"><b><a href="#quick-start">Install</a></b> · <a href="https://github.com/erkamyaman/safe-anything/releases">Releases</a> · <a href="#for-ai-agents">Claude Code plugin</a> · <a href="#in-ci">GitHub Action</a> · <a href="docs/rules.md">All 76 rules</a> · <a href="docs/agent-setups.md">Agent setups</a><br>+<p align="center"><b><a href="#quick-start">Install</a></b> · <a href="https://github.com/erkamyaman/safe-anything/releases">Releases</a> · <a href="#for-ai-agents">Claude Code plugin</a> · <a href="#in-ci">GitHub Action</a> · <a href="docs/rules.md">All 77 rules</a> · <a href="docs/agent-setups.md">Agent setups</a><br>Made in Türkiye 🇹🇷 by <a href="https://github.com/erkamyaman">erKam Yaman</a>, who also made <a href="https://github.com/erkamyaman/rust-anything">rust-anything</a> · <a href="https://github.com/sponsors/erkamyaman">❤️ Sponsor me</a> · Sponsored by <a href="https://coderabbit.link/er-kam">CodeRabbit</a></p><p align="center">@@ -86,7 +86,7 @@ safe-anything --list-rules## What it finds-76 rules, each with a CWE id, an OWASP category and a link to the OWASP page that explains it.+77 rules, each with a CWE id, an OWASP category and a link to the OWASP page that explains it.The full list is in [docs/rules.md](docs/rules.md).| | |@@ -175,7 +175,7 @@ lockfile listed under Dependencies. Nothing is executed. The only network call inames and versions to OSV.dev ([privacy](docs/privacy.md)).It finds known patterns; it does not trace data through your program. A clean scan means none of-these 76 problems were found, not that the code is safe. [Design notes](docs/adr).+these 77 problems were found, not that the code is safe. [Design notes](docs/adr).## Creditsdiff --git a/docs/rules.md b/docs/rules.mdindex f378089..7edf91d 100644--- a/docs/rules.md+++ b/docs/rules.md@@ -31,7 +31,7 @@ Every rule safe-anything checks, generated from `safe-anything --list-rules --js| [`code.sql-grant-all`](https://cheatsheetseries.owasp.org/cheatsheets/Database_Security_Cheat_Sheet.html) | medium | [CWE-250](https://cwe.mitre.org/data/definitions/250.html) | A01:2021 Broken Access Control | A database user gets every privilege on every database. || [`code.sql-plaintext-password`](https://cheatsheetseries.owasp.org/cheatsheets/Database_Security_Cheat_Sheet.html) | medium | [CWE-798](https://cwe.mitre.org/data/definitions/798.html) | A07:2021 Identification and Authentication Failures | A database password is written in a SQL file. |-## Secrets (18)+## Secrets (19)| Rule | Severity | CWE | OWASP | What it means || --- | --- | --- | --- | --- |@@ -46,6 +46,7 @@ Every rule safe-anything checks, generated from `safe-anything --list-rules --js| [`secret.openai-key`](https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html) | critical | [CWE-798](https://cwe.mitre.org/data/definitions/798.html) | A07:2021 Identification and Authentication Failures | An OpenAI API key is written in the file. || [`secret.google-api-key`](https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html) | high | [CWE-798](https://cwe.mitre.org/data/definitions/798.html) | A07:2021 Identification and Authentication Failures | A Google API key is written in the file. || [`secret.mailgun-key`](https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html) | critical | [CWE-798](https://cwe.mitre.org/data/definitions/798.html) | A07:2021 Identification and Authentication Failures | A Mailgun API key is written in the file. |+| [`secret.telegram-bot-token`](https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html) | high | [CWE-798](https://cwe.mitre.org/data/definitions/798.html) | A07:2021 Identification and Authentication Failures | A Telegram bot token is written in the file. || [`secret.private-key`](https://cheatsheetseries.owasp.org/cheatsheets/Key_Management_Cheat_Sheet.html) | critical | [CWE-321](https://cwe.mitre.org/data/definitions/321.html) | A02:2021 Cryptographic Failures | A private key is stored in the repository. || [`secret.hardcoded-password`](https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html) | high | [CWE-798](https://cwe.mitre.org/data/definitions/798.html) | A07:2021 Identification and Authentication Failures | A password or secret is written in the code. || [`secret.url-credentials`](https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html) | high | [CWE-798](https://cwe.mitre.org/data/definitions/798.html) | A07:2021 Identification and Authentication Failures | A connection string carries a username and password. |diff --git a/src/rules/secrets.rs b/src/rules/secrets.rsindex c64527d..e64b583 100644--- a/src/rules/secrets.rs+++ b/src/rules/secrets.rs@@ -153,6 +153,12 @@ pub static RULES: &[Rule] = &[r"\bkey-[0-9a-f]{32}\b","A Mailgun API key is written in the file."),+ secret!(+ "secret.telegram-bot-token",+ High,+ r"\b([0-9]{8,10}:[A-Za-z0-9_\-]{35})(?:[^A-Za-z0-9_\-]|\z)",+ "A Telegram bot token is written in the file."+ ),secret!("secret.private-key",Critical,diff --git a/tests/common/mod.rs b/tests/common/mod.rsindex 486dbe2..7ea3947 100644--- a/tests/common/mod.rs+++ b/tests/common/mod.rs@@ -32,6 +32,8 @@ pub fn fake(name: &str) -> String {"openai" => ["sk-", "proj-", &body(48, MIXED)].concat(),"google" => ["AI", "za", &body(35, MIXED)].concat(),"mailgun" => ["ke", "y-", &body(32, HEX)].concat(),+ "telegram" => ["1234", "567890", ":", &body(35, MIXED)].concat(),+ "telegram-hyphen" => ["1234", "567890", ":", &body(34, MIXED), "-"].concat(),"password" => ["hunter2", "hunter2"].concat(),"db-password" => ["S3cret", "Passw0rd"].concat(),"base64-padded" => [&body(30, MIXED), "=="].concat(),diff --git a/tests/fixtures/secrets/EXPECTED b/tests/fixtures/secrets/EXPECTEDindex 8abb36a..aaa16bf 100644--- a/tests/fixtures/secrets/EXPECTED+++ b/tests/fixtures/secrets/EXPECTED@@ -20,4 +20,6 @@ app/client.ts:2 secret.public-env-secretconfig.py:17 secret.npm-tokenconfig.py:18 secret.gitlab-tokenconfig.py:19 secret.huggingface-token-config.py:21 secret.mailgun-key\ No newline at end of file+config.py:21 secret.mailgun-key+config.py:23 secret.telegram-bot-token+config.py:26 secret.telegram-bot-token\ No newline at end of filediff --git a/tests/fixtures/secrets/config.py b/tests/fixtures/secrets/config.pyindex 71fcfd4..1f0bb9b 100644--- a/tests/fixtures/secrets/config.py+++ b/tests/fixtures/secrets/config.py@@ -19,4 +19,8 @@ gitlab_token = "{{fake:gitlab}}"hf_token = "{{fake:huggingface-token}}"hf_model = "hf-internal-testing/tiny-random-bert"mailgun = "{{fake:mailgun}}"-mailgun_short = "key-short"\ No newline at end of file+mailgun_short = "key-short"+telegram = "{{fake:telegram}}"+clock = "12:30:45"+upstream = "localhost:8080"+telegram_hyphen = "{{fake:telegram-hyphen}}"\ No newline at end of file