xploitscan-shared-rules 1.36.2 → 1.36.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 +7 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +7 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2089,8 +2089,12 @@ var sqlInjection = {
|
|
|
2089
2089
|
/["'`]\s*(?:SELECT|INSERT|UPDATE|DELETE)\b[^"'`\n]*\b(?:FROM|INTO|SET|VALUES|WHERE|JOIN|RETURNING)\b[^"'`\n]*\$\{(?!.*parameterized)/gi
|
|
2090
2090
|
];
|
|
2091
2091
|
const matches = [];
|
|
2092
|
-
const
|
|
2093
|
-
|
|
2092
|
+
const sqlLiterals = (content.match(/'(?:[^'\\\n]|\\.)*'|"(?:[^"\\\n]|\\.)*"|`(?:[^`\\]|\\.)*`/g) ?? []).filter(
|
|
2093
|
+
(lit) => /\b(?:SELECT|INSERT|UPDATE|DELETE)\b[\s\S]*\b(?:FROM|INTO|SET|VALUES|WHERE)\b/i.test(lit)
|
|
2094
|
+
);
|
|
2095
|
+
const usesParams = /\bprepare\b/i.test(content) || sqlLiterals.some((lit) => /\?\s*,|\?[^?,;]{1,20}\?|\$\d+|:[A-Za-z_]\w*|@[A-Za-z_]\w*|=\s*\?/.test(lit));
|
|
2096
|
+
const code = content.replace(/\/\*[\s\S]*?\*\//g, " ").replace(/(^|[^:"'`\\])\/\/.*$/gm, "$1");
|
|
2097
|
+
if (usesParams || namesPlaceholderRun(code)) return [];
|
|
2094
2098
|
for (const pattern of patterns) {
|
|
2095
2099
|
const raw = findMatches(
|
|
2096
2100
|
content,
|
|
@@ -2104,6 +2108,7 @@ var sqlInjection = {
|
|
|
2104
2108
|
if (/\bPrisma\.sql\s*`/.test(lineText)) continue;
|
|
2105
2109
|
if (/\bsql\s*`/.test(lineText) && !/\bsql\.raw\s*\(/.test(lineText)) continue;
|
|
2106
2110
|
if (/\$queryRaw\s*\(\s*Prisma\.sql|\$executeRaw\s*\(\s*Prisma\.sql/.test(lineText)) continue;
|
|
2111
|
+
if (matches.some((x) => x.line === m.line)) continue;
|
|
2107
2112
|
matches.push(m);
|
|
2108
2113
|
}
|
|
2109
2114
|
}
|