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.
- package/CHANGELOG.md +6 -0
- package/README.md +1 -1
- package/docs/SAFE-TRACE-SHARING.md +1 -1
- package/package.json +1 -1
- package/packages/cli/dist/index.cjs +62 -12
- package/packages/cli/dist/index.cjs.map +1 -1
- package/packages/cli/dist/index.mjs +62 -12
- package/packages/cli/dist/index.mjs.map +1 -1
- package/packages/core/dist/exporters.cjs +30 -5
- package/packages/core/dist/exporters.cjs.map +1 -1
- package/packages/core/dist/exporters.mjs +30 -5
- package/packages/core/dist/exporters.mjs.map +1 -1
|
@@ -14,6 +14,19 @@ var EXPORT_PAYLOAD_VERSION = "0.1.2";
|
|
|
14
14
|
|
|
15
15
|
// packages/core/src/safety/url-redaction.ts
|
|
16
16
|
var HTTP_URL = /^https?:\/\/[^\s]+$/i;
|
|
17
|
+
var CONNECTION_PROTOCOLS = /* @__PURE__ */ new Set([
|
|
18
|
+
"postgres:",
|
|
19
|
+
"postgresql:",
|
|
20
|
+
"mysql:",
|
|
21
|
+
"mariadb:",
|
|
22
|
+
"mongodb:",
|
|
23
|
+
"mongodb+srv:",
|
|
24
|
+
"redis:",
|
|
25
|
+
"rediss:",
|
|
26
|
+
"amqp:",
|
|
27
|
+
"amqps:"
|
|
28
|
+
]);
|
|
29
|
+
var CONNECTION_URI = /^(?:postgres|postgresql|mysql|mariadb|mongodb(?:\+srv)?|rediss?|amqps?):\/\/[^\s]+$/i;
|
|
17
30
|
var UUID_SEGMENT = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
18
31
|
var HEX_SEGMENT = /^[0-9a-f]{12,}$/i;
|
|
19
32
|
var NUMERIC_SEGMENT = /^\d{5,}$/;
|
|
@@ -21,14 +34,25 @@ var OPAQUE_SEGMENT = /^[A-Za-z0-9_-]{20,}$/;
|
|
|
21
34
|
function looksLikeHttpUrl(value) {
|
|
22
35
|
return HTTP_URL.test(value.trim());
|
|
23
36
|
}
|
|
24
|
-
function
|
|
37
|
+
function looksLikeConnectionUri(value) {
|
|
38
|
+
return CONNECTION_URI.test(value.trim());
|
|
39
|
+
}
|
|
40
|
+
function looksLikeUrlForRedaction(value) {
|
|
41
|
+
return looksLikeHttpUrl(value) || looksLikeConnectionUri(value);
|
|
42
|
+
}
|
|
43
|
+
function parseRedactableUrl(value) {
|
|
25
44
|
try {
|
|
26
45
|
const url = new URL(value.trim());
|
|
27
|
-
|
|
46
|
+
if (url.protocol === "http:" || url.protocol === "https:") return url;
|
|
47
|
+
if (CONNECTION_PROTOCOLS.has(url.protocol)) return url;
|
|
48
|
+
return void 0;
|
|
28
49
|
} catch {
|
|
29
50
|
return void 0;
|
|
30
51
|
}
|
|
31
52
|
}
|
|
53
|
+
function isHttpProtocol(protocol) {
|
|
54
|
+
return protocol === "http:" || protocol === "https:";
|
|
55
|
+
}
|
|
32
56
|
function isIdentifierSegment(segment) {
|
|
33
57
|
if (UUID_SEGMENT.test(segment)) return true;
|
|
34
58
|
if (HEX_SEGMENT.test(segment)) return true;
|
|
@@ -66,15 +90,16 @@ function redactUrlString(value, options) {
|
|
|
66
90
|
credentialRedacted: false,
|
|
67
91
|
identifiersMasked: false
|
|
68
92
|
};
|
|
69
|
-
if (!
|
|
70
|
-
const url =
|
|
93
|
+
if (!looksLikeUrlForRedaction(value)) return unchanged;
|
|
94
|
+
const url = parseRedactableUrl(value);
|
|
71
95
|
if (!url) return unchanged;
|
|
72
96
|
const replacement = options.replacement ?? "[REDACTED]";
|
|
73
97
|
const idPlaceholder = options.idPlaceholder ?? "[id]";
|
|
98
|
+
const http = isHttpProtocol(url.protocol);
|
|
74
99
|
let credentialRedacted = url.username.length > 0 || url.password.length > 0;
|
|
75
100
|
let identifiersMasked = false;
|
|
76
101
|
let pathname = url.pathname;
|
|
77
|
-
if (options.maskPathIds === true) {
|
|
102
|
+
if (http && options.maskPathIds === true) {
|
|
78
103
|
pathname = url.pathname.split("/").map((segment) => {
|
|
79
104
|
if (segment.length === 0 || !isIdentifierSegment(decodeParam(segment))) {
|
|
80
105
|
return segment;
|