@agent-inspect/eval 6.31.4 → 6.31.5
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 +31 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +31 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -289,6 +289,19 @@ function valueContainsKeyValueSecret(value) {
|
|
|
289
289
|
|
|
290
290
|
// packages/redact/src/url-redaction.ts
|
|
291
291
|
var HTTP_URL = /^https?:\/\/[^\s]+$/i;
|
|
292
|
+
var CONNECTION_PROTOCOLS = /* @__PURE__ */ new Set([
|
|
293
|
+
"postgres:",
|
|
294
|
+
"postgresql:",
|
|
295
|
+
"mysql:",
|
|
296
|
+
"mariadb:",
|
|
297
|
+
"mongodb:",
|
|
298
|
+
"mongodb+srv:",
|
|
299
|
+
"redis:",
|
|
300
|
+
"rediss:",
|
|
301
|
+
"amqp:",
|
|
302
|
+
"amqps:"
|
|
303
|
+
]);
|
|
304
|
+
var CONNECTION_URI = /^(?:postgres|postgresql|mysql|mariadb|mongodb(?:\+srv)?|rediss?|amqps?):\/\/[^\s]+$/i;
|
|
292
305
|
var UUID_SEGMENT = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
293
306
|
var HEX_SEGMENT = /^[0-9a-f]{12,}$/i;
|
|
294
307
|
var NUMERIC_SEGMENT = /^\d{5,}$/;
|
|
@@ -296,14 +309,25 @@ var OPAQUE_SEGMENT = /^[A-Za-z0-9_-]{20,}$/;
|
|
|
296
309
|
function looksLikeHttpUrl(value) {
|
|
297
310
|
return HTTP_URL.test(value.trim());
|
|
298
311
|
}
|
|
299
|
-
function
|
|
312
|
+
function looksLikeConnectionUri(value) {
|
|
313
|
+
return CONNECTION_URI.test(value.trim());
|
|
314
|
+
}
|
|
315
|
+
function looksLikeUrlForRedaction(value) {
|
|
316
|
+
return looksLikeHttpUrl(value) || looksLikeConnectionUri(value);
|
|
317
|
+
}
|
|
318
|
+
function parseRedactableUrl(value) {
|
|
300
319
|
try {
|
|
301
320
|
const url = new URL(value.trim());
|
|
302
|
-
|
|
321
|
+
if (url.protocol === "http:" || url.protocol === "https:") return url;
|
|
322
|
+
if (CONNECTION_PROTOCOLS.has(url.protocol)) return url;
|
|
323
|
+
return void 0;
|
|
303
324
|
} catch {
|
|
304
325
|
return void 0;
|
|
305
326
|
}
|
|
306
327
|
}
|
|
328
|
+
function isHttpProtocol(protocol) {
|
|
329
|
+
return protocol === "http:" || protocol === "https:";
|
|
330
|
+
}
|
|
307
331
|
function isIdentifierSegment(segment) {
|
|
308
332
|
if (UUID_SEGMENT.test(segment)) return true;
|
|
309
333
|
if (HEX_SEGMENT.test(segment)) return true;
|
|
@@ -341,15 +365,16 @@ function redactUrlString(value, options) {
|
|
|
341
365
|
credentialRedacted: false,
|
|
342
366
|
identifiersMasked: false
|
|
343
367
|
};
|
|
344
|
-
if (!
|
|
345
|
-
const url =
|
|
368
|
+
if (!looksLikeUrlForRedaction(value)) return unchanged;
|
|
369
|
+
const url = parseRedactableUrl(value);
|
|
346
370
|
if (!url) return unchanged;
|
|
347
371
|
const replacement = options.replacement ?? "[REDACTED]";
|
|
348
372
|
const idPlaceholder = options.idPlaceholder ?? "[id]";
|
|
373
|
+
const http = isHttpProtocol(url.protocol);
|
|
349
374
|
let credentialRedacted = url.username.length > 0 || url.password.length > 0;
|
|
350
375
|
let identifiersMasked = false;
|
|
351
376
|
let pathname = url.pathname;
|
|
352
|
-
if (options.maskPathIds === true) {
|
|
377
|
+
if (http && options.maskPathIds === true) {
|
|
353
378
|
pathname = url.pathname.split("/").map((segment) => {
|
|
354
379
|
if (segment.length === 0 || !isIdentifierSegment(decodeParam(segment))) {
|
|
355
380
|
return segment;
|
|
@@ -799,7 +824,7 @@ var Redactor = class {
|
|
|
799
824
|
return applyRule(rule, value, this.#replacement);
|
|
800
825
|
}
|
|
801
826
|
}
|
|
802
|
-
if (typeof value === "string" &&
|
|
827
|
+
if (typeof value === "string" && looksLikeUrlForRedaction(value)) {
|
|
803
828
|
const url = redactUrlString(value, {
|
|
804
829
|
sensitiveKeys: this.#sensitiveKeys,
|
|
805
830
|
isSensitiveValue: (candidate) => this.#detect(candidate, key, path) !== void 0,
|