@agent-inspect/eval 6.8.0 → 6.9.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 +72 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +72 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -245,7 +245,12 @@ var SHARE_PROFILE_EXTRA_KEYS = [
|
|
|
245
245
|
"organizationId",
|
|
246
246
|
"traceId",
|
|
247
247
|
"spanId",
|
|
248
|
-
"parentSpanId"
|
|
248
|
+
"parentSpanId",
|
|
249
|
+
"currentTask",
|
|
250
|
+
"task",
|
|
251
|
+
"userInput",
|
|
252
|
+
"requestText",
|
|
253
|
+
"conversationText"
|
|
249
254
|
];
|
|
250
255
|
var STRICT_PROFILE_EXTRA_KEYS = [
|
|
251
256
|
"prompt",
|
|
@@ -313,6 +318,61 @@ function passesLuhn(value) {
|
|
|
313
318
|
}
|
|
314
319
|
return sum % 10 === 0;
|
|
315
320
|
}
|
|
321
|
+
var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
322
|
+
var EPOCH_MS_RE = /^1[0-9]{12}$/;
|
|
323
|
+
var EMAIL_RE = /\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/gi;
|
|
324
|
+
function pathSuggestsNonCard(path) {
|
|
325
|
+
const normalized = path.toLowerCase().replace(/[^a-z0-9._]/g, "");
|
|
326
|
+
return /(^|\.)(tokenusage|usage)(\.|$)/.test(normalized) || /(startedat|endedat|durationms|timestamp|createdat|updatedat)(\.|$)/.test(normalized) || /(^|\.)(runid|traceid|spanid|eventid|sessionid|userid|parentid|requestid|correlationid)(\.|$)/.test(
|
|
327
|
+
normalized
|
|
328
|
+
) || /(^|\.)ts(\.|$)/.test(normalized);
|
|
329
|
+
}
|
|
330
|
+
function isUuidLike(value) {
|
|
331
|
+
return UUID_RE.test(value.trim());
|
|
332
|
+
}
|
|
333
|
+
function isPlausibleCardCandidate(candidate, fullValue) {
|
|
334
|
+
const digits = digitsOnly(candidate);
|
|
335
|
+
if (digits.length < 13 || digits.length > 19) return false;
|
|
336
|
+
if (!passesLuhn(candidate)) return false;
|
|
337
|
+
const trimmed = fullValue.trim();
|
|
338
|
+
if (isUuidLike(trimmed)) return false;
|
|
339
|
+
if (EPOCH_MS_RE.test(digits) && digitsOnly(trimmed) === digits && /^\d+$/.test(trimmed)) {
|
|
340
|
+
return false;
|
|
341
|
+
}
|
|
342
|
+
const start = fullValue.indexOf(candidate);
|
|
343
|
+
if (start >= 0) {
|
|
344
|
+
const before = fullValue[start - 1];
|
|
345
|
+
const after = fullValue[start + candidate.length];
|
|
346
|
+
if (before && /[A-Za-z0-9_]/.test(before)) return false;
|
|
347
|
+
if (after && /[A-Za-z0-9_]/.test(after)) return false;
|
|
348
|
+
}
|
|
349
|
+
return true;
|
|
350
|
+
}
|
|
351
|
+
function looksLikePathOrPackageOrUrl(value) {
|
|
352
|
+
const trimmed = value.trim();
|
|
353
|
+
if (/^(?:[a-z][a-z0-9+.-]*:)?\/\//i.test(trimmed)) return true;
|
|
354
|
+
if (/^webpack:/i.test(trimmed)) return true;
|
|
355
|
+
if (/^@[A-Za-z0-9_.-]+\/[A-Za-z0-9_.@/-]+$/.test(trimmed)) return true;
|
|
356
|
+
if (/^[A-Za-z]:[\\/]/.test(trimmed) || /^[/\\]/.test(trimmed)) return true;
|
|
357
|
+
if (/[\\/]/.test(trimmed) && !/\s/.test(trimmed)) return true;
|
|
358
|
+
return false;
|
|
359
|
+
}
|
|
360
|
+
function emailMatchIsPathAdjacent(value, index, length) {
|
|
361
|
+
const before = value[index - 1];
|
|
362
|
+
const after = value[index + length];
|
|
363
|
+
return before === "/" || before === "\\" || after === "/" || after === "\\";
|
|
364
|
+
}
|
|
365
|
+
function valueContainsEmail(value) {
|
|
366
|
+
if (looksLikePathOrPackageOrUrl(value)) return false;
|
|
367
|
+
EMAIL_RE.lastIndex = 0;
|
|
368
|
+
for (const match of value.matchAll(EMAIL_RE)) {
|
|
369
|
+
const text = match[0] ?? "";
|
|
370
|
+
const index = match.index ?? 0;
|
|
371
|
+
if (emailMatchIsPathAdjacent(value, index, text.length)) continue;
|
|
372
|
+
return true;
|
|
373
|
+
}
|
|
374
|
+
return false;
|
|
375
|
+
}
|
|
316
376
|
var credentialDetectors = [
|
|
317
377
|
patternDetector({
|
|
318
378
|
id: "value.authorizationHeader",
|
|
@@ -360,10 +420,12 @@ var credentialDetectors = [
|
|
|
360
420
|
matchKind: "value",
|
|
361
421
|
detect(input) {
|
|
362
422
|
if (typeof input.value !== "string") return [];
|
|
423
|
+
if (pathSuggestsNonCard(input.path)) return [];
|
|
424
|
+
if (isUuidLike(input.value)) return [];
|
|
363
425
|
const candidatePattern = /(?:\d[ -]?){13,19}/g;
|
|
364
426
|
for (const match of input.value.matchAll(candidatePattern)) {
|
|
365
427
|
const candidate = match[0] ?? "";
|
|
366
|
-
if (
|
|
428
|
+
if (isPlausibleCardCandidate(candidate, input.value)) {
|
|
367
429
|
return [{ action: "replace", severity: "error", matchKind: "value" }];
|
|
368
430
|
}
|
|
369
431
|
}
|
|
@@ -372,10 +434,15 @@ var credentialDetectors = [
|
|
|
372
434
|
}
|
|
373
435
|
];
|
|
374
436
|
var identifierDetectors = [
|
|
375
|
-
|
|
437
|
+
{
|
|
376
438
|
id: "value.email",
|
|
377
|
-
|
|
378
|
-
|
|
439
|
+
severity: "warning",
|
|
440
|
+
matchKind: "value",
|
|
441
|
+
detect(input) {
|
|
442
|
+
if (typeof input.value !== "string") return [];
|
|
443
|
+
return valueContainsEmail(input.value) ? [{ action: "replace", severity: "warning", matchKind: "value" }] : [];
|
|
444
|
+
}
|
|
445
|
+
},
|
|
379
446
|
patternDetector({
|
|
380
447
|
id: "value.phone",
|
|
381
448
|
pattern: /\b(?:\+\d{1,3}[\s.-]?)?(?:\(?\d{3}\)?[\s.-])\d{3}[\s.-]\d{4}\b/
|