@tellagen/mcp-server 0.5.0 → 0.6.0
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/README.md +32 -6
- package/SKILL.md +44 -7
- package/contracts/mcp-protocol.json +13 -1
- package/contracts/runbooks/manifest.json +20 -10
- package/contracts/runbooks/v2/client-protocol.json +59 -2
- package/contracts/runbooks/v2/client-writes.guidance.json +16 -1
- package/contracts/runbooks/v2/fixtures/timeline-event-blocks-rejected.json +15 -1
- package/contracts/runbooks/v2/investigation-window.guidance.json +45 -0
- package/contracts/runbooks/v2/question-checks.guidance.json +49 -0
- package/contracts/runbooks/v2/timeline-event-blocks.schema.json +62 -1
- package/contracts/tellagen-runbook-contracts.json +3 -3
- package/dist/cli/doctor.d.ts +19 -0
- package/dist/cli/doctor.js +212 -0
- package/dist/cli/doctor.js.map +1 -0
- package/dist/cli/main.js +5 -0
- package/dist/cli/main.js.map +1 -1
- package/dist/diagnosis-structure.d.ts +131 -106
- package/dist/diagnosis-structure.js +64 -7
- package/dist/diagnosis-structure.js.map +1 -1
- package/dist/doctor/checks.d.ts +42 -0
- package/dist/doctor/checks.js +175 -0
- package/dist/doctor/checks.js.map +1 -0
- package/dist/doctor/config-files.d.ts +49 -0
- package/dist/doctor/config-files.js +121 -0
- package/dist/doctor/config-files.js.map +1 -0
- package/dist/doctor/toml.d.ts +13 -0
- package/dist/doctor/toml.js +205 -0
- package/dist/doctor/toml.js.map +1 -0
- package/dist/figures.d.ts +447 -123
- package/dist/figures.js +297 -5
- package/dist/figures.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/k8s-safety.d.ts +42 -0
- package/dist/k8s-safety.js +33 -0
- package/dist/k8s-safety.js.map +1 -0
- package/dist/log-lines.d.ts +118 -0
- package/dist/log-lines.js +534 -0
- package/dist/log-lines.js.map +1 -0
- package/dist/redact.d.ts +21 -0
- package/dist/redact.js +212 -5
- package/dist/redact.js.map +1 -1
- package/dist/run-state.d.ts +37 -0
- package/dist/run-state.js +14 -0
- package/dist/run-state.js.map +1 -1
- package/dist/run-window.d.ts +59 -0
- package/dist/run-window.js +141 -0
- package/dist/run-window.js.map +1 -0
- package/dist/server.d.ts +1 -1
- package/dist/server.js +1 -1
- package/dist/session.d.ts +13 -0
- package/dist/session.js +32 -0
- package/dist/session.js.map +1 -1
- package/dist/source-bases.d.ts +75 -0
- package/dist/source-bases.js +125 -0
- package/dist/source-bases.js.map +1 -0
- package/dist/tool-report.d.ts +2 -0
- package/dist/tool-report.js +3 -0
- package/dist/tool-report.js.map +1 -0
- package/dist/tools/catalog.js +1 -0
- package/dist/tools/catalog.js.map +1 -1
- package/dist/tools/datasources.js +70 -13
- package/dist/tools/datasources.js.map +1 -1
- package/dist/tools/diagnostics.js +85 -2
- package/dist/tools/diagnostics.js.map +1 -1
- package/dist/tools/figures.d.ts +2 -2
- package/dist/tools/figures.js +29 -7
- package/dist/tools/figures.js.map +1 -1
- package/dist/tools/findings.d.ts +8 -0
- package/dist/tools/findings.js +63 -2
- package/dist/tools/findings.js.map +1 -1
- package/dist/tools/investigations.d.ts +1 -1
- package/dist/tools/investigations.js +46 -4
- package/dist/tools/investigations.js.map +1 -1
- package/dist/tools/postmortem-runbooks.d.ts +20 -20
- package/dist/tools/source-links.d.ts +23 -0
- package/dist/tools/source-links.js +53 -16
- package/dist/tools/source-links.js.map +1 -1
- package/dist/tools/timeline.js +13 -2
- package/dist/tools/timeline.js.map +1 -1
- package/dist/version.d.ts +2 -2
- package/dist/version.js +3 -1
- package/dist/version.js.map +1 -1
- package/package.json +1 -1
- package/server.json +5 -5
|
@@ -0,0 +1,534 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds the lines of a `log_lines` figure from the result of a Loki query.
|
|
3
|
+
*
|
|
4
|
+
* The figure shows the log lines that prove a claim, or the proof that there
|
|
5
|
+
* are none: how many lines matched out of how many were scanned, in what
|
|
6
|
+
* range, and at most 8 of the matches, each with a time, a level, the text as
|
|
7
|
+
* logged and a relation to the event. This module only reshapes what a tool
|
|
8
|
+
* returned. It never writes a line, a count or a time of its own, and a line
|
|
9
|
+
* it cannot read is reported by name, not guessed.
|
|
10
|
+
*
|
|
11
|
+
* Two result shapes are read:
|
|
12
|
+
* - the Loki HTTP API: streams of `{stream: {labels}, values: [[ns, line]]}`;
|
|
13
|
+
* - a flat list of entries `{timestamp, line, labels}`, as the Grafana MCP
|
|
14
|
+
* server and most log tools return.
|
|
15
|
+
*/
|
|
16
|
+
import { createHash } from "node:crypto";
|
|
17
|
+
import { isPairNameKey, isPairValueKey, isSecretKey, redactLogText } from "./redact.js";
|
|
18
|
+
export const MAX_LOG_LINES = 8;
|
|
19
|
+
export const MAX_LOG_TEXT = 500;
|
|
20
|
+
export const MAX_LOG_NOTE = 160;
|
|
21
|
+
export const MAX_LOG_FIELDS = 6;
|
|
22
|
+
export const MAX_LOG_FIELD_KEY = 40;
|
|
23
|
+
export const MAX_LOG_FIELD_VALUE = 200;
|
|
24
|
+
export const MAX_LOG_COUNT = 1_000_000_000;
|
|
25
|
+
/** The most of one raw line that is read. The rest is dropped and never sent. */
|
|
26
|
+
export const MAX_LOG_INPUT_LINE = 8192;
|
|
27
|
+
/** The most of one label value that is read. */
|
|
28
|
+
export const MAX_LOG_INPUT_LABEL = 1000;
|
|
29
|
+
/** The most entries of a result that are read. */
|
|
30
|
+
export const MAX_LOG_INPUT_ENTRIES = 5000;
|
|
31
|
+
function isRecord(value) {
|
|
32
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
33
|
+
}
|
|
34
|
+
/* ------------------------------------------------------------------ */
|
|
35
|
+
/* Times */
|
|
36
|
+
/* ------------------------------------------------------------------ */
|
|
37
|
+
/**
|
|
38
|
+
* A time as milliseconds since the epoch. Loki sends nanoseconds as a digit
|
|
39
|
+
* string; other tools send an RFC 3339 time or a number of seconds,
|
|
40
|
+
* milliseconds, microseconds or nanoseconds. Undefined when it is none of
|
|
41
|
+
* these.
|
|
42
|
+
*/
|
|
43
|
+
export function logTimeMs(value) {
|
|
44
|
+
if (typeof value === "number") {
|
|
45
|
+
if (!Number.isFinite(value) || value <= 0)
|
|
46
|
+
return undefined;
|
|
47
|
+
return unitMs(Math.trunc(value).toString());
|
|
48
|
+
}
|
|
49
|
+
if (typeof value !== "string")
|
|
50
|
+
return undefined;
|
|
51
|
+
const text = value.trim();
|
|
52
|
+
if (/^\d{9,20}$/.test(text))
|
|
53
|
+
return unitMs(text);
|
|
54
|
+
const at = Date.parse(text);
|
|
55
|
+
return Number.isFinite(at) && at > Date.UTC(2000, 0, 1) ? at : undefined;
|
|
56
|
+
}
|
|
57
|
+
function unitMs(digits) {
|
|
58
|
+
// Digits count: 10 seconds, 13 milliseconds, 16 microseconds, 19 nanoseconds.
|
|
59
|
+
const n = digits.length;
|
|
60
|
+
let ms;
|
|
61
|
+
if (n <= 11)
|
|
62
|
+
ms = Number(digits) * 1000;
|
|
63
|
+
else if (n <= 14)
|
|
64
|
+
ms = Number(digits);
|
|
65
|
+
else if (n <= 17)
|
|
66
|
+
ms = Number(digits) / 1000;
|
|
67
|
+
else
|
|
68
|
+
ms = Number(digits.slice(0, digits.length - 6));
|
|
69
|
+
return Number.isFinite(ms) && ms > Date.UTC(2000, 0, 1) ? Math.trunc(ms) : undefined;
|
|
70
|
+
}
|
|
71
|
+
/* ------------------------------------------------------------------ */
|
|
72
|
+
/* Reading a result */
|
|
73
|
+
/* ------------------------------------------------------------------ */
|
|
74
|
+
function labelsOf(value) {
|
|
75
|
+
if (!isRecord(value))
|
|
76
|
+
return {};
|
|
77
|
+
const out = {};
|
|
78
|
+
for (const [key, item] of Object.entries(value)) {
|
|
79
|
+
if (typeof item === "string")
|
|
80
|
+
out[key] = item;
|
|
81
|
+
else if (typeof item === "number" || typeof item === "boolean")
|
|
82
|
+
out[key] = String(item);
|
|
83
|
+
}
|
|
84
|
+
return out;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The entries of a query result. `streams` holds Loki streams (or the whole
|
|
88
|
+
* Loki response), `entries` a flat list. Problems name the place in the input.
|
|
89
|
+
*/
|
|
90
|
+
export function readLogEntries(input) {
|
|
91
|
+
let overflow = 0;
|
|
92
|
+
const entries = [];
|
|
93
|
+
const issues = [];
|
|
94
|
+
const push = (at, line, labels) => {
|
|
95
|
+
if (entries.length >= MAX_LOG_INPUT_ENTRIES) {
|
|
96
|
+
overflow += 1;
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const cut = line.length > MAX_LOG_INPUT_LINE;
|
|
100
|
+
const capped = Object.fromEntries(Object.entries(labels).map(([k, v]) => [k.slice(0, 200), v.slice(0, MAX_LOG_INPUT_LABEL)]));
|
|
101
|
+
entries.push({ at, line: cut ? line.slice(0, MAX_LOG_INPUT_LINE) : line, labels: capped, ...(cut ? { cut: true } : {}) });
|
|
102
|
+
};
|
|
103
|
+
let streams = input.streams;
|
|
104
|
+
if (isRecord(streams)) {
|
|
105
|
+
// The whole body of a Loki response: {status, data: {resultType, result: [...]}}.
|
|
106
|
+
const data = isRecord(streams.data) ? streams.data : streams;
|
|
107
|
+
streams = data.result;
|
|
108
|
+
}
|
|
109
|
+
if (streams !== undefined) {
|
|
110
|
+
if (!Array.isArray(streams)) {
|
|
111
|
+
issues.push("streams: send the streams array of the Loki result (each {stream, values: [[time, line]]}).");
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
streams.forEach((stream, s) => {
|
|
115
|
+
if (!isRecord(stream) || !Array.isArray(stream.values)) {
|
|
116
|
+
issues.push(`streams.${s}: send {stream: {labels}, values: [[time, line]]}.`);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const labels = labelsOf(stream.stream ?? stream.labels ?? stream.metric);
|
|
120
|
+
stream.values.forEach((pair, v) => {
|
|
121
|
+
if (!Array.isArray(pair) || typeof pair[1] !== "string") {
|
|
122
|
+
issues.push(`streams.${s}.values.${v}: send [time, line] with the line as a string.`);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const at = logTimeMs(pair[0]);
|
|
126
|
+
if (at === undefined) {
|
|
127
|
+
issues.push(`streams.${s}.values.${v}: the time "${String(pair[0]).slice(0, 40)}" is not a time. Send the nanosecond string or an RFC 3339 time as the query returned it.`);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
push(at, pair[1], labels);
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (input.entries !== undefined) {
|
|
136
|
+
if (!Array.isArray(input.entries)) {
|
|
137
|
+
issues.push("entries: send the list of log entries, each {timestamp, line, labels}.");
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
input.entries.forEach((entry, i) => {
|
|
141
|
+
if (!isRecord(entry)) {
|
|
142
|
+
issues.push(`entries.${i}: send {timestamp, line, labels}.`);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
const text = [entry.line, entry.text, entry.message, entry.body, entry.log].find((x) => typeof x === "string");
|
|
146
|
+
if (typeof text !== "string") {
|
|
147
|
+
issues.push(`entries.${i}: send the line as a string in line.`);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
const when = entry.timestamp ?? entry.time ?? entry.ts ?? entry.t ?? entry.Timestamp;
|
|
151
|
+
const at = logTimeMs(when);
|
|
152
|
+
if (at === undefined) {
|
|
153
|
+
issues.push(`entries.${i}: the time "${String(when).slice(0, 40)}" is not a time. Send the timestamp as the query returned it.`);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
push(at, text, labelsOf(entry.labels ?? entry.stream ?? entry.fields));
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return { entries, issues, overflow };
|
|
161
|
+
}
|
|
162
|
+
// ANSI colour and cursor sequences, which a terminal log may carry.
|
|
163
|
+
// eslint-disable-next-line no-control-regex
|
|
164
|
+
const ANSI = /\u001b\[[0-9;?]*[ -/]*[@-~]/g;
|
|
165
|
+
/* ------------------------------------------------------------------ */
|
|
166
|
+
/* Level */
|
|
167
|
+
/* ------------------------------------------------------------------ */
|
|
168
|
+
const LEVEL_KEYS = [
|
|
169
|
+
"level",
|
|
170
|
+
"lvl",
|
|
171
|
+
"severity",
|
|
172
|
+
"loglevel",
|
|
173
|
+
"log_level",
|
|
174
|
+
"levelname",
|
|
175
|
+
"detected_level",
|
|
176
|
+
"severity_text",
|
|
177
|
+
];
|
|
178
|
+
const TIME_KEYS = new Set(["time", "ts", "timestamp", "t", "@timestamp", "datetime", "date"]);
|
|
179
|
+
const MESSAGE_KEYS = new Set(["msg", "message", "log", "body", "text"]);
|
|
180
|
+
/** A level word as one of the five levels; undefined when it is not a level word. */
|
|
181
|
+
export function levelWord(word) {
|
|
182
|
+
if (typeof word === "number") {
|
|
183
|
+
// Syslog severity 0 to 7, and the pino levels 10 to 60.
|
|
184
|
+
if (word >= 0 && word <= 3)
|
|
185
|
+
return "error";
|
|
186
|
+
if (word === 4)
|
|
187
|
+
return "warn";
|
|
188
|
+
if (word === 5 || word === 6)
|
|
189
|
+
return "info";
|
|
190
|
+
if (word === 7)
|
|
191
|
+
return "debug";
|
|
192
|
+
if (word >= 10 && word <= 60)
|
|
193
|
+
return word >= 50 ? "error" : word === 40 ? "warn" : word === 30 ? "info" : "debug";
|
|
194
|
+
return undefined;
|
|
195
|
+
}
|
|
196
|
+
if (typeof word !== "string")
|
|
197
|
+
return undefined;
|
|
198
|
+
const w = word.trim().toLowerCase();
|
|
199
|
+
if (["error", "err", "fatal", "critical", "crit", "panic", "alert", "emerg", "emergency", "severe"].includes(w))
|
|
200
|
+
return "error";
|
|
201
|
+
if (["warn", "warning"].includes(w))
|
|
202
|
+
return "warn";
|
|
203
|
+
if (["info", "information", "notice"].includes(w))
|
|
204
|
+
return "info";
|
|
205
|
+
if (["debug", "trace", "verbose", "dbg"].includes(w))
|
|
206
|
+
return "debug";
|
|
207
|
+
if (/^\d+$/.test(w))
|
|
208
|
+
return levelWord(Number(w));
|
|
209
|
+
return undefined;
|
|
210
|
+
}
|
|
211
|
+
const LEADING_LEVEL = /^[\s[(<]*(?:\d{4}[-/]\d{2}[-/]\d{2}[T ][\d:.,]+(?:Z|[+-]\d{2}:?\d{2})?[\s\])>:|-]*)?[[(<]?(ERROR|ERR|WARN(?:ING)?|INFO|DEBUG|TRACE|FATAL|CRITICAL|PANIC)\b/i;
|
|
212
|
+
const LOGFMT_LEVEL = /(?:^|\s)(?:level|lvl|severity|loglevel)=("?)([A-Za-z0-9]+)\1(?=\s|$)/;
|
|
213
|
+
/** The JSON object a line holds, or undefined. */
|
|
214
|
+
export function parseJsonLine(line) {
|
|
215
|
+
const text = line.trim();
|
|
216
|
+
if (!text.startsWith("{") || !text.endsWith("}"))
|
|
217
|
+
return undefined;
|
|
218
|
+
try {
|
|
219
|
+
const value = JSON.parse(text);
|
|
220
|
+
return isRecord(value) ? value : undefined;
|
|
221
|
+
}
|
|
222
|
+
catch {
|
|
223
|
+
return undefined;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
/** The key=value pairs of a logfmt line. Quoted values lose their quotes. */
|
|
227
|
+
export function parseLogfmt(line) {
|
|
228
|
+
if (!/(?:^|\s)[A-Za-z_][\w.-]*=/.test(line))
|
|
229
|
+
return undefined;
|
|
230
|
+
const out = {};
|
|
231
|
+
const pattern = /(?:^|\s)([A-Za-z_][\w.-]*)=(?:"((?:[^"\\]|\\.)*)"|(\S*))/g;
|
|
232
|
+
let match;
|
|
233
|
+
while ((match = pattern.exec(line)) !== null) {
|
|
234
|
+
const key = match[1];
|
|
235
|
+
if (!(key in out))
|
|
236
|
+
out[key] = match[2] !== undefined ? match[2].replace(/\\(.)/g, "$1") : (match[3] ?? "");
|
|
237
|
+
}
|
|
238
|
+
return Object.keys(out).length > 0 ? out : undefined;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* The level of a line. A level label of the stream wins, then a level in the
|
|
242
|
+
* JSON or logfmt of the line, then a level word at the start of the text.
|
|
243
|
+
* Anything else is `other`.
|
|
244
|
+
*/
|
|
245
|
+
export function levelOfEntry(entry) {
|
|
246
|
+
for (const key of LEVEL_KEYS) {
|
|
247
|
+
const found = levelWord(entry.labels[key]);
|
|
248
|
+
if (found)
|
|
249
|
+
return found;
|
|
250
|
+
}
|
|
251
|
+
// Colour codes in front of a level word must not hide it.
|
|
252
|
+
const text = entry.line.replace(ANSI, "");
|
|
253
|
+
const json = parseJsonLine(text);
|
|
254
|
+
if (json) {
|
|
255
|
+
for (const key of LEVEL_KEYS) {
|
|
256
|
+
const found = levelWord(json[key]);
|
|
257
|
+
if (found)
|
|
258
|
+
return found;
|
|
259
|
+
}
|
|
260
|
+
const nested = isRecord(json.log) ? levelWord(json.log.level) : undefined;
|
|
261
|
+
if (nested)
|
|
262
|
+
return nested;
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
const logfmt = LOGFMT_LEVEL.exec(text);
|
|
266
|
+
if (logfmt) {
|
|
267
|
+
const found = levelWord(logfmt[2]);
|
|
268
|
+
if (found)
|
|
269
|
+
return found;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
const lead = LEADING_LEVEL.exec(text);
|
|
273
|
+
if (lead) {
|
|
274
|
+
const found = levelWord(lead[1]);
|
|
275
|
+
if (found)
|
|
276
|
+
return found;
|
|
277
|
+
}
|
|
278
|
+
return "other";
|
|
279
|
+
}
|
|
280
|
+
/* ------------------------------------------------------------------ */
|
|
281
|
+
/* Text and fields */
|
|
282
|
+
/* ------------------------------------------------------------------ */
|
|
283
|
+
// Control characters the Tellagen API refuses in log text (tabs are allowed).
|
|
284
|
+
// eslint-disable-next-line no-control-regex
|
|
285
|
+
const TEXT_CONTROL = /[\u0000-\u0008\u000b-\u001f\u007f-\u009f\u2028\u2029\u200e\u200f\u202a-\u202e\u2066-\u2069]/g;
|
|
286
|
+
const TEXT_CONTROL_ONE = new RegExp(TEXT_CONTROL.source);
|
|
287
|
+
/**
|
|
288
|
+
* The text of a line for the figure: ANSI sequences out, line breaks turned
|
|
289
|
+
* into a visible mark, secrets masked and other control characters out. A text
|
|
290
|
+
* over 500 characters is cut with an ellipsis. `what` names each change.
|
|
291
|
+
*/
|
|
292
|
+
export function cleanLogText(line, options = {}) {
|
|
293
|
+
const what = [];
|
|
294
|
+
// The input is cut first, so the redaction cost is bounded by the input limit and not by the line.
|
|
295
|
+
const input = line.length > MAX_LOG_INPUT_LINE ? line.slice(0, MAX_LOG_INPUT_LINE) : line;
|
|
296
|
+
let text = input.replace(ANSI, "");
|
|
297
|
+
if (text !== input)
|
|
298
|
+
what.push("terminal colour codes removed");
|
|
299
|
+
// Redaction runs once, on the raw line, so a value on the next line is still found.
|
|
300
|
+
if (options.masked !== true) {
|
|
301
|
+
const masked = redactLogText(text);
|
|
302
|
+
if (masked !== text)
|
|
303
|
+
what.push("secrets masked");
|
|
304
|
+
text = masked;
|
|
305
|
+
}
|
|
306
|
+
else if (text.includes("[redacted]")) {
|
|
307
|
+
what.push("secrets masked");
|
|
308
|
+
}
|
|
309
|
+
const flat = text.replace(/\r?\n|\r/g, " \u23ce ");
|
|
310
|
+
if (flat !== text)
|
|
311
|
+
what.push("line breaks shown as \u23ce");
|
|
312
|
+
text = flat;
|
|
313
|
+
const clean = text.replace(TEXT_CONTROL, " ");
|
|
314
|
+
if (clean !== text)
|
|
315
|
+
what.push("control characters removed");
|
|
316
|
+
text = clean.trimEnd();
|
|
317
|
+
const chars = [...text];
|
|
318
|
+
if (chars.length > MAX_LOG_TEXT) {
|
|
319
|
+
text = chars.slice(0, MAX_LOG_TEXT - 1).join("") + "\u2026";
|
|
320
|
+
what.push(`cut at ${MAX_LOG_TEXT} characters`);
|
|
321
|
+
}
|
|
322
|
+
return { text, what };
|
|
323
|
+
}
|
|
324
|
+
const NOISY_LABELS = /^(?:__.*|filename|detected_level|level|lvl|severity|loglevel|log_level|levelname|severity_text|service_name|job)$/;
|
|
325
|
+
function scalar(value) {
|
|
326
|
+
if (typeof value === "string")
|
|
327
|
+
return value;
|
|
328
|
+
// A whole number the parser cannot hold exactly would differ from the line: leave it out.
|
|
329
|
+
if (typeof value === "number")
|
|
330
|
+
return Number.isInteger(value) && !Number.isSafeInteger(value) ? undefined : String(value);
|
|
331
|
+
if (typeof value === "boolean")
|
|
332
|
+
return String(value);
|
|
333
|
+
return undefined;
|
|
334
|
+
}
|
|
335
|
+
/** All the fields a line offers, in order: those of its JSON or logfmt first, then its stream labels. */
|
|
336
|
+
function candidateFields(raw, masked = false) {
|
|
337
|
+
// Fields come only from what is left after redaction: a key that sits inside a
|
|
338
|
+
// masked header or phrase is gone from the line, so it can never become a field.
|
|
339
|
+
const entry = masked
|
|
340
|
+
? raw
|
|
341
|
+
: {
|
|
342
|
+
...raw,
|
|
343
|
+
line: redactLogText(raw.line.slice(0, MAX_LOG_INPUT_LINE).replace(ANSI, "")),
|
|
344
|
+
labels: Object.fromEntries(Object.entries(raw.labels).map(([k, v]) => [k, redactLogText(v)])),
|
|
345
|
+
};
|
|
346
|
+
const out = [];
|
|
347
|
+
const own = (key) => {
|
|
348
|
+
const k = key.toLowerCase();
|
|
349
|
+
return !(TIME_KEYS.has(k) || MESSAGE_KEYS.has(k) || LEVEL_KEYS.includes(k));
|
|
350
|
+
};
|
|
351
|
+
const parsed = parseJsonLine(entry.line);
|
|
352
|
+
if (parsed) {
|
|
353
|
+
for (const [key, value] of Object.entries(parsed)) {
|
|
354
|
+
if (!own(key))
|
|
355
|
+
continue;
|
|
356
|
+
const text = scalar(value);
|
|
357
|
+
if (text !== undefined)
|
|
358
|
+
out.push([key, text]);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
else {
|
|
362
|
+
const logfmt = parseLogfmt(entry.line);
|
|
363
|
+
if (logfmt) {
|
|
364
|
+
for (const [key, value] of Object.entries(logfmt)) {
|
|
365
|
+
if (own(key))
|
|
366
|
+
out.push([key, value]);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
if (entry.cut) {
|
|
371
|
+
// The end of the line was dropped: its last pair may be cut, and a value whose name was cut off
|
|
372
|
+
// looks harmless. Take no pair value and not the last pair.
|
|
373
|
+
const kept = out.slice(0, -1).filter(([key]) => !isPairValueKey(key));
|
|
374
|
+
out.length = 0;
|
|
375
|
+
out.push(...kept);
|
|
376
|
+
}
|
|
377
|
+
for (const [key, value] of Object.entries(entry.labels)) {
|
|
378
|
+
if (!NOISY_LABELS.test(key))
|
|
379
|
+
out.push([key, value]);
|
|
380
|
+
}
|
|
381
|
+
// A secret logged as a name and a value: the name says it, so the paired value is not shown.
|
|
382
|
+
if (out.some(([key, value]) => isPairNameKey(key) && isSecretKey(value))) {
|
|
383
|
+
return out.filter(([key]) => !isPairValueKey(key));
|
|
384
|
+
}
|
|
385
|
+
return out;
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* The fields of one line. With `wanted` it takes those keys, in that order.
|
|
389
|
+
* Without it, the fields of the line itself first and then the stream labels,
|
|
390
|
+
* at most six. A value over 200 characters is left out, never cut.
|
|
391
|
+
*/
|
|
392
|
+
export function fieldsOfEntry(entry, wanted, masked = false) {
|
|
393
|
+
const all = candidateFields(entry, masked);
|
|
394
|
+
const seen = new Set();
|
|
395
|
+
const picked = [];
|
|
396
|
+
// A field the API would refuse is left out or cleaned, never the reason the figure fails.
|
|
397
|
+
const shape = ([rawKey, rawValue]) => {
|
|
398
|
+
const key = rawKey.trim();
|
|
399
|
+
if (key === "" || [...key].length > MAX_LOG_FIELD_KEY || TEXT_CONTROL_ONE.test(key) || /[\t\r\n]/.test(key))
|
|
400
|
+
return undefined;
|
|
401
|
+
// A field named token, password, secret or the like never leaves this computer.
|
|
402
|
+
if (isSecretKey(key))
|
|
403
|
+
return undefined;
|
|
404
|
+
const cleaned = rawValue.replace(ANSI, "");
|
|
405
|
+
// The field rule is never weaker than the text rule: a pair the text rule would mask is not a field.
|
|
406
|
+
if (redactLogText(`${key}=${cleaned}`) !== `${key}=${redactLogText(cleaned)}`)
|
|
407
|
+
return undefined;
|
|
408
|
+
const value = redactLogText(cleaned.replace(/\r?\n|\r|\t/g, " ").replace(TEXT_CONTROL, " ")).trim();
|
|
409
|
+
if (value === "" || value.includes("[redacted") || [...value].length > MAX_LOG_FIELD_VALUE)
|
|
410
|
+
return undefined;
|
|
411
|
+
return [key, value];
|
|
412
|
+
};
|
|
413
|
+
const candidates = wanted && wanted.length > 0
|
|
414
|
+
? wanted.flatMap((key) => {
|
|
415
|
+
const hit = all.find(([k]) => k === key);
|
|
416
|
+
return hit ? [hit] : [];
|
|
417
|
+
})
|
|
418
|
+
: all;
|
|
419
|
+
for (const pair of candidates) {
|
|
420
|
+
if (picked.length >= MAX_LOG_FIELDS)
|
|
421
|
+
break;
|
|
422
|
+
const shaped = shape(pair);
|
|
423
|
+
if (!shaped || seen.has(shaped[0]))
|
|
424
|
+
continue;
|
|
425
|
+
seen.add(shaped[0]);
|
|
426
|
+
picked.push(shaped);
|
|
427
|
+
}
|
|
428
|
+
if (picked.length === 0)
|
|
429
|
+
return undefined;
|
|
430
|
+
return Object.fromEntries(picked);
|
|
431
|
+
}
|
|
432
|
+
/* ------------------------------------------------------------------ */
|
|
433
|
+
/* Choosing the lines */
|
|
434
|
+
/* ------------------------------------------------------------------ */
|
|
435
|
+
const LEVEL_RANK = { error: 0, warn: 1, other: 2, info: 3, debug: 4 };
|
|
436
|
+
function markOf(entry, marks) {
|
|
437
|
+
const lower = entry.line.toLowerCase();
|
|
438
|
+
return marks.find((mark) => {
|
|
439
|
+
if (mark.contains === undefined && mark.field === undefined)
|
|
440
|
+
return false;
|
|
441
|
+
if (mark.contains !== undefined && !lower.includes(mark.contains.toLowerCase()))
|
|
442
|
+
return false;
|
|
443
|
+
if (mark.field !== undefined) {
|
|
444
|
+
const parsed = parseJsonLine(entry.line);
|
|
445
|
+
const logfmt = parsed ? undefined : parseLogfmt(entry.line);
|
|
446
|
+
const fromLine = parsed ? scalar(parsed[mark.field.key]) : logfmt?.[mark.field.key];
|
|
447
|
+
const value = fromLine ?? entry.labels[mark.field.key];
|
|
448
|
+
if (value !== mark.field.value)
|
|
449
|
+
return false;
|
|
450
|
+
}
|
|
451
|
+
return true;
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Chooses at most 8 lines and shapes each one. The order is: lines that show
|
|
456
|
+
* the event (those that hold a `match` term or are marked matches_event), then
|
|
457
|
+
* lines marked unrelated (a line that looks like proof and is not must stay
|
|
458
|
+
* visible), then lines marked context, then the rest by level, errors first.
|
|
459
|
+
* Inside a group the lines closest to `eventAt` come first when it is given,
|
|
460
|
+
* else the earliest; the chosen lines are then shown in time order inside
|
|
461
|
+
* their group. The same line at the same time is never shown twice.
|
|
462
|
+
*/
|
|
463
|
+
export function selectLogLines(entries, options) {
|
|
464
|
+
const limit = Math.min(options.limit ?? MAX_LOG_LINES, MAX_LOG_LINES);
|
|
465
|
+
const terms = (options.match ?? []).map((t) => t.toLowerCase()).filter((t) => t !== "");
|
|
466
|
+
const marks = options.marks ?? [];
|
|
467
|
+
const notes = [];
|
|
468
|
+
const changes = new Set();
|
|
469
|
+
const seenLines = new Set();
|
|
470
|
+
// Rank on the raw entries (cheap, local), then clean and redact only the lines that are shown.
|
|
471
|
+
const ranked = [];
|
|
472
|
+
for (const entry of entries) {
|
|
473
|
+
const identity = `${entry.at}\u0000${createHash("sha1").update(entry.line).digest("hex")}\u0000${JSON.stringify(entry.labels)}`;
|
|
474
|
+
if (seenLines.has(identity))
|
|
475
|
+
continue;
|
|
476
|
+
seenLines.add(identity);
|
|
477
|
+
if (entry.line.replace(ANSI, "").trim() === "")
|
|
478
|
+
continue;
|
|
479
|
+
const level = levelOfEntry(entry);
|
|
480
|
+
const mark = markOf(entry, marks);
|
|
481
|
+
const termHit = terms.some((term) => entry.line.toLowerCase().includes(term));
|
|
482
|
+
let relation = mark?.relation;
|
|
483
|
+
if (relation === undefined && termHit)
|
|
484
|
+
relation = "matches_event";
|
|
485
|
+
const tier = relation === "matches_event" ? 0 : relation === "unrelated" ? 1 : relation === "context" ? 2 : 3 + LEVEL_RANK[level];
|
|
486
|
+
ranked.push({ entry, level, mark, relation, tier });
|
|
487
|
+
}
|
|
488
|
+
const distanceOf = (r) => options.eventAt === undefined ? r.entry.at : Math.abs(r.entry.at - options.eventAt);
|
|
489
|
+
ranked.sort((a, b) => a.tier - b.tier || distanceOf(a) - distanceOf(b) || a.entry.at - b.entry.at);
|
|
490
|
+
const shaped = [];
|
|
491
|
+
for (const r of ranked.slice(0, limit)) {
|
|
492
|
+
// One redaction of the capped line serves the text and the fields.
|
|
493
|
+
const maskedLine = redactLogText(r.entry.line.replace(ANSI, ""));
|
|
494
|
+
const cleaned = cleanLogText(maskedLine, { masked: true });
|
|
495
|
+
if (r.entry.line.replace(ANSI, "") !== r.entry.line)
|
|
496
|
+
cleaned.what.unshift("terminal colour codes removed");
|
|
497
|
+
const line = { time: new Date(r.entry.at).toISOString(), level: r.level, text: cleaned.text };
|
|
498
|
+
const masked = {
|
|
499
|
+
...r.entry,
|
|
500
|
+
line: maskedLine,
|
|
501
|
+
labels: Object.fromEntries(Object.entries(r.entry.labels).map(([k, v]) => [k, redactLogText(v)])),
|
|
502
|
+
};
|
|
503
|
+
const fields = fieldsOfEntry(masked, options.fieldKeys, true);
|
|
504
|
+
if (fields)
|
|
505
|
+
line.fields = fields;
|
|
506
|
+
if (r.relation)
|
|
507
|
+
line.relation = r.relation;
|
|
508
|
+
if (r.mark?.note)
|
|
509
|
+
line.note = r.mark.note.trim();
|
|
510
|
+
else if (r.entry.cut)
|
|
511
|
+
line.note = "The line was longer than 8 KiB; the rest was not read or sent.";
|
|
512
|
+
shaped.push({ entry: r.entry, line, tier: r.tier, what: cleaned.what });
|
|
513
|
+
}
|
|
514
|
+
const chosen = shaped;
|
|
515
|
+
chosen.sort((a, b) => a.tier - b.tier || a.entry.at - b.entry.at);
|
|
516
|
+
for (const item of chosen)
|
|
517
|
+
for (const change of item.what)
|
|
518
|
+
changes.add(change);
|
|
519
|
+
if (changes.size > 0)
|
|
520
|
+
notes.push(`Log text was cleaned: ${[...changes].join("; ")}.`);
|
|
521
|
+
return { lines: chosen.map((s) => s.line), total: ranked.length, notes };
|
|
522
|
+
}
|
|
523
|
+
/** A figure's relation counts, for the one-line summary. */
|
|
524
|
+
export function relationCounts(lines) {
|
|
525
|
+
const counts = { matches_event: 0, context: 0, unrelated: 0, unmarked: 0 };
|
|
526
|
+
for (const line of lines) {
|
|
527
|
+
if (line.relation)
|
|
528
|
+
counts[line.relation] += 1;
|
|
529
|
+
else
|
|
530
|
+
counts.unmarked += 1;
|
|
531
|
+
}
|
|
532
|
+
return counts;
|
|
533
|
+
}
|
|
534
|
+
//# sourceMappingURL=log-lines.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log-lines.js","sourceRoot":"","sources":["../src/log-lines.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAExF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC;AAC/B,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAC;AAChC,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAC;AAChC,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC;AAChC,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AACpC,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAC;AACvC,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAAC;AAC3C,iFAAiF;AACjF,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAC;AACvC,gDAAgD;AAChD,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAC;AACxC,kDAAkD;AAClD,MAAM,CAAC,MAAM,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
package/dist/redact.d.ts
CHANGED
|
@@ -11,3 +11,24 @@
|
|
|
11
11
|
export declare function redactSecrets(text: string): string;
|
|
12
12
|
/** A JSON value with secrets masked: a secret key loses its value, every string is cleaned. */
|
|
13
13
|
export declare function redactValue(value: unknown, depth?: number): unknown;
|
|
14
|
+
/**
|
|
15
|
+
* Whether a field or variable name says that its value is a secret: token,
|
|
16
|
+
* secret, password, passwd, pass, pwd, api key, auth, authorization, cookie,
|
|
17
|
+
* set-cookie, session, private key, client secret, credential, dsn and
|
|
18
|
+
* connection string, in any case and form (DB_PASSWORD, DB_PASS, X-Api-Key,
|
|
19
|
+
* setCookie). This is the one key rule: the text rule and the field rule both
|
|
20
|
+
* use it.
|
|
21
|
+
*/
|
|
22
|
+
export declare function isSecretKey(key: string): boolean;
|
|
23
|
+
/** The value key of a name/value pair: value, val, env_value, secretValue. */
|
|
24
|
+
export declare function isPairValueKey(key: string): boolean;
|
|
25
|
+
/** The name key of a name/value pair: name, key, env_name, varName. */
|
|
26
|
+
export declare function isPairNameKey(key: string): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* The one redaction step for text that leaves this computer in a log figure:
|
|
29
|
+
* the line text, every field value and the query. Order: the value shapes of
|
|
30
|
+
* redactSecrets (tokens, keys, URL userinfo, headers), then the one key rule
|
|
31
|
+
* (isSecretKey) on every key/value in the text, then name/value pairs decided
|
|
32
|
+
* on the whole line or JSON object, in any order and at any distance.
|
|
33
|
+
*/
|
|
34
|
+
export declare function redactLogText(text: string): string;
|