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.js CHANGED
@@ -373,6 +373,26 @@ function vendoredReason(filePath) {
373
373
  return null;
374
374
  }
375
375
 
376
+ // src/silencing.ts
377
+ function isInlineSilenced(content, matchIndex, ruleId) {
378
+ const lines = content.split("\n");
379
+ const matchLineNum = content.substring(0, matchIndex).split("\n").length - 1;
380
+ return isLineSilenced(lines, matchLineNum, ruleId);
381
+ }
382
+ function isLineSilenced(lines, lineIdx, ruleId) {
383
+ const matchLine = lines[lineIdx] ?? "";
384
+ const marker = new RegExp(`(?://|/\\*|#)\\s*(?:${ruleId}|scanner)-OK\\b`, "i");
385
+ if (marker.test(matchLine)) return true;
386
+ const COMMENT_LINE = /^\s*[{(]?\s*(?:\/\/|#|\/\*|\*)/;
387
+ const MAX_BLOCK_LINES = 20;
388
+ for (let i = lineIdx - 1, seen = 0; i >= 0 && seen < MAX_BLOCK_LINES; i--, seen++) {
389
+ const line = lines[i] ?? "";
390
+ if (marker.test(line)) return true;
391
+ if (!COMMENT_LINE.test(line)) break;
392
+ }
393
+ return false;
394
+ }
395
+
376
396
  // src/ast/parse.ts
377
397
  import { parse } from "@babel/parser";
378
398
  var MAX_CACHE = 256;
@@ -971,17 +991,6 @@ function isInsideFixMessage(content, matchIndex) {
971
991
  const lineText = content.substring(lineStart, content.indexOf("\n", matchIndex));
972
992
  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);
973
993
  }
974
- function isInlineSilenced(content, matchIndex, ruleId) {
975
- const lines = content.split("\n");
976
- const matchLineNum = content.substring(0, matchIndex).split("\n").length - 1;
977
- const matchLine = lines[matchLineNum] ?? "";
978
- const prevLine = matchLineNum > 0 ? lines[matchLineNum - 1] ?? "" : "";
979
- const marker = new RegExp(
980
- `(?://|/\\*|#)\\s*(?:${ruleId}|scanner)-OK\\b`,
981
- "i"
982
- );
983
- return marker.test(matchLine) || marker.test(prevLine);
984
- }
985
994
  function filterSilenced(matches, content, ruleId) {
986
995
  if (matches.length === 0) return matches;
987
996
  const lines = content.split("\n");
@@ -1240,11 +1249,11 @@ var missingAuthMiddleware = {
1240
1249
  pattern,
1241
1250
  missingAuthMiddleware,
1242
1251
  filePath,
1243
- () => "Add authentication middleware to protect this route. Check the user's session/token before processing the request."
1252
+ () => "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."
1244
1253
  )
1245
1254
  );
1246
1255
  }
1247
- return matches;
1256
+ return filterSilenced(matches, content, "VC003");
1248
1257
  }
1249
1258
  };
1250
1259
  var supabaseNoRLS = {
@@ -8778,6 +8787,17 @@ async function filterFalsePositives(findings, fileContents) {
8778
8787
  {
8779
8788
  model: "claude-haiku-4-5-20251001",
8780
8789
  max_tokens: 1024,
8790
+ // Pinned, NOT left to the API default of 1.0. This is a binary
8791
+ // classification (real vs. false positive), not generation — there
8792
+ // is no upside to sampling variety and a real downside to it: a
8793
+ // filtered finding is a finding the user never sees, so drift here
8794
+ // means scanning the same unchanged code twice can yield different
8795
+ // results. Temperature 0 does not make the model bit-deterministic
8796
+ // (Anthropic makes no such guarantee), but it removes the one
8797
+ // variance source that was ours to control. See
8798
+ // scripts/fp-filter-repeatability.cjs for the measured flip rate,
8799
+ // and the assertion in ai-fp-filter.test.ts that keeps it pinned.
8800
+ temperature: 0,
8781
8801
  system: REVIEW_SYSTEM_PROMPT,
8782
8802
  messages: [{ role: "user", content: prompt }]
8783
8803
  },
@@ -8989,6 +9009,7 @@ function scanEntropy(files) {
8989
9009
  if (HASH_LIKE_VAR_NAMES.test(varName) && (isHex || isBase64)) continue;
8990
9010
  const isLikelySecret = SECRET_VAR_NAMES.test(varName);
8991
9011
  if (entropy < 4.5 && !isLikelySecret) continue;
9012
+ if (isLineSilenced(lines, i, "ENTROPY")) continue;
8992
9013
  const masked = value.substring(0, 6) + "..." + value.substring(value.length - 4);
8993
9014
  findings.push({
8994
9015
  ...vendored ? { vendored: true } : {},
@@ -9000,7 +9021,7 @@ function scanEntropy(files) {
9000
9021
  file: filePath,
9001
9022
  line: i + 1,
9002
9023
  snippet: getSnippet2(content, i + 1),
9003
- 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.",
9024
+ 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.",
9004
9025
  category: "Secrets",
9005
9026
  source: "custom",
9006
9027
  owasp: "A02:2021",