xploitscan-shared-rules 1.27.2 → 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 +34 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +34 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2338,6 +2338,19 @@ var stripeWebhookUnprotected = {
|
|
|
2338
2338
|
return matches;
|
|
2339
2339
|
}
|
|
2340
2340
|
};
|
|
2341
|
+
var PLACEHOLDER_IDENT_RE = /(?<![\w$])([\w$]*?)(placeholders?)(?![\w$])/gi;
|
|
2342
|
+
function namesPlaceholderRun(content) {
|
|
2343
|
+
PLACEHOLDER_IDENT_RE.lastIndex = 0;
|
|
2344
|
+
let m = PLACEHOLDER_IDENT_RE.exec(content);
|
|
2345
|
+
for (; m !== null; m = PLACEHOLDER_IDENT_RE.exec(content)) {
|
|
2346
|
+
const prefix = m[1];
|
|
2347
|
+
if (prefix === "") return true;
|
|
2348
|
+
const boundary = prefix[prefix.length - 1];
|
|
2349
|
+
if (boundary === "_" || boundary === "$") return true;
|
|
2350
|
+
if (/[a-z0-9]/.test(boundary) && /[A-Z]/.test(m[2][0])) return true;
|
|
2351
|
+
}
|
|
2352
|
+
return false;
|
|
2353
|
+
}
|
|
2341
2354
|
var sqlInjection = {
|
|
2342
2355
|
id: "VC006",
|
|
2343
2356
|
title: "Potential SQL Injection",
|
|
@@ -2373,8 +2386,8 @@ var sqlInjection = {
|
|
|
2373
2386
|
/["'`]\s*(?:SELECT|INSERT|UPDATE|DELETE)\b[^"'`\n]*\b(?:FROM|INTO|SET|VALUES|WHERE|JOIN|RETURNING)\b[^"'`\n]*\$\{(?!.*parameterized)/gi
|
|
2374
2387
|
];
|
|
2375
2388
|
const matches = [];
|
|
2376
|
-
const usesParams = /\?\s*,|\?[^?,;]{1,20}\?|\$\d+|:[\w]+|\bprepare\b
|
|
2377
|
-
if (usesParams) return [];
|
|
2389
|
+
const usesParams = /\?\s*,|\?[^?,;]{1,20}\?|\$\d+|:[\w]+|\bprepare\b/i.test(content);
|
|
2390
|
+
if (usesParams || namesPlaceholderRun(content)) return [];
|
|
2378
2391
|
for (const pattern of patterns) {
|
|
2379
2392
|
const raw = findMatches(
|
|
2380
2393
|
content,
|
|
@@ -10064,6 +10077,9 @@ var SKIP_FILENAMES = /(?:package-lock\.json|pnpm-lock\.yaml|yarn\.lock|composer\
|
|
|
10064
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;
|
|
10065
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;
|
|
10066
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;
|
|
10067
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;
|
|
10068
10084
|
function getSnippet2(content, line) {
|
|
10069
10085
|
const lines = content.split("\n");
|
|
@@ -10088,8 +10104,21 @@ function scanEntropy(files) {
|
|
|
10088
10104
|
if (/(?:\.test\.|\.spec\.|__tests__|__mocks__|fixtures?\/)/i.test(filePath)) continue;
|
|
10089
10105
|
const vendored = isVendoredPath(filePath);
|
|
10090
10106
|
const lines = content.split("\n");
|
|
10107
|
+
let verificationDepth = -1;
|
|
10108
|
+
let braceDepth = 0;
|
|
10091
10109
|
for (let i = 0; i < lines.length; i++) {
|
|
10092
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;
|
|
10093
10122
|
const trimmed = line.trimStart();
|
|
10094
10123
|
if (trimmed.startsWith("//") || trimmed.startsWith("#") || trimmed.startsWith("*") || trimmed.startsWith("/*")) continue;
|
|
10095
10124
|
const stringPattern = /(?:[:=]\s*)(["'`])([^"'`\n]{20,120})\1/g;
|
|
@@ -10111,7 +10140,9 @@ function scanEntropy(files) {
|
|
|
10111
10140
|
if (value.length < 20) continue;
|
|
10112
10141
|
const entropy = shannonEntropy(value);
|
|
10113
10142
|
if (entropy < threshold) continue;
|
|
10114
|
-
const varName = beforeAssign.match(/(
|
|
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;
|
|
10115
10146
|
if (HASH_LIKE_VAR_NAMES.test(varName) && (isHex || isBase64)) continue;
|
|
10116
10147
|
const isLikelySecret = SECRET_VAR_NAMES.test(varName);
|
|
10117
10148
|
if (entropy < 4.5 && !isLikelySecret) continue;
|