xploitscan-shared-rules 1.27.3 → 1.27.4

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.js CHANGED
@@ -9776,6 +9776,9 @@ var SKIP_FILENAMES = /(?:package-lock\.json|pnpm-lock\.yaml|yarn\.lock|composer\
9776
9776
  var SAFE_VAR_NAMES = /(?:description|message|text|label|title|content|template|html|svg|css|style|class(?:Name)?|query|mutation|schema|regex|pattern|format|placeholder|comment|url|path|route|endpoint|href|src|alt|name|type|version|encoding|charset|chars|alphabet|locale|translation|copy|prose|markdown|slug|handle)/i;
9777
9777
  var HASH_LIKE_VAR_NAMES = /(?:^|[^a-z])(?:hash|digest|checksum|fingerprint|etag|crc|md5|sha1|sha256|sha512|contenthash|buildid|revision|commit|sri|integrity|cacheKey|fileHash|assetId|versionId)(?:$|[^a-z])/i;
9778
9778
  var HASH_PREFIX_RE = /^(?:sha\d+|md5|crc32|base64|bcrypt|argon2|pbkdf2|blake2b?)[:_]/i;
9779
+ var VERIFICATION_BLOCK_RE = /\bverification\s*:\s*\{/;
9780
+ var VERIFICATION_KEY_NAMES = /^(?:google|yandex|yahoo|bing|me|other|["']?(?:google-site-verification|facebook-domain-verification|msvalidate\.01|norton-safeweb-site-verification|ahrefs-site-verification|p:domain_verify|wot-verification)["']?)$/i;
9781
+ var VERIFICATION_META_RE = /<meta[^>]+name\s*=\s*["'][^"']*(?:site-verification|domain-verification|msvalidate|domain_verify)[^"']*["']/i;
9779
9782
  var SECRET_VAR_NAMES = /(?:^|[^a-z])(?:key|secret|token|password|passwd|pwd|api[_-]?key|auth|credential|private|signing|bearer|access[_-]?token|refresh[_-]?token|session[_-]?id)(?:$|[^a-z])/i;
9780
9783
  function getSnippet2(content, line) {
9781
9784
  const lines = content.split("\n");
@@ -9800,8 +9803,21 @@ function scanEntropy(files) {
9800
9803
  if (/(?:\.test\.|\.spec\.|__tests__|__mocks__|fixtures?\/)/i.test(filePath)) continue;
9801
9804
  const vendored = isVendoredPath(filePath);
9802
9805
  const lines = content.split("\n");
9806
+ let verificationDepth = -1;
9807
+ let braceDepth = 0;
9803
9808
  for (let i = 0; i < lines.length; i++) {
9804
9809
  const line = lines[i];
9810
+ if (VERIFICATION_BLOCK_RE.test(line) && verificationDepth === -1) {
9811
+ verificationDepth = braceDepth;
9812
+ }
9813
+ const opens = (line.match(/\{/g) || []).length;
9814
+ const closes = (line.match(/\}/g) || []).length;
9815
+ const depthBefore = braceDepth;
9816
+ braceDepth += opens - closes;
9817
+ if (verificationDepth !== -1 && braceDepth <= verificationDepth && depthBefore > verificationDepth) {
9818
+ verificationDepth = -1;
9819
+ }
9820
+ const inVerificationBlock = verificationDepth !== -1;
9805
9821
  const trimmed = line.trimStart();
9806
9822
  if (trimmed.startsWith("//") || trimmed.startsWith("#") || trimmed.startsWith("*") || trimmed.startsWith("/*")) continue;
9807
9823
  const stringPattern = /(?:[:=]\s*)(["'`])([^"'`\n]{20,120})\1/g;
@@ -9823,7 +9839,9 @@ function scanEntropy(files) {
9823
9839
  if (value.length < 20) continue;
9824
9840
  const entropy = shannonEntropy(value);
9825
9841
  if (entropy < threshold) continue;
9826
- const varName = beforeAssign.match(/(\w+)\s*[:=]\s*$/)?.[1] || "";
9842
+ const varName = beforeAssign.match(/["']([^"']+)["']\s*$/)?.[1] || beforeAssign.match(/([\w$-]+)\s*$/)?.[1] || "";
9843
+ if (inVerificationBlock && VERIFICATION_KEY_NAMES.test(varName)) continue;
9844
+ if (VERIFICATION_META_RE.test(line)) continue;
9827
9845
  if (HASH_LIKE_VAR_NAMES.test(varName) && (isHex || isBase64)) continue;
9828
9846
  const isLikelySecret = SECRET_VAR_NAMES.test(varName);
9829
9847
  if (entropy < 4.5 && !isLikelySecret) continue;