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.cjs CHANGED
@@ -10077,6 +10077,9 @@ var SKIP_FILENAMES = /(?:package-lock\.json|pnpm-lock\.yaml|yarn\.lock|composer\
10077
10077
  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;
10078
10078
  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;
10079
10079
  var HASH_PREFIX_RE = /^(?:sha\d+|md5|crc32|base64|bcrypt|argon2|pbkdf2|blake2b?)[:_]/i;
10080
+ var VERIFICATION_BLOCK_RE = /\bverification\s*:\s*\{/;
10081
+ 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;
10082
+ var VERIFICATION_META_RE = /<meta[^>]+name\s*=\s*["'][^"']*(?:site-verification|domain-verification|msvalidate|domain_verify)[^"']*["']/i;
10080
10083
  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;
10081
10084
  function getSnippet2(content, line) {
10082
10085
  const lines = content.split("\n");
@@ -10101,8 +10104,21 @@ function scanEntropy(files) {
10101
10104
  if (/(?:\.test\.|\.spec\.|__tests__|__mocks__|fixtures?\/)/i.test(filePath)) continue;
10102
10105
  const vendored = isVendoredPath(filePath);
10103
10106
  const lines = content.split("\n");
10107
+ let verificationDepth = -1;
10108
+ let braceDepth = 0;
10104
10109
  for (let i = 0; i < lines.length; i++) {
10105
10110
  const line = lines[i];
10111
+ if (VERIFICATION_BLOCK_RE.test(line) && verificationDepth === -1) {
10112
+ verificationDepth = braceDepth;
10113
+ }
10114
+ const opens = (line.match(/\{/g) || []).length;
10115
+ const closes = (line.match(/\}/g) || []).length;
10116
+ const depthBefore = braceDepth;
10117
+ braceDepth += opens - closes;
10118
+ if (verificationDepth !== -1 && braceDepth <= verificationDepth && depthBefore > verificationDepth) {
10119
+ verificationDepth = -1;
10120
+ }
10121
+ const inVerificationBlock = verificationDepth !== -1;
10106
10122
  const trimmed = line.trimStart();
10107
10123
  if (trimmed.startsWith("//") || trimmed.startsWith("#") || trimmed.startsWith("*") || trimmed.startsWith("/*")) continue;
10108
10124
  const stringPattern = /(?:[:=]\s*)(["'`])([^"'`\n]{20,120})\1/g;
@@ -10124,7 +10140,9 @@ function scanEntropy(files) {
10124
10140
  if (value.length < 20) continue;
10125
10141
  const entropy = shannonEntropy(value);
10126
10142
  if (entropy < threshold) continue;
10127
- const varName = beforeAssign.match(/(\w+)\s*[:=]\s*$/)?.[1] || "";
10143
+ const varName = beforeAssign.match(/["']([^"']+)["']\s*$/)?.[1] || beforeAssign.match(/([\w$-]+)\s*$/)?.[1] || "";
10144
+ if (inVerificationBlock && VERIFICATION_KEY_NAMES.test(varName)) continue;
10145
+ if (VERIFICATION_META_RE.test(line)) continue;
10128
10146
  if (HASH_LIKE_VAR_NAMES.test(varName) && (isHex || isBase64)) continue;
10129
10147
  const isLikelySecret = SECRET_VAR_NAMES.test(varName);
10130
10148
  if (entropy < 4.5 && !isLikelySecret) continue;