xploitscan-shared-rules 2.1.0 → 2.1.1

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.d.cts CHANGED
@@ -956,6 +956,16 @@ declare function isInsideFixMessage(content: string, matchIndex: number): boolea
956
956
  */
957
957
  declare function filterSilenced(matches: RuleMatch[], content: string, ruleId: string): RuleMatch[];
958
958
  declare function findMatches(content: string, pattern: RegExp, rule: Omit<CustomRule, "check">, filePath: string, fixTemplate?: (match: RegExpExecArray) => string): RuleMatch[];
959
+ /**
960
+ * findMatches for a matcher that is not a single RegExp — one a regex can
961
+ * only express with super-linear backtracking. `found` yields the matches'
962
+ * start indices in increasing order, as RegExp#exec would; the comment and
963
+ * fix-message skips, line numbers and the per-file cap are findMatches' own,
964
+ * so a rule moved off a regex reports exactly what the regex reported.
965
+ */
966
+ declare function findMatchesAt<M extends {
967
+ index: number;
968
+ }>(content: string, found: Iterable<M>, rule: Omit<CustomRule, "check">, filePath: string, fixTemplate?: (match: M) => string): RuleMatch[];
959
969
  /**
960
970
  * Build a RuleMatch from an AST-derived location. Mirrors findMatches' output
961
971
  * shape so AST-based rules can be mixed into the same Finding stream. `line`
@@ -1487,4 +1497,4 @@ input: {
1487
1497
  content: string;
1488
1498
  }[] | QualityContext, rules?: QualityRule[]): Finding[];
1489
1499
 
1490
- export { type AIFilterResult, type AppRoute, type BuilderFingerprint, CHECKABLE_CLAIMS, type Confidence, type CustomRule, DOTENV_ASSIGN_RE, type DetectedFramework, type ExposedConfig, type Exposure, FREE_RULE_COUNT, type FilteredFinding, type Finding, type GradeOptions, type GradeResult, type HeaderFinding, INTENT_EXPECTATIONS, type IntentExpectation, type IntentMismatch, type IntentOrigin, type IntentReport, type IntentStatement, MODEL_ANALYSIS, MODEL_POLICY_REVIEWED, MODEL_REVIEW_INTERVAL_DAYS, MODEL_TEMPERATURE, MODEL_TRIAGE, NON_APP_PATH_PATTERNS, PRO_RULE_COUNT, PUBLIC_ENV_PREFIX_RE, type ParsedFile, type ProjectContext, QUALITY_EXAMPLES, type QualityContext, type QualityExample, type QualityFile, type QualityHit, type QualityRule, RULE_IMPACTS, type RouteFramework, type RouteTable, type RuleMatch, type SecurityGrade, type Severity, TEST_FILE_PATTERN, TOTAL_RULE_COUNT, type TaintMap, type TargetCheck, type VibePlatform, allRules, assessHeaders, astMatch, buildProjectContext, buildQualityContext, buildTaintMap, calculateGrade, callSpreads, checkIntent, classifyExposure, classifyPublicEnvVar, classifyStatement, clientSideAuth, complianceMap, consoleLogProduction, corsWildcard, dangerousInnerHTML, detectBuilder, detectExposedConfig, detectFramework, detectPlatform, disabledTLSVerification, dotenvValue, emptyCatchBlock, enclosingHandler, envNotGitignored, evalUsage, exposedAuthSecret, exposedDebugMode, exposedEnvFile, exposedStackTraces, extractRoutes, extractScriptUrls, filterFalsePositives, filterSilenced, findMatches, findSourceMapRefs, freeRules, getObjectProperty, getSnippet, hardcodedJWTSecret, hardcodedSecrets, harvestIntent, insecureCookies, insecureRandomness, isCalleeNamed, isClientTarget, isCommentLine, isDotenvPath, isInlineSilenced, isInsideFixMessage, isLineSilenced, isMethodCall, isPrivateAddress, isServerSideFile, isServerTarget, isTestFile, isVendoredFinding, isVendoredPath, lineNumberAt, lineTextAt, maskComments, maskOutboundAuthNoise, missingAuthMiddleware, missingCSP, missingErrorBoundary, missingHTTPS, missingLockFile, nextPublicSecret, noRateLimiting, normalizeScanPath, parseFile, parseScanTarget, parseSupabaseConfig, qualityRules, replaceBlockComments, routeForFile, runCustomRules, scanEntropy, scanQuality, sqlInjection, stripeWebhookUnprotected, supabaseFunctionName, supabaseNoRLS, todoLeftInCode, tryParse, unmeasuredQualityRules, unvalidatedRedirect, vendoredReason, visitBinary, visitCalls, weakHashing, xssVulnerability };
1500
+ export { type AIFilterResult, type AppRoute, type BuilderFingerprint, CHECKABLE_CLAIMS, type Confidence, type CustomRule, DOTENV_ASSIGN_RE, type DetectedFramework, type ExposedConfig, type Exposure, FREE_RULE_COUNT, type FilteredFinding, type Finding, type GradeOptions, type GradeResult, type HeaderFinding, INTENT_EXPECTATIONS, type IntentExpectation, type IntentMismatch, type IntentOrigin, type IntentReport, type IntentStatement, MODEL_ANALYSIS, MODEL_POLICY_REVIEWED, MODEL_REVIEW_INTERVAL_DAYS, MODEL_TEMPERATURE, MODEL_TRIAGE, NON_APP_PATH_PATTERNS, PRO_RULE_COUNT, PUBLIC_ENV_PREFIX_RE, type ParsedFile, type ProjectContext, QUALITY_EXAMPLES, type QualityContext, type QualityExample, type QualityFile, type QualityHit, type QualityRule, RULE_IMPACTS, type RouteFramework, type RouteTable, type RuleMatch, type SecurityGrade, type Severity, TEST_FILE_PATTERN, TOTAL_RULE_COUNT, type TaintMap, type TargetCheck, type VibePlatform, allRules, assessHeaders, astMatch, buildProjectContext, buildQualityContext, buildTaintMap, calculateGrade, callSpreads, checkIntent, classifyExposure, classifyPublicEnvVar, classifyStatement, clientSideAuth, complianceMap, consoleLogProduction, corsWildcard, dangerousInnerHTML, detectBuilder, detectExposedConfig, detectFramework, detectPlatform, disabledTLSVerification, dotenvValue, emptyCatchBlock, enclosingHandler, envNotGitignored, evalUsage, exposedAuthSecret, exposedDebugMode, exposedEnvFile, exposedStackTraces, extractRoutes, extractScriptUrls, filterFalsePositives, filterSilenced, findMatches, findMatchesAt, findSourceMapRefs, freeRules, getObjectProperty, getSnippet, hardcodedJWTSecret, hardcodedSecrets, harvestIntent, insecureCookies, insecureRandomness, isCalleeNamed, isClientTarget, isCommentLine, isDotenvPath, isInlineSilenced, isInsideFixMessage, isLineSilenced, isMethodCall, isPrivateAddress, isServerSideFile, isServerTarget, isTestFile, isVendoredFinding, isVendoredPath, lineNumberAt, lineTextAt, maskComments, maskOutboundAuthNoise, missingAuthMiddleware, missingCSP, missingErrorBoundary, missingHTTPS, missingLockFile, nextPublicSecret, noRateLimiting, normalizeScanPath, parseFile, parseScanTarget, parseSupabaseConfig, qualityRules, replaceBlockComments, routeForFile, runCustomRules, scanEntropy, scanQuality, sqlInjection, stripeWebhookUnprotected, supabaseFunctionName, supabaseNoRLS, todoLeftInCode, tryParse, unmeasuredQualityRules, unvalidatedRedirect, vendoredReason, visitBinary, visitCalls, weakHashing, xssVulnerability };
package/dist/index.d.ts CHANGED
@@ -956,6 +956,16 @@ declare function isInsideFixMessage(content: string, matchIndex: number): boolea
956
956
  */
