@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 CHANGED
@@ -295,6 +295,19 @@ function valueContainsKeyValueSecret(value) {
295
295
 
296
296
  // packages/redact/src/url-redaction.ts
297
297
  var HTTP_URL = /^https?:\/\/[^\s]+$/i;
298
+ var CONNECTION_PROTOCOLS = /* @__PURE__ */ new Set([
299
+ "postgres:",
300
+ "postgresql:",
301
+ "mysql:",
302
+ "mariadb:",
303
+ "mongodb:",
304
+ "mongodb+srv:",
305
+ "redis:",
306
+ "rediss:",
307
+ "amqp:",
308
+ "amqps:"
309
+ ]);
310
+ var CONNECTION_URI = /^(?:postgres|postgresql|mysql|mariadb|mongodb(?:\+srv)?|rediss?|amqps?):\/\/[^\s]+$/i;
298
311
  var UUID_SEGMENT = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
299
312
  var HEX_SEGMENT = /^[0-9a-f]{12,}$/i;
300
313
  var NUMERIC_SEGMENT = /^\d{5,}$/;
@@ -302,14 +315,25 @@ var OPAQUE_SEGMENT = /^[A-Za-z0-9_-]{20,}$/;
302
315
  function looksLikeHttpUrl(value) {
303
316
  return HTTP_URL.test(value.trim());
304
317
  }
305
- function parseHttpUrl(value) {
318
+ function looksLikeConnectionUri(value) {
319
+ return CONNECTION_URI.test(value.trim());
320
+ }
321
+ function looksLikeUrlForRedaction(value) {
322
+ return looksLikeHttpUrl(value) || looksLikeConnectionUri(value);
323
+ }
324
+ function parseRedactableUrl(value) {
306
325
  try {
307
326
  const url = new URL(value.trim());
308
- return url.protocol === "http:" || url.protocol === "https:" ? url : void 0;
327
+ if (url.protocol === "http:" || url.protocol === "https:") return url;
328
+ if (CONNECTION_PROTOCOLS.has(url.protocol)) return url;
329
+ return void 0;
309
330
  } catch {
310
331
  return void 0;
311
332
  }
312
333
  }
334
+ function isHttpProtocol(protocol) {
335
+ return protocol === "http:" || protocol === "https:";
336
+ }
313
337
  function isIdentifierSegment(segment) {
314
338
  if (UUID_SEGMENT.test(segment)) return true;
315
339
  if (HEX_SEGMENT.test(segment)) return true;
@@ -347,15 +371,16 @@ function redactUrlString(value, options) {
347
371
  credentialRedacted: false,
348
372
  identifiersMasked: false
349
373
  };
350
- if (!looksLikeHttpUrl(value)) return unchanged;
351
- const url = parseHttpUrl(value);
374
+ if (!looksLikeUrlForRedaction(value)) return unchanged;
375
+ const url = parseRedactableUrl(value);
352
376
  if (!url) return unchanged;
353
377
  const replacement = options.replacement ?? "[REDACTED]";
354
378
  const idPlaceholder = options.idPlaceholder ?? "[id]";
379
+ const http = isHttpProtocol(url.protocol);
355
380
  let credentialRedacted = url.username.length > 0 || url.password.length > 0;
356
381
  let identifiersMasked = false;
357
382
  let pathname = url.pathname;
358
- if (options.maskPathIds === true) {
383
+ if (http && options.maskPathIds === true) {
359
384
  pathname = url.pathname.split("/").map((segment) => {
360
385
  if (segment.length === 0 || !isIdentifierSegment(decodeParam(segment))) {
361
386
  return segment;
@@ -805,7 +830,7 @@ var Redactor = class {
805
830
  return applyRule(rule, value, this.#replacement);
806
831
  }
807
832
  }
808
- if (typeof value === "string" && looksLikeHttpUrl(value)) {
833
+ if (typeof value === "string" && looksLikeUrlForRedaction(value)) {
809
834
  const url = redactUrlString(value, {
810
835
  sensitiveKeys: this.#sensitiveKeys,
811
836
  isSensitiveValue: (candidate) => this.#detect(candidate, key, path) !== void 0,