xploitscan-shared-rules 2.4.8 → 2.4.10

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
@@ -160,7 +160,7 @@ interface CustomRule {
160
160
  * before a scan can be saved without enough provenance to explain a changed
161
161
  * grade.
162
162
  */
163
- declare const SCANNER_VERSION = "2.4.8";
163
+ declare const SCANNER_VERSION = "2.4.10";
164
164
 
165
165
  /**
166
166
  * Line-oriented helpers shared by every rule. Pure string manipulation — no fs
@@ -189,6 +189,16 @@ declare function lineNumberAt(content: string, index: number): number;
189
189
  */
190
190
  declare function getSnippet(content: string, line: number, contextLines?: number): string;
191
191
 
192
+ /**
193
+ * Remove repeated reports of the same finding while preserving distinct
194
+ * problems that happen to share a line.
195
+ *
196
+ * Multiple engines can surface the same custom-rule match, and some rules use
197
+ * overlapping patterns. The title remains part of the key because one rule
198
+ * may intentionally report two different problems at one location.
199
+ */
200
+ declare function deduplicateFindings<T extends Finding>(findings: readonly T[]): T[];
201
+
192
202
  /**
193
203
  * Inline finding suppression — the `// VC###-OK: <reason>` marker.
194
204
  *
@@ -1674,4 +1684,4 @@ input: {
1674
1684
  content: string;
1675
1685
  }[] | QualityContext, rules?: QualityRule[]): Finding[];
1676
1686
 
1677
- 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, GRADE_FINDINGS_PER_RULE, 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, SCANNER_VERSION, type SecurityGrade, type Severity, TEST_FILE_PATTERN, TOTAL_RULE_COUNT, type TaintMap, type TargetCheck, type VibePlatform, allRules, assessHeaders, astMatch, buildProjectContext, buildQualityContext, buildReviewPrompt, 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, gradeRuleFamily, hardcodedJWTSecret, hardcodedSecrets, harvestIntent, insecureCookies, insecureRandomness, isCalleeNamed, isClientTarget, isCommentLine, isDotenvPath, isInlineSilenced, isInsideFixMessage, isLineSilenced, isLive, isMethodCall, isPrivateAddress, isProtectedFromAiRemoval, isSbomPath, isServerSideFile, isServerTarget, isTestFile, isTestPath, isUngradedFinding, isVendoredFinding, isVendoredPath, lineNumberAt, lineTextAt, maskComments, maskOutboundAuthNoise, missingAuthMiddleware, missingCSP, missingErrorBoundary, missingHTTPS, missingLockFile, newDataFence, nextPublicSecret, noRateLimiting, normalizeScanPath, packReviewBatches, parseFile, parseScanTarget, parseSupabaseConfig, qualityRules, replaceBlockComments, routeForFile, runCustomRules, scanConfigs, scanDependencies, scanEntropy, scanMultiFile, scanQuality, sqlInjection, stripeWebhookUnprotected, supabaseFunctionName, supabaseNoRLS, todoLeftInCode, tryParse, unmeasuredQualityRules, unvalidatedRedirect, vendoredReason, visitBinary, visitCalls, weakHashing, xssVulnerability };
1687
+ 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, GRADE_FINDINGS_PER_RULE, 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, SCANNER_VERSION, type SecurityGrade, type Severity, TEST_FILE_PATTERN, TOTAL_RULE_COUNT, type TaintMap, type TargetCheck, type VibePlatform, allRules, assessHeaders, astMatch, buildProjectContext, buildQualityContext, buildReviewPrompt, buildTaintMap, calculateGrade, callSpreads, checkIntent, classifyExposure, classifyPublicEnvVar, classifyStatement, clientSideAuth, complianceMap, consoleLogProduction, corsWildcard, dangerousInnerHTML, deduplicateFindings, detectBuilder, detectExposedConfig, detectFramework, detectPlatform, disabledTLSVerification, dotenvValue, emptyCatchBlock, enclosingHandler, envNotGitignored, evalUsage, exposedAuthSecret, exposedDebugMode, exposedEnvFile, exposedStackTraces, extractRoutes, extractScriptUrls, filterFalsePositives, filterSilenced, findMatches, findMatchesAt, findSourceMapRefs, freeRules, getObjectProperty, getSnippet, gradeRuleFamily, hardcodedJWTSecret, hardcodedSecrets, harvestIntent, insecureCookies, insecureRandomness, isCalleeNamed, isClientTarget, isCommentLine, isDotenvPath, isInlineSilenced, isInsideFixMessage, isLineSilenced, isLive, isMethodCall, isPrivateAddress, isProtectedFromAiRemoval, isSbomPath, isServerSideFile, isServerTarget, isTestFile, isTestPath, isUngradedFinding, isVendoredFinding, isVendoredPath, lineNumberAt, lineTextAt, maskComments, maskOutboundAuthNoise, missingAuthMiddleware, missingCSP, missingErrorBoundary, missingHTTPS, missingLockFile, newDataFence, nextPublicSecret, noRateLimiting, normalizeScanPath, packReviewBatches, parseFile, parseScanTarget, parseSupabaseConfig, qualityRules, replaceBlockComments, routeForFile, runCustomRules, scanConfigs, scanDependencies, scanEntropy, scanMultiFile, scanQuality, sqlInjection, stripeWebhookUnprotected, supabaseFunctionName, supabaseNoRLS, todoLeftInCode, tryParse, unmeasuredQualityRules, unvalidatedRedirect, vendoredReason, visitBinary, visitCalls, weakHashing, xssVulnerability };
package/dist/index.d.ts CHANGED
@@ -160,7 +160,7 @@ interface CustomRule {
160
160
  * before a scan can be saved without enough provenance to explain a changed
161
161
  * grade.
162
162
  */
163
- declare const SCANNER_VERSION = "2.4.8";
163
+ declare const SCANNER_VERSION = "2.4.10";
164
164
 
165
165
  /**
166
166
  * Line-oriented helpers shared by every rule. Pure string manipulation — no fs
@@ -189,6 +189,16 @@ declare function lineNumberAt(content: string, index: number): number;
189
189
  */
190
190
  declare function getSnippet(content: string, line: number, contextLines?: number): string;
191
191
 
192
+ /**
193
+ * Remove repeated reports of the same finding while preserving distinct
194
+ * problems that happen to share a line.
195
+ *
196
+ * Multiple engines can surface the same custom-rule match, and some rules use
197
+ * overlapping patterns. The title remains part of the key because one rule
198
+ * may intentionally report two different problems at one location.
199
+ */
200
+ declare function deduplicateFindings<T extends Finding>(findings: readonly T[]): T[];
201
+
192
202
  /**
193
203
  * Inline finding suppression — the `// VC###-OK: <reason>` marker.
194
204
  *
@@ -1674,4 +1684,4 @@ input: {
1674
1684
  content: string;
1675
1685
  }[] | QualityContext, rules?: QualityRule[]): Finding[];
1676
1686
 
1677
- 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, GRADE_FINDINGS_PER_RULE, 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, SCANNER_VERSION, type SecurityGrade, type Severity, TEST_FILE_PATTERN, TOTAL_RULE_COUNT, type TaintMap, type TargetCheck, type VibePlatform, allRules, assessHeaders, astMatch, buildProjectContext, buildQualityContext, buildReviewPrompt, 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, gradeRuleFamily, hardcodedJWTSecret, hardcodedSecrets, harvestIntent, insecureCookies, insecureRandomness, isCalleeNamed, isClientTarget, isCommentLine, isDotenvPath, isInlineSilenced, isInsideFixMessage, isLineSilenced, isLive, isMethodCall, isPrivateAddress, isProtectedFromAiRemoval, isSbomPath, isServerSideFile, isServerTarget, isTestFile, isTestPath, isUngradedFinding, isVendoredFinding, isVendoredPath, lineNumberAt, lineTextAt, maskComments, maskOutboundAuthNoise, missingAuthMiddleware, missingCSP, missingErrorBoundary, missingHTTPS, missingLockFile, newDataFence, nextPublicSecret, noRateLimiting, normalizeScanPath, packReviewBatches, parseFile, parseScanTarget, parseSupabaseConfig, qualityRules, replaceBlockComments, routeForFile, runCustomRules, scanConfigs, scanDependencies, scanEntropy, scanMultiFile, scanQuality, sqlInjection, stripeWebhookUnprotected, supabaseFunctionName, supabaseNoRLS, todoLeftInCode, tryParse, unmeasuredQualityRules, unvalidatedRedirect, vendoredReason, visitBinary, visitCalls, weakHashing, xssVulnerability };
1687
+ 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, GRADE_FINDINGS_PER_RULE, 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, SCANNER_VERSION, type SecurityGrade, type Severity, TEST_FILE_PATTERN, TOTAL_RULE_COUNT, type TaintMap, type TargetCheck, type VibePlatform, allRules, assessHeaders, astMatch, buildProjectContext, buildQualityContext, buildReviewPrompt, buildTaintMap, calculateGrade, callSpreads, checkIntent, classifyExposure, classifyPublicEnvVar, classifyStatement, clientSideAuth, complianceMap, consoleLogProduction, corsWildcard, dangerousInnerHTML, deduplicateFindings, detectBuilder, detectExposedConfig, detectFramework, detectPlatform, disabledTLSVerification, dotenvValue, emptyCatchBlock, enclosingHandler, envNotGitignored, evalUsage, exposedAuthSecret, exposedDebugMode, exposedEnvFile, exposedStackTraces, extractRoutes, extractScriptUrls, filterFalsePositives, filterSilenced, findMatches, findMatchesAt, findSourceMapRefs, freeRules, getObjectProperty, getSnippet, gradeRuleFamily, hardcodedJWTSecret, hardcodedSecrets, harvestIntent, insecureCookies, insecureRandomness, isCalleeNamed, isClientTarget, isCommentLine, isDotenvPath, isInlineSilenced, isInsideFixMessage, isLineSilenced, isLive, isMethodCall, isPrivateAddress, isProtectedFromAiRemoval, isSbomPath, isServerSideFile, isServerTarget, isTestFile, isTestPath, isUngradedFinding, isVendoredFinding, isVendoredPath, lineNumberAt, lineTextAt, maskComments, maskOutboundAuthNoise, missingAuthMiddleware, missingCSP, missingErrorBoundary, missingHTTPS, missingLockFile, newDataFence, nextPublicSecret, noRateLimiting, normalizeScanPath, packReviewBatches, parseFile, parseScanTarget, parseSupabaseConfig, qualityRules, replaceBlockComments, routeForFile, runCustomRules, scanConfigs, scanDependencies, scanEntropy, scanMultiFile, scanQuality, sqlInjection, stripeWebhookUnprotected, supabaseFunctionName, supabaseNoRLS, todoLeftInCode, tryParse, unmeasuredQualityRules, unvalidatedRedirect, vendoredReason, visitBinary, visitCalls, weakHashing, xssVulnerability };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var SCANNER_VERSION = "2.4.8";
2
+ var SCANNER_VERSION = "2.4.10";
3
3
 
4
4
  // src/snippet.ts
5
5
  var cacheContent = null;
@@ -48,6 +48,28 @@ function getSnippet(content, line, contextLines = 2) {
48
48
  return out.join("\n");
49
49
  }
50
50
 
51
+ // src/dedupe.ts
52
+ function deduplicateFindings(findings) {
53
+ const seen = /* @__PURE__ */ new Set();
54
+ const unique = [];
55
+ for (const finding of findings) {
56
+ let key;
57
+ if (finding.rule === "VC001" || finding.rule === "ENTROPY") {
58
+ key = `hardcoded-secret:${finding.file}:${finding.line}`;
59
+ } else if (finding.rule === "VC014" || finding.rule === "MFA002") {
60
+ key = `env-not-ignored:${finding.file}:${finding.line}`;
61
+ } else if (finding.source === "gitleaks") {
62
+ key = `gitleaks-secret:${finding.file}:${finding.line}`;
63
+ } else {
64
+ key = `${finding.rule}:${finding.file}:${finding.line}:${finding.title}`;
65
+ }
66
+ if (seen.has(key)) continue;
67
+ seen.add(key);
68
+ unique.push(finding);
69
+ }
70
+ return unique;
71
+ }
72
+
51
73
  // src/silencing.ts
