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.d.cts CHANGED
@@ -160,7 +160,7 @@ interface CustomRule {
160
160
  * before a scan can be saved without enough provenance to explain a changed
161
161
  * grade.
162
162
  */
163
- declare const SCANNER_VERSION = "2.4.9";
163
+ declare const SCANNER_VERSION = "2.4.10";
164
164
 
165
165
  /**
166
166
  * Line-oriented helpers shared by every rule. Pure string manipulation — no fs
package/dist/index.d.ts CHANGED
@@ -160,7 +160,7 @@ interface CustomRule {
160
160
  * before a scan can be saved without enough provenance to explain a changed
161
161
  * grade.
162
162
  */
163
- declare const SCANNER_VERSION = "2.4.9";
163
+ declare const SCANNER_VERSION = "2.4.10";
164
164
 
165
165
  /**
166
166
  * Line-oriented helpers shared by every rule. Pure string manipulation — no fs
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var SCANNER_VERSION = "2.4.9";
2
+ var SCANNER_VERSION = "2.4.10";
3
3
 
4
4
  // src/snippet.ts
5
5
  var cacheContent = null;
@@ -1925,11 +1925,14 @@ var hardcodedSecrets = {
1925
1925
  /\b(?:password|passwd|pwd)\s*:\s*["'`]([a-zA-Z0-9_\-!@#$%^&*.\/:\-]{8,})["'`]/gi,
1926
1926
  // Private keys
1927
1927
  /-----BEGIN (?:RSA |EC |DSA )?PRIVATE KEY-----/g,
1928
- // Database URLs with credentials. The user and password cannot cross
1929
- // whitespace or a newline, and each is capped at 1024 characters, so
1930
- // a localhost URL cannot run forward to a later `@` and a run of
1931
- // `postgres://a:b` with no `@` cannot backtrack.
1932
- /(?:postgres|mysql|mongodb(?:\+srv)?):\/\/[^:@\s/]{1,1024}:[^@\s]{1,1024}@[^/\s"'`]{1,256}/gi,
1928
+ // Database URLs with credentials. Align with Pro VC049: `postgresql://`
1929
+ // and `postgresql+asyncpg://` (and mysql/mongodb+srv) are what providers
1930
+ // actually hand out — `postgres://` alone missed Supabase/Prisma URLs.
1931
+ // The user and password cannot cross whitespace or a newline, and each
1932
+ // is capped at 1024 characters, so a localhost URL cannot run forward
1933
+ // to a later `@` and a run of `postgres://a:b` with no `@` cannot
1934
+ // backtrack.
1935
+ /(?:postgres(?:ql)?(?:\+[a-z0-9]{1,20})?|mysql|mongodb(?:\+srv)?):\/\/[^:@\s/]{1,1024}:[^@\s]{1,1024}@[^/\s"'`]{1,256}/gi,
1933
1936
  // ── [11]–[14] Fixed-prefix AI-provider and payment keys ──
1934
1937
  // These match the token itself, so they fire whatever it is bound to:
1935
1938
  // `const k = "…"`, a positional `new OpenAI("…")`, an unquoted .env
@@ -2044,11 +2047,11 @@ var hardcodedSecrets = {
2044
2047
  }
2045
2048
  if (pi === 6) {
2046
2049
  const valMatch = lineText.match(/[:=]\s*["'`]([^"'`]+)["'`]/);
2047
- const nameMatch = lineText.match(/([A-Z][A-Z0-9_]*_(?:SECRET|TOKEN|KEY|PASSWORD|PASSWD))\b/);
2050
+ const nameMatch = (matchedText[ri] ?? "").match(/^[A-Z][A-Z0-9_]{0,64}_(?:SECRET|TOKEN|KEY|PASSWORD|PASSWD)\b/);
2048
2051
  if (valMatch && nameMatch) {
2049
2052
  const value = valMatch[1];
2050
- const isKeySuffix = nameMatch[1].endsWith("_KEY");
2051
- const isSlotIdentifier = value.length < 40 && (/^[a-z0-9]+([_-][a-z0-9]+)+$/.test(value) || isNamespacedSlotKey(nameMatch[1], value));
2053
+ const isKeySuffix = nameMatch[0].endsWith("_KEY");
2054
+ const isSlotIdentifier = value.length < 40 && (/^[a-z0-9]+([_-][a-z0-9]+)+$/.test(value) || isNamespacedSlotKey(nameMatch[0], value));
2052
2055
  if (isKeySuffix && isSlotIdentifier) continue;
2053
2056
  }
2054
2057
  }
@@ -5182,7 +5185,8 @@ function scanEntropy(files) {
5182
5185
  if (value.includes("${")) continue;
5183
5186
  if (value.includes("\\(")) continue;
5184
5187
  if (value.includes("#{") || value.includes("{{")) continue;
5185
- if (SAFE_PATTERNS.some((p) => p.test(value))) continue;
5188
+ 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);
5189
+ if (!isUuidShape && SAFE_PATTERNS.some((p) => p.test(value))) continue;
5186
5190
  if (HASH_PREFIX_RE.test(value)) continue;
5187
5191
  if (SAFE_VAR_NAMES.test(beforeAssign)) continue;
5188
5192
  if (/^https?:\/\/[^:@]*$/.test(value)) continue;
@@ -5193,9 +5197,10 @@ function scanEntropy(files) {
5193
5197
  if (isHex) threshold = 3;
5194
5198
  else if (isBase64) threshold = 4.5;
5195
5199
  if (value.length < 20) continue;
5196
- const entropy = shannonEntropy(value);
5197
- if (entropy < threshold) continue;
5198
5200
  const varName = variableName || dotenvName || beforeAssign.match(/["']([^"']+)["']\s*$/)?.[1] || beforeAssign.match(/([\w$-]+)\s*$/)?.[1] || "";
5201
+ if (isUuidShape && !isSecretVariableName(varName)) continue;
5202
+ const entropy = shannonEntropy(value);
5203
+ if (entropy < threshold && !(isUuidShape && isSecretVariableName(varName))) continue;
5199
5204
  if (HUMAN_READABLE_ENV_REFERENCE_RE.test(value) && !isSecretVariableName(varName)) {
5200
5205
  continue;
5201
5206
  }