@agent-inspect/mcp-server 6.31.4 → 6.31.6

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.
@@ -208,7 +208,7 @@ var Redactor = class {
208
208
  };
209
209
 
210
210
  // packages/core/src/safety/credential-value-patterns.ts
211
- var KEY_VALUE_SECRET_PATTERN = /\b(?:api[_-]?key|internal[_-]?token|access[_-]?token|auth[_-]?token|password|secret|token)=(?!\[(?:REDACTED(?::[^\]]*)?|HASH:[0-9a-f]{8})\](?![^\s"'\\&#?;/]))([^\s"'\\]{8,})/i;
211
+ var KEY_VALUE_SECRET_PATTERN = /\b(?:api[_-]?key|internal[_-]?token|access[_-]?token|auth[_-]?token|password|secret|token)=(?!\[(?:REDACTED(?::[^\]]*)?|HASH:[0-9a-f]{8})\](?![^\s"'\\&#?]))([^\s"'\\]{8,})/i;
212
212
  var HIGH_CONFIDENCE_CREDENTIAL_PATTERNS = [
213
213
  /^(?:basic|bearer|digest|apikey)\s+[a-z0-9._~+/=-]+$/i,
214
214
  /\bbearer\s+[a-z0-9._~+/=-]{12,}\b/i,
@@ -3351,7 +3351,7 @@ var DEFAULT_SECRET_PATTERNS = [
3351
3351
  // Keep in sync with packages/redact/src/key-value-secret.ts (KEY_VALUE_SECRET_PATTERN_SOURCE).
3352
3352
  {
3353
3353
  id: "key-value-secret",
3354
- pattern: /\b(?:api[_-]?key|internal[_-]?token|access[_-]?token|auth[_-]?token|password|secret|token)=(?!\[(?:REDACTED(?::[^\]]*)?|HASH:[0-9a-f]{8})\](?![^\s"'\\&#?;/]))([^\s"'\\]{8,})/i
3354
+ pattern: /\b(?:api[_-]?key|internal[_-]?token|access[_-]?token|auth[_-]?token|password|secret|token)=(?!\[(?:REDACTED(?::[^\]]*)?|HASH:[0-9a-f]{8})\](?![^\s"'\\&#?]))([^\s"'\\]{8,})/i
3355
3355
  }
3356
3356
  ];
3357
3357
  function compareStrings(a, b) {
@@ -3666,9 +3666,6 @@ function limitFindings(findings, maxFindings) {
3666
3666
  if (maxFindings === void 0 || findings.length <= maxFindings) return findings;
3667
3667
  return findings.slice(0, Math.max(0, maxFindings));
3668
3668
  }
3669
- function hasRedactionMarker(value, markers) {
3670
- return markers.some((marker) => value.includes(marker)) || /^\[HASH:[A-Za-z0-9_-]+\]$/.test(value);
3671
- }
3672
3669
  function isFullyRedactedValue(value, markers = ["[REDACTED]", "[REDACTED:"]) {
3673
3670
  if (typeof value !== "string") return false;
3674
3671
  const trimmed = value.trim();
@@ -3753,7 +3750,7 @@ function createSafetyRedactionRule(options = {}) {
3753
3750
  for (const event of context.events) {
3754
3751
  for (const entry of eventValueEntries(event, { includeSummaries: true, includeError: true })) {
3755
3752
  if (!isSensitiveKey(entry.key ?? lastPathSegment(entry.path), sensitiveKeys)) continue;
3756
- if (typeof entry.value === "string" && hasRedactionMarker(entry.value, markers)) continue;
3753
+ if (isFullyRedactedValue(entry.value, markers)) continue;
3757
3754
  findings.push(
3758
3755
  failFinding(
3759
3756
  "safety.redaction",
@@ -6694,6 +6691,21 @@ var EXPORT_PAYLOAD_VERSION = "0.1.2";
6694
6691
 
6695
6692
  // packages/core/src/safety/url-redaction.ts
6696
6693
  var HTTP_URL = /^https?:\/\/[^\s]+$/i;
6694
+ var CONNECTION_PROTOCOLS = /* @__PURE__ */ new Set([
6695
+ "postgres:",
6696
+ "postgresql:",
6697
+ "mysql:",
6698
+ "mariadb:",
6699
+ "mongodb:",
6700
+ "mongodb+srv:",
6701
+ "redis:",
6702
+ "rediss:",
6703
+ "amqp:",
6704
+ "amqps:"
6705
+ ]);
6706
+ var CONNECTION_URI = /^(?:postgres|postgresql|mysql|mariadb|mongodb(?:\+srv)?|rediss?|amqps?):\/\/[^\s]+$/i;
6707
+ var CONNECTION_USERINFO = /^(postgres|postgresql|mysql|mariadb|mongodb(?:\+srv)?|rediss?|amqps?):\/\/([^@/?#]+)@(.+)$/i;
6708
+ var CONNECTION_HAS_USERINFO = /^(?:postgres|postgresql|mysql|mariadb|mongodb(?:\+srv)?|rediss?|amqps?):\/\/[^@/?#]+@/i;
6697
6709
  var UUID_SEGMENT = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
6698
6710
  var HEX_SEGMENT = /^[0-9a-f]{12,}$/i;
6699
6711
  var NUMERIC_SEGMENT = /^\d{5,}$/;
@@ -6701,14 +6713,47 @@ var OPAQUE_SEGMENT = /^[A-Za-z0-9_-]{20,}$/;
6701
6713
  function looksLikeHttpUrl(value) {
6702
6714
  return HTTP_URL.test(value.trim());
6703
6715
  }
6704
- function parseHttpUrl(value) {
6716
+ function looksLikeConnectionUri(value) {
6717
+ return CONNECTION_URI.test(value.trim());
6718
+ }
6719
+ function looksLikeUrlForRedaction(value) {
6720
+ return looksLikeHttpUrl(value) || looksLikeConnectionUri(value);
6721
+ }
6722
+ function parseRedactableUrl(value) {
6705
6723
  try {
6706
6724
  const url = new URL(value.trim());
6707
- return url.protocol === "http:" || url.protocol === "https:" ? url : void 0;
6725
+ if (url.protocol === "http:" || url.protocol === "https:") return url;
6726
+ if (CONNECTION_PROTOCOLS.has(url.protocol)) return url;
6727
+ return void 0;
6708
6728
  } catch {
6709
6729
  return void 0;
6710
6730
  }
6711
6731
  }
6732
+ function redactConnectionUserinfoFallback(value, replacement) {
6733
+ const trimmed = value.trim();
6734
+ const match = CONNECTION_USERINFO.exec(trimmed);
6735
+ if (match) {
6736
+ const [, scheme, , rest] = match;
6737
+ if (scheme && rest && rest.length > 0) {
6738
+ return {
6739
+ value: `${scheme}://${rest}`,
6740
+ credentialRedacted: true,
6741
+ identifiersMasked: false
6742
+ };
6743
+ }
6744
+ }
6745
+ if (looksLikeConnectionUri(trimmed) && CONNECTION_HAS_USERINFO.test(trimmed)) {
6746
+ return {
6747
+ value: replacement,
6748
+ credentialRedacted: true,
6749
+ identifiersMasked: false
6750
+ };
6751
+ }
6752
+ return void 0;
6753
+ }
6754
+ function isHttpProtocol(protocol) {
6755
+ return protocol === "http:" || protocol === "https:";
6756
+ }
6712
6757
  function isIdentifierSegment(segment) {
6713
6758
  if (UUID_SEGMENT.test(segment)) return true;
6714
6759
  if (HEX_SEGMENT.test(segment)) return true;
@@ -6746,15 +6791,18 @@ function redactUrlString(value, options) {
6746
6791
  credentialRedacted: false,
6747
6792
  identifiersMasked: false
6748
6793
  };
6749
- if (!looksLikeHttpUrl(value)) return unchanged;
6750
- const url = parseHttpUrl(value);
6751
- if (!url) return unchanged;
6794
+ if (!looksLikeUrlForRedaction(value)) return unchanged;
6752
6795
  const replacement = options.replacement ?? "[REDACTED]";
6796
+ const url = parseRedactableUrl(value);
6797
+ if (!url) {
6798
+ return redactConnectionUserinfoFallback(value, replacement) ?? unchanged;
6799
+ }
6753
6800
  const idPlaceholder = options.idPlaceholder ?? "[id]";
6801
+ const http = isHttpProtocol(url.protocol);
6754
6802
  let credentialRedacted = url.username.length > 0 || url.password.length > 0;
6755
6803
  let identifiersMasked = false;
6756
6804
  let pathname = url.pathname;
6757
- if (options.maskPathIds === true) {
6805
+ if (http && options.maskPathIds === true) {
6758
6806
  pathname = url.pathname.split("/").map((segment) => {
6759
6807
  if (segment.length === 0 || !isIdentifierSegment(decodeParam(segment))) {
6760
6808
  return segment;
@@ -7540,7 +7588,7 @@ function isCredentialSensitiveKey2(key, sensitiveKeys) {
7540
7588
  }
7541
7589
 
7542
7590
  // packages/redact/src/key-value-secret.ts
7543
- var KEY_VALUE_SECRET_PATTERN_SOURCE = String.raw`\b(?:api[_-]?key|internal[_-]?token|access[_-]?token|auth[_-]?token|password|secret|token)=(?!\[(?:REDACTED(?::[^\]]*)?|HASH:[0-9a-f]{8})\](?![^\s"'\\&#?;/]))([^\s"'\\]{8,})`;
7591
+ var KEY_VALUE_SECRET_PATTERN_SOURCE = String.raw`\b(?:api[_-]?key|internal[_-]?token|access[_-]?token|auth[_-]?token|password|secret|token)=(?!\[(?:REDACTED(?::[^\]]*)?|HASH:[0-9a-f]{8})\](?![^\s"'\\&#?]))([^\s"'\\]{8,})`;
7544
7592
  var KEY_VALUE_SECRET_PATTERN2 = new RegExp(
7545
7593
  KEY_VALUE_SECRET_PATTERN_SOURCE,
7546
7594
  "i"
@@ -7552,6 +7600,21 @@ function valueContainsKeyValueSecret(value) {
7552
7600
 
7553
7601
  // packages/redact/src/url-redaction.ts
7554
7602
  var HTTP_URL2 = /^https?:\/\/[^\s]+$/i;
7603
+ var CONNECTION_PROTOCOLS2 = /* @__PURE__ */ new Set([
7604
+ "postgres:",
7605
+ "postgresql:",
7606
+ "mysql:",
7607
+ "mariadb:",
7608
+ "mongodb:",
7609
+ "mongodb+srv:",
7610
+ "redis:",
7611
+ "rediss:",
7612
+ "amqp:",
7613
+ "amqps:"
7614
+ ]);
7615
+ var CONNECTION_URI2 = /^(?:postgres|postgresql|mysql|mariadb|mongodb(?:\+srv)?|rediss?|amqps?):\/\/[^\s]+$/i;
7616
+ var CONNECTION_USERINFO2 = /^(postgres|postgresql|mysql|mariadb|mongodb(?:\+srv)?|rediss?|amqps?):\/\/([^@/?#]+)@(.+)$/i;
7617
+ var CONNECTION_HAS_USERINFO2 = /^(?:postgres|postgresql|mysql|mariadb|mongodb(?:\+srv)?|rediss?|amqps?):\/\/[^@/?#]+@/i;
7555
7618
  var UUID_SEGMENT2 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
7556
7619
  var HEX_SEGMENT2 = /^[0-9a-f]{12,}$/i;
7557
7620
  var NUMERIC_SEGMENT2 = /^\d{5,}$/;
@@ -7559,14 +7622,47 @@ var OPAQUE_SEGMENT2 = /^[A-Za-z0-9_-]{20,}$/;
7559
7622
  function looksLikeHttpUrl2(value) {
7560
7623
  return HTTP_URL2.test(value.trim());
7561
7624
  }
7562
- function parseHttpUrl2(value) {
7625
+ function looksLikeConnectionUri2(value) {
7626
+ return CONNECTION_URI2.test(value.trim());
7627
+ }
7628
+ function looksLikeUrlForRedaction2(value) {
7629
+ return looksLikeHttpUrl2(value) || looksLikeConnectionUri2(value);
7630
+ }
7631
+ function parseRedactableUrl2(value) {
7563
7632
  try {
7564
7633
  const url = new URL(value.trim());
7565
- return url.protocol === "http:" || url.protocol === "https:" ? url : void 0;
7634
+ if (url.protocol === "http:" || url.protocol === "https:") return url;
7635
+ if (CONNECTION_PROTOCOLS2.has(url.protocol)) return url;
7636
+ return void 0;
7566
7637
  } catch {
7567
7638
  return void 0;
7568
7639
  }
7569
7640
  }
7641
+ function redactConnectionUserinfoFallback2(value, replacement) {
7642
+ const trimmed = value.trim();
7643
+ const match = CONNECTION_USERINFO2.exec(trimmed);
7644
+ if (match) {
7645
+ const [, scheme, , rest] = match;
7646
+ if (scheme && rest && rest.length > 0) {
7647
+ return {
7648
+ value: `${scheme}://${rest}`,
7649
+ credentialRedacted: true,
7650
+ identifiersMasked: false
7651
+ };
7652
+ }
7653
+ }
7654
+ if (looksLikeConnectionUri2(trimmed) && CONNECTION_HAS_USERINFO2.test(trimmed)) {
7655
+ return {
7656
+ value: replacement,
7657
+ credentialRedacted: true,
7658
+ identifiersMasked: false
7659
+ };
7660
+ }
7661
+ return void 0;
7662
+ }
7663
+ function isHttpProtocol2(protocol) {
7664
+ return protocol === "http:" || protocol === "https:";
7665
+ }
7570
7666
  function isIdentifierSegment2(segment) {
7571
7667
  if (UUID_SEGMENT2.test(segment)) return true;
7572
7668
  if (HEX_SEGMENT2.test(segment)) return true;
@@ -7604,15 +7700,18 @@ function redactUrlString2(value, options) {
7604
7700
  credentialRedacted: false,
7605
7701
  identifiersMasked: false
7606
7702
  };
7607
- if (!looksLikeHttpUrl2(value)) return unchanged;
7608
- const url = parseHttpUrl2(value);
7609
- if (!url) return unchanged;
7703
+ if (!looksLikeUrlForRedaction2(value)) return unchanged;
7610
7704
  const replacement = options.replacement ?? "[REDACTED]";
7705
+ const url = parseRedactableUrl2(value);
7706
+ if (!url) {
7707
+ return redactConnectionUserinfoFallback2(value, replacement) ?? unchanged;
7708
+ }
7611
7709
  const idPlaceholder = options.idPlaceholder ?? "[id]";
7710
+ const http = isHttpProtocol2(url.protocol);
7612
7711
  let credentialRedacted = url.username.length > 0 || url.password.length > 0;
7613
7712
  let identifiersMasked = false;
7614
7713
  let pathname = url.pathname;
7615
- if (options.maskPathIds === true) {
7714
+ if (http && options.maskPathIds === true) {
7616
7715
  pathname = url.pathname.split("/").map((segment) => {
7617
7716
  if (segment.length === 0 || !isIdentifierSegment2(decodeParam2(segment))) {
7618
7717
  return segment;
@@ -8062,7 +8161,7 @@ var Redactor2 = class {
8062
8161
  return applyRule(rule, value, this.#replacement);
8063
8162
  }
8064
8163
  }
8065
- if (typeof value === "string" && looksLikeHttpUrl2(value)) {
8164
+ if (typeof value === "string" && looksLikeUrlForRedaction2(value)) {
8066
8165
  const url = redactUrlString2(value, {
8067
8166
  sensitiveKeys: this.#sensitiveKeys,
8068
8167
  isSensitiveValue: (candidate) => this.#detect(candidate, key, path16) !== void 0,
@@ -9031,5 +9130,5 @@ async function runReadOnlyMcpServer(options = {}) {
9031
9130
  }
9032
9131
 
9033
9132
  export { MCP_MAX_REQUEST_BYTES, MCP_PROTOCOL_VERSION, MCP_SERVER_INSTRUCTIONS, READ_ONLY_TOOLS, TRACE_DATA_UNTRUSTED_WARNING, callReadOnlyTool, createMcpServerContext, handleMcpProtocolLine, runReadOnlyMcpServer };
9034
- //# sourceMappingURL=chunk-OGX7RS23.mjs.map
9035
- //# sourceMappingURL=chunk-OGX7RS23.mjs.map
9133
+ //# sourceMappingURL=chunk-P72E7RLD.mjs.map
9134
+ //# sourceMappingURL=chunk-P72E7RLD.mjs.map