xploitscan-shared-rules 2.4.9 → 2.4.10

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 CHANGED
@@ -159,7 +159,7 @@ __export(index_exports, {
159
159
  module.exports = __toCommonJS(index_exports);
160
160
 
161
161
  // src/version.ts
162
- var SCANNER_VERSION = "2.4.9";
162
+ var SCANNER_VERSION = "2.4.10";
163
163
 
164
164
  // src/snippet.ts
165
165
  var cacheContent = null;
@@ -2085,11 +2085,14 @@ var hardcodedSecrets = {
2085
2085
  /\b(?:password|passwd|pwd)\s*:\s*["'`]([a-zA-Z0-9_\-!@#$%^&*.\/:\-]{8,})["'`]/gi,
2086
2086
  // Private keys
2087
2087
  /-----BEGIN (?:RSA |EC |DSA )?PRIVATE KEY-----/g,
2088
- // Database URLs with credentials. The user and password cannot cross
2089
- // whitespace or a newline, and each is capped at 1024 characters, so
2090
- // a localhost URL cannot run forward to a later `@` and a run of
2091
- // `postgres://a:b` with no `@` cannot backtrack.
2092
- /(?:postgres|mysql|mongodb(?:\+srv)?):\/\/[^:@\s/]{1,1024}:[^@\s]{1,1024}@[^/\s"'`]{1,256}/gi,
2088
+ // Database URLs with credentials. Align with Pro VC049: `postgresql://`
2089
+ // and `postgresql+asyncpg://` (and mysql/mongodb+srv) are what providers
2090
+ // actually hand out — `postgres://` alone missed Supabase/Prisma URLs.
2091
+ // The user and password cannot cross whitespace or a newline, and each
2092
+ // is capped at 1024 characters, so a localhost URL cannot run forward
2093
+ // to a later `@` and a run of `postgres://a:b` with no `@` cannot
2094
+ // backtrack.
2095
+ /(?:postgres(?:ql)?(?:\+[a-z0-9]{1,20})?|mysql|mongodb(?:\+srv)?):\/\/[^:@\s/]{1,1024}:[^@\s]{1,1024}@[^/\s"'`]{1,256}/gi,
2093
2096
  // ── [11]–[14] Fixed-prefix AI-provider and payment keys ──
2094
2097
  // These match the token itself, so they fire whatever it is bound to:
2095
2098
  // `const k = "…"`, a positional `new OpenAI("…")`, an unquoted .env
@@ -2204,11 +2207,11 @@ var hardcodedSecrets = {
2204
2207
  }
2205
2208
  if (pi === 6) {
2206
2209
  const valMatch = lineText.match(/[:=]\s*["'`]([^"'`]+)["'`]/);
2207
- const nameMatch = lineText.match(/([A-Z][A-Z0-9_]*_(?:SECRET|TOKEN|KEY|PASSWORD|PASSWD))\b/);
2210
+ const nameMatch = (matchedText[ri] ?? "").match(/^[A-Z][A-Z0-9_]{0,64}_(?:SECRET|TOKEN|KEY|PASSWORD|PASSWD)\b/);
2208
2211
  if (valMatch && nameMatch) {
2209
2212
  const value = valMatch[1];
2210
- const isKeySuffix = nameMatch[1].endsWith("_KEY");
2211
- const isSlotIdentifier = value.length < 40 && (/^[a-z0-9]+([_-][a-z0-9]+)+$/.test(value) || isNamespacedSlotKey(nameMatch[1], value));
2213
+ const isKeySuffix = nameMatch[0].endsWith("_KEY");
2214
+ const isSlotIdentifier = value.length < 40 && (/^[a-z0-9]+([_-][a-z0-9]+)+$/.test(value) || isNamespacedSlotKey(nameMatch[0], value));
2212
2215
  if (isKeySuffix && isSlotIdentifier) continue;
2213
2216
  }
2214
2217
  }
@@ -5342,7 +5345,8 @@ function scanEntropy(files) {
5342
5345
  if (value.includes("${")) continue;
5343
5346
  if (value.includes("\\(")) continue;
5344
5347
  if (value.includes("#{") || value.includes("{{")) continue;
5345
- if (SAFE_PATTERNS.some((p) => p.test(value))) continue;
5348
+ const isUuidShape = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value);
5349
+ if (!isUuidShape && SAFE_PATTERNS.some((p) => p.test(value))) continue;
5346
5350
  if (HASH_PREFIX_RE.test(value)) continue;
5347
5351
  if (SAFE_VAR_NAMES.test(beforeAssign)) continue;
5348
5352
  if (/^https?:\/\/[^:@]*$/.test(value)) continue;
@@ -5353,9 +5357,10 @@ function scanEntropy(files) {
5353
5357
  if (isHex) threshold = 3;
5354
5358
  else if (isBase64) threshold = 4.5;
5355
5359
  if (value.length < 20) continue;
5356
- const entropy = shannonEntropy(value);
5357
- if (entropy < threshold) continue;
5358
5360
  const varName = variableName || dotenvName || beforeAssign.match(/["']([^"']+)["']\s*$/)?.[1] || beforeAssign.match(/([\w$-]+)\s*$/)?.[1] || "";
5361
+ if (isUuidShape && !isSecretVariableName(varName)) continue;
5362
+ const entropy = shannonEntropy(value);
5363
+ if (entropy < threshold && !(isUuidShape && isSecretVariableName(varName))) continue;
5359
5364
  if (HUMAN_READABLE_ENV_REFERENCE_RE.test(value) && !isSecretVariableName(varName)) {
5360
5365
  continue;
5361
5366
  }