@agent-inspect/eval 6.14.1 → 6.14.2
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 +54 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +54 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -221,6 +221,53 @@ function runCircuits(events, options = {}) {
|
|
|
221
221
|
const ok = !results.some((result) => result.status === "open" && result.severity === "error");
|
|
222
222
|
return { ok, results };
|
|
223
223
|
}
|
|
224
|
+
|
|
225
|
+
// packages/redact/src/sensitive-key.ts
|
|
226
|
+
function normalizeSensitiveKey(value) {
|
|
227
|
+
return value.toLowerCase().replace(/[^a-z0-9_]/g, "");
|
|
228
|
+
}
|
|
229
|
+
var NON_CREDENTIAL_TOKEN_CONFIG_KEYS = new Set(
|
|
230
|
+
[
|
|
231
|
+
"tokens",
|
|
232
|
+
"max_tokens",
|
|
233
|
+
"min_tokens",
|
|
234
|
+
"ls_max_tokens",
|
|
235
|
+
"token_count",
|
|
236
|
+
"token_limit",
|
|
237
|
+
"token_budget",
|
|
238
|
+
"input_tokens",
|
|
239
|
+
"output_tokens",
|
|
240
|
+
"total_tokens",
|
|
241
|
+
"cached_tokens",
|
|
242
|
+
"prompt_tokens",
|
|
243
|
+
"completion_tokens"
|
|
244
|
+
].map(normalizeSensitiveKey)
|
|
245
|
+
);
|
|
246
|
+
function isTokenCredentialKey(normalized) {
|
|
247
|
+
if (NON_CREDENTIAL_TOKEN_CONFIG_KEYS.has(normalized)) return false;
|
|
248
|
+
if (normalized === "token") return true;
|
|
249
|
+
if (normalized.endsWith("tokens")) return false;
|
|
250
|
+
return normalized.endsWith("token");
|
|
251
|
+
}
|
|
252
|
+
function isCredentialSensitiveKey(key, sensitiveKeys) {
|
|
253
|
+
if (!key) return false;
|
|
254
|
+
const normalized = normalizeSensitiveKey(key);
|
|
255
|
+
if (!normalized) return false;
|
|
256
|
+
if (NON_CREDENTIAL_TOKEN_CONFIG_KEYS.has(normalized)) return false;
|
|
257
|
+
for (const sensitive of sensitiveKeys) {
|
|
258
|
+
const s = normalizeSensitiveKey(sensitive);
|
|
259
|
+
if (!s) continue;
|
|
260
|
+
if (s === "token") {
|
|
261
|
+
if (isTokenCredentialKey(normalized)) return true;
|
|
262
|
+
continue;
|
|
263
|
+
}
|
|
264
|
+
if (normalized === s) return true;
|
|
265
|
+
if (normalized.endsWith(`_${s}`) || normalized.startsWith(`${s}_`)) return true;
|
|
266
|
+
}
|
|
267
|
+
return false;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// packages/redact/src/index.ts
|
|
224
271
|
var DEFAULT_REDACT_KEYS = [
|
|
225
272
|
"authorization",
|
|
226
273
|
"cookie",
|
|
@@ -282,6 +329,12 @@ function isRecord(value) {
|
|
|
282
329
|
function toKey(key) {
|
|
283
330
|
return key.toLowerCase();
|
|
284
331
|
}
|
|
332
|
+
function findCompiledKeyRule(key, rules) {
|
|
333
|
+
const exact = toKey(key);
|
|
334
|
+
const direct = rules.find((candidate) => candidate.key === exact);
|
|
335
|
+
if (direct) return direct;
|
|
336
|
+
return rules.find((candidate) => isCredentialSensitiveKey(key, [candidate.key]));
|
|
337
|
+
}
|
|
285
338
|
function stableHash(value) {
|
|
286
339
|
const hash = crypto__default.default.createHash("sha256").update(value, "utf8").digest("hex");
|
|
287
340
|
return hash.slice(0, 8);
|
|
@@ -603,7 +656,7 @@ var Redactor = class {
|
|
|
603
656
|
return "[Truncated]";
|
|
604
657
|
}
|
|
605
658
|
if (key !== void 0) {
|
|
606
|
-
const rule = this.#rules
|
|
659
|
+
const rule = findCompiledKeyRule(key, this.#rules);
|
|
607
660
|
if (rule) {
|
|
608
661
|
this.#recordFinding(
|
|
609
662
|
state,
|