xploitscan-shared-rules 2.4.0 → 2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +18 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -3
- package/dist/index.d.ts +8 -3
- package/dist/index.js +18 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -492,8 +492,12 @@ declare function vendoredReason(filePath: string): string | null;
|
|
|
492
492
|
* `src/routes/test/handler_test.go` is still a test file.
|
|
493
493
|
* `Testimonial.py` and `Testing.py` stay application code: `Test*.py`
|
|
494
494
|
* requires an uppercase letter or underscore after `Test`.
|
|
495
|
-
* A C# `WidgetTest.cs`
|
|
496
|
-
* `
|
|
495
|
+
* A singular C# `WidgetTest.cs`, `ABTest.cs`, `SpeedTest.cs`, `LoadTest.cs`,
|
|
496
|
+
* or `Models/Test.cs` stays application code. A plural `<Name>Tests.cs`
|
|
497
|
+
* (PascalCase name, then `Tests.cs`) is a suite anywhere. Singular
|
|
498
|
+
* `<Name>Test.cs` counts only inside a test directory: `tests/`, `test/`,
|
|
499
|
+
* `*.Tests/`, `*.UnitTests/`, `*.IntegrationTests/`, or a `*Tests/` folder
|
|
500
|
+
* when the file itself is `.cs` (`src/Features/ABTests/routes.ts` is not).
|
|
497
501
|
*/
|
|
498
502
|
declare function isTestPath(filePath: string): boolean;
|
|
499
503
|
declare function isSbomPath(filePath: string): boolean;
|
|
@@ -501,7 +505,8 @@ declare function isSbomPath(filePath: string): boolean;
|
|
|
501
505
|
* A credential that is live wherever the file sits. Test-mode keys,
|
|
502
506
|
* placeholder tokens, connection strings, and PEM private keys are not.
|
|
503
507
|
*
|
|
504
|
-
* Formats: `AKIA`/`ABIA`/`ACCA`/`ASIA`
|
|
508
|
+
* Formats: `AKIA`/`ABIA`/`ACCA`/`ASIA` plus exactly 16 letters or digits
|
|
509
|
+
* (20 characters, not inside a longer letter-or-digit run; not a key ending in EXAMPLE),
|
|
505
510
|
* `sk_live_`, `rk_live_`, an OpenAI key (`T3BlbkFJ`), an OpenRouter key
|
|
506
511
|
* (`sk-or-v1-`), `ghp_` and `github_pat_`, a Slack `xox*` token, `AIza`,
|
|
507
512
|
* an Anthropic `sk-ant-api03-` key, SendGrid `SG.`, and a Hugging Face
|
package/dist/index.d.ts
CHANGED
|
@@ -492,8 +492,12 @@ declare function vendoredReason(filePath: string): string | null;
|
|
|
492
492
|
* `src/routes/test/handler_test.go` is still a test file.
|
|
493
493
|
* `Testimonial.py` and `Testing.py` stay application code: `Test*.py`
|
|
494
494
|
* requires an uppercase letter or underscore after `Test`.
|
|
495
|
-
* A C# `WidgetTest.cs`
|
|
496
|
-
* `
|
|
495
|
+
* A singular C# `WidgetTest.cs`, `ABTest.cs`, `SpeedTest.cs`, `LoadTest.cs`,
|
|
496
|
+
* or `Models/Test.cs` stays application code. A plural `<Name>Tests.cs`
|
|
497
|
+
* (PascalCase name, then `Tests.cs`) is a suite anywhere. Singular
|
|
498
|
+
* `<Name>Test.cs` counts only inside a test directory: `tests/`, `test/`,
|
|
499
|
+
* `*.Tests/`, `*.UnitTests/`, `*.IntegrationTests/`, or a `*Tests/` folder
|
|
500
|
+
* when the file itself is `.cs` (`src/Features/ABTests/routes.ts` is not).
|
|
497
501
|
*/
|
|
498
502
|
declare function isTestPath(filePath: string): boolean;
|
|
499
503
|
declare function isSbomPath(filePath: string): boolean;
|
|
@@ -501,7 +505,8 @@ declare function isSbomPath(filePath: string): boolean;
|
|
|
501
505
|
* A credential that is live wherever the file sits. Test-mode keys,
|
|
502
506
|
* placeholder tokens, connection strings, and PEM private keys are not.
|
|
503
507
|
*
|
|
504
|
-
* Formats: `AKIA`/`ABIA`/`ACCA`/`ASIA`
|
|
508
|
+
* Formats: `AKIA`/`ABIA`/`ACCA`/`ASIA` plus exactly 16 letters or digits
|
|
509
|
+
* (20 characters, not inside a longer letter-or-digit run; not a key ending in EXAMPLE),
|
|
505
510
|
* `sk_live_`, `rk_live_`, an OpenAI key (`T3BlbkFJ`), an OpenRouter key
|
|
506
511
|
* (`sk-or-v1-`), `ghp_` and `github_pat_`, a Slack `xox*` token, `AIza`,
|
|
507
512
|
* an Anthropic `sk-ant-api03-` key, SendGrid `SG.`, and a Hugging Face
|
package/dist/index.js
CHANGED
|
@@ -479,10 +479,12 @@ function isTestPath(filePath) {
|
|
|
479
479
|
if (/^Test[A-Z_]\w*\.py$/.test(base)) return true;
|
|
480
480
|
if (/^conftest\.py$/i.test(base)) return true;
|
|
481
481
|
if (/_test\.go$/.test(base)) return true;
|
|
482
|
+
if (/^[A-Z][A-Za-z0-9]*Tests\.cs$/.test(base)) return true;
|
|
482
483
|
if (/(?:^|\/)routes\/test\//i.test(normalized)) return false;
|
|
483
484
|
if (/(?:^|\/)(?:tests|testdata|spec|__tests__|__mocks__|fixtures?|mocks?)(?:\/|$)/i.test(normalized)) return true;
|
|
484
485
|
if (/(?:^|\/)test\//i.test(normalized)) return true;
|
|
485
486
|
if (/(?:^|\/)[^/]*\.(?:UnitTests|IntegrationTests|Tests)\//i.test(normalized)) return true;
|
|
487
|
+
if (/\.cs$/.test(base) && /(?:^|\/)[^/]*Tests\//.test(normalized)) return true;
|
|
486
488
|
if (/test-utils/i.test(normalized)) return true;
|
|
487
489
|
if (/(?:^|\/)testing(?:\/|$)/i.test(normalized)) return true;
|
|
488
490
|
return false;
|
|
@@ -497,6 +499,7 @@ function isPlaceholderToken(token) {
|
|
|
497
499
|
if (new Set(token).size < 8) return true;
|
|
498
500
|
return /example|placeholder|redacted|your_?(?:api_?)?(?:key|token)|insert_?your|replace_?me|\b(?:test|fake|dummy|sample|your)\b/i.test(token);
|
|
499
501
|
}
|
|
502
|
+
var AWS_ACCESS_KEY_SOURCE = String.raw`(?:(?<![A-Z0-9])|(?<=%3[Dd]|\\x[0-9A-Fa-f]{2}|\\u[0-9A-Fa-f]{4}))(?:AKIA|ABIA|ACCA|ASIA)[A-Z0-9]{16}(?![A-Z0-9])`;
|
|
500
503
|
var LIVE_TOKEN_SOURCES = [
|
|
501
504
|
String.raw`(?:sk|rk)_live_[A-Za-z0-9]+`,
|
|
502
505
|
// OpenAI (`T3BlbkFJ` sits in every sk-proj- / sk-svcacct- / sk-admin- / legacy
|
|
@@ -510,7 +513,7 @@ var LIVE_TOKEN_SOURCES = [
|
|
|
510
513
|
String.raw`AIza[A-Za-z0-9_-]{35}`,
|
|
511
514
|
String.raw`SG\.[A-Za-z0-9_-]{22}\.[A-Za-z0-9_-]{43}`,
|
|
512
515
|
String.raw`\bhf_[A-Za-z]{34}\b`,
|
|
513
|
-
|
|
516
|
+
AWS_ACCESS_KEY_SOURCE
|
|
514
517
|
];
|
|
515
518
|
function providerTokens(text) {
|
|
516
519
|
if (!text) return [];
|
|
@@ -1857,8 +1860,10 @@ var hardcodedSecrets = {
|
|
|
1857
1860
|
const patterns = [
|
|
1858
1861
|
// Generic API key patterns — require actual value assignment, not variable declarations
|
|
1859
1862
|
/(?:api[_-]?key|apikey|api[_-]?secret)\s*[:=]\s*["'`]([a-zA-Z0-9_\-]{20,})["'`]/gi,
|
|
1860
|
-
// AWS
|
|
1861
|
-
|
|
1863
|
+
// AWS access key IDs: exactly 20 characters. Same source as the
|
|
1864
|
+
// live-key check. A longer ASIA token must not match, and a key
|
|
1865
|
+
// ending in EXAMPLE stays non-live in tokenIsLive.
|
|
1866
|
+
new RegExp(AWS_ACCESS_KEY_SOURCE, "g"),
|
|
1862
1867
|
// Stripe keys
|
|
1863
1868
|
/(?:sk_live|pk_live|sk_test|pk_test)_[a-zA-Z0-9]{20,}/g,
|
|
1864
1869
|
// Supabase anon/service keys (JWT format)
|
|
@@ -1878,7 +1883,9 @@ var hardcodedSecrets = {
|
|
|
1878
1883
|
// SCREAMING_CASE identifiers ending in SECRET/TOKEN/KEY/PASSWORD
|
|
1879
1884
|
// (OAUTH_CLIENT_SECRET, JWT_PRIVATE_KEY, STRIPE_WEBHOOK_SECRET, etc.)
|
|
1880
1885
|
// that are assigned a string literal, not an env var or function call.
|
|
1881
|
-
|
|
1886
|
+
// The name is capped at 64 characters so a long run of A's cannot
|
|
1887
|
+
// backtrack into the suffix.
|
|
1888
|
+
/[A-Z][A-Z0-9_]{0,64}_(?:SECRET|TOKEN|KEY|PASSWORD|PASSWD)\s*[:=]\s*["'`]([a-zA-Z0-9_\-!@#$%^&*.\/]{12,})["'`]/g,
|
|
1882
1889
|
// camelCase / snake_case object properties that look like credentials:
|
|
1883
1890
|
// apiKey: "...", webhookUrl: "https://...", accountSid: "...", authToken: "..."
|
|
1884
1891
|
// password: "..." caught here separately with a lower threshold (many
|
|
@@ -1888,8 +1895,11 @@ var hardcodedSecrets = {
|
|
|
1888
1895
|
/\b(?:password|passwd|pwd)\s*:\s*["'`]([a-zA-Z0-9_\-!@#$%^&*.\/:\-]{8,})["'`]/gi,
|
|
1889
1896
|
// Private keys
|
|
1890
1897
|
/-----BEGIN (?:RSA |EC |DSA )?PRIVATE KEY-----/g,
|
|
1891
|
-
// Database URLs with credentials
|
|
1892
|
-
|
|
1898
|
+
// Database URLs with credentials. The user and password cannot cross
|
|
1899
|
+
// whitespace or a newline, and each is capped at 1024 characters, so
|
|
1900
|
+
// a localhost URL cannot run forward to a later `@` and a run of
|
|
1901
|
+
// `postgres://a:b` with no `@` cannot backtrack.
|
|
1902
|
+
/(?:postgres|mysql|mongodb(?:\+srv)?):\/\/[^:@\s/]{1,1024}:[^@\s]{1,1024}@[^/\s"'`]{1,256}/gi,
|
|
1893
1903
|
// ── [11]–[14] Fixed-prefix AI-provider and payment keys ──
|
|
1894
1904
|
// These match the token itself, so they fire whatever it is bound to:
|
|
1895
1905
|
// `const k = "…"`, a positional `new OpenAI("…")`, an unquoted .env
|
|
@@ -2004,7 +2014,7 @@ var hardcodedSecrets = {
|
|
|
2004
2014
|
}
|
|
2005
2015
|
if (pi === 6) {
|
|
2006
2016
|
const valMatch = lineText.match(/[:=]\s*["'`]([^"'`]+)["'`]/);
|
|
2007
|
-
const nameMatch = lineText.match(
|
|
2017
|
+
const nameMatch = lineText.match(/([A-Z][A-Z0-9_]*_(?:SECRET|TOKEN|KEY|PASSWORD|PASSWD))\b/);
|
|
2008
2018
|
if (valMatch && nameMatch) {
|
|
2009
2019
|
const value = valMatch[1];
|
|
2010
2020
|
const isKeySuffix = nameMatch[1].endsWith("_KEY");
|
|
@@ -2664,7 +2674,7 @@ var stripeWebhookUnprotected = {
|
|
|
2664
2674
|
const code = maskComments(content);
|
|
2665
2675
|
const pathSaysStripeWebhook = /(?:^|\/)(?:stripe[_-]?webhooks?|webhooks?[_-]?stripe)(?:\/|\.|$)/i.test(filePath) || /webhooks?\/stripe/i.test(filePath) || /stripe\/webhooks?/i.test(filePath);
|
|
2666
2676
|
if (!/stripe/i.test(code) && !pathSaysStripeWebhook) return [];
|
|
2667
|
-
const hasStripeWebhookHandler = pathSaysStripeWebhook || /(?:stripe
|
|
2677
|
+
const hasStripeWebhookHandler = pathSaysStripeWebhook || /(?:stripe.{0,200}webhook|webhook.{0,200}stripe)/i.test(code) || /(?:checkout\.session\.completed|invoice\.paid|payment_intent|customer\.subscription)/i.test(code);
|
|
2668
2678
|
if (!hasStripeWebhookHandler) return [];
|
|
2669
2679
|
if (/constructEvent|verifyHeader|stripe[_-]?signature|webhook[_-]?secret|STRIPE_WEBHOOK_SECRET/i.test(code) || /\b\w*verif\w*\s*\(/i.test(code) && /\bverif\w*(?:stripe|webhook|signature|sig)\w*\s*\(/i.test(code)) return [];
|
|
2670
2680
|
const handlerPatterns = [
|