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.d.cts
CHANGED
|
@@ -169,7 +169,7 @@ interface CustomRule {
|
|
|
169
169
|
* before a scan can be saved without enough provenance to explain a changed
|
|
170
170
|
* grade.
|
|
171
171
|
*/
|
|
172
|
-
declare const SCANNER_VERSION = "2.4.
|
|
172
|
+
declare const SCANNER_VERSION = "2.4.35";
|
|
173
173
|
|
|
174
174
|
/**
|
|
175
175
|
* Line-oriented helpers shared by every rule. Pure string manipulation — no fs
|
package/dist/index.d.ts
CHANGED
|
@@ -169,7 +169,7 @@ interface CustomRule {
|
|
|
169
169
|
* before a scan can be saved without enough provenance to explain a changed
|
|
170
170
|
* grade.
|
|
171
171
|
*/
|
|
172
|
-
declare const SCANNER_VERSION = "2.4.
|
|
172
|
+
declare const SCANNER_VERSION = "2.4.35";
|
|
173
173
|
|
|
174
174
|
/**
|
|
175
175
|
* Line-oriented helpers shared by every rule. Pure string manipulation — no fs
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/version.ts
|
|
2
|
-
var SCANNER_VERSION = "2.4.
|
|
2
|
+
var SCANNER_VERSION = "2.4.35";
|
|
3
3
|
|
|
4
4
|
// src/snippet.ts
|
|
5
5
|
var cacheContent = null;
|
|
@@ -10216,9 +10216,8 @@ if (!(perCallTimeoutMs(AI_FILTER_BUDGET_MS) < AI_FILTER_BUDGET_MS)) {
|
|
|
10216
10216
|
throw new Error("per-call AI timeout must be strictly below the filter budget");
|
|
10217
10217
|
}
|
|
10218
10218
|
function isAbortError(err) {
|
|
10219
|
-
|
|
10220
|
-
|
|
10221
|
-
return name === "AbortError" || name === "APIUserAbortError";
|
|
10219
|
+
const { category } = classifyModelError(err);
|
|
10220
|
+
return category === "abort" || category === "timeout";
|
|
10222
10221
|
}
|
|
10223
10222
|
function isTimeoutError(err) {
|
|
10224
10223
|
if (!err || typeof err !== "object") return false;
|
|
@@ -10232,11 +10231,6 @@ function errorHttpStatus(err) {
|
|
|
10232
10231
|
const status = err.status;
|
|
10233
10232
|
return typeof status === "number" && Number.isFinite(status) ? Math.trunc(status) : null;
|
|
10234
10233
|
}
|
|
10235
|
-
function callWasAborted(err) {
|
|
10236
|
-
if (!err || typeof err !== "object") return false;
|
|
10237
|
-
const name = "name" in err ? String(err.name) : "";
|
|
10238
|
-
return name === "AbortError" || name === "APIUserAbortError";
|
|
10239
|
-
}
|
|
10240
10234
|
var SAFE_ERROR_IDENT = /^[A-Za-z][A-Za-z0-9_]{0,63}$/;
|
|
10241
10235
|
var SAFE_ERROR_CODE = /^[A-Z][A-Z0-9_]{1,47}$/;
|
|
10242
10236
|
function safeIdent(value) {
|
|
@@ -10253,9 +10247,15 @@ function errorClassChain(err) {
|
|
|
10253
10247
|
}
|
|
10254
10248
|
return names;
|
|
10255
10249
|
}
|
|
10256
|
-
|
|
10250
|
+
var TIMEOUT_CAUSE_CODES = /* @__PURE__ */ new Set([
|
|
10251
|
+
"ETIMEDOUT",
|
|
10252
|
+
"ESOCKETTIMEDOUT",
|
|
10253
|
+
"UND_ERR_CONNECT_TIMEOUT",
|
|
10254
|
+
"UND_ERR_HEADERS_TIMEOUT"
|
|
10255
|
+
]);
|
|
10256
|
+
function causeInfo(err) {
|
|
10257
10257
|
const cause = err.cause;
|
|
10258
|
-
if (!cause || typeof cause !== "object") return null;
|
|
10258
|
+
if (!cause || typeof cause !== "object") return { label: null, code: null };
|
|
10259
10259
|
const chain = errorClassChain(cause);
|
|
10260
10260
|
const name = chain[0] ?? safeIdent(cause.name);
|
|
10261
10261
|
let code = null;
|
|
@@ -10265,8 +10265,8 @@ function causeLabel(err) {
|
|
|
10265
10265
|
if (typeof raw === "string" && SAFE_ERROR_CODE.test(raw)) code = raw;
|
|
10266
10266
|
node = node.cause;
|
|
10267
10267
|
}
|
|
10268
|
-
if (!name && !code) return null;
|
|
10269
|
-
return code ? `${name ?? "unknown"}/${code}` : name;
|
|
10268
|
+
if (!name && !code) return { label: null, code: null };
|
|
10269
|
+
return { label: code ? `${name ?? "unknown"}/${code}` : name, code };
|
|
10270
10270
|
}
|
|
10271
10271
|
function classifyModelError(err) {
|
|
10272
10272
|
if (!err || typeof err !== "object") {
|
|
@@ -10279,17 +10279,18 @@ function classifyModelError(err) {
|
|
|
10279
10279
|
const status = errorHttpStatus(err);
|
|
10280
10280
|
const names = new Set(chain);
|
|
10281
10281
|
if (ownName) names.add(ownName);
|
|
10282
|
+
const { label: cause, code: causeCode } = causeInfo(err);
|
|
10282
10283
|
let category = "unknown";
|
|
10283
10284
|
if (status === 401 || status === 403) category = "auth";
|
|
10284
10285
|
else if (status === 400) category = "bad_request";
|
|
10285
10286
|
else if (status === 429) category = "rate_limit";
|
|
10286
10287
|
else if (status != null && status >= 500) category = "server";
|
|
10287
10288
|
else if (status != null && status >= 400) category = "client";
|
|
10288
|
-
else if (names.has("APIConnectionTimeoutError") || names.has("TimeoutError")
|
|
10289
|
-
|
|
10289
|
+
else if (names.has("APIConnectionTimeoutError") || names.has("TimeoutError") || causeCode !== null && TIMEOUT_CAUSE_CODES.has(causeCode)) {
|
|
10290
|
+
category = "timeout";
|
|
10291
|
+
} else if (names.has("APIUserAbortError") || names.has("AbortError")) category = "abort";
|
|
10290
10292
|
else if (names.has("APIConnectionError")) category = "connection";
|
|
10291
|
-
|
|
10292
|
-
if (category === "unknown" && cause && cause.includes("/")) category = "connection";
|
|
10293
|
+
if (category === "unknown" && causeCode) category = "connection";
|
|
10293
10294
|
return { name, category, status, cause };
|
|
10294
10295
|
}
|
|
10295
10296
|
function isRetryableModelError(info) {
|
|
@@ -10646,7 +10647,7 @@ async function filterFalsePositives(findings, fileContents, budgetMs = AI_FILTER
|
|
|
10646
10647
|
const totalBefore = findings.length;
|
|
10647
10648
|
let client;
|
|
10648
10649
|
try {
|
|
10649
|
-
client = new Anthropic();
|
|
10650
|
+
client = retryTransient ? new Anthropic({ maxRetries: 1 }) : new Anthropic();
|
|
10650
10651
|
} catch {
|
|
10651
10652
|
if (budgetTimer) clearTimeout(budgetTimer);
|
|
10652
10653
|
return early("failed", "client_init", {
|
|
@@ -10662,6 +10663,7 @@ async function filterFalsePositives(findings, fileContents, budgetMs = AI_FILTER
|
|
|
10662
10663
|
let firstErrorStatus = null;
|
|
10663
10664
|
let authFailed = false;
|
|
10664
10665
|
let badOutput = false;
|
|
10666
|
+
let exceptionFailure = false;
|
|
10665
10667
|
const maskStats = { prompt_batches: 0, prompt_chars: 0, masked_count: 0, had_secret_pattern: false, raw_after_mask: 0 };
|
|
10666
10668
|
let failedBatches = 0;
|
|
10667
10669
|
let failedFindingCount = 0;
|
|
@@ -10746,6 +10748,8 @@ async function filterFalsePositives(findings, fileContents, budgetMs = AI_FILTER
|
|
|
10746
10748
|
return;
|
|
10747
10749
|
}
|
|
10748
10750
|
let active = targets;
|
|
10751
|
+
let callAborted = false;
|
|
10752
|
+
let malformed = false;
|
|
10749
10753
|
try {
|
|
10750
10754
|
const remaining = Math.max(1, deadlineMs - Date.now());
|
|
10751
10755
|
const fences = assignFileFences(targets, fileContents);
|
|
@@ -10808,7 +10812,6 @@ async function filterFalsePositives(findings, fileContents, budgetMs = AI_FILTER
|
|
|
10808
10812
|
);
|
|
10809
10813
|
}
|
|
10810
10814
|
const perCall = perCallTimeoutMs(budgetMs);
|
|
10811
|
-
let callAborted = false;
|
|
10812
10815
|
const send = async (callTimeout) => {
|
|
10813
10816
|
const callAbort = new AbortController();
|
|
10814
10817
|
const onParentAbort = () => callAbort.abort();
|
|
@@ -10860,6 +10863,7 @@ async function filterFalsePositives(findings, fileContents, budgetMs = AI_FILTER
|
|
|
10860
10863
|
const results = parseReviewResponse(text);
|
|
10861
10864
|
if (!results) {
|
|
10862
10865
|
badOutput = true;
|
|
10866
|
+
malformed = true;
|
|
10863
10867
|
throw new Error("AI review returned malformed JSON");
|
|
10864
10868
|
}
|
|
10865
10869
|
const multiFile = files.length > 1;
|
|
@@ -10898,6 +10902,7 @@ async function filterFalsePositives(findings, fileContents, budgetMs = AI_FILTER
|
|
|
10898
10902
|
if (unmatched > 0) {
|
|
10899
10903
|
failedFindingCount += unmatched;
|
|
10900
10904
|
failedBatches++;
|
|
10905
|
+
exceptionFailure = true;
|
|
10901
10906
|
if (!firstError) firstError = new Error("AI review returned incomplete verdicts");
|
|
10902
10907
|
}
|
|
10903
10908
|
} catch (err) {
|
|
@@ -10913,7 +10918,7 @@ async function filterFalsePositives(findings, fileContents, budgetMs = AI_FILTER
|
|
|
10913
10918
|
console.error(`[ai-fp-filter] AI review failed: auth status ${status2}`);
|
|
10914
10919
|
return;
|
|
10915
10920
|
}
|
|
10916
|
-
const callTimedOut = isAbortError(err) || isTimeoutError(err) || abortController.signal.aborted
|
|
10921
|
+
const callTimedOut = callAborted || isAbortError(err) || isTimeoutError(err) || abortController.signal.aborted;
|
|
10917
10922
|
if (callTimedOut) {
|
|
10918
10923
|
timedOutCount += active.length;
|
|
10919
10924
|
budgetExpired = true;
|
|
@@ -10921,6 +10926,7 @@ async function filterFalsePositives(findings, fileContents, budgetMs = AI_FILTER
|
|
|
10921
10926
|
}
|
|
10922
10927
|
failedBatches++;
|
|
10923
10928
|
failedFindingCount += active.length;
|
|
10929
|
+
if (status2 == null && !malformed) exceptionFailure = true;
|
|
10924
10930
|
if (!firstError) {
|
|
10925
10931
|
firstError = err;
|
|
10926
10932
|
firstErrorStatus = status2;
|
|
@@ -10984,6 +10990,9 @@ async function filterFalsePositives(findings, fileContents, budgetMs = AI_FILTER
|
|
|
10984
10990
|
} else if (totalBefore > 0 && reviewedCount === totalBefore) {
|
|
10985
10991
|
status = "reviewed";
|
|
10986
10992
|
reason = null;
|
|
10993
|
+
} else if (reviewedCount === 0 && exceptionFailure && (timedOut || budgetExpired && tasks.length > 0)) {
|
|
10994
|
+
status = "failed";
|
|
10995
|
+
reason = "exception";
|
|
10987
10996
|
} else if (reviewedCount === 0 && (timedOut || budgetExpired && tasks.length > 0)) {
|
|
10988
10997
|
status = "failed";
|
|
10989
10998
|
reason = "budget_timeout";
|