xploitscan-shared-rules 1.15.0 → 1.15.2

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
@@ -646,6 +646,26 @@ function vendoredReason(filePath) {
646
646
  return null;
647
647
  }
648
648
 
649
+ // src/silencing.ts
650
+ function isInlineSilenced(content, matchIndex, ruleId) {
651
+ const lines = content.split("\n");
652
+ const matchLineNum = content.substring(0, matchIndex).split("\n").length - 1;
653
+ return isLineSilenced(lines, matchLineNum, ruleId);
654
+ }
655
+ function isLineSilenced(lines, lineIdx, ruleId) {
656
+ const matchLine = lines[lineIdx] ?? "";
657
+ const marker = new RegExp(`(?://|/\\*|#)\\s*(?:${ruleId}|scanner)-OK\\b`, "i");
658
+ if (marker.test(matchLine)) return true;
659
+ const COMMENT_LINE = /^\s*[{(]?\s*(?:\/\/|#|\/\*|\*)/;
660
+ const MAX_BLOCK_LINES = 20;
661
+ for (let i = lineIdx - 1, seen = 0; i >= 0 && seen < MAX_BLOCK_LINES; i--, seen++) {
662
+ const line = lines[i] ?? "";
663
+ if (marker.test(line)) return true;
664
+ if (!COMMENT_LINE.test(line)) break;
665
+ }
666
+ return false;
667
+ }
668
+
649
669
  // src/ast/parse.ts
650
670
  var import_parser = require("@babel/parser");
651
671
  var MAX_CACHE = 256;
@@ -1244,17 +1264,6 @@ function isInsideFixMessage(content, matchIndex) {
1244
1264
  const lineText = content.substring(lineStart, content.indexOf("\n", matchIndex));
1245
1265
  return /(?:fix|description|message|suggestion|hint|help|example|doc|comment)\s*[:=]\s*["'`]/i.test(lineText) || /return\s*["'`].*\b(?:Use|Replace|Add|Move|Set|Enable|Disable|Never|Don't|Do not|Instead)\b/i.test(lineText);
1246
1266
  }
1247
- function isInlineSilenced(content, matchIndex, ruleId) {
1248
- const lines = content.split("\n");
1249
- const matchLineNum = content.substring(0, matchIndex).split("\n").length - 1;
1250
- const matchLine = lines[matchLineNum] ?? "";
1251
- const prevLine = matchLineNum > 0 ? lines[matchLineNum - 1] ?? "" : "";
1252
- const marker = new RegExp(
1253
- `(?://|/\\*|#)\\s*(?:${ruleId}|scanner)-OK\\b`,
1254
- "i"
1255
- );
1256
- return marker.test(matchLine) || marker.test(prevLine);
1257
- }
1258
1267
  function filterSilenced(matches, content, ruleId) {
1259
1268
  if (matches.length === 0) return matches;
1260
1269
  const lines = content.split("\n");
@@ -1513,11 +1522,11 @@ var missingAuthMiddleware = {
1513
1522
  pattern,
1514
1523
  missingAuthMiddleware,
1515
1524
  filePath,
1516
- () => "Add authentication middleware to protect this route. Check the user's session/token before processing the request."
1525
+ () => "Add authentication middleware to protect this route. Check the user's session/token before processing the request. If the endpoint is public by design (an OG image, an embeddable badge, a health check), add an inline `// VC003-OK: <reason>` comment above the handler to silence."
1517
1526
  )
1518
1527
  );
1519
1528
  }
1520
- return matches;
1529
+ return filterSilenced(matches, content, "VC003");
1521
1530
  }
1522
1531
  };
1523
1532
  var supabaseNoRLS = {
@@ -9051,6 +9060,17 @@ async function filterFalsePositives(findings, fileContents) {
9051
9060
  {
9052
9061
  model: "claude-haiku-4-5-20251001",
9053
9062
  max_tokens: 1024,
9063
+ // Pinned, NOT left to the API default of 1.0. This is a binary
9064
+ // classification (real vs. false positive), not generation — there
9065
+ // is no upside to sampling variety and a real downside to it: a
9066
+ // filtered finding is a finding the user never sees, so drift here
9067
+ // means scanning the same unchanged code twice can yield different
9068
+ // results. Temperature 0 does not make the model bit-deterministic
9069
+ // (Anthropic makes no such guarantee), but it removes the one
9070
+ // variance source that was ours to control. See
9071
+ // scripts/fp-filter-repeatability.cjs for the measured flip rate,
9072
+ // and the assertion in ai-fp-filter.test.ts that keeps it pinned.
9073
+ temperature: 0,
9054
9074
  system: REVIEW_SYSTEM_PROMPT,
9055
9075
  messages: [{ role: "user", content: prompt }]
9056
9076
  },
@@ -9262,6 +9282,7 @@ function scanEntropy(files) {
9262
9282
  if (HASH_LIKE_VAR_NAMES.test(varName) && (isHex || isBase64)) continue;
9263
9283
  const isLikelySecret = SECRET_VAR_NAMES.test(varName);
9264
9284
  if (entropy < 4.5 && !isLikelySecret) continue;
9285
+ if (isLineSilenced(lines, i, "ENTROPY")) continue;
9265
9286
  const masked = value.substring(0, 6) + "..." + value.substring(value.length - 4);
9266
9287
  findings.push({
9267
9288
  ...vendored ? { vendored: true } : {},
@@ -9273,7 +9294,7 @@ function scanEntropy(files) {
9273
9294
  file: filePath,
9274
9295
  line: i + 1,
9275
9296
  snippet: getSnippet2(content, i + 1),
9276
- fix: "If this is a secret, move it to an environment variable. If it's not a secret (e.g., hash, encoded data), add it to .xploitscanignore.",
9297
+ fix: "If this is a secret, move it to an environment variable. If it's not a secret (e.g. a hash, encoded data, or a public verification token), add an inline `// ENTROPY-OK: <reason>` comment above the line, or add the file to .xploitscanignore.",
9277
9298
  category: "Secrets",
9278
9299
  source: "custom",
9279
9300
  owasp: "A02:2021",