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.cjs +24 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +24 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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 = {
|
|
@@ -9273,6 +9282,7 @@ function scanEntropy(files) {
|
|
|
9273
9282
|
if (HASH_LIKE_VAR_NAMES.test(varName) && (isHex || isBase64)) continue;
|
|
9274
9283
|
const isLikelySecret = SECRET_VAR_NAMES.test(varName);
|
|
9275
9284
|
if (entropy < 4.5 && !isLikelySecret) continue;
|
|
9285
|
+
if (isLineSilenced(lines, i, "ENTROPY")) continue;
|
|
9276
9286
|
const masked = value.substring(0, 6) + "..." + value.substring(value.length - 4);
|
|
9277
9287
|
findings.push({
|
|
9278
9288
|
...vendored ? { vendored: true } : {},
|
|
@@ -9284,7 +9294,7 @@ function scanEntropy(files) {
|
|
|
9284
9294
|
file: filePath,
|
|
9285
9295
|
line: i + 1,
|
|
9286
9296
|
snippet: getSnippet2(content, i + 1),
|
|
9287
|
-
fix: "If this is a secret, move it to an environment variable. If it's not a secret (e.g
|
|
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.",
|
|
9288
9298
|
category: "Secrets",
|
|
9289
9299
|
source: "custom",
|
|
9290
9300
|
owasp: "A02:2021",
|