agent-inspect 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.
@@ -210,6 +210,19 @@ function stringContainsHighConfidenceCredential(value) {
210
210
 
211
211
  // packages/core/src/safety/url-redaction.ts
212
212
  var HTTP_URL = /^https?:\/\/[^\s]+$/i;
213
+ var CONNECTION_PROTOCOLS = /* @__PURE__ */ new Set([
214
+ "postgres:",
215
+ "postgresql:",
216
+ "mysql:",
217
+ "mariadb:",
218
+ "mongodb:",
219
+ "mongodb+srv:",
220
+ "redis:",
221
+ "rediss:",
222
+ "amqp:",
223
+ "amqps:"
224
+ ]);
225
+ var CONNECTION_URI = /^(?:postgres|postgresql|mysql|mariadb|mongodb(?:\+srv)?|rediss?|amqps?):\/\/[^\s]+$/i;
213
226
  var UUID_SEGMENT = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
214
227
  var HEX_SEGMENT = /^[0-9a-f]{12,}$/i;
215
228
  var NUMERIC_SEGMENT = /^\d{5,}$/;
@@ -217,14 +230,25 @@ var OPAQUE_SEGMENT = /^[A-Za-z0-9_-]{20,}$/;
217
230
  function looksLikeHttpUrl(value) {
218
231
  return HTTP_URL.test(value.trim());
219
232
  }
220
- function parseHttpUrl(value) {
233
+ function looksLikeConnectionUri(value) {
234
+ return CONNECTION_URI.test(value.trim());
235
+ }
236
+ function looksLikeUrlForRedaction(value) {
237
+ return looksLikeHttpUrl(value) || looksLikeConnectionUri(value);
238
+ }
239
+ function parseRedactableUrl(value) {
221
240
  try {
222
241
  const url = new URL(value.trim());
223
- return url.protocol === "http:" || url.protocol === "https:" ? url : void 0;
242
+ if (url.protocol === "http:" || url.protocol === "https:") return url;
243
+ if (CONNECTION_PROTOCOLS.has(url.protocol)) return url;
244
+ return void 0;
224
245
  } catch {
225
246
  return void 0;
226
247
  }
227
248
  }
249
+ function isHttpProtocol(protocol) {
250
+ return protocol === "http:" || protocol === "https:";
251
+ }
228
252
  function isIdentifierSegment(segment) {
229
253
  if (UUID_SEGMENT.test(segment)) return true;
230
254
  if (HEX_SEGMENT.test(segment)) return true;
@@ -262,15 +286,16 @@ function redactUrlString(value, options) {
262
286
  credentialRedacted: false,
263
287
  identifiersMasked: false
264
288
  };
265
- if (!looksLikeHttpUrl(value)) return unchanged;
266
- const url = parseHttpUrl(value);
289
+ if (!looksLikeUrlForRedaction(value)) return unchanged;
290
+ const url = parseRedactableUrl(value);
267
291
  if (!url) return unchanged;
268
292
  const replacement = options.replacement ?? "[REDACTED]";
269
293
  const idPlaceholder = options.idPlaceholder ?? "[id]";
294
+ const http = isHttpProtocol(url.protocol);
270
295
  let credentialRedacted = url.username.length > 0 || url.password.length > 0;
271
296
  let identifiersMasked = false;
272
297
  let pathname = url.pathname;
273
- if (options.maskPathIds === true) {
298
+ if (http && options.maskPathIds === true) {
274
299
  pathname = url.pathname.split("/").map((segment) => {
275
300
  if (segment.length === 0 || !isIdentifierSegment(decodeParam(segment))) {
276
301
  return segment;