957
957
  declare function filterSilenced(matches: RuleMatch[], content: string, ruleId: string): RuleMatch[];
958
958
  declare function findMatches(content: string, pattern: RegExp, rule: Omit<CustomRule, "check">, filePath: string, fixTemplate?: (match: RegExpExecArray) => string): RuleMatch[];
959
+ /**
960
+ * findMatches for a matcher that is not a single RegExp — one a regex can
961
+ * only express with super-linear backtracking. `found` yields the matches'
962
+ * start indices in increasing order, as RegExp#exec would; the comment and
963
+ * fix-message skips, line numbers and the per-file cap are findMatches' own,
964
+ * so a rule moved off a regex reports exactly what the regex reported.
965
+ */
966
+ declare function findMatchesAt<M extends {
967
+ index: number;
968
+ }>(content: string, found: Iterable<M>, rule: Omit<CustomRule, "check">, filePath: string, fixTemplate?: (match: M) => string): RuleMatch[];
959
969
  /**
960
970
  * Build a RuleMatch from an AST-derived location. Mirrors findMatches' output
961
971
  * shape so AST-based rules can be mixed into the same Finding stream. `line`
@@ -1487,4 +1497,4 @@ input: {
1487
1497
  content: string;
1488
1498
  }[] | QualityContext, rules?: QualityRule[]): Finding[];
1489
1499
 
1490
- export { type AIFilterResult, type AppRoute, type BuilderFingerprint, CHECKABLE_CLAIMS, type Confidence, type CustomRule, DOTENV_ASSIGN_RE, type DetectedFramework, type ExposedConfig, type Exposure, FREE_RULE_COUNT, type FilteredFinding, type Finding, type GradeOptions, type GradeResult, type HeaderFinding, INTENT_EXPECTATIONS, type IntentExpectation, type IntentMismatch, type IntentOrigin, type IntentReport, type IntentStatement, MODEL_ANALYSIS, MODEL_POLICY_REVIEWED, MODEL_REVIEW_INTERVAL_DAYS, MODEL_TEMPERATURE, MODEL_TRIAGE, NON_APP_PATH_PATTERNS, PRO_RULE_COUNT, PUBLIC_ENV_PREFIX_RE, type ParsedFile, type ProjectContext, QUALITY_EXAMPLES, type QualityContext, type QualityExample, type QualityFile, type QualityHit, type QualityRule, RULE_IMPACTS, type RouteFramework, type RouteTable, type RuleMatch, type SecurityGrade, type Severity, TEST_FILE_PATTERN, TOTAL_RULE_COUNT, type TaintMap, type TargetCheck, type VibePlatform, allRules, assessHeaders, astMatch, buildProjectContext, buildQualityContext, buildTaintMap, calculateGrade, callSpreads, checkIntent, classifyExposure, classifyPublicEnvVar, classifyStatement, clientSideAuth, complianceMap, consoleLogProduction, corsWildcard, dangerousInnerHTML, detectBuilder, detectExposedConfig, detectFramework, detectPlatform, disabledTLSVerification, dotenvValue, emptyCatchBlock, enclosingHandler, envNotGitignored, evalUsage, exposedAuthSecret, exposedDebugMode, exposedEnvFile, exposedStackTraces, extractRoutes, extractScriptUrls, filterFalsePositives, filterSilenced, findMatches, findSourceMapRefs, freeRules, getObjectProperty, getSnippet, hardcodedJWTSecret, hardcodedSecrets, harvestIntent, insecureCookies, insecureRandomness, isCalleeNamed, isClientTarget, isCommentLine, isDotenvPath, isInlineSilenced, isInsideFixMessage, isLineSilenced, isMethodCall, isPrivateAddress, isServerSideFile, isServerTarget, isTestFile, isVendoredFinding, isVendoredPath, lineNumberAt, lineTextAt, maskComments, maskOutboundAuthNoise, missingAuthMiddleware, missingCSP, missingErrorBoundary, missingHTTPS, missingLockFile, nextPublicSecret, noRateLimiting, normalizeScanPath, parseFile, parseScanTarget, parseSupabaseConfig, qualityRules, replaceBlockComments, routeForFile, runCustomRules, scanEntropy, scanQuality, sqlInjection, stripeWebhookUnprotected, supabaseFunctionName, supabaseNoRLS, todoLeftInCode, tryParse, unmeasuredQualityRules, unvalidatedRedirect, vendoredReason, visitBinary, visitCalls, weakHashing, xssVulnerability };
1500
+ export { type AIFilterResult, type AppRoute, type BuilderFingerprint, CHECKABLE_CLAIMS, type Confidence, type CustomRule, DOTENV_ASSIGN_RE, type DetectedFramework, type ExposedConfig, type Exposure, FREE_RULE_COUNT, type FilteredFinding, type Finding, type GradeOptions, type GradeResult, type HeaderFinding, INTENT_EXPECTATIONS, type IntentExpectation, type IntentMismatch, type IntentOrigin, type IntentReport, type IntentStatement, MODEL_ANALYSIS, MODEL_POLICY_REVIEWED, MODEL_REVIEW_INTERVAL_DAYS, MODEL_TEMPERATURE, MODEL_TRIAGE, NON_APP_PATH_PATTERNS, PRO_RULE_COUNT, PUBLIC_ENV_PREFIX_RE, type ParsedFile, type ProjectContext, QUALITY_EXAMPLES, type QualityContext, type QualityExample, type QualityFile, type QualityHit, type QualityRule, RULE_IMPACTS, type RouteFramework, type RouteTable, type RuleMatch, type SecurityGrade, type Severity, TEST_FILE_PATTERN, TOTAL_RULE_COUNT, type TaintMap, type TargetCheck, type VibePlatform, allRules, assessHeaders, astMatch, buildProjectContext, buildQualityContext, buildTaintMap, calculateGrade, callSpreads, checkIntent, classifyExposure, classifyPublicEnvVar, classifyStatement, clientSideAuth, complianceMap, consoleLogProduction, corsWildcard, dangerousInnerHTML, detectBuilder, detectExposedConfig, detectFramework, detectPlatform, disabledTLSVerification, dotenvValue, emptyCatchBlock, enclosingHandler, envNotGitignored, evalUsage, exposedAuthSecret, exposedDebugMode, exposedEnvFile, exposedStackTraces, extractRoutes, extractScriptUrls, filterFalsePositives, filterSilenced, findMatches, findMatchesAt, findSourceMapRefs, freeRules, getObjectProperty, getSnippet, hardcodedJWTSecret, hardcodedSecrets, harvestIntent, insecureCookies, insecureRandomness, isCalleeNamed, isClientTarget, isCommentLine, isDotenvPath, isInlineSilenced, isInsideFixMessage, isLineSilenced, isMethodCall, isPrivateAddress, isServerSideFile, isServerTarget, isTestFile, isVendoredFinding, isVendoredPath, lineNumberAt, lineTextAt, maskComments, maskOutboundAuthNoise, missingAuthMiddleware, missingCSP, missingErrorBoundary, missingHTTPS, missingLockFile, nextPublicSecret, noRateLimiting, normalizeScanPath, parseFile, parseScanTarget, parseSupabaseConfig, qualityRules, replaceBlockComments, routeForFile, runCustomRules, scanEntropy, scanQuality, sqlInjection, stripeWebhookUnprotected, supabaseFunctionName, supabaseNoRLS, todoLeftInCode, tryParse, unmeasuredQualityRules, unvalidatedRedirect, vendoredReason, visitBinary, visitCalls, weakHashing, xssVulnerability };
package/dist/index.js CHANGED
@@ -1621,19 +1621,27 @@ function filterSilenced(matches, content, ruleId) {
1621
1621
  return matches.filter((m) => !isInlineSilenced(content, lineStartIndex(m.line), ruleId));
1622
1622
  }
1623
1623
  function findMatches(content, pattern, rule, filePath, fixTemplate) {
1624
- const matches = [];
1625
- let m;
1626
1624
  const re = new RegExp(pattern.source, pattern.flags.includes("g") ? pattern.flags : `${pattern.flags}g`);
1625
+ function* execAll() {
1626
+ let m;
1627
+ let lastMatchIndex = -1;
1628
+ while ((m = re.exec(content)) !== null) {
1629
+ if (m.index === lastMatchIndex && m[0].length === 0) {
1630
+ re.lastIndex++;
1631
+ continue;
1632
+ }
1633
+ lastMatchIndex = m.index;
1634
+ yield m;
1635
+ }
1636
+ }
1637
+ return findMatchesAt(content, execAll(), rule, filePath, fixTemplate);
1638
+ }
1639
+ function findMatchesAt(content, found, rule, filePath, fixTemplate) {
1640
+ const matches = [];
1627
1641
  let scanned = 0;
1628
1642
  let lineNum = 1;
1629
- let lastMatchIndex = -1;
1630
1643
  const MAX_MATCHES = 500;
1631
- while ((m = re.exec(content)) !== null) {
1632
- if (m.index === lastMatchIndex && m[0].length === 0) {
1633
- re.lastIndex++;
1634
- continue;
1635
- }
1636
- lastMatchIndex = m.index;
1644
+ for (const m of found) {
1637
1645
  if (isCommentLine(content, m.index)) continue;
1638
1646
  if (isInsideFixMessage(content, m.index)) continue;
1639
1647
  for (; scanned < m.index; scanned++) {
@@ -2575,6 +2583,105 @@ function namesPlaceholderRun(content) {
2575
2583
  }
2576
2584
  return false;
2577
2585
  }
2586
+ function isLineTerminator(c) {
2587
+ return c === 10 || c === 13 || c === 8232 || c === 8233;
2588
+ }
2589
+ function quotedLiterals(content) {
2590
+ const literals = [];
2591
+ const failedUpTo = /* @__PURE__ */ new Map();
2592
+ for (let i = 0; i < content.length; i++) {
2593
+ const quote = content.charCodeAt(i);
2594
+ if (quote !== 39 && quote !== 34 && quote !== 96) continue;
2595
+ if (i < (failedUpTo.get(quote) ?? -1)) continue;
2596
+ let j = i + 1;
2597
+ let closed = false;
2598
+ while (j < content.length) {
2599
+ const c = content.charCodeAt(j);
2600
+ if (c === quote) {
2601
+ closed = true;
2602
+ break;
2603
+ }
2604
+ if (c === 92) {
2605
+ if (j + 1 >= content.length || isLineTerminator(content.charCodeAt(j + 1))) break;
2606
+ j += 2;
2607
+ continue;
2608
+ }
2609
+ if (c === 10 && quote !== 96) break;
2610
+ j++;
2611
+ }
2612
+ if (!closed) {
2613
+ failedUpTo.set(quote, j);
2614
+ continue;
2615
+ }
2616
+ literals.push(content.slice(i, j + 1));
2617
+ i = j;
2618
+ }
2619
+ return literals;
2620
+ }
2621
+ var SQL_VERB_RE = /\b(?:SELECT|INSERT|UPDATE|DELETE)\b/i;
2622
+ var SQL_CLAUSE_RE = /\b(?:FROM|INTO|SET|VALUES|WHERE)\b/gi;
2623
+ function isSqlStatement(lit) {
2624
+ const verb = SQL_VERB_RE.exec(lit);
2625
+ if (!verb) return false;
2626
+ SQL_CLAUSE_RE.lastIndex = verb.index + verb[0].length;
2627
+ return SQL_CLAUSE_RE.test(lit);
2628
+ }
2629
+ function* interpolatedSqlLiterals(content) {
2630
+ const opener = /["'`]\s*(?:SELECT|INSERT|UPDATE|DELETE)\b/gi;
2631
+ const literalBreak = /["'`\n]/g;
2632
+ const clauseRe = /\b(?:FROM|INTO|SET|VALUES|WHERE|JOIN|RETURNING)\b/i;
2633
+ let lineEnds = null;
2634
+ let lastOnLine = [];
2635
+ const parameterizedLater = (x) => {
2636
+ if (lineEnds === null) {
2637
+ const ends = [];
2638
+ for (let i = 0; i < content.length; i++) {
2639
+ if (isLineTerminator(content.charCodeAt(i))) ends.push(i);
2640
+ }
2641
+ ends.push(content.length);
2642
+ lastOnLine = new Array(ends.length).fill(-1);
2643
+ const word = /parameterized/gi;
2644
+ let line = 0;
2645
+ for (let w = word.exec(content); w !== null; w = word.exec(content)) {
2646
+ while (ends[line] < w.index) line++;
2647
+ lastOnLine[line] = w.index;
2648
+ }
2649
+ lineEnds = ends;
2650
+ }
2651
+ let lo = 0;
2652
+ let hi = lineEnds.length - 1;
2653
+ while (lo < hi) {
2654
+ const mid = lo + hi >> 1;
2655
+ if (lineEnds[mid] < x) lo = mid + 1;
2656
+ else hi = mid;
2657
+ }
2658
+ return lastOnLine[lo] >= x;
2659
+ };
2660
+ for (let m = opener.exec(content); m !== null; m = opener.exec(content)) {
2661
+ const start = m.index;
2662
+ const runStart = opener.lastIndex;
2663
+ literalBreak.lastIndex = runStart;
2664
+ const runEnd = literalBreak.exec(content)?.index ?? content.length;
2665
+ const run = content.slice(runStart, runEnd);
2666
+ const clause = clauseRe.exec(run);
2667
+ let matchEnd = -1;
2668
+ if (clause) {
2669
+ const clauseEnd = clause.index + clause[0].length;
2670
+ for (let d = run.lastIndexOf("${"); d >= clauseEnd; d = run.lastIndexOf("${", d - 1)) {
2671
+ if (!parameterizedLater(runStart + d + 2)) {
2672
+ matchEnd = runStart + d + 2;
2673
+ break;
2674
+ }
2675
+ }
2676
+ }
2677
+ if (matchEnd === -1) {
2678
+ opener.lastIndex = start + 1;
2679
+ continue;
2680
+ }
2681
+ yield { index: start };
2682
+ opener.lastIndex = matchEnd;
2683
+ }
2684
+ }
2578
2685
  var sqlInjection = {
2579
2686
  id: "VC006",
2580
2687
  title: "Potential SQL Injection",
@@ -2597,35 +2704,22 @@ var sqlInjection = {
2597
2704
  // allows the opposite quote type inside (common in SQL — "WHERE x = 'a'").
2598
2705
  // The older `[^"']*` class bailed out at the first inner quote and
2599
2706
  // missed every realistic SQL-containing concat.
2600
- /(?:query|execute|raw|sql|queryRaw|queryRawUnsafe|executeRaw|executeRawUnsafe)\s*\(\s*(?:"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')\s*\+/gi,
2601
- // Direct variable interpolation in a SQL string literal. Requires the
2602
- // verb to START a quoted/backtick literal AND be followed — within the
2603
- // same literal — by a SQL structural keyword (FROM/SET/WHERE/…), then a
2604
- // `${` interpolation. The structural keyword is what distinguishes a
2605
- // real query from ordinary prose: the previous pattern matched any
2606
- // SELECT/UPDATE/… word anywhere on a line followed by `${`, so UI copy
2607
- // like `UPDATE your profile settings ${name}` flagged as a CRITICAL SQL
2608
- // injection. Real queries ("SELECT … FROM …", "UPDATE … SET …") always
2609
- // carry a second structural keyword; sentences almost never do.
2610
- /["'`]\s*(?:SELECT|INSERT|UPDATE|DELETE)\b[^"'`\n]*\b(?:FROM|INTO|SET|VALUES|WHERE|JOIN|RETURNING)\b[^"'`\n]*\$\{(?!.*parameterized)/gi
2707
+ /(?:query|execute|raw|sql|queryRaw|queryRawUnsafe|executeRaw|executeRawUnsafe)\s*\(\s*(?:"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')\s*\+/gi
2611
2708
  ];
2612
2709
  const matches = [];
2613
- const sqlLiterals = (content.match(/'(?:[^'\\\n]|\\.)*'|"(?:[^"\\\n]|\\.)*"|`(?:[^`\\]|\\.)*`/g) ?? []).filter(
2614
- (lit) => /\b(?:SELECT|INSERT|UPDATE|DELETE)\b[\s\S]*\b(?:FROM|INTO|SET|VALUES|WHERE)\b/i.test(lit)
2615
- );
2710
+ const sqlLiterals = quotedLiterals(content).filter(isSqlStatement);
2616
2711
  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));
2617
- const code = content.replace(/\/\*[\s\S]*?\*\//g, " ").replace(/(^|[^:"'`\\])\/\/.*$/gm, "$1");
2712
+ const code = replaceBlockComments(content, () => " ").replace(/(^|[^:"'`\\])\/\/.*$/gm, "$1");
2618
2713
  if (usesParams || namesPlaceholderRun(code)) return [];
2619
- for (const pattern of patterns) {
2620
- const raw = findMatches(
2621
- content,
2622
- pattern,
2623
- sqlInjection,
2624
- filePath,
2625
- () => "Use parameterized queries or prepared statements instead of string interpolation. Example: db.query('SELECT * FROM users WHERE id = ?', [userId])"
2626
- );
2714
+ const fix = () => "Use parameterized queries or prepared statements instead of string interpolation. Example: db.query('SELECT * FROM users WHERE id = ?', [userId])";
2715
+ const raws = [
2716
+ ...patterns.map((pattern) => findMatches(content, pattern, sqlInjection, filePath, fix)),
2717
+ findMatchesAt(content, interpolatedSqlLiterals(content), sqlInjection, filePath, fix)
2718
+ ];
2719
+ let lines;
2720
+ for (const raw of raws) {
2627
2721
  for (const m of raw) {
2628
- const lineText = content.split("\n")[m.line - 1] || "";
2722
+ const lineText = (lines ??= content.split("\n"))[m.line - 1] || "";
2629
2723
  if (/\bPrisma\.sql\s*`/.test(lineText)) continue;
2630
2724
  if (/\bsql\s*`/.test(lineText) && !/\bsql\.raw\s*\(/.test(lineText)) continue;
2631
2725
  if (/\$queryRaw\s*\(\s*Prisma\.sql|\$executeRaw\s*\(\s*Prisma\.sql/.test(lineText)) continue;
@@ -3435,7 +3529,7 @@ var dangerousInnerHTML = {
3435
3529
  if (!filePath.match(/\.(jsx|tsx)$/)) return [];
3436
3530
  if (isTestFile(filePath)) return [];
3437
3531
  if (!/dangerouslySetInnerHTML/i.test(content)) return [];
3438
- const codeOnly = content.replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[^:])\/\/.*$/gm, "$1").replace(/\{\s*\/\*[\s\S]*?\*\/\s*\}/g, "");
3532
+ const codeOnly = replaceBlockComments(content, () => "").replace(/(^|[^:])\/\/.*$/gm, "$1").replace(/\{\s*\/\*[\s\S]*?\*\/\s*\}/g, "");
3439
3533
  const hasSanitize = /\b(?:DOMPurify|sanitizeHtml|sanitize-html|isomorphic-dompurify)\b|\b(?:sanitize|purify|xss)\s*\(/i.test(codeOnly);
3440
3534
  if (hasSanitize) return [];
3441
3535
  const findings = [];
@@ -8238,6 +8332,7 @@ export {
8238
8332
  filterFalsePositives,
8239
8333
  filterSilenced,
8240
8334
  findMatches,
8335
+ findMatchesAt,
8241
8336
  findSourceMapRefs,
8242
8337
  freeRules,
8243
8338
  getObjectProperty,