xploitscan-shared-rules 2.4.8 → 2.4.9

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 CHANGED
@@ -66,6 +66,7 @@ __export(index_exports, {
66
66
  consoleLogProduction: () => consoleLogProduction,
67
67
  corsWildcard: () => corsWildcard,
68
68
  dangerousInnerHTML: () => dangerousInnerHTML,
69
+ deduplicateFindings: () => deduplicateFindings,
69
70
  detectBuilder: () => detectBuilder,
70
71
  detectExposedConfig: () => detectExposedConfig,
71
72
  detectFramework: () => detectFramework,
@@ -158,7 +159,7 @@ __export(index_exports, {
158
159
  module.exports = __toCommonJS(index_exports);
159
160
 
160
161
  // src/version.ts
161
- var SCANNER_VERSION = "2.4.8";
162
+ var SCANNER_VERSION = "2.4.9";
162
163
 
163
164
  // src/snippet.ts
164
165
  var cacheContent = null;
@@ -207,6 +208,28 @@ function getSnippet(content, line, contextLines = 2) {
207
208
  return out.join("\n");
208
209
  }
209
210
 
211
+ // src/dedupe.ts
212
+ function deduplicateFindings(findings) {
213
+ const seen = /* @__PURE__ */ new Set();
214
+ const unique = [];
215
+ for (const finding of findings) {
216
+ let key;
217
+ if (finding.rule === "VC001" || finding.rule === "ENTROPY") {
218
+ key = `hardcoded-secret:${finding.file}:${finding.line}`;
219
+ } else if (finding.rule === "VC014" || finding.rule === "MFA002") {
220
+ key = `env-not-ignored:${finding.file}:${finding.line}`;
221
+ } else if (finding.source === "gitleaks") {
222
+ key = `gitleaks-secret:${finding.file}:${finding.line}`;
223
+ } else {
224
+ key = `${finding.rule}:${finding.file}:${finding.line}:${finding.title}`;
225
+ }
226
+ if (seen.has(key)) continue;
227
+ seen.add(key);
228
+ unique.push(finding);
229
+ }
230
+ return unique;
231
+ }
232
+
210
233
  // src/silencing.ts
211
234
  function isInlineSilenced(content, matchIndex, ruleId) {
212
235
  const lines = content.split("\n");
@@ -2765,7 +2788,11 @@ var missingAuthMiddleware = {
2765
2788
  if (content[i] === "\n") lineStarts.push(i + 1);
2766
2789
  }
2767
2790
  const indexOfLine = (line) => lineStarts[Math.max(0, Math.min(line - 1, lineStarts.length - 1))];
2768
- const unauthenticated = matches.filter((m) => !handlerHasAuth(indexOfLine(m.line)));
2791
+ const isPublicRootGet = (index) => /\.\s*get\s*\(\s*["'`]\/["'`]\s*,/i.test(content.slice(index, index + 240));
2792
+ const unauthenticated = matches.filter((m) => {
2793
+ const index = indexOfLine(m.line);
2794
+ return !isPublicRootGet(index) && !handlerHasAuth(index);
2795
+ });
2769
2796
  if (serverSide || tanstackCandidate) {
2770
2797
  for (const idx of unauthenticatedTanStackHandlers(maskedForScope, filePath)) {
2771
2798
  const line = lineNumberAt(content, idx);
@@ -4687,7 +4714,7 @@ function runCustomRules(content, filePath, disabledRules = [], tier = "free", ex
4687
4714
  });
4688
4715
  }
4689
4716
  }
4690
- return findings;
4717
+ return deduplicateFindings(findings);
4691
4718
  }
4692
4719
 
4693
4720
  // src/rule-counts.ts
@@ -9865,6 +9892,7 @@ function scanQuality(input, rules = qualityRules) {
9865
9892
  consoleLogProduction,
9866
9893
  corsWildcard,
9867
9894
  dangerousInnerHTML,
9895
+ deduplicateFindings,
9868
9896
  detectBuilder,
9869
9897
  detectExposedConfig,
9870
9898
  detectFramework,