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.js
CHANGED
|
@@ -2037,6 +2037,19 @@ var stripeWebhookUnprotected = {
|
|
|
2037
2037
|
return matches;
|
|
2038
2038
|
}
|
|
2039
2039
|
};
|
|
2040
|
+
var PLACEHOLDER_IDENT_RE = /(?<![\w$])([\w$]*?)(placeholders?)(?![\w$])/gi;
|
|
2041
|
+
function namesPlaceholderRun(content) {
|
|
2042
|
+
PLACEHOLDER_IDENT_RE.lastIndex = 0;
|
|
2043
|
+
let m = PLACEHOLDER_IDENT_RE.exec(content);
|
|
2044
|
+
for (; m !== null; m = PLACEHOLDER_IDENT_RE.exec(content)) {
|
|
2045
|
+
const prefix = m[1];
|
|
2046
|
+
if (prefix === "") return true;
|
|
2047
|
+
const boundary = prefix[prefix.length - 1];
|
|
2048
|
+
if (boundary === "_" || boundary === "$") return true;
|
|
2049
|
+
if (/[a-z0-9]/.test(boundary) && /[A-Z]/.test(m[2][0])) return true;
|
|
2050
|
+
}
|
|
2051
|
+
return false;
|
|
2052
|
+
}
|
|
2040
2053
|
var sqlInjection = {
|
|
2041
2054
|
id: "VC006",
|
|
2042
2055
|
title: "Potential SQL Injection",
|
|
@@ -2072,8 +2085,8 @@ var sqlInjection = {
|
|
|
2072
2085
|
/["'`]\s*(?:SELECT|INSERT|UPDATE|DELETE)\b[^"'`\n]*\b(?:FROM|INTO|SET|VALUES|WHERE|JOIN|RETURNING)\b[^"'`\n]*\$\{(?!.*parameterized)/gi
|
|
2073
2086
|
];
|
|
2074
2087
|
const matches = [];
|
|
2075
|
-
const usesParams = /\?\s*,|\?[^?,;]{1,20}\?|\$\d+|:[\w]+|\bprepare\b
|
|
2076
|
-
if (usesParams) return [];
|
|
2088
|
+
const usesParams = /\?\s*,|\?[^?,;]{1,20}\?|\$\d+|:[\w]+|\bprepare\b/i.test(content);
|
|
2089
|
+
if (usesParams || namesPlaceholderRun(content)) return [];
|
|
2077
2090
|
for (const pattern of patterns) {
|
|
2078
2091
|
const raw = findMatches(
|
|
2079
2092
|
content,
|
|
@@ -9763,6 +9776,9 @@ var SKIP_FILENAMES = /(?:package-lock\.json|pnpm-lock\.yaml|yarn\.lock|composer\
|
|
|
9763
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;
|
|
9764
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;
|
|
9765
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;
|
|
9766
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;
|
|
9767
9783
|
function getSnippet2(content, line) {
|
|
9768
9784
|
const lines = content.split("\n");
|
|
@@ -9787,8 +9803,21 @@ function scanEntropy(files) {
|
|
|
9787
9803
|
if (/(?:\.test\.|\.spec\.|__tests__|__mocks__|fixtures?\/)/i.test(filePath)) continue;
|
|
9788
9804
|
const vendored = isVendoredPath(filePath);
|
|
9789
9805
|
const lines = content.split("\n");
|
|
9806
|
+
let verificationDepth = -1;
|
|
9807
|
+
let braceDepth = 0;
|
|
9790
9808
|
for (let i = 0; i < lines.length; i++) {
|
|
9791
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;
|
|
9792
9821
|
const trimmed = line.trimStart();
|
|
9793
9822
|
if (trimmed.startsWith("//") || trimmed.startsWith("#") || trimmed.startsWith("*") || trimmed.startsWith("/*")) continue;
|
|
9794
9823
|
const stringPattern = /(?:[:=]\s*)(["'`])([^"'`\n]{20,120})\1/g;
|
|
@@ -9810,7 +9839,9 @@ function scanEntropy(files) {
|
|
|
9810
9839
|
if (value.length < 20) continue;
|
|
9811
9840
|
const entropy = shannonEntropy(value);
|
|
9812
9841
|
if (entropy < threshold) continue;
|
|
9813
|
-
const varName = beforeAssign.match(/(
|
|
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;
|
|
9814
9845
|
if (HASH_LIKE_VAR_NAMES.test(varName) && (isHex || isBase64)) continue;
|
|
9815
9846
|
const isLikelySecret = SECRET_VAR_NAMES.test(varName);
|
|
9816
9847
|
if (entropy < 4.5 && !isLikelySecret) continue;
|