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
feat(secrets): detect DigitalOcean tokens (#107)
Onur Ugurd5411045afb4
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 2042bd2..8686925 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -32,6 +32,7 @@- 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 `-`).+- Secrets: new rule `secret.digitalocean-token` (critical) for DigitalOcean tokens (`dop_v1_`, `doo_v1_` or `dor_v1_` followed by 64 lowercase hex characters).- Secrets: new rule `secret.shopify-token` (critical) for Shopify access tokens (`shpat_`, `shpca_`, `shppa_` or `shpss_` followed by 32 hex characters).- Secrets: new rule `secret.pypi-token` (critical) for PyPI upload tokens (`pypi-AgEIcHlwaS5vcmc` followed by 50 or more characters).- Secrets: new rule `secret.sendgrid-key` (critical) for SendGrid API keys (`SG.`, 22 characters, a dot, then 43 characters).diff --git a/README.md b/README.mdindex 9e4b228..0d2a4d3 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 86 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 87 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-86 rules, each with a CWE id, an OWASP category and a link to the OWASP page that explains it.+87 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 86 problems were found, not that the code is safe. [Design notes](docs/adr).+these 87 problems were found, not that the code is safe. [Design notes](docs/adr).## Creditsdiff --git a/docs/rules.md b/docs/rules.mdindex b8d5695..4963507 100644--- a/docs/rules.md+++ b/docs/rules.md@@ -32,7 +32,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 (25)+## Secrets (26)| Rule | Severity | CWE | OWASP | What it means || --- | --- | --- | --- | --- |@@ -54,6 +54,7 @@ Every rule safe-anything checks, generated from `safe-anything --list-rules --js| [`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.sendgrid-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 SendGrid 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.digitalocean-token`](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 DigitalOcean 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 5f50773..cfa533b 100644--- a/src/rules/secrets.rs+++ b/src/rules/secrets.rs@@ -226,6 +226,12 @@ pub static RULES: &[Rule] = &[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.digitalocean-token",+ Critical,+ r"\bdo[opr]_v1_[a-f0-9]{64}\b",+ "A DigitalOcean token is written in the file."+ ),secret!("secret.private-key",Critical,diff --git a/tests/common/mod.rs b/tests/common/mod.rsindex b63f94d..d2eacf7 100644--- a/tests/common/mod.rs+++ b/tests/common/mod.rs@@ -96,6 +96,7 @@ pub fn fake(name: &str) -> String {"sendgrid-key" => ["S", "G.", &body(22, MIXED), ".", &body(43, MIXED)].concat(),"pypi-token" => ["py", "pi-", "AgEIcHlw", "aS5vcmc", &body(70, MIXED)].concat(),"shopify-token" => ["sh", "pat_", &body(32, HEX)].concat(),+ "digitalocean-token" => ["do", "p_v1_", &body(64, HEX)].concat(),other => panic!("no fake value named {other}"),}}diff --git a/tests/fixtures/secrets/EXPECTED b/tests/fixtures/secrets/EXPECTEDindex a60ce2a..f76003e 100644--- a/tests/fixtures/secrets/EXPECTED+++ b/tests/fixtures/secrets/EXPECTED@@ -29,4 +29,5 @@ config.py:30 secret.slack-webhookconfig.py:32 secret.discord-webhookconfig.py:34 secret.sendgrid-keyconfig.py:36 secret.pypi-token-config.py:38 secret.shopify-token\ No newline at end of file+config.py:38 secret.shopify-token+config.py:39 secret.digitalocean-token\ No newline at end of filediff --git a/tests/fixtures/secrets/config.py b/tests/fixtures/secrets/config.pyindex b540429..18fdbfd 100644--- a/tests/fixtures/secrets/config.py+++ b/tests/fixtures/secrets/config.py@@ -35,4 +35,6 @@ sendgrid = "{{fake:sendgrid-key}}"pypi_index = "pypi-simple"pypi_token = "{{fake:pypi-token}}"shopify_short = "shpat_123"-shopify_token = "{{fake:shopify-token}}"\ No newline at end of file+shopify_token = "{{fake:shopify-token}}"+digitalocean = "{{fake:digitalocean-token}}"+digitalocean_short = "dop_v1_0123abcd"\ No newline at end of file