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.cjs
CHANGED
|
@@ -8046,7 +8046,21 @@ For each finding, respond ONLY with a JSON array. No other text.
|
|
|
8046
8046
|
Each element: {"index": <number>, "verdict": "real" or "fp", "reason": "<1 sentence>"}`;
|
|
8047
8047
|
var MAX_FINDINGS_PER_BATCH = 15;
|
|
8048
8048
|
var MAX_CONTEXT_LINES = 10;
|
|
8049
|
-
var
|
|
8049
|
+
var DEFAULT_MAX_TOTAL_FINDINGS = 200;
|
|
8050
|
+
var MAX_TOTAL_FINDINGS = (() => {
|
|
8051
|
+
const raw = process.env.XPLOITSCAN_AI_FILTER_MAX;
|
|
8052
|
+
if (!raw) return DEFAULT_MAX_TOTAL_FINDINGS;
|
|
8053
|
+
const n = parseInt(raw, 10);
|
|
8054
|
+
if (!Number.isFinite(n) || n < 1) return DEFAULT_MAX_TOTAL_FINDINGS;
|
|
8055
|
+
return Math.min(n, 1e3);
|
|
8056
|
+
})();
|
|
8057
|
+
var SEVERITY_PRIORITY = {
|
|
8058
|
+
critical: 0,
|
|
8059
|
+
high: 1,
|
|
8060
|
+
medium: 2,
|
|
8061
|
+
low: 3,
|
|
8062
|
+
info: 4
|
|
8063
|
+
};
|
|
8050
8064
|
function getExpandedContext(content, line, contextLines = MAX_CONTEXT_LINES) {
|
|
8051
8065
|
const lines = content.split("\n");
|
|
8052
8066
|
const start = Math.max(0, line - 1 - contextLines);
|
|
@@ -8094,8 +8108,13 @@ async function filterFalsePositives(findings, fileContents) {
|
|
|
8094
8108
|
const empty = { findings, filteredFindings: [], aiReviewed: false, removedCount: 0, totalBefore: findings.length };
|
|
8095
8109
|
if (!process.env.ANTHROPIC_API_KEY) return empty;
|
|
8096
8110
|
if (findings.length === 0) return empty;
|
|
8097
|
-
const
|
|
8098
|
-
|
|
8111
|
+
const prioritized = [...findings].sort((a, b) => {
|
|
8112
|
+
const pa = SEVERITY_PRIORITY[(a.severity || "").toLowerCase()] ?? 5;
|
|
8113
|
+
const pb = SEVERITY_PRIORITY[(b.severity || "").toLowerCase()] ?? 5;
|
|
8114
|
+
return pa - pb;
|
|
8115
|
+
});
|
|
8116
|
+
const toReview = prioritized.slice(0, MAX_TOTAL_FINDINGS);
|
|
8117
|
+
const overflow = prioritized.slice(MAX_TOTAL_FINDINGS);
|
|
8099
8118
|
const totalBefore = findings.length;
|
|
8100
8119
|
const byFile = /* @__PURE__ */ new Map();
|
|
8101
8120
|
for (const f of toReview) {
|