@profullstack/threatcrush 0.19.0 → 0.19.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/daemon.js.map +1 -1
- package/dist/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -48409,11 +48409,20 @@ Answer with ONLY a JSON object, no prose, keys in this order:
|
|
|
48409
48409
|
function needsSource(finding) {
|
|
48410
48410
|
return finding.category === "code" && !finding.ruleId.startsWith("gha-ssh");
|
|
48411
48411
|
}
|
|
48412
|
+
var SELF_CONTRADICTION = /\bnot (?:attacker[- ]controlled|attacker[- ]influenced|user[- ]supplied|user[- ]controlled|from the user|controlled by (?:the )?(?:user|attacker))\b|\b(?:app(?:lication)?'s|its) own (?:backend|api|server|constants?)\b|\bnever ships?\b|\btest (?:value|file|fixture)\b/i;
|
|
48412
48413
|
function norm(s) {
|
|
48413
48414
|
return s.replace(/\s+/g, "").replace(/[`'"]/g, "");
|
|
48414
48415
|
}
|
|
48415
48416
|
function enforceEvidence(finding, context, text, parsed) {
|
|
48416
|
-
if (parsed.verdict !== "true_positive"
|
|
48417
|
+
if (parsed.verdict !== "true_positive") return parsed;
|
|
48418
|
+
if (SELF_CONTRADICTION.test(parsed.reason)) {
|
|
48419
|
+
return {
|
|
48420
|
+
verdict: "uncertain",
|
|
48421
|
+
confidence: Math.min(parsed.confidence, 0.5),
|
|
48422
|
+
reason: `model's verdict contradicts its own reasoning: ${parsed.reason}`
|
|
48423
|
+
};
|
|
48424
|
+
}
|
|
48425
|
+
if (!needsSource(finding)) return parsed;
|
|
48417
48426
|
let source = "";
|
|
48418
48427
|
try {
|
|
48419
48428
|
const obj = extractJson(text);
|