@agent-inspect/eval 6.14.1 → 6.15.0
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.mjs
CHANGED
|
@@ -215,6 +215,53 @@ function runCircuits(events, options = {}) {
|
|
|
215
215
|
const ok = !results.some((result) => result.status === "open" && result.severity === "error");
|
|
216
216
|
return { ok, results };
|
|
217
217
|
}
|
|
218
|
+
|
|
219
|
+
// packages/redact/src/sensitive-key.ts
|
|
220
|
+
function normalizeSensitiveKey(value) {
|
|
221
|
+
return value.toLowerCase().replace(/[^a-z0-9_]/g, "");
|
|
222
|
+
}
|
|
223
|
+
var NON_CREDENTIAL_TOKEN_CONFIG_KEYS = new Set(
|
|
224
|
+
[
|
|
225
|
+
"tokens",
|
|
226
|
+
"max_tokens",
|
|
227
|
+
"min_tokens",
|
|
228
|
+
"ls_max_tokens",
|
|
229
|
+
"token_count",
|
|
230
|
+
"token_limit",
|
|
231
|
+
"token_budget",
|
|
232
|
+
"input_tokens",
|
|
233
|
+
"output_tokens",
|
|
234
|
+
"total_tokens",
|
|
235
|
+
"cached_tokens",
|
|
236
|
+
"prompt_tokens",
|
|
237
|
+
"completion_tokens"
|
|
238
|
+
].map(normalizeSensitiveKey)
|
|
239
|
+
);
|
|
240
|
+
function isTokenCredentialKey(normalized) {
|
|
241
|
+
if (NON_CREDENTIAL_TOKEN_CONFIG_KEYS.has(normalized)) return false;
|
|
242
|
+
if (normalized === "token") return true;
|
|
243
|
+
if (normalized.endsWith("tokens")) return false;
|
|
244
|
+
return normalized.endsWith("token");
|
|
245
|
+
}
|
|
246
|
+
function isCredentialSensitiveKey(key, sensitiveKeys) {
|
|
247
|
+
if (!key) return false;
|
|
248
|
+
const normalized = normalizeSensitiveKey(key);
|
|
249
|
+
if (!normalized) return false;
|
|
250
|
+
if (NON_CREDENTIAL_TOKEN_CONFIG_KEYS.has(normalized)) return false;
|
|
251
|
+
for (const sensitive of sensitiveKeys) {
|
|
252
|
+
const s = normalizeSensitiveKey(sensitive);
|
|
253
|
+
if (!s) continue;
|
|
254
|
+
if (s === "token") {
|
|
255
|
+
if (isTokenCredentialKey(normalized)) return true;
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
258
|
+
if (normalized === s) return true;
|
|
259
|
+
if (normalized.endsWith(`_${s}`) || normalized.startsWith(`${s}_`)) return true;
|
|
260
|
+
}
|
|
261
|
+
return false;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// packages/redact/src/index.ts
|
|
218
265
|
var DEFAULT_REDACT_KEYS = [
|
|
219
266
|
"authorization",
|
|
220
267
|
"cookie",
|
|
@@ -276,6 +323,12 @@ function isRecord(value) {
|
|
|
276
323
|
function toKey(key) {
|
|
277
324
|
return key.toLowerCase();
|
|
278
325
|
}
|
|
326
|
+
function findCompiledKeyRule(key, rules) {
|
|
327
|
+
const exact = toKey(key);
|
|
328
|
+
const direct = rules.find((candidate) => candidate.key === exact);
|
|
329
|
+
if (direct) return direct;
|
|
330
|
+
return rules.find((candidate) => isCredentialSensitiveKey(key, [candidate.key]));
|
|
331
|
+
}
|
|
279
332
|
function stableHash(value) {
|
|
280
333
|
const hash = crypto.createHash("sha256").update(value, "utf8").digest("hex");
|
|
281
334
|
return hash.slice(0, 8);
|
|
@@ -597,7 +650,7 @@ var Redactor = class {
|
|
|
597
650
|
return "[Truncated]";
|
|
598
651
|
}
|
|
599
652
|
if (key !== void 0) {
|
|
600
|
-
const rule = this.#rules
|
|
653
|
+
const rule = findCompiledKeyRule(key, this.#rules);
|
|
601
654
|
if (rule) {
|
|
602
655
|
this.#recordFinding(
|
|
603
656
|
state,
|