@bli-cockpit/telemetry-core 0.1.109 → 0.1.110

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.
@@ -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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bli-cockpit/telemetry-core",
3
- "version": "0.1.109",
3
+ "version": "0.1.110",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",