@pinta-ai/mcp-logger 0.4.1 → 0.4.2-dev.1010
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/cli/index.js +1 -1
- package/node_modules/@pinta-ai/core/README.md +180 -0
- package/node_modules/@pinta-ai/core/dist/atomic-write.d.ts +9 -0
- package/node_modules/@pinta-ai/core/dist/atomic-write.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/atomic-write.js +20 -0
- package/node_modules/@pinta-ai/core/dist/atomic-write.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/credential-semantics.d.ts +20 -0
- package/node_modules/@pinta-ai/core/dist/credential-semantics.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/credential-semantics.js +156 -0
- package/node_modules/@pinta-ai/core/dist/credential-semantics.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/env-file.d.ts +17 -0
- package/node_modules/@pinta-ai/core/dist/env-file.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/env-file.js +81 -0
- package/node_modules/@pinta-ai/core/dist/env-file.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/export-mask.d.ts +26 -0
- package/node_modules/@pinta-ai/core/dist/export-mask.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/export-mask.js +202 -0
- package/node_modules/@pinta-ai/core/dist/export-mask.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/guard.d.ts +196 -0
- package/node_modules/@pinta-ai/core/dist/guard.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/guard.js +275 -0
- package/node_modules/@pinta-ai/core/dist/guard.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/index.d.ts +23 -0
- package/node_modules/@pinta-ai/core/dist/index.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/index.js +85 -0
- package/node_modules/@pinta-ai/core/dist/index.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/json-text.d.ts +45 -0
- package/node_modules/@pinta-ai/core/dist/json-text.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/json-text.js +116 -0
- package/node_modules/@pinta-ai/core/dist/json-text.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/lifecycle.d.ts +143 -0
- package/node_modules/@pinta-ai/core/dist/lifecycle.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/lifecycle.js +20 -0
- package/node_modules/@pinta-ai/core/dist/lifecycle.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/matches.d.ts +24 -0
- package/node_modules/@pinta-ai/core/dist/matches.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/matches.js +39 -0
- package/node_modules/@pinta-ai/core/dist/matches.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/mysql-password.d.ts +15 -0
- package/node_modules/@pinta-ai/core/dist/mysql-password.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/mysql-password.js +375 -0
- package/node_modules/@pinta-ai/core/dist/mysql-password.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/otlp-types.d.ts +41 -0
- package/node_modules/@pinta-ai/core/dist/otlp-types.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/otlp-types.js +7 -0
- package/node_modules/@pinta-ai/core/dist/otlp-types.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/otlp.d.ts +142 -0
- package/node_modules/@pinta-ai/core/dist/otlp.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/otlp.js +638 -0
- package/node_modules/@pinta-ai/core/dist/otlp.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/output-denial.d.ts +69 -0
- package/node_modules/@pinta-ai/core/dist/output-denial.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/output-denial.js +105 -0
- package/node_modules/@pinta-ai/core/dist/output-denial.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/redact.d.ts +65 -0
- package/node_modules/@pinta-ai/core/dist/redact.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/redact.js +193 -0
- package/node_modules/@pinta-ai/core/dist/redact.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/retry-queue.d.ts +47 -0
- package/node_modules/@pinta-ai/core/dist/retry-queue.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/retry-queue.js +177 -0
- package/node_modules/@pinta-ai/core/dist/retry-queue.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/secret-shapes.d.ts +47 -0
- package/node_modules/@pinta-ai/core/dist/secret-shapes.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/secret-shapes.js +377 -0
- package/node_modules/@pinta-ai/core/dist/secret-shapes.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/session-trace.d.ts +50 -0
- package/node_modules/@pinta-ai/core/dist/session-trace.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/session-trace.js +103 -0
- package/node_modules/@pinta-ai/core/dist/session-trace.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/shape-rules.d.ts +117 -0
- package/node_modules/@pinta-ai/core/dist/shape-rules.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/shape-rules.js +592 -0
- package/node_modules/@pinta-ai/core/dist/shape-rules.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/trace.d.ts +17 -0
- package/node_modules/@pinta-ai/core/dist/trace.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/trace.js +78 -0
- package/node_modules/@pinta-ai/core/dist/trace.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/transport.d.ts +75 -0
- package/node_modules/@pinta-ai/core/dist/transport.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/transport.js +260 -0
- package/node_modules/@pinta-ai/core/dist/transport.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/value-copies.d.ts +46 -0
- package/node_modules/@pinta-ai/core/dist/value-copies.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/value-copies.js +279 -0
- package/node_modules/@pinta-ai/core/dist/value-copies.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/value-masking.d.ts +22 -0
- package/node_modules/@pinta-ai/core/dist/value-masking.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/value-masking.js +243 -0
- package/node_modules/@pinta-ai/core/dist/value-masking.js.map +1 -0
- package/node_modules/@pinta-ai/core/package.json +50 -0
- package/package.json +3 -1
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mysqlPasswordRanges = mysqlPasswordRanges;
|
|
4
|
+
exports.nonPasswordShortOptionRanges = nonPasswordShortOptionRanges;
|
|
5
|
+
const NON_PASSWORD_OPTIONS = new Map([
|
|
6
|
+
["find", /^-(?:path|print0?|printf|perm|prune)$/],
|
|
7
|
+
["mkdir", /^-p[v]*$/],
|
|
8
|
+
["node", /^-p/],
|
|
9
|
+
["nodejs", /^-p/],
|
|
10
|
+
["psql", /^-p/],
|
|
11
|
+
]);
|
|
12
|
+
const EXECUTABLES = new Set([
|
|
13
|
+
"mysql", "mysqldump", "mysqladmin", "mysqlcheck", "mysqlimport", "mysqlshow",
|
|
14
|
+
"mariadb", "mariadb-dump", "mariadb-admin", "mariadb-check", "mariadb-import", "mariadb-show",
|
|
15
|
+
]);
|
|
16
|
+
const SHELLS = new Set(["sh", "bash", "dash", "zsh", "ksh"]);
|
|
17
|
+
const VALUE_OPTIONS = new Set([
|
|
18
|
+
"-u", "--user", "-h", "--host", "-P", "--port", "-D", "--database",
|
|
19
|
+
"-S", "--socket", "-e", "--execute", "--protocol", "--default-character-set",
|
|
20
|
+
"--defaults-file", "--defaults-extra-file", "--login-path", "--init-command",
|
|
21
|
+
"--ssl-ca", "--ssl-capath", "--ssl-cert", "--ssl-key", "--ssl-cipher",
|
|
22
|
+
]);
|
|
23
|
+
const MAX_NESTING = 16;
|
|
24
|
+
function slice(text, start, end = text.value.length) {
|
|
25
|
+
return { value: text.value.slice(start, end), ranges: text.ranges.slice(start, end) };
|
|
26
|
+
}
|
|
27
|
+
function append(target, text, start, end) {
|
|
28
|
+
target.value += text.value.slice(start, end);
|
|
29
|
+
for (let index = start; index < end; index++)
|
|
30
|
+
target.ranges.push(text.ranges[index]);
|
|
31
|
+
}
|
|
32
|
+
function executable(word) {
|
|
33
|
+
if (!word?.literal)
|
|
34
|
+
return undefined;
|
|
35
|
+
return word.value.slice(word.value.lastIndexOf("/") + 1).replace(/\.exe$/, "");
|
|
36
|
+
}
|
|
37
|
+
function executionIndex(words) {
|
|
38
|
+
let index = 0;
|
|
39
|
+
for (let wrappers = 0; wrappers <= MAX_NESTING; wrappers++) {
|
|
40
|
+
while (/^[A-Za-z_][A-Za-z0-9_]*=/.test(words[index]?.value ?? ""))
|
|
41
|
+
index++;
|
|
42
|
+
const name = executable(words[index]);
|
|
43
|
+
if (!name)
|
|
44
|
+
return undefined;
|
|
45
|
+
if (["!", "if", "then", "elif", "else", "while", "until", "do"].includes(name)) {
|
|
46
|
+
index++;
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
const optionValues = {
|
|
50
|
+
env: ["-u", "--unset", "-C", "--chdir"],
|
|
51
|
+
sudo: ["-u", "--user", "-g", "--group", "-p", "--prompt", "-D", "--chdir",
|
|
52
|
+
"-R", "--chroot", "-C", "--close-from", "-T", "--command-timeout"],
|
|
53
|
+
exec: ["-a"],
|
|
54
|
+
nice: ["-n", "--adjustment"],
|
|
55
|
+
timeout: ["-s", "--signal", "-k", "--kill-after"],
|
|
56
|
+
};
|
|
57
|
+
const flags = {
|
|
58
|
+
env: ["-i", "--ignore-environment", "-0", "--null"],
|
|
59
|
+
sudo: ["-n", "-E", "-H", "-S", "-b", "-k"],
|
|
60
|
+
command: ["-p"],
|
|
61
|
+
exec: ["-c", "-l"],
|
|
62
|
+
nohup: [],
|
|
63
|
+
nice: [],
|
|
64
|
+
time: ["-p"],
|
|
65
|
+
timeout: ["--foreground", "--preserve-status"],
|
|
66
|
+
};
|
|
67
|
+
if (!Object.prototype.hasOwnProperty.call(flags, name))
|
|
68
|
+
return index;
|
|
69
|
+
index++;
|
|
70
|
+
while (words[index]?.value.startsWith("-")) {
|
|
71
|
+
const option = words[index++].value;
|
|
72
|
+
if (option === "--")
|
|
73
|
+
break;
|
|
74
|
+
if (flags[name].includes(option))
|
|
75
|
+
continue;
|
|
76
|
+
if ((optionValues[name] ?? []).includes(option)) {
|
|
77
|
+
if (!words[index++])
|
|
78
|
+
return undefined;
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
if ((optionValues[name] ?? []).some((key) => key.startsWith("--") ? option.startsWith(key + "=") : option.startsWith(key) && option.length > 2))
|
|
82
|
+
continue;
|
|
83
|
+
if (name === "nice" && /^-\d+$/.test(option))
|
|
84
|
+
continue;
|
|
85
|
+
return undefined;
|
|
86
|
+
}
|
|
87
|
+
if (name === "timeout") {
|
|
88
|
+
if (!/^\d+(?:\.\d+)?[smhd]?$/.test(words[index++]?.value ?? ""))
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
94
|
+
function substitutionEnd(text, start) {
|
|
95
|
+
let nesting = 1;
|
|
96
|
+
let quote = "";
|
|
97
|
+
for (let index = start; index < text.length; index++) {
|
|
98
|
+
const char = text[index];
|
|
99
|
+
if (char === "\\" && quote !== "'") {
|
|
100
|
+
index++;
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (quote) {
|
|
104
|
+
if (char === quote)
|
|
105
|
+
quote = "";
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
if (char === "'" || char === '"')
|
|
109
|
+
quote = char;
|
|
110
|
+
else if (char === "(")
|
|
111
|
+
nesting++;
|
|
112
|
+
else if (char === ")" && --nesting === 0)
|
|
113
|
+
return index;
|
|
114
|
+
}
|
|
115
|
+
return text.length;
|
|
116
|
+
}
|
|
117
|
+
function readWord(text, start, out, depth) {
|
|
118
|
+
const word = { value: "", ranges: [], start, end: start, literal: true };
|
|
119
|
+
let quote = "";
|
|
120
|
+
let index = start;
|
|
121
|
+
while (index < text.value.length) {
|
|
122
|
+
const char = text.value[index];
|
|
123
|
+
if (!quote && /[\s;|&()<>{}]/.test(char))
|
|
124
|
+
break;
|
|
125
|
+
if (char === quote) {
|
|
126
|
+
quote = "";
|
|
127
|
+
index++;
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
if (!quote && (char === "'" || char === '"')) {
|
|
131
|
+
quote = char;
|
|
132
|
+
index++;
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
if (char === "\\" && quote !== "'") {
|
|
136
|
+
const next = text.value[index + 1];
|
|
137
|
+
if (next === "\n") {
|
|
138
|
+
index += 2;
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
if (next && (!quote || /[$`"\\]/.test(next))) {
|
|
142
|
+
append(word, text, index + 1, index + 2);
|
|
143
|
+
index += 2;
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
if (quote !== "'" && text.value.startsWith("$(", index)) {
|
|
148
|
+
const end = substitutionEnd(text.value, index + 2);
|
|
149
|
+
if (text.value[index + 2] !== "(" && depth < MAX_NESTING) {
|
|
150
|
+
scanShell(slice(text, index + 2, end), out, depth + 1);
|
|
151
|
+
}
|
|
152
|
+
append(word, text, index, Math.min(end + 1, text.value.length));
|
|
153
|
+
word.literal = false;
|
|
154
|
+
index = Math.min(end + 1, text.value.length);
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
if (char === "`" && quote !== "'") {
|
|
158
|
+
let end = index + 1;
|
|
159
|
+
while (end < text.value.length && text.value[end] !== "`") {
|
|
160
|
+
end += text.value[end] === "\\" ? 2 : 1;
|
|
161
|
+
}
|
|
162
|
+
if (depth < MAX_NESTING)
|
|
163
|
+
scanShell(slice(text, index + 1, end), out, depth + 1);
|
|
164
|
+
append(word, text, index, Math.min(end + 1, text.value.length));
|
|
165
|
+
word.literal = false;
|
|
166
|
+
index = Math.min(end + 1, text.value.length);
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
if (char === "$" && quote !== "'")
|
|
170
|
+
word.literal = false;
|
|
171
|
+
append(word, text, index, index + 1);
|
|
172
|
+
index++;
|
|
173
|
+
}
|
|
174
|
+
word.end = index;
|
|
175
|
+
return word;
|
|
176
|
+
}
|
|
177
|
+
function scanCommand(text, words, out, depth) {
|
|
178
|
+
const index = executionIndex(words);
|
|
179
|
+
if (index === undefined)
|
|
180
|
+
return;
|
|
181
|
+
const name = executable(words[index]);
|
|
182
|
+
if (SHELLS.has(name) && depth < MAX_NESTING) {
|
|
183
|
+
for (let option = index + 1; option < words.length; option++) {
|
|
184
|
+
const value = words[option].value;
|
|
185
|
+
if (value === "--command" || /^-[a-zA-Z]*c[a-zA-Z]*$/.test(value)) {
|
|
186
|
+
const script = words[option + 1];
|
|
187
|
+
if (script)
|
|
188
|
+
scanShell(script, out, depth + 1);
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
if (!value.startsWith("-") || value === "--")
|
|
192
|
+
return;
|
|
193
|
+
if (value === "-o" || value === "-O")
|
|
194
|
+
option++;
|
|
195
|
+
}
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
if (out.purpose === "non-password") {
|
|
199
|
+
const pattern = NON_PASSWORD_OPTIONS.get(name);
|
|
200
|
+
if (!pattern)
|
|
201
|
+
return;
|
|
202
|
+
for (const word of words.slice(index + 1)) {
|
|
203
|
+
if (!word.literal)
|
|
204
|
+
return;
|
|
205
|
+
if (word.value === "--" || (name === "find" && /^-(?:exec|execdir|ok|okdir)$/.test(word.value)))
|
|
206
|
+
return;
|
|
207
|
+
if (pattern.test(word.value)) {
|
|
208
|
+
out.ranges.push({ start: text.ranges[word.start].start, end: text.ranges[word.end - 1].end });
|
|
209
|
+
}
|
|
210
|
+
// Later Node arguments can belong to a script or another option's value.
|
|
211
|
+
if (name === "node" || name === "nodejs")
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
if (!EXECUTABLES.has(name))
|
|
217
|
+
return;
|
|
218
|
+
for (let option = index + 1; option < words.length; option++) {
|
|
219
|
+
const word = words[option];
|
|
220
|
+
if (word.value === "--")
|
|
221
|
+
return;
|
|
222
|
+
if (VALUE_OPTIONS.has(word.value)) {
|
|
223
|
+
option++;
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
// Bare -p prompts interactively; the next positional word is not its password.
|
|
227
|
+
if (word.value.startsWith("-p") && word.value.length > 2) {
|
|
228
|
+
out.ranges.push({ start: text.ranges[word.start].start, end: text.ranges[word.end - 1].end });
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
function scanShell(text, out, depth = 0) {
|
|
233
|
+
let words = [];
|
|
234
|
+
let redirect;
|
|
235
|
+
const documents = [];
|
|
236
|
+
let index = 0;
|
|
237
|
+
const flush = () => {
|
|
238
|
+
scanCommand(text, words, out, depth);
|
|
239
|
+
words = [];
|
|
240
|
+
redirect = undefined;
|
|
241
|
+
};
|
|
242
|
+
while (index < text.value.length) {
|
|
243
|
+
const char = text.value[index];
|
|
244
|
+
if (char === "\n") {
|
|
245
|
+
flush();
|
|
246
|
+
index++;
|
|
247
|
+
for (const document of documents.splice(0)) {
|
|
248
|
+
while (index < text.value.length) {
|
|
249
|
+
const end = text.value.indexOf("\n", index);
|
|
250
|
+
const stop = end < 0 ? text.value.length : end;
|
|
251
|
+
const line = text.value.slice(index, stop);
|
|
252
|
+
index = end < 0 ? stop : stop + 1;
|
|
253
|
+
if ((document.stripTabs ? line.replace(/^\t+/, "") : line) === document.delimiter)
|
|
254
|
+
break;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
else if (/\s/.test(char)) {
|
|
259
|
+
index++;
|
|
260
|
+
}
|
|
261
|
+
else if (char === "#") {
|
|
262
|
+
const end = text.value.indexOf("\n", index);
|
|
263
|
+
index = end < 0 ? text.value.length : end;
|
|
264
|
+
}
|
|
265
|
+
else if (text.value.startsWith("((", index)) {
|
|
266
|
+
flush();
|
|
267
|
+
index = Math.min(substitutionEnd(text.value, index + 1) + 1, text.value.length);
|
|
268
|
+
}
|
|
269
|
+
else if (/[;|&(){}]/.test(char)) {
|
|
270
|
+
flush();
|
|
271
|
+
index++;
|
|
272
|
+
}
|
|
273
|
+
else if (char === "<" || char === ">") {
|
|
274
|
+
if (words.at(-1)?.end === index && /^\d+$/.test(words.at(-1).value))
|
|
275
|
+
words.pop();
|
|
276
|
+
const match = /^(?:<<<|<<-?|>>|<&|>&|[<>])/.exec(text.value.slice(index));
|
|
277
|
+
redirect = match?.[0] ?? char;
|
|
278
|
+
index += redirect.length;
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
const word = readWord(text, index, out, depth);
|
|
282
|
+
index = word.end;
|
|
283
|
+
if (redirect === "<<" || redirect === "<<-") {
|
|
284
|
+
documents.push({ delimiter: word.value, stripTabs: redirect === "<<-" });
|
|
285
|
+
}
|
|
286
|
+
if (!redirect)
|
|
287
|
+
words.push(word);
|
|
288
|
+
redirect = undefined;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
flush();
|
|
292
|
+
}
|
|
293
|
+
function jsonString(text, start, end) {
|
|
294
|
+
const result = { value: "", ranges: [] };
|
|
295
|
+
for (let index = start + 1; index < end - 1; index++) {
|
|
296
|
+
if (text.value[index] !== "\\") {
|
|
297
|
+
append(result, text, index, index + 1);
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
const stop = index + (text.value[index + 1] === "u" ? 6 : 2);
|
|
301
|
+
const decoded = JSON.parse(`"${text.value.slice(index, stop)}"`);
|
|
302
|
+
result.value += decoded;
|
|
303
|
+
for (let unit = 0; unit < decoded.length; unit++) {
|
|
304
|
+
result.ranges.push({ start: text.ranges[index].start, end: text.ranges[stop - 1].end });
|
|
305
|
+
}
|
|
306
|
+
index = stop - 1;
|
|
307
|
+
}
|
|
308
|
+
return result;
|
|
309
|
+
}
|
|
310
|
+
function scanOptionText(text, out, jsonStringValues, depth = 0) {
|
|
311
|
+
if (depth > MAX_NESTING)
|
|
312
|
+
return;
|
|
313
|
+
const input = text.value;
|
|
314
|
+
if (/^\s*[{[]/.test(input)) {
|
|
315
|
+
let parsed;
|
|
316
|
+
try {
|
|
317
|
+
parsed = JSON.parse(input);
|
|
318
|
+
}
|
|
319
|
+
catch {
|
|
320
|
+
scanShell(text, out);
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
if (parsed !== null && typeof parsed === "object") {
|
|
324
|
+
// Execution context stays field-restricted. MCP's wider text scan can also
|
|
325
|
+
// prove flag roles in returned string values, never member names.
|
|
326
|
+
const strings = /"(?:[^"\\]|\\.)*"/g;
|
|
327
|
+
let match;
|
|
328
|
+
while ((match = strings.exec(input))) {
|
|
329
|
+
if (jsonStringValues) {
|
|
330
|
+
if (!/^\s*:/.test(input.slice(strings.lastIndex))) {
|
|
331
|
+
scanOptionText(jsonString(text, match.index, strings.lastIndex), out, true, depth + 1);
|
|
332
|
+
}
|
|
333
|
+
continue;
|
|
334
|
+
}
|
|
335
|
+
const key = JSON.parse(match[0]);
|
|
336
|
+
if (key !== "command" && key !== "cmd" && key !== "CommandLine")
|
|
337
|
+
continue;
|
|
338
|
+
const separator = /^\s*:\s*/.exec(input.slice(strings.lastIndex));
|
|
339
|
+
if (!separator)
|
|
340
|
+
continue;
|
|
341
|
+
const start = strings.lastIndex + separator[0].length;
|
|
342
|
+
if (input[start] !== '"')
|
|
343
|
+
continue;
|
|
344
|
+
strings.lastIndex = start;
|
|
345
|
+
const value = strings.exec(input);
|
|
346
|
+
if (value?.index === start) {
|
|
347
|
+
scanShell(jsonString(text, start, start + value[0].length), out);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
scanShell(text, out);
|
|
354
|
+
}
|
|
355
|
+
function collectOptionRanges(input, purpose, jsonStringValues = false) {
|
|
356
|
+
const text = {
|
|
357
|
+
value: input,
|
|
358
|
+
ranges: Array.from({ length: input.length }, (_, index) => ({ start: index, end: index + 1 })),
|
|
359
|
+
};
|
|
360
|
+
const out = { ranges: [], purpose };
|
|
361
|
+
scanOptionText(text, out, jsonStringValues);
|
|
362
|
+
return out.ranges;
|
|
363
|
+
}
|
|
364
|
+
/** Literal executable/option ranges only. Never evaluates shell text or reads files. */
|
|
365
|
+
function mysqlPasswordRanges(input) {
|
|
366
|
+
return collectOptionRanges(input, "mysql-password");
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Proven non-password flags only. Unknown consumers are not exemptions.
|
|
370
|
+
* jsonStringValues matches MCP's legacy scan of returned JSON text, not execution context.
|
|
371
|
+
*/
|
|
372
|
+
function nonPasswordShortOptionRanges(input, options = {}) {
|
|
373
|
+
return collectOptionRanges(input, "non-password", options.jsonStringValues === true);
|
|
374
|
+
}
|
|
375
|
+
//# sourceMappingURL=mysql-password.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mysql-password.js","sourceRoot":"","sources":["../src/mysql-password.ts"],"names":[],"mappings":";;AAkWA,kDAEC;AAMD,oEAEC;AAvVD,MAAM,oBAAoB,GAAgC,IAAI,GAAG,CAAC;IAChE,CAAC,MAAM,EAAE,uCAAuC,CAAC;IACjD,CAAC,OAAO,EAAE,UAAU,CAAC;IACrB,CAAC,MAAM,EAAE,KAAK,CAAC;IACf,CAAC,QAAQ,EAAE,KAAK,CAAC;IACjB,CAAC,MAAM,EAAE,KAAK,CAAC;CAChB,CAAC,CAAC;AAEH,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC;IAC1B,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,WAAW;IAC5E,SAAS,EAAE,cAAc,EAA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AE,KAAK;QACZ,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC;KAC/F,CAAC;IACF,MAAM,GAAG,GAAe,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC;IAChD,cAAc,CAAC,IAAI,EAAE,GAAG,EAAE,gBAAgB,CAAC,CAAC;IAC5C,OAAO,GAAG,CAAC,MAAM,CAAC;AACpB,CAAC;AAED,wFAAwF;AACxF,SAAgB,mBAAmB,CAAC,KAAa;IAC/C,OAAO,mBAAmB,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;AACtD,CAAC;AAED;;;GAGG;AACH,SAAgB,4BAA4B,CAAC,KAAa,EAAE,UAA0C,EAAE;IACtG,OAAO,mBAAmB,CAAC,KAAK,EAAE,cAAc,EAAE,OAAO,CAAC,gBAAgB,KAAK,IAAI,CAAC,CAAC;AACvF,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OTLP/HTTP JSON wire types shared by every Pinta adapter. These mirror the
|
|
3
|
+
* subset of the OpenTelemetry trace export schema the adapters actually emit.
|
|
4
|
+
*/
|
|
5
|
+
export interface OtlpAttribute {
|
|
6
|
+
key: string;
|
|
7
|
+
value: {
|
|
8
|
+
stringValue: string;
|
|
9
|
+
} | {
|
|
10
|
+
intValue: number;
|
|
11
|
+
} | {
|
|
12
|
+
doubleValue: number;
|
|
13
|
+
} | {
|
|
14
|
+
boolValue: boolean;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export interface OtlpSpan {
|
|
18
|
+
traceId: string;
|
|
19
|
+
spanId: string;
|
|
20
|
+
name: string;
|
|
21
|
+
kind: number;
|
|
22
|
+
startTimeUnixNano: string;
|
|
23
|
+
endTimeUnixNano: string;
|
|
24
|
+
attributes: OtlpAttribute[];
|
|
25
|
+
}
|
|
26
|
+
export interface ResourceSpans {
|
|
27
|
+
resource: {
|
|
28
|
+
attributes: OtlpAttribute[];
|
|
29
|
+
};
|
|
30
|
+
scopeSpans: Array<{
|
|
31
|
+
scope: {
|
|
32
|
+
name: string;
|
|
33
|
+
version: string;
|
|
34
|
+
};
|
|
35
|
+
spans: OtlpSpan[];
|
|
36
|
+
}>;
|
|
37
|
+
}
|
|
38
|
+
export interface OtlpPayload {
|
|
39
|
+
resourceSpans: ResourceSpans[];
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=otlp-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"otlp-types.d.ts","sourceRoot":"","sources":["../src/otlp-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EACD;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,GACvB;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,GACpB;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,GACvB;QAAE,SAAS,EAAE,OAAO,CAAA;KAAE,CAAC;CAC5B;AAED,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB,EAAE,MAAM,CAAC;IAC1B,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,aAAa,EAAE,CAAC;CAC7B;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE;QAAE,UAAU,EAAE,aAAa,EAAE,CAAA;KAAE,CAAC;IAC1C,UAAU,EAAE,KAAK,CAAC;QAChB,KAAK,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,MAAM,CAAA;SAAE,CAAC;QACzC,KAAK,EAAE,QAAQ,EAAE,CAAC;KACnB,CAAC,CAAC;CACJ;AAED,MAAM,WAAW,WAAW;IAC1B,aAAa,EAAE,aAAa,EAAE,CAAC;CAChC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* OTLP/HTTP JSON wire types shared by every Pinta adapter. These mirror the
|
|
4
|
+
* subset of the OpenTelemetry trace export schema the adapters actually emit.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
//# sourceMappingURL=otlp-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"otlp-types.js","sourceRoot":"","sources":["../src/otlp-types.ts"],"names":[],"mappings":";AAAA;;;GAGG"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import type { GuardResult } from "./guard.js";
|
|
2
|
+
import type { OtlpAttribute, OtlpPayload, OtlpSpan } from "./otlp-types.js";
|
|
3
|
+
export type { OtlpAttribute, OtlpPayload, OtlpSpan, ResourceSpans } from "./otlp-types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Convert a 26-char Crockford ULID into 32 lowercase hex chars (16 bytes)
|
|
6
|
+
* suitable for an OTLP traceId. Decoding is straightforward because each
|
|
7
|
+
* Crockford char carries 5 bits and 26 chars = 130 bits; we keep the low
|
|
8
|
+
* 128 bits (the spec already pads timestamp+randomness into 128 bits).
|
|
9
|
+
*/
|
|
10
|
+
export declare function ulidToTraceId(ulid: string): string;
|
|
11
|
+
/** Generate a fresh 16-hex-char (8-byte) span ID. */
|
|
12
|
+
export declare function newSpanId(): string;
|
|
13
|
+
/** "PreToolUse" → "pre_tool_use". */
|
|
14
|
+
export declare function snakeCase(name: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Per-attribute redaction policy. Keys here are the FINAL attribute keys
|
|
17
|
+
* (already prefixed, e.g. "cc.tool_input").
|
|
18
|
+
*/
|
|
19
|
+
export interface AttrPolicy {
|
|
20
|
+
/** Keys for which Tier-1 redaction is skipped (truncation still applies). */
|
|
21
|
+
skipRedactKeys?: ReadonlySet<string>;
|
|
22
|
+
/** Keys whose value may carry shell command text → redact with bash context. */
|
|
23
|
+
bashContextKeys?: ReadonlySet<string>;
|
|
24
|
+
/** Native returned content, selected before masking; never sent as provenance. */
|
|
25
|
+
outputForKey?: (key: string, value: unknown) => unknown;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The version of `payload` the guard judges, or the payload itself. `buildPayload`
|
|
29
|
+
* returns the version that is stored; the guard sees the one built with the
|
|
30
|
+
* masker `pinta-core` has always used, so its verdicts do not move.
|
|
31
|
+
*/
|
|
32
|
+
export declare function guardVersionOf(payload: OtlpPayload): OtlpPayload;
|
|
33
|
+
/**
|
|
34
|
+
* Convert a JS value into an OTLP attribute value (with redaction/truncation
|
|
35
|
+
* applied to strings). `key` is the final attribute key. Returns null to omit.
|
|
36
|
+
*/
|
|
37
|
+
export declare function toOtlpValue(key: string, v: unknown, policy?: AttrPolicy): OtlpAttribute["value"] | null;
|
|
38
|
+
/**
|
|
39
|
+
* Flatten a record into prefixed OTLP attributes, applying the redaction
|
|
40
|
+
* pipeline. Each adapter passes its own `prefix` (e.g. "cc") and policy.
|
|
41
|
+
* Keys are emitted as `<prefix>.<recordKey>`; null/undefined values are omitted.
|
|
42
|
+
*/
|
|
43
|
+
export declare function attrsFromRecord(record: Record<string, unknown>, prefix: string, policy?: AttrPolicy): OtlpAttribute[];
|
|
44
|
+
/** Build the standard pinta.guard.* attributes from a guard result. */
|
|
45
|
+
export declare function guardAttrs(guard: GuardResult): OtlpAttribute[];
|
|
46
|
+
/** Which sidecar call a client-measured RTT belongs to. */
|
|
47
|
+
export interface ClientCallTiming {
|
|
48
|
+
op: "guard" | "trace_post";
|
|
49
|
+
/** Wall-clock RTT in ms, as measured by this client (not the sidecar). */
|
|
50
|
+
rttMs: number;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Build the `pinta.client.*` attributes describing how long *this* client waited
|
|
54
|
+
* on a sidecar call. The sidecar can only time its own handler, so it cannot see
|
|
55
|
+
* the transport/IPC overhead; reporting our wall-clock lets it derive that.
|
|
56
|
+
*
|
|
57
|
+
* Note `op: "trace_post"` is intentionally not emitted automatically: a trace
|
|
58
|
+
* POST's RTT is only known once the POST completes, by which point its spans are
|
|
59
|
+
* already on the wire (and may be re-batched by the retry queue), so it could
|
|
60
|
+
* only ride a later batch. `op: "guard"` has no such lag — the guard call is
|
|
61
|
+
* awaited before the span is built.
|
|
62
|
+
*/
|
|
63
|
+
export declare function clientAttrs(timing: ClientCallTiming): OtlpAttribute[];
|
|
64
|
+
export interface BuildPayloadArgs {
|
|
65
|
+
/** ULID (26 Crockford chars) — converted to a 128-bit hex traceId. */
|
|
66
|
+
traceId: string;
|
|
67
|
+
spanName: string;
|
|
68
|
+
/** Span attributes — adapter-built (e.g. via attrsFromRecord). */
|
|
69
|
+
attributes: OtlpAttribute[];
|
|
70
|
+
/** Resource attributes — adapter-specific (service.name/version, host, etc.). */
|
|
71
|
+
resource: OtlpAttribute[];
|
|
72
|
+
scope: {
|
|
73
|
+
name: string;
|
|
74
|
+
version: string;
|
|
75
|
+
};
|
|
76
|
+
/** ms since epoch; injectable for tests. Defaults to Date.now(). */
|
|
77
|
+
now?: number;
|
|
78
|
+
/** Optional guard result; its pinta.guard.* attrs are appended. */
|
|
79
|
+
guard?: GuardResult | null;
|
|
80
|
+
/**
|
|
81
|
+
* Optional client-call timing; its pinta.client.* attrs are appended. When
|
|
82
|
+
* omitted, a `guard` result carrying `clientRttMs` supplies it automatically
|
|
83
|
+
* (op: "guard"), so adapters get client RTT reporting without any code change.
|
|
84
|
+
*/
|
|
85
|
+
clientTiming?: ClientCallTiming | null;
|
|
86
|
+
/** OTLP span kind. Defaults to 1 (SPAN_KIND_INTERNAL). */
|
|
87
|
+
spanKind?: number;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Per-span byte budget, enforced by `buildPayload`.
|
|
91
|
+
*
|
|
92
|
+
* Sits under the transport's per-POST budget (`MAX_POST_BYTES`, 900 KiB —
|
|
93
|
+
* itself sized against aware-backend's 1,000,000 B `POST /traces` bodyLimit)
|
|
94
|
+
* with headroom for the resource/scope envelope. Without this, per-string
|
|
95
|
+
* truncation alone (`MAX_BYTES`, 100 KiB) lets a span with ~10 payload
|
|
96
|
+
* attributes exceed what the backend will ever accept, and such a span is
|
|
97
|
+
* indivisible downstream — it can only be dropped whole.
|
|
98
|
+
*/
|
|
99
|
+
export declare const MAX_SPAN_BYTES: number;
|
|
100
|
+
/**
|
|
101
|
+
* Shrink a span in place until it serializes to <= `maxBytes`, by re-truncating
|
|
102
|
+
* its largest string attributes (largest first). Non-string values, keys, and
|
|
103
|
+
* already-small strings are left untouched. Gives up (span stays oversized)
|
|
104
|
+
* only when no truncatable string above `MIN_ATTR_KEEP_BYTES` remains — the
|
|
105
|
+
* transport then drops it with a diagnostic instead of poisoning a batch.
|
|
106
|
+
*/
|
|
107
|
+
export declare function enforceSpanBudget(span: OtlpSpan, maxBytes?: number): OtlpSpan;
|
|
108
|
+
/**
|
|
109
|
+
* Assemble a single-span OTLP payload. The adapter owns attribute/resource
|
|
110
|
+
* construction; this owns the envelope shape and guard-attr appending.
|
|
111
|
+
*
|
|
112
|
+
* Two versions of the span are built from the same ids and time (PTA-735). The
|
|
113
|
+
* one returned is what is relayed and stored: the original text with only the
|
|
114
|
+
* ranges of values replaced, so a secret is hidden and every other byte keeps
|
|
115
|
+
* its place. The one the guard judges is attached to it (`guardVersionOf`) and
|
|
116
|
+
* is the text `pinta-core` has always produced, so the verdicts the sidecar
|
|
117
|
+
* gives do not move. If that version cannot be built the guard is sent the
|
|
118
|
+
* stored one.
|
|
119
|
+
*/
|
|
120
|
+
export declare function buildPayload(args: BuildPayloadArgs): OtlpPayload;
|
|
121
|
+
/**
|
|
122
|
+
* Append the guard verdict — and the client-measured RTT of the call that
|
|
123
|
+
* produced it — to a payload that was built before the guard was asked.
|
|
124
|
+
*
|
|
125
|
+
* This is the second half of the 0.8.0 guard flow: `buildPayload` (no guard)
|
|
126
|
+
* → `evaluateGuard(payload)` → `attachGuard(payload, guard)` → send. The same
|
|
127
|
+
* object goes to the manager and to the relay, so the span judged and the span
|
|
128
|
+
* stored share one `spanId`. Appends to the first span only — a single-span
|
|
129
|
+
* payload is what `buildPayload` produces and what the guard route takes.
|
|
130
|
+
*
|
|
131
|
+
* Mirrors the `guard`/`clientTiming` handling of `buildPayload` exactly; the
|
|
132
|
+
* attributes are the same, only the moment they are added differs. A null or
|
|
133
|
+
* undefined `guard` (guarding inactive) attaches nothing unless an explicit
|
|
134
|
+
* `clientTiming` is given. Returns the same object for chaining.
|
|
135
|
+
*/
|
|
136
|
+
export declare function attachGuard(payload: OtlpPayload, guard: GuardResult | null | undefined, clientTiming?: ClientCallTiming | null): OtlpPayload;
|
|
137
|
+
/**
|
|
138
|
+
* Combine multiple per-event payloads into one by concatenating their
|
|
139
|
+
* resourceSpans arrays. aware-backend's parser iterates resourceSpans natively.
|
|
140
|
+
*/
|
|
141
|
+
export declare function mergeBatch(payloads: OtlpPayload[]): OtlpPayload;
|
|
142
|
+
//# sourceMappingURL=otlp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"otlp.d.ts","sourceRoot":"","sources":["../src/otlp.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAiB,MAAM,iBAAiB,CAAC;AAE3F,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAI3F;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAgBlD;AAED,qD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