52
74
  function isInlineSilenced(content, matchIndex, ruleId) {
53
75
  const lines = content.split("\n");
@@ -1903,11 +1925,14 @@ var hardcodedSecrets = {
1903
1925
  /\b(?:password|passwd|pwd)\s*:\s*["'`]([a-zA-Z0-9_\-!@#$%^&*.\/:\-]{8,})["'`]/gi,
1904
1926
  // Private keys
1905
1927
  /-----BEGIN (?:RSA |EC |DSA )?PRIVATE KEY-----/g,
1906
- // Database URLs with credentials. The user and password cannot cross
1907
- // whitespace or a newline, and each is capped at 1024 characters, so
1908
- // a localhost URL cannot run forward to a later `@` and a run of
1909
- // `postgres://a:b` with no `@` cannot backtrack.
1910
- /(?:postgres|mysql|mongodb(?:\+srv)?):\/\/[^:@\s/]{1,1024}:[^@\s]{1,1024}@[^/\s"'`]{1,256}/gi,
1928
+ // Database URLs with credentials. Align with Pro VC049: `postgresql://`
1929
+ // and `postgresql+asyncpg://` (and mysql/mongodb+srv) are what providers
1930
+ // actually hand out — `postgres://` alone missed Supabase/Prisma URLs.
1931
+ // The user and password cannot cross whitespace or a newline, and each
1932
+ // is capped at 1024 characters, so a localhost URL cannot run forward
1933
+ // to a later `@` and a run of `postgres://a:b` with no `@` cannot
1934
+ // backtrack.
1935
+ /(?:postgres(?:ql)?(?:\+[a-z0-9]{1,20})?|mysql|mongodb(?:\+srv)?):\/\/[^:@\s/]{1,1024}:[^@\s]{1,1024}@[^/\s"'`]{1,256}/gi,
1911
1936
  // ── [11]–[14] Fixed-prefix AI-provider and payment keys ──
1912
1937
  // These match the token itself, so they fire whatever it is bound to:
1913
1938
  // `const k = "…"`, a positional `new OpenAI("…")`, an unquoted .env
@@ -2022,11 +2047,11 @@ var hardcodedSecrets = {
2022
2047
  }
2023
2048
  if (pi === 6) {
2024
2049
  const valMatch = lineText.match(/[:=]\s*["'`]([^"'`]+)["'`]/);
2025
- const nameMatch = lineText.match(/([A-Z][A-Z0-9_]*_(?:SECRET|TOKEN|KEY|PASSWORD|PASSWD))\b/);
2050
+ const nameMatch = (matchedText[ri] ?? "").match(/^[A-Z][A-Z0-9_]{0,64}_(?:SECRET|TOKEN|KEY|PASSWORD|PASSWD)\b/);
2026
2051
  if (valMatch && nameMatch) {
2027
2052
  const value = valMatch[1];
2028
- const isKeySuffix = nameMatch[1].endsWith("_KEY");
2029
- const isSlotIdentifier = value.length < 40 && (/^[a-z0-9]+([_-][a-z0-9]+)+$/.test(value) || isNamespacedSlotKey(nameMatch[1], value));
2053
+ const isKeySuffix = nameMatch[0].endsWith("_KEY");
2054
+ const isSlotIdentifier = value.length < 40 && (/^[a-z0-9]+([_-][a-z0-9]+)+$/.test(value) || isNamespacedSlotKey(nameMatch[0], value));
2030
2055
  if (isKeySuffix && isSlotIdentifier) continue;
2031
2056
  }
2032
2057
  }
@@ -2606,7 +2631,11 @@ var missingAuthMiddleware = {
2606
2631
  if (content[i] === "\n") lineStarts.push(i + 1);
2607
2632
  }
2608
2633
  const indexOfLine = (line) => lineStarts[Math.max(0, Math.min(line - 1, lineStarts.length - 1))];
2609
- const unauthenticated = matches.filter((m) => !handlerHasAuth(indexOfLine(m.line)));
2634
+ const isPublicRootGet = (index) => /\.\s*get\s*\(\s*["'`]\/["'`]\s*,/i.test(content.slice(index, index + 240));
2635
+ const unauthenticated = matches.filter((m) => {
2636
+ const index = indexOfLine(m.line);
2637
+ return !isPublicRootGet(index) && !handlerHasAuth(index);
2638
+ });
2610
2639
  if (serverSide || tanstackCandidate) {
2611
2640
  for (const idx of unauthenticatedTanStackHandlers(maskedForScope, filePath)) {
2612
2641
  const line = lineNumberAt(content, idx);
@@ -4528,7 +4557,7 @@ function runCustomRules(content, filePath, disabledRules = [], tier = "free", ex
4528
4557
  });
4529
4558
  }
4530
4559
  }
4531
- return findings;
4560
+ return deduplicateFindings(findings);
4532
4561
  }
4533
4562
 
4534
4563
  // src/rule-counts.ts
@@ -5156,7 +5185,8 @@ function scanEntropy(files) {
5156
5185
  if (value.includes("${")) continue;
5157
5186
  if (value.includes("\\(")) continue;
5158
5187
  if (value.includes("#{") || value.includes("{{")) continue;
5159
- if (SAFE_PATTERNS.some((p) => p.test(value))) continue;
5188
+ const isUuidShape = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value);
5189
+ if (!isUuidShape && SAFE_PATTERNS.some((p) => p.test(value))) continue;
5160
5190
  if (HASH_PREFIX_RE.test(value)) continue;
5161
5191
  if (SAFE_VAR_NAMES.test(beforeAssign)) continue;
5162
5192
  if (/^https?:\/\/[^:@]*$/.test(value)) continue;
@@ -5167,9 +5197,10 @@ function scanEntropy(files) {
5167
5197
  if (isHex) threshold = 3;
5168
5198
  else if (isBase64) threshold = 4.5;
5169
5199
  if (value.length < 20) continue;
5170
- const entropy = shannonEntropy(value);
5171
- if (entropy < threshold) continue;
5172
5200
  const varName = variableName || dotenvName || beforeAssign.match(/["']([^"']+)["']\s*$/)?.[1] || beforeAssign.match(/([\w$-]+)\s*$/)?.[1] || "";
5201
+ if (isUuidShape && !isSecretVariableName(varName)) continue;
5202
+ const entropy = shannonEntropy(value);
5203
+ if (entropy < threshold && !(isUuidShape && isSecretVariableName(varName))) continue;
5173
5204
  if (HUMAN_READABLE_ENV_REFERENCE_RE.test(value) && !isSecretVariableName(varName)) {
5174
5205
  continue;
5175
5206
  }
@@ -9705,6 +9736,7 @@ export {
9705
9736
  consoleLogProduction,
9706
9737
  corsWildcard,
9707
9738
  dangerousInnerHTML,
9739
+ deduplicateFindings,
9708
9740
  detectBuilder,
9709
9741
  detectExposedConfig,
9710
9742
  detectFramework,