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.

Match a Linear or Sentry token after an escaped newline (#226)

shi-wang32e8f94a8d55
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 98af469..7968df0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,8 @@
## Unreleased
+- Secrets: `secret.linear-api-key` now reports a key that comes right after an escaped newline,
+ tab or carriage return in a quoted string (`"line\nlin_api_..."`).
- 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.
diff --git a/src/rules/secrets.rs b/src/rules/secrets.rs
index e8d810f..11d0dce 100644
--- a/src/rules/secrets.rs
+++ b/src/rules/secrets.rs
@@ -422,7 +422,7 @@ pub static RULES: &[Rule] = &[
secret!(
"secret.linear-api-key",
Critical,
- r"\blin_api_[A-Za-z0-9]{40}\b",
+ r"(?:\\[nrt]|\b)(lin_api_[A-Za-z0-9]{40})\b",
"A Linear API key is written in the file."
),
secret!(
diff --git a/tests/fixtures/secrets/EXPECTED b/tests/fixtures/secrets/EXPECTED
index b45874a..8437774 100644
--- a/tests/fixtures/secrets/EXPECTED
+++ b/tests/fixtures/secrets/EXPECTED
@@ -15,6 +15,8 @@ config.py:8 secret.anthropic-key
config.py:9 secret.openai-key
keys/deploy.pem:1 secret.private-key
keys/service-account.json:5 secret.private-key
+keys/service-account.json:9 secret.linear-api-key
+keys/service-account.json:10 secret.sentry-token
.env.example:2 secret.env-example-value
.env.example:17 secret.env-example-value
.env.example:18 secret.env-example-value
@@ -81,3 +83,4 @@ config.py:115 secret.flyio-token
config.py:117 secret.flyio-token
config.py:118 secret.openrouter-key
config.py:119 secret.sentry-token
+config.py:120 secret.linear-api-key
diff --git a/tests/fixtures/secrets/config.py b/tests/fixtures/secrets/config.py
index 9375133..58c13d1 100644
--- a/tests/fixtures/secrets/config.py
+++ b/tests/fixtures/secrets/config.py
@@ -117,3 +117,4 @@ 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}}"
+linear_escaped = "line\\n{{fake:linear}}"
diff --git a/tests/fixtures/secrets/keys/service-account.json b/tests/fixtures/secrets/keys/service-account.json
index aac200b..31a041b 100644
--- a/tests/fixtures/secrets/keys/service-account.json
+++ b/tests/fixtures/secrets/keys/service-account.json
@@ -5,5 +5,7 @@
"private_key": "{{fake:private-key-json}}",
"client_email": "[email protected]",
"client_id": "123456789012345678901",
- "token_uri": "https://oauth2.googleapis.com/token"
+ "token_uri": "https://oauth2.googleapis.com/token",
+ "note_linear": "logged at midnight\n{{fake:linear}}",
+ "note_sentry": "logged at midnight\n{{fake:sentry}}"
}