@bli-cockpit/telemetry-core 0.1.109 → 0.1.111
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/log-digest/mask.js
CHANGED
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
* say the same thing become the same template and can be counted instead of read.
|
|
7
7
|
*
|
|
8
8
|
* Fixed masking order, so a memory address can never fake a status code
|
|
9
|
-
* (`0x7f...403...`): memory addresses, URLs, UUIDs, timestamps, IPs,
|
|
10
|
-
* long ids, build-chunk names and minified frame
|
|
11
|
-
* numeric quoted strings, `#<digits>` ids, long
|
|
12
|
-
* (`call_490779`), then every other number except a
|
|
13
|
-
* position (`HTTP 403`, `status=500`, `[Errno 28]`).
|
|
9
|
+
* (`0x7f...403...`): memory addresses, URLs, UUIDs, timestamps, IPs, provider
|
|
10
|
+
* deploy/build ids, long hex, long ids, build-chunk names and minified frame
|
|
11
|
+
* names, absolute paths, long or numeric quoted strings, `#<digits>` ids, long
|
|
12
|
+
* digit runs glued to a word (`call_490779`), then every other number except a
|
|
13
|
+
* status code in a status position (`HTTP 403`, `status=500`, `[Errno 28]`).
|
|
14
14
|
*
|
|
15
15
|
* BLI-17921: `Call #490779` used to keep its id (the number rule skips a digit
|
|
16
16
|
* run right after `#`), so every call id was its own template, its own incident
|
|
@@ -44,6 +44,9 @@ const URL_PATTERN = /\b[a-zA-Z][a-zA-Z0-9+.-]*:\/\/([^/\s"'<>?#:]+)[^\s"'<>]*/g;
|
|
|
44
44
|
const UUID = /\b[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\b/g;
|
|
45
45
|
const TIMESTAMP = /\b\d{4}-\d{2}-\d{2}(?:[T ]\d{2}:\d{2}(?::\d{2}(?:[.,]\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?)?\b|\b\d{2}:\d{2}:\d{2}(?:[.,]\d+)?\b/g;
|
|
46
46
|
const IP_ADDRESS = /\b\d{1,3}(?:\.\d{1,3}){3}(?::\d+)?\b/g;
|
|
47
|
+
// Provider deploy and build ids: Vercel (`dpl_8E81`, `dpl_EENt`, `dpl_HGuDxvZfLwLJoBjoqP6mmxJygwFt`, `bld_gcoie8z5g`)
|
|
48
|
+
// and Render/generic (`dep-c9abc123def4`, `dep_8e81`), including truncated or digit-poor ids `LONG_ID` misses (BLI-27247).
|
|
49
|
+
const PROVIDER_DEPLOY_ID = /(?<![\w-])(?:dpl_(?:[A-Za-z0-9]{4,}|[A-Za-z0-9]*\d[A-Za-z0-9]*)|bld_(?:[A-Za-z0-9]{8,}|(?=[A-Za-z0-9]*\d)[A-Za-z0-9]{4,})|dep[-_](?=[A-Za-z0-9]*\d)[A-Za-z0-9]{4,})(?![\w-])/g;
|
|
47
50
|
// 8+ hex characters that mix digits and letters, or any 32+ hex run (a md5, sha1, sha256 or a dashless uuid
|
|
48
51
|
// is never a word, even when luck left it without a digit).
|
|
49
52
|
const LONG_HEX = /\b(?=[0-9a-fA-F]*[0-9])(?=[0-9a-fA-F]*[a-fA-F])[0-9a-fA-F]{8,}\b|\b[0-9a-fA-F]{32,}\b/g;
|
|
@@ -110,6 +113,7 @@ export function mask(input) {
|
|
|
110
113
|
text = text.replace(UUID, "<uuid>");
|
|
111
114
|
text = text.replace(TIMESTAMP, "<ts>");
|
|
112
115
|
text = text.replace(IP_ADDRESS, "<ip>");
|
|
116
|
+
text = text.replace(PROVIDER_DEPLOY_ID, "<id>");
|
|
113
117
|
text = text.replace(LONG_HEX, "<hex>");
|
|
114
118
|
text = text.replace(LONG_ID, "<id>");
|
|
115
119
|
text = text.replace(BUILD_CHUNK, "$1__<hash>");
|
|
@@ -68,6 +68,8 @@ export declare const SECRET_ASSIGNMENT_SOURCE = "[\"']?\\s*[:=]\\s*[\"']?";
|
|
|
68
68
|
*/
|
|
69
69
|
export declare const PASSWORD_NAME_MATCH_SOURCE = "(?<![A-Za-z0-9])(?:password|passwd|passcode|pwd(?![A-Za-z0-9_-]{0,40}\\s*[\"']?\\s*[:=]\\s*[\"']?\\s*[/~]))(?:[_-][A-Za-z0-9_-]{0,40})?";
|
|
70
70
|
export declare const PASSWORD_VALUE_SOURCE = "[^\\s\"'`,;<>(){}\\[\\]]{6}[^\\s\"'`,;<>(){}\\[\\]]*";
|
|
71
|
+
export declare const KEY_BODY_RUN_SOURCE: string;
|
|
72
|
+
export declare const KEY_BODY_BEFORE_FOOTER_SOURCE: string;
|
|
71
73
|
export declare const SECRET_LIKE_CONTENT_PATTERNS: RegExp[];
|
|
72
74
|
/**
|
|
73
75
|
* Does this text carry something the fleet must not upload as it stands? The
|
|
@@ -101,6 +101,44 @@ export const PASSWORD_VALUE_SOURCE = "[^\\s\"'`,;<>(){}\\[\\]]{6}[^\\s\"'`,;<>()
|
|
|
101
101
|
*/
|
|
102
102
|
const SECRET_NAME_WITH_VALUE_PATTERN = new RegExp(`${SECRET_NAME_MATCH_SOURCE}${SECRET_ASSIGNMENT_SOURCE}[A-Za-z0-9_./+=-]{12}[A-Za-z0-9_./+=-]*`, "i");
|
|
103
103
|
const PASSWORD_WITH_VALUE_PATTERN = new RegExp(`${PASSWORD_NAME_MATCH_SOURCE}${SECRET_ASSIGNMENT_SOURCE}${PASSWORD_VALUE_SOURCE}`, "i");
|
|
104
|
+
/**
|
|
105
|
+
* A private key body with its BEGIN line cut away (BLI-26798). On 2026-11-28 `railway variables --kv | cut -d= -f1`
|
|
106
|
+
* printed every body line of a multi-line key (no line has an `=`) and dropped the header, the only thing the rules
|
|
107
|
+
* below key on, so the collector masked 0 values and the body reached the raw evidence bucket.
|
|
108
|
+
*
|
|
109
|
+
* Two tells, both bounded so a megabyte base64 blob cannot overflow V8's backtrack stack, and both start only at the
|
|
110
|
+
* FIRST body line (a line after a full-width one is a continuation, which also keeps a long blob linear):
|
|
111
|
+
*
|
|
112
|
+
* - a RUN: 4+ lines of exactly 64 (PEM, PGP, PuTTY), 70 (OpenSSH) or 76 (MIME) base64 characters, each with both
|
|
113
|
+
* letter cases (a sha256 list is one-case hex and stays untouched), plus an optional short last line, at most 256
|
|
114
|
+
* lines per match (an 8192-bit RSA key is about 100);
|
|
115
|
+
* - a BODY BEFORE A FOOTER: one 40+ character base64 line and any lines after it, ending right before an END
|
|
116
|
+
* PRIVATE KEY footer, which catches a short key (EC, Ed25519) whose body is under four lines; at most 9 lines, so a
|
|
117
|
+
* long list of base64 hashes is not rescanned from every line.
|
|
118
|
+
*
|
|
119
|
+
* A line break is a real newline (`\n`, `\r\n`) or the escaped one a JSONL transcript carries (`\\n`, `\\r\\n`, up
|
|
120
|
+
* to eight backslashes deep), so macOS and Windows transcripts read the same. A line may carry indentation, never a diff
|
|
121
|
+
* `+`: `+` is base64 too, and reading it both ways backtracks exponentially (a diff of a key carries its header).
|
|
122
|
+
* Indentation and escape depth are bounded (16 blanks, 8 backslashes) for the same reason: an unbounded `[ \t]*`
|
|
123
|
+
* inside a lookbehind made a 200,000-space line take 100 seconds. A match starts AT the first body character, behind
|
|
124
|
+
* one-character checks and then `(?=[A-Za-z0-9+/]{40})` (both tells need a 40+ character first line), so a megabyte of blanks (a 277 MiB
|
|
125
|
+
* transcript of them is a collector test) or ordinary prose fails in a few steps, never reaching the lookbehinds. A run right under a certificate or public key
|
|
126
|
+
* armor line (`-----BEGIN CERTIFICATE-----`) is public and left alone; a PGP public key block, whose armor headers sit between, is masked (over-masking, never a leak).
|
|
127
|
+
*/
|
|
128
|
+
const KEY_BODY_ALPHABET = "A-Za-z0-9+/";
|
|
129
|
+
const KEY_BODY_LINE_BREAK = "(?:\\r?\\n|(?:\\\\{1,8}r)?\\\\{1,8}n)[ \\t]{0,16}";
|
|
130
|
+
const KEY_BODY_LINE_START = [
|
|
131
|
+
`(?=[${KEY_BODY_ALPHABET}])`,
|
|
132
|
+
`(?:(?<![${KEY_BODY_ALPHABET}=\\\\])|(?<=\\\\n))`,
|
|
133
|
+
`(?=[${KEY_BODY_ALPHABET}]{40})`,
|
|
134
|
+
`(?<![${KEY_BODY_ALPHABET}]{64}${KEY_BODY_LINE_BREAK})`,
|
|
135
|
+
`(?<!-----BEGIN (?![A-Z ]*PRIVATE KEY)[A-Z0-9 ]+-----${KEY_BODY_LINE_BREAK})`,
|
|
136
|
+
].join("");
|
|
137
|
+
const KEY_BODY_FULL_LINE = `(?=[${KEY_BODY_ALPHABET}]{0,75}[A-Z])(?=[${KEY_BODY_ALPHABET}]{0,75}[a-z])(?:[${KEY_BODY_ALPHABET}]{76}|[${KEY_BODY_ALPHABET}]{70}|[${KEY_BODY_ALPHABET}]{64})`;
|
|
138
|
+
const KEY_BODY_ANY_LINE = `[${KEY_BODY_ALPHABET}]{1,76}={0,2}`;
|
|
139
|
+
const KEY_FOOTER_SOURCE = "-----END [A-Z ]*PRIVATE KEY-----";
|
|
140
|
+
export const KEY_BODY_RUN_SOURCE = `${KEY_BODY_LINE_START}${KEY_BODY_FULL_LINE}(?:${KEY_BODY_LINE_BREAK}${KEY_BODY_FULL_LINE}){3}(?:${KEY_BODY_LINE_BREAK}${KEY_BODY_FULL_LINE}){0,252}(?:${KEY_BODY_LINE_BREAK}${KEY_BODY_ANY_LINE}(?![${KEY_BODY_ALPHABET}=]))?`;
|
|
141
|
+
export const KEY_BODY_BEFORE_FOOTER_SOURCE = `${KEY_BODY_LINE_START}[${KEY_BODY_ALPHABET}]{40,76}={0,2}(?:${KEY_BODY_LINE_BREAK}${KEY_BODY_ANY_LINE}){0,8}(?=${KEY_BODY_LINE_BREAK}${KEY_FOOTER_SOURCE})`;
|
|
104
142
|
/**
|
|
105
143
|
* Self-identifying secret values — blocked regardless of context because the
|
|
106
144
|
* token shape itself is the credential, with no benign reading.
|
|
@@ -130,6 +168,8 @@ const SECRET_VALUE_PATTERNS = [
|
|
|
130
168
|
/\b(?:AKIA|ASIA)[A-Z0-9]{16}\b/,
|
|
131
169
|
/\b(?:pk|sk)-lf-[A-Za-z0-9_-]{16}[A-Za-z0-9_-]*\b/i,
|
|
132
170
|
/\bm0[-_][A-Za-z0-9_-]{16}[A-Za-z0-9_-]*\b/i,
|
|
171
|
+
new RegExp(KEY_BODY_RUN_SOURCE),
|
|
172
|
+
new RegExp(KEY_BODY_BEFORE_FOOTER_SOURCE),
|
|
133
173
|
];
|
|
134
174
|
// BLI-22794: changing these rules changes `evidenceRulesFingerprint()` (evidence-rules-fingerprint.ts), which
|
|
135
175
|
// rebuilds every collector's prepare memo once. That is intended; update the pin in its test.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PASSWORD_NAME_MATCH_SOURCE, PASSWORD_VALUE_SOURCE, SECRET_ASSIGNMENT_SOURCE, SECRET_LIKE_CONTENT_PATTERNS, SECRET_NAME_MATCH_SOURCE, } from "./secret-guards-content-rules.js";
|
|
1
|
+
import { KEY_BODY_BEFORE_FOOTER_SOURCE, KEY_BODY_RUN_SOURCE, PASSWORD_NAME_MATCH_SOURCE, PASSWORD_VALUE_SOURCE, SECRET_ASSIGNMENT_SOURCE, SECRET_LIKE_CONTENT_PATTERNS, SECRET_NAME_MATCH_SOURCE, } from "./secret-guards-content-rules.js";
|
|
2
2
|
import { RawEvidenceRedactionMetadataSchema } from "./secret-guards-metadata.js";
|
|
3
3
|
// Same fence as the detector (BLI-3116) — the two must agree or a prefixed
|
|
4
4
|
// name would be detected and then left unredacted, which costs whole sessions
|
|
@@ -110,6 +110,16 @@ export const SECRET_REDACTION_RULES = [
|
|
|
110
110
|
pattern: PASSWORD_ASSIGNMENT_REDACTION_PATTERN,
|
|
111
111
|
secretGroup: 2,
|
|
112
112
|
},
|
|
113
|
+
// BLI-26798: a private key body whose BEGIN line was cut away. Appended so no
|
|
114
|
+
// existing rule's priority moves; both tells carry one label.
|
|
115
|
+
{
|
|
116
|
+
ruleId: "private_key_body",
|
|
117
|
+
pattern: new RegExp(KEY_BODY_RUN_SOURCE, "g"),
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
ruleId: "private_key_body",
|
|
121
|
+
pattern: new RegExp(KEY_BODY_BEFORE_FOOTER_SOURCE, "g"),
|
|
122
|
+
},
|
|
113
123
|
];
|
|
114
124
|
/**
|
|
115
125
|
* Mask every secret-shaped span and keep the rest of the text, because a
|