xploitscan-shared-rules 1.15.1 → 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 = {
@@ -9000,6 +9009,7 @@ function scanEntropy(files) {
9000
9009
  if (HASH_LIKE_VAR_NAMES.test(varName) && (isHex || isBase64)) continue;
9001
9010
  const isLikelySecret = SECRET_VAR_NAMES.test(varName);
9002
9011
  if (entropy < 4.5 && !isLikelySecret) continue;
9012
+ if (isLineSilenced(lines, i, "ENTROPY")) continue;
9003
9013
  const masked = value.substring(0, 6) + "..." + value.substring(value.length - 4);
9004
9014
  findings.push({
9005
9015
  ...vendored ? { vendored: true } : {},
@@ -9011,7 +9021,7 @@ function scanEntropy(files) {
9011
9021
  file: filePath,
9012
9022
  line: i + 1,
9013
9023
  snippet: getSnippet2(content, i + 1),
9014
- 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.",
9015
9025
  category: "Secrets",
9016
9026
  source: "custom",
9017
9027
  owasp: "A02:2021",