xploitscan-shared-rules 2.4.33 → 2.4.35
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 +29 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +29 -20
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -236,7 +236,7 @@ __export(index_exports, {
|
|
|
236
236
|
module.exports = __toCommonJS(index_exports);
|
|
237
237
|
|
|
238
238
|
// src/version.ts
|
|
239
|
-
var SCANNER_VERSION = "2.4.
|
|
239
|
+
var SCANNER_VERSION = "2.4.35";
|
|
240
240
|
|
|
241
241
|
// src/snippet.ts
|
|
242
242
|
var cacheContent = null;
|
|
@@ -10453,9 +10453,8 @@ if (!(perCallTimeoutMs(AI_FILTER_BUDGET_MS) < AI_FILTER_BUDGET_MS)) {
|
|
|
10453
10453
|
throw new Error("per-call AI timeout must be strictly below the filter budget");
|
|
10454
10454
|
}
|
|
10455
10455
|
function isAbortError(err) {
|
|
10456
|
-
|
|
10457
|
-
|
|
10458
|
-
return name === "AbortError" || name === "APIUserAbortError";
|
|
10456
|
+
const { category } = classifyModelError(err);
|
|
10457
|
+
return category === "abort" || category === "timeout";
|
|
10459
10458
|
}
|
|
10460
10459
|
function isTimeoutError(err) {
|
|
10461
10460
|
if (!err || typeof err !== "object") return false;
|
|
@@ -10469,11 +10468,6 @@ function errorHttpStatus(err) {
|
|
|
10469
10468
|
const status = err.status;
|
|
10470
10469
|
return typeof status === "number" && Number.isFinite(status) ? Math.trunc(status) : null;
|
|
10471
10470
|
}
|
|
10472
|
-
function callWasAborted(err) {
|
|
10473
|
-
if (!err || typeof err !== "object") return false;
|
|
10474
|
-
const name = "name" in err ? String(err.name) : "";
|
|
10475
|
-
return name === "AbortError" || name === "APIUserAbortError";
|
|
10476
|
-
}
|
|
10477
10471
|
var SAFE_ERROR_IDENT = /^[A-Za-z][A-Za-z0-9_]{0,63}$/;
|
|
10478
10472
|
var SAFE_ERROR_CODE = /^[A-Z][A-Z0-9_]{1,47}$/;
|
|
10479
10473
|
function safeIdent(value) {
|
|
@@ -10490,9 +10484,15 @@ function errorClassChain(err) {
|
|
|
10490
10484
|
}
|
|
10491
10485
|
return names;
|
|
10492
10486
|
}
|
|
10493
|
-
|
|
10487
|
+
var TIMEOUT_CAUSE_CODES = /* @__PURE__ */ new Set([
|
|
10488
|
+
"ETIMEDOUT",
|
|
10489
|
+
"ESOCKETTIMEDOUT",
|
|
10490
|
+
"UND_ERR_CONNECT_TIMEOUT",
|
|
10491
|
+
"UND_ERR_HEADERS_TIMEOUT"
|
|
10492
|
+
]);
|
|
10493
|
+
function causeInfo(err) {
|
|
10494
10494
|
const cause = err.cause;
|
|
10495
|
-
if (!cause || typeof cause !== "object") return null;
|
|
10495
|
+
if (!cause || typeof cause !== "object") return { label: null, code: null };
|
|
10496
10496
|
const chain = errorClassChain(cause);
|
|
10497
10497
|
const name = chain[0] ?? safeIdent(cause.name);
|
|
10498
10498
|
let code = null;
|
|
@@ -10502,8 +10502,8 @@ function causeLabel(err) {
|
|
|
10502
10502
|
if (typeof raw === "string" && SAFE_ERROR_CODE.test(raw)) code = raw;
|
|
10503
10503
|
node = node.cause;
|
|
10504
10504
|
}
|
|
10505
|
-
if (!name && !code) return null;
|
|
10506
|
-
return code ? `${name ?? "unknown"}/${code}` : name;
|
|
10505
|
+
if (!name && !code) return { label: null, code: null };
|
|
10506
|
+
return { label: code ? `${name ?? "unknown"}/${code}` : name, code };
|
|
10507
10507
|
}
|
|
10508
10508
|
function classifyModelError(err) {
|
|
10509
10509
|
if (!err || typeof err !== "object") {
|
|
@@ -10516,17 +10516,18 @@ function classifyModelError(err) {
|
|
|
10516
10516
|
const status = errorHttpStatus(err);
|
|
10517
10517
|
const names = new Set(chain);
|
|
10518
10518
|
if (ownName) names.add(ownName);
|
|
10519
|
+
const { label: cause, code: causeCode } = causeInfo(err);
|
|
10519
10520
|
let category = "unknown";
|
|
10520
10521
|
if (status === 401 || status === 403) category = "auth";
|
|
10521
10522
|
else if (status === 400) category = "bad_request";
|
|
10522
10523
|
else if (status === 429) category = "rate_limit";
|
|
10523
10524
|
else if (status != null && status >= 500) category = "server";
|
|
10524
10525
|
else if (status != null && status >= 400) category = "client";
|
|
10525
|
-
else if (names.has("APIConnectionTimeoutError") || names.has("TimeoutError")
|
|
10526
|
-
|
|
10526
|
+
else if (names.has("APIConnectionTimeoutError") || names.has("TimeoutError") || causeCode !== null && TIMEOUT_CAUSE_CODES.has(causeCode)) {
|
|
10527
|
+
category = "timeout";
|
|
10528
|
+
} else if (names.has("APIUserAbortError") || names.has("AbortError")) category = "abort";
|
|
10527
10529
|
else if (names.has("APIConnectionError")) category = "connection";
|
|
10528
|
-
|
|
10529
|
-
if (category === "unknown" && cause && cause.includes("/")) category = "connection";
|
|
10530
|
+
if (category === "unknown" && causeCode) category = "connection";
|
|
10530
10531
|
return { name, category, status, cause };
|
|
10531
10532
|
}
|
|
10532
10533
|
function isRetryableModelError(info) {
|
|
@@ -10883,7 +10884,7 @@ async function filterFalsePositives(findings, fileContents, budgetMs = AI_FILTER
|
|
|
10883
10884
|
const totalBefore = findings.length;
|
|
10884
10885
|
let client;
|
|
10885
10886
|
try {
|
|
10886
|
-
client = new import_sdk.default();
|
|
10887
|
+
client = retryTransient ? new import_sdk.default({ maxRetries: 1 }) : new import_sdk.default();
|
|
10887
10888
|
} catch {
|
|
10888
10889
|
if (budgetTimer) clearTimeout(budgetTimer);
|
|
10889
10890
|
return early("failed", "client_init", {
|
|
@@ -10899,6 +10900,7 @@ async function filterFalsePositives(findings, fileContents, budgetMs = AI_FILTER
|
|
|
10899
10900
|
let firstErrorStatus = null;
|
|
10900
10901
|
let authFailed = false;
|
|
10901
10902
|
let badOutput = false;
|
|
10903
|
+
let exceptionFailure = false;
|
|
10902
10904
|
const maskStats = { prompt_batches: 0, prompt_chars: 0, masked_count: 0, had_secret_pattern: false, raw_after_mask: 0 };
|
|
10903
10905
|
let failedBatches = 0;
|
|
10904
10906
|
let failedFindingCount = 0;
|
|
@@ -10983,6 +10985,8 @@ async function filterFalsePositives(findings, fileContents, budgetMs = AI_FILTER
|
|
|
10983
10985
|
return;
|
|
10984
10986
|
}
|
|
10985
10987
|
let active = targets;
|
|
10988
|
+
let callAborted = false;
|
|
10989
|
+
let malformed = false;
|
|
10986
10990
|
try {
|
|
10987
10991
|
const remaining = Math.max(1, deadlineMs - Date.now());
|
|
10988
10992
|
const fences = assignFileFences(targets, fileContents);
|
|
@@ -11045,7 +11049,6 @@ async function filterFalsePositives(findings, fileContents, budgetMs = AI_FILTER
|
|
|
11045
11049
|
);
|
|
11046
11050
|
}
|
|
11047
11051
|
const perCall = perCallTimeoutMs(budgetMs);
|
|
11048
|
-
let callAborted = false;
|
|
11049
11052
|
const send = async (callTimeout) => {
|
|
11050
11053
|
const callAbort = new AbortController();
|
|
11051
11054
|
const onParentAbort = () => callAbort.abort();
|
|
@@ -11097,6 +11100,7 @@ async function filterFalsePositives(findings, fileContents, budgetMs = AI_FILTER
|
|
|
11097
11100
|
const results = parseReviewResponse(text);
|
|
11098
11101
|
if (!results) {
|
|
11099
11102
|
badOutput = true;
|
|
11103
|
+
malformed = true;
|
|
11100
11104
|
throw new Error("AI review returned malformed JSON");
|
|
11101
11105
|
}
|
|
11102
11106
|
const multiFile = files.length > 1;
|
|
@@ -11135,6 +11139,7 @@ async function filterFalsePositives(findings, fileContents, budgetMs = AI_FILTER
|
|
|
11135
11139
|
if (unmatched > 0) {
|
|
11136
11140
|
failedFindingCount += unmatched;
|
|
11137
11141
|
failedBatches++;
|
|
11142
|
+
exceptionFailure = true;
|
|
11138
11143
|
if (!firstError) firstError = new Error("AI review returned incomplete verdicts");
|
|
11139
11144
|
}
|
|
11140
11145
|
} catch (err) {
|
|
@@ -11150,7 +11155,7 @@ async function filterFalsePositives(findings, fileContents, budgetMs = AI_FILTER
|
|
|
11150
11155
|
console.error(`[ai-fp-filter] AI review failed: auth status ${status2}`);
|
|
11151
11156
|
return;
|
|
11152
11157
|
}
|
|
11153
|
-
const callTimedOut = isAbortError(err) || isTimeoutError(err) || abortController.signal.aborted
|
|
11158
|
+
const callTimedOut = callAborted || isAbortError(err) || isTimeoutError(err) || abortController.signal.aborted;
|
|
11154
11159
|
if (callTimedOut) {
|
|
11155
11160
|
timedOutCount += active.length;
|
|
11156
11161
|
budgetExpired = true;
|
|
@@ -11158,6 +11163,7 @@ async function filterFalsePositives(findings, fileContents, budgetMs = AI_FILTER
|
|
|
11158
11163
|
}
|
|
11159
11164
|
failedBatches++;
|
|
11160
11165
|
failedFindingCount += active.length;
|
|
11166
|
+
if (status2 == null && !malformed) exceptionFailure = true;
|
|
11161
11167
|
if (!firstError) {
|
|
11162
11168
|
firstError = err;
|
|
11163
11169
|
firstErrorStatus = status2;
|
|
@@ -11221,6 +11227,9 @@ async function filterFalsePositives(findings, fileContents, budgetMs = AI_FILTER
|
|
|
11221
11227
|
} else if (totalBefore > 0 && reviewedCount === totalBefore) {
|
|
11222
11228
|
status = "reviewed";
|
|
11223
11229
|
reason = null;
|
|
11230
|
+
} else if (reviewedCount === 0 && exceptionFailure && (timedOut || budgetExpired && tasks.length > 0)) {
|
|
11231
|
+
status = "failed";
|
|
11232
|
+
reason = "exception";
|
|
11224
11233
|
} else if (reviewedCount === 0 && (timedOut || budgetExpired && tasks.length > 0)) {
|
|
11225
11234
|
status = "failed";
|
|
11226
11235
|
reason = "budget_timeout";
|