Skip to content

Find the holes before someone else does. A fast, 100% Rust vulnerability scanner: XSS, SQL injection, leaked secrets, dependency CVEs and AI agent setups.

fix(secrets): detect Sentry token after escaped whitespace (issue #218) (#225)

Alima59b8da83cc78
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 87c6f79..98af469 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,9 @@
## Unreleased
+- Secrets: `secret.sentry-token` now reports a token that comes right after an escaped newline,
+ tab or carriage return in a quoted string (`"line\nsntryu_..."`), as the OpenRouter and New
+ Relic rules already did.
- Dependencies: a binary `bun.lockb` is no longer named when a text `bun.lock` sits beside it in
the same folder; the text lockfile was already read, so the old binary one is not an unchecked
dependency.
diff --git a/src/rules/secrets.rs b/src/rules/secrets.rs
index b389de3..e8d810f 100644
--- a/src/rules/secrets.rs
+++ b/src/rules/secrets.rs
@@ -440,7 +440,7 @@ pub static RULES: &[Rule] = &[
secret!(
"secret.sentry-token",
Critical,
- r"\bsntryu_[0-9a-f]{64}\b",
+ r"(?:\\[nrt]|\b)(sntryu_[0-9a-f]{64})\b",
"A Sentry user auth token is written in the file."
),
secret!(
diff --git a/tests/fixtures/secrets/EXPECTED b/tests/fixtures/secrets/EXPECTED
index ce056b5..b45874a 100644
--- a/tests/fixtures/secrets/EXPECTED
+++ b/tests/fixtures/secrets/EXPECTED
@@ -80,3 +80,4 @@ config.py:114 secret.newrelic-key
config.py:115 secret.flyio-token
config.py:117 secret.flyio-token
config.py:118 secret.openrouter-key
+config.py:119 secret.sentry-token
diff --git a/tests/fixtures/secrets/config.py b/tests/fixtures/secrets/config.py
index 5b54b73..9375133 100644
--- a/tests/fixtures/secrets/config.py
+++ b/tests/fixtures/secrets/config.py
@@ -116,3 +116,4 @@ flyio = "{{fake:flyio}}"
flyio_lookalike = "{{fake:flyio-short}} my{{fake:flyio}} {{fake:flyio}}a"
flyio_escaped = "line\\n{{fake:flyio}}"
openrouter_escaped = "line\\n{{fake:openrouter}}"
+sentry_escaped = "line\\n{{fake:sentry}}"