xploitscan-shared-rules 1.6.0 → 1.6.1
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 +22 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +22 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -7785,7 +7785,21 @@ For each finding, respond ONLY with a JSON array. No other text.
|
|
|
7785
7785
|
Each element: {"index": <number>, "verdict": "real" or "fp", "reason": "<1 sentence>"}`;
|
|
7786
7786
|
var MAX_FINDINGS_PER_BATCH = 15;
|
|
7787
7787
|
var MAX_CONTEXT_LINES = 10;
|
|
7788
|
-
var
|
|
7788
|
+
var DEFAULT_MAX_TOTAL_FINDINGS = 200;
|
|
7789
|
+
var MAX_TOTAL_FINDINGS = (() => {
|
|
7790
|
+
const raw = process.env.XPLOITSCAN_AI_FILTER_MAX;
|
|
7791
|
+
if (!raw) return DEFAULT_MAX_TOTAL_FINDINGS;
|
|
7792
|
+
const n = parseInt(raw, 10);
|
|
7793
|
+
if (!Number.isFinite(n) || n < 1) return DEFAULT_MAX_TOTAL_FINDINGS;
|
|
7794
|
+
return Math.min(n, 1e3);
|
|
7795
|
+
})();
|
|
7796
|
+
var SEVERITY_PRIORITY = {
|
|
7797
|
+
critical: 0,
|
|
7798
|
+
high: 1,
|
|
7799
|
+
medium: 2,
|
|
7800
|
+
low: 3,
|
|
7801
|
+
info: 4
|
|
7802
|
+
};
|
|
7789
7803
|
function getExpandedContext(content, line, contextLines = MAX_CONTEXT_LINES) {
|
|
7790
7804
|
const lines = content.split("\n");
|
|
7791
7805
|
const start = Math.max(0, line - 1 - contextLines);
|
|
@@ -7833,8 +7847,13 @@ async function filterFalsePositives(findings, fileContents) {
|
|
|
7833
7847
|
const empty = { findings, filteredFindings: [], aiReviewed: false, removedCount: 0, totalBefore: findings.length };
|
|
7834
7848
|
if (!process.env.ANTHROPIC_API_KEY) return empty;
|
|
7835
7849
|
if (findings.length === 0) return empty;
|
|
7836
|
-
const
|
|
7837
|
-
|
|
7850
|
+
const prioritized = [...findings].sort((a, b) => {
|
|
7851
|
+
const pa = SEVERITY_PRIORITY[(a.severity || "").toLowerCase()] ?? 5;
|
|
7852
|
+
const pb = SEVERITY_PRIORITY[(b.severity || "").toLowerCase()] ?? 5;
|
|
7853
|
+
return pa - pb;
|
|
7854
|
+
});
|
|
7855
|
+
const toReview = prioritized.slice(0, MAX_TOTAL_FINDINGS);
|
|
7856
|
+
const overflow = prioritized.slice(MAX_TOTAL_FINDINGS);
|
|
7838
7857
|
const totalBefore = findings.length;
|
|
7839
7858
|
const byFile = /* @__PURE__ */ new Map();
|
|
7840
7859
|
for (const f of toReview) {
|