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.cjs
CHANGED
|
@@ -633,10 +633,12 @@ function isTestPath(filePath) {
|
|
|
633
633
|
if (/^Test[A-Z_]\w*\.py$/.test(base)) return true;
|
|
634
634
|
if (/^conftest\.py$/i.test(base)) return true;
|
|
635
635
|
if (/_test\.go$/.test(base)) return true;
|
|
636
|
+
if (/^[A-Z][A-Za-z0-9]*Tests\.cs$/.test(base)) return true;
|
|
636
637
|
if (/(?:^|\/)routes\/test\//i.test(normalized)) return false;
|
|
637
638
|
if (/(?:^|\/)(?:tests|testdata|spec|__tests__|__mocks__|fixtures?|mocks?)(?:\/|$)/i.test(normalized)) return true;
|
|
638
639
|
if (/(?:^|\/)test\//i.test(normalized)) return true;
|
|
639
640
|
if (/(?:^|\/)[^/]*\.(?:UnitTests|IntegrationTests|Tests)\//i.test(normalized)) return true;
|
|
641
|
+
if (/\.cs$/.test(base) && /(?:^|\/)[^/]*Tests\//.test(normalized)) return true;
|
|
640
642
|
if (/test-utils/i.test(normalized)) return true;
|
|
641
643
|
if (/(?:^|\/)testing(?:\/|$)/i.test(normalized)) return true;
|
|
642
644
|
return false;
|
|
@@ -651,6 +653,7 @@ function isPlaceholderToken(token) {
|
|
|
651
653
|
if (new Set(token).size < 8) return true;
|
|
652
654
|
return /example|placeholder|redacted|your_?(?:api_?)?(?:key|token)|insert_?your|replace_?me|\b(?:test|fake|dummy|sample|your)\b/i.test(token);
|
|
653
655
|
}
|
|
656
|
+
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])`;
|
|
654
657
|
var LIVE_TOKEN_SOURCES = [
|
|
655
658
|
String.raw`(?:sk|rk)_live_[A-Za-z0-9]+`,
|
|
656
659
|
// OpenAI (`T3BlbkFJ` sits in every sk-proj- / sk-svcacct- / sk-admin- / legacy
|
|
@@ -664,7 +667,7 @@ var LIVE_TOKEN_SOURCES = [
|
|
|
664
667
|
String.raw`AIza[A-Za-z0-9_-]{35}`,
|
|
665
668
|
String.raw`SG\.[A-Za-z0-9_-]{22}\.[A-Za-z0-9_-]{43}`,
|
|
666
669
|
String.raw`\bhf_[A-Za-z]{34}\b`,
|
|
667
|
-
|
|
670
|
+
AWS_ACCESS_KEY_SOURCE
|
|
668
671
|
];
|
|
669
672
|
function providerTokens(text) {
|
|
670
673
|
if (!text) return [];
|
|
@@ -2011,8 +2014,10 @@ var hardcodedSecrets = {
|
|
|
2011
2014
|
const patterns = [
|
|
2012
2015
|
// Generic API key patterns — require actual value assignment, not variable declarations
|
|
2013
2016
|
/(?:api[_-]?key|apikey|api[_-]?secret)\s*[:=]\s*["'`]([a-zA-Z0-9_\-]{20,})["'`]/gi,
|
|
2014
|
-
// AWS
|
|
2015
|
-
|
|
2017
|
+
// AWS access key IDs: exactly 20 characters. Same source as the
|
|
2018
|
+
// live-key check. A longer ASIA token must not match, and a key
|
|
2019
|
+
// ending in EXAMPLE stays non-live in tokenIsLive.
|
|
2020
|
+
new RegExp(AWS_ACCESS_KEY_SOURCE, "g"),
|
|
2016
2021
|
// Stripe keys
|
|
2017
2022
|
/(?:sk_live|pk_live|sk_test|pk_test)_[a-zA-Z0-9]{20,}/g,
|
|
2018
2023
|
// Supabase anon/service keys (JWT format)
|
|
@@ -2032,7 +2037,9 @@ var hardcodedSecrets = {
|
|
|
2032
2037
|
// SCREAMING_CASE identifiers ending in SECRET/TOKEN/KEY/PASSWORD
|
|
2033
2038
|
// (OAUTH_CLIENT_SECRET, JWT_PRIVATE_KEY, STRIPE_WEBHOOK_SECRET, etc.)
|
|
2034
2039
|
// that are assigned a string literal, not an env var or function call.
|
|
2035
|
-
|
|
2040
|
+
// The name is capped at 64 characters so a long run of A's cannot
|
|
2041
|
+
// backtrack into the suffix.
|
|
2042
|
+
/[A-Z][A-Z0-9_]{0,64}_(?:SECRET|TOKEN|KEY|PASSWORD|PASSWD)\s*[:=]\s*["'`]([a-zA-Z0-9_\-!@#$%^&*.\/]{12,})["'`]/g,
|
|
2036
2043
|
// camelCase / snake_case object properties that look like credentials:
|
|
2037
2044
|
// apiKey: "...", webhookUrl: "https://...", accountSid: "...", authToken: "..."
|
|
2038
2045
|
// password: "..." caught here separately with a lower threshold (many
|
|
@@ -2042,8 +2049,11 @@ var hardcodedSecrets = {
|
|
|
2042
2049
|
/\b(?:password|passwd|pwd)\s*:\s*["'`]([a-zA-Z0-9_\-!@#$%^&*.\/:\-]{8,})["'`]/gi,
|
|
2043
2050
|
// Private keys
|
|
2044
2051
|
/-----BEGIN (?:RSA |EC |DSA )?PRIVATE KEY-----/g,
|
|
2045
|
-
// Database URLs with credentials
|
|
2046
|
-
|
|
2052
|
+
// Database URLs with credentials. The user and password cannot cross
|
|
2053
|
+
// whitespace or a newline, and each is capped at 1024 characters, so
|
|
2054
|
+
// a localhost URL cannot run forward to a later `@` and a run of
|
|
2055
|
+
// `postgres://a:b` with no `@` cannot backtrack.
|
|
2056
|
+
/(?:postgres|mysql|mongodb(?:\+srv)?):\/\/[^:@\s/]{1,1024}:[^@\s]{1,1024}@[^/\s"'`]{1,256}/gi,
|
|
2047
2057
|
// ── [11]–[14] Fixed-prefix AI-provider and payment keys ──
|
|
2048
2058
|
// These match the token itself, so they fire whatever it is bound to:
|
|
2049
2059
|
// `const k = "…"`, a positional `new OpenAI("…")`, an unquoted .env
|
|
@@ -2158,7 +2168,7 @@ var hardcodedSecrets = {
|
|
|
2158
2168
|
}
|
|
2159
2169
|
if (pi === 6) {
|
|
2160
2170
|
const valMatch = lineText.match(/[:=]\s*["'`]([^"'`]+)["'`]/);
|
|
2161
|
-
const nameMatch = lineText.match(
|
|
2171
|
+
const nameMatch = lineText.match(/([A-Z][A-Z0-9_]*_(?:SECRET|TOKEN|KEY|PASSWORD|PASSWD))\b/);
|
|
2162
2172
|
if (valMatch && nameMatch) {
|
|
2163
2173
|
const value = valMatch[1];
|
|
2164
2174
|
const isKeySuffix = nameMatch[1].endsWith("_KEY");
|
|
@@ -2818,7 +2828,7 @@ var stripeWebhookUnprotected = {
|
|
|
2818
2828
|
const code = maskComments(content);
|
|
2819
2829
|
const pathSaysStripeWebhook = /(?:^|\/)(?:stripe[_-]?webhooks?|webhooks?[_-]?stripe)(?:\/|\.|$)/i.test(filePath) || /webhooks?\/stripe/i.test(filePath) || /stripe\/webhooks?/i.test(filePath);
|
|
2820
2830
|
if (!/stripe/i.test(code) && !pathSaysStripeWebhook) return [];
|
|
2821
|
-
const hasStripeWebhookHandler = pathSaysStripeWebhook || /(?:stripe
|
|
2831
|
+
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);
|
|
2822
2832
|
if (!hasStripeWebhookHandler) return [];
|
|
2823
2833
|
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 [];
|
|
2824
2834
|
const handlerPatterns = [
|