claude-mem-lite 6.30.12 → 6.30.13

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.
@@ -9,7 +9,7 @@
9
9
  "plugins": [
10
10
  {
11
11
  "name": "claude-mem-lite",
12
- "version": "6.30.12",
12
+ "version": "6.30.13",
13
13
  "source": "./",
14
14
  "homepage": "https://github.com/sdsrss/claude-mem-lite",
15
15
  "description": "Persistent long-term memory for Claude Code via MCP — captures coding decisions, bugfixes, and context across sessions. FTS5 BM25 keyword search with episode batching. Single SQLite DB, no external services. A lighter, lower-cost alternative to claude-mem (episode batching + a smaller model; cost savings are an internal estimate, not a measured benchmark)."
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-mem-lite",
3
- "version": "6.30.12",
3
+ "version": "6.30.13",
4
4
  "description": "Persistent long-term memory for Claude Code via MCP — captures coding decisions, bugfixes, and context across sessions. FTS5 BM25 keyword search with episode batching. Single SQLite DB, no external services. A lighter, lower-cost alternative to claude-mem (episode batching + a smaller model; cost savings are an internal estimate, not a measured benchmark).",
5
5
  "author": {
6
6
  "name": "sdsrss"
@@ -67,6 +67,89 @@ function importedObsTitle(toolUse) {
67
67
  return scrubbed.slice(0, prefix.length + IMPORTED_TITLE_DETAIL_MAX);
68
68
  }
69
69
 
70
+ // A private-key marker, BEGIN or END: the key arm of utils.mjs's PRIVATE_MARK_RE.
71
+ const KEY_MARK_RE = /-----(BEGIN|END) [A-Z0-9 ]*PRIVATE KEY/;
72
+ // Every tag lib/private-strip.mjs pairs (`<private>`, `<private …>`, `</private>`), and a little more.
73
+ const PRIVATE_TAG_HINT_RE = /<\/?private[\s>]/i;
74
+ const STORED_PART_MAX = 4000;
75
+
76
+ /**
77
+ * One tool part (a tool_use input or a tool_result content) as it is stored: scrubbed, then cut
78
+ * to STORED_PART_MAX (scrub first, cut second, for the reason importedObsTitle gives). `json` says
79
+ * the part is a parsed value stored as its JSON text; otherwise `value` is the text itself.
80
+ *
81
+ * Two rules come before that scrub (2026-11-02: of 12 shape groups measured, import-jsonl stored 7
82
+ * and stores none with these rules):
83
+ * - A part keeps only what comes before its first private-key marker, in the order JSON writes it,
84
+ * object keys included: the string or key holding the marker is cut there and every later member
85
+ * is left out; a part whose first marker is an END is stored empty, since what precedes an END
86
+ * can be a key's tail. This covers keys the scrubber cannot read, such as the diff of a key that
87
+ * gained a passphrase.
88
+ * - Each string value of a parsed part is scrubbed as text before the JSON wrap. Scrubbing only the
89
+ * JSON text left every string one escape level deep, where the raw-text rules do not hold: a label
90
+ * at an escaped line start, a JSON object inside a string, a key printed one string per line. Not
91
+ * done when a string value holds a `<private>` tag, since a pair can span two strings and only the
92
+ * whole text pairs it. The whole-text scrub still runs: it reads object keys as labels.
93
+ * The JSON text is written by an explicit-stack walk, not by JSON.stringify: a JSON.stringify replacer
94
+ * recursed, so a part nested a few thousand levels deep threw and the whole transcript was lost
95
+ * (v6.30.13 pre-tag review r1), and on Node 22 plain JSON.stringify throws from about 4,200 levels.
96
+ */
97
+ function storedToolPart(value, json) {
98
+ let stopped = false;
99
+ let endFirst = false;
100
+ const cut = (s) => {
101
+ const m = KEY_MARK_RE.exec(s);
102
+ if (!m) return s;
103
+ stopped = true;
104
+ if (m[1] === 'END') endFirst = true;
105
+ return s.slice(0, m.index);
106
+ };
107
+ if (!json) {
108
+ const text = cut(value);
109
+ return endFirst ? '' : scrubSecrets(text).slice(0, STORED_PART_MAX);
110
+ }
111
+ const out = []; // pieces of the JSON text
112
+ const strings = []; // indexes in `out` of string values, still raw; quoted below
113
+ let tagged = false;
114
+ const leaf = (v) => {
115
+ if (typeof v !== 'string') return out.push(JSON.stringify(v));
116
+ const s = cut(v);
117
+ if (PRIVATE_TAG_HINT_RE.test(s)) tagged = true;
118
+ strings.push(out.length);
119
+ out.push(s);
120
+ };
121
+ const open = (v) => {
122
+ const keys = Array.isArray(v) ? null : Object.keys(v);
123
+ out.push(keys ? '{' : '[');
124
+ return { v, keys, i: 0 };
125
+ };
126
+ const stack = value !== null && typeof value === 'object' ? [open(value)] : (leaf(value), []);
127
+ while (stack.length) {
128
+ const f = stack[stack.length - 1];
129
+ if (stopped || f.i >= (f.keys ? f.keys.length : f.v.length)) {
130
+ out.push(f.keys ? '}' : ']');
131
+ stack.pop();
132
+ continue;
133
+ }
134
+ if (f.i > 0) out.push(',');
135
+ const k = f.keys ? f.keys[f.i] : f.i;
136
+ f.i++;
137
+ if (f.keys) {
138
+ out.push(JSON.stringify(cut(k)), ':');
139
+ if (stopped) {
140
+ out.push('""');
141
+ continue;
142
+ }
143
+ }
144
+ const v = f.v[k];
145
+ if (v !== null && typeof v === 'object') stack.push(open(v));
146
+ else leaf(v);
147
+ }
148
+ if (endFirst) return '';
149
+ for (const i of strings) out[i] = JSON.stringify(tagged ? out[i] : scrubSecrets(out[i]));
150
+ return scrubSecrets(out.join('')).slice(0, STORED_PART_MAX);
151
+ }
152
+
70
153
  function dedupKey(parts) {
71
154
  return createHash('sha256').update(parts.join('\x1f')).digest('hex');
72
155
  }
@@ -160,20 +243,21 @@ function importToolPair(db, toolUse, toolResult, project) {
160
243
 
161
244
  const toolName = toolUse.name || 'unknown';
162
245
  const type = TOOL_TO_TYPE[toolName] || 'change';
163
- // Each part is scrubbed BEFORE its 4000-character cap, for the reason importedObsTitle
164
- // gives: a cap that splits a token leaves a prefix too short for the scrubber's pattern.
165
- // The body is therefore kept out of the scrubRecord call below, so it is scrubbed once.
166
- const inputJson = scrubSecrets(
167
- typeof toolUse.input === 'object' ? JSON.stringify(toolUse.input) : String(toolUse.input ?? ''),
168
- ).slice(0, 4000);
246
+ // Each part is scrubbed BEFORE its 4000-character cap (storedToolPart), for the reason
247
+ // importedObsTitle gives: a cap that splits a token leaves a prefix too short for the
248
+ // scrubber's pattern. The body is therefore kept out of the scrubRecord call below.
249
+ const inputObject = typeof toolUse.input === 'object';
250
+ const inputJson = storedToolPart(inputObject ? toolUse.input : String(toolUse.input ?? ''), inputObject);
169
251
  // The cap binds to BOTH shapes: it bound only to the array branch, so a string tool_result
170
252
  // (what Bash and Read return in real transcripts) was stored whole (E2E 2026-10-16). The
171
253
  // whole result is scrubbed before the cut, as the array branch always was: a pre-scrub cut
172
254
  // at twice the cap split a token there, and secrets ahead of it that the scrub shortened
173
255
  // pulled that head inside the 4000 kept (E2E round 2, data R2).
174
- const rawResult =
175
- typeof toolResult?.content === 'string' ? toolResult.content : JSON.stringify(toolResult?.content ?? '');
176
- const resultText = scrubSecrets(rawResult).slice(0, 4000);
256
+ const resultString = typeof toolResult?.content === 'string';
257
+ const resultText = storedToolPart(
258
+ resultString ? toolResult.content : (toolResult?.content ?? ''),
259
+ !resultString,
260
+ );
177
261
 
178
262
  // D#35: this gated on `input.file_path` alone, and `NotebookEdit` carries
179
263
  // `notebook_path` and never `file_path` — so the branch named NotebookEdit
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "claude-mem-lite",
3
- "version": "6.30.12",
3
+ "version": "6.30.13",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "claude-mem-lite",
9
- "version": "6.30.12",
9
+ "version": "6.30.13",
10
10
  "os": [
11
11
  "darwin",
12
12
  "linux",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-mem-lite",
3
- "version": "6.30.12",
3
+ "version": "6.30.13",
4
4
  "description": "Persistent long-term memory for Claude Code via MCP — captures coding decisions, bugfixes, and context across sessions. FTS5 BM25 keyword search with episode batching. Single SQLite DB, no external services. A lighter, lower-cost alternative to claude-mem (episode batching + a smaller model; cost savings are an internal estimate, not a measured benchmark).",
5
5
  "type": "module",
6
6
  "packageManager": "npm@10.9.2",
package/secret-scrub.mjs CHANGED
@@ -76,9 +76,18 @@ export const SECRET_PATTERNS = [
76
76
  // that way was stored when the text was in a JSON string. A quoted value with more of the
77
77
  // key in it is erased to its closing quote as before: the key passes miss some of what that erases
78
78
  // (a first body line cut inside its first 40 characters).
79
+ //
80
+ // A VALUE ON A LATER LINE (D#683). The whitespace after a separator may run onto the next lines, so a
81
+ // value written below its label is still erased (`password:` then ` <v>`; prettier's `const X =` then
82
+ // ` "<v>";`), but not when that line opens with a label of its own (`NAME: v`, `NAME=v`, `"name":`).
83
+ // A label with an empty value (`POSTGRES_PASSWORD:` in a compose file, `password =` in an INI section)
84
+ // took the next line's label as its value, and that line's value was stored. Such a line is now read
85
+ // as it would be on its own; text with no line break between a separator and its value scrubs exactly
86
+ // as before. A name over 64 characters is not taken for a label, so the check reads a bounded prefix
87
+ // of the line. The quoted-value, JSON-key and env-name patterns below carry the same rule.
79
88
  // 1a. `=` assignment → ALWAYS scrub (config syntax, never prose):
80
89
  [
81
- /((?:\b|_)(?:password|passwd|passphrase|token|bearer|secret)(?:[*_~`]{1,3})?\s*=(?:[*_~]{1,2}(?=\s))?\s*)(?!process\.env\.)(?!new\s)(?!\w+\()(?!(?:null|undefined|true|false|None|nil|empty|""|''|0)\b)(?:(?!-----BEGIN [A-Z0-9 ]*PRIVATE KEY|\*\*\*PEM_KEY\*\*\*)[^\s,;'"}\]]){6,}/gi,
90
+ /((?:\b|_)(?:password|passwd|passphrase|token|bearer|secret)(?:[*_~`]{1,3})?\s*=(?:[*_~]{1,2}(?=\s))?(?:[^\S\r\n]*|[^\S\r\n]*[\r\n]\s*(?![*~`]{0,3}[\w.-]{1,64}[*~`]{0,3}[^\S\r\n]*(?:[=:](?!=)|:(?=[\s'"]))[^\S\r\n]*\S)))(?!process\.env\.)(?!new\s)(?!\w+\()(?!(?:null|undefined|true|false|None|nil|empty|""|''|0)\b)(?:(?!-----BEGIN [A-Z0-9 ]*PRIVATE KEY|\*\*\*PEM_KEY\*\*\*)[^\s,;'"}\]]){6,}/gi,
82
91
  '$1***',
83
92
  ],
84
93
  // 1b. `:` separator, PASSWORD nouns. Position decides how permissive the value
@@ -119,16 +128,16 @@ export const SECRET_PATTERNS = [
119
128
  // Both arms emit `***` (3 chars, under the {6,} floor), so they cannot
120
129
  // double-apply.
121
130
  [
122
- /((?:(?<![A-Za-z][ \t][*_~]{0,3})(?:\b|_)(?:password|passwd|passphrase)(?:[*_~]{1,3})?|(?=_?(?:password|passwd|passphrase)`)(?<![A-Za-z][ \t]`[\w-]{0,40})(?<=`[\w-]{0,40})(?:\b|_)(?:password|passwd|passphrase)`)\s*[::](?:[*_~]{1,2}(?=\s))?\s*)(?!process\.env\.)(?!new\s)(?!\w+\()(?!(?:null|undefined|true|false|None|nil|empty|""|''|0)\b)(?:(?!-----BEGIN [A-Z0-9 ]*PRIVATE KEY|\*\*\*PEM_KEY\*\*\*)[^\s,;'"}\]]){6,}/gi,
131
+ /((?:(?<![A-Za-z][ \t][*_~]{0,3})(?:\b|_)(?:password|passwd|passphrase)(?:[*_~]{1,3})?|(?=_?(?:password|passwd|passphrase)`)(?<![A-Za-z][ \t]`[\w-]{0,40})(?<=`[\w-]{0,40})(?:\b|_)(?:password|passwd|passphrase)`)\s*[::](?:[*_~]{1,2}(?=\s))?(?:[^\S\r\n]*|[^\S\r\n]*[\r\n]\s*(?![*~`]{0,3}[\w.-]{1,64}[*~`]{0,3}[^\S\r\n]*(?:[=:](?!=)|:(?=[\s'"]))[^\S\r\n]*\S)))(?!process\.env\.)(?!new\s)(?!\w+\()(?!(?:null|undefined|true|false|None|nil|empty|""|''|0)\b)(?:(?!-----BEGIN [A-Z0-9 ]*PRIVATE KEY|\*\*\*PEM_KEY\*\*\*)[^\s,;'"}\]]){6,}/gi,
123
132
  '$1***',
124
133
  ],
125
134
  [
126
- /((?:\b|_)(?:password|passwd|passphrase)(?:[*_~`]{1,3})?\s*[::](?:[*_~]{1,2}(?=\s))?\s*)(?!process\.env\.)(?!new\s)(?!\w+\()(?!(?:null|undefined|true|false|None|nil|empty|""|''|0)\b)(?![A-Za-z]{1,15}(?=[`*~]*(?:[\s,;'"}\]]|$)))(?:(?!-----BEGIN [A-Z0-9 ]*PRIVATE KEY|\*\*\*PEM_KEY\*\*\*)[^\s,;'"}\]]){6,}/gi,
135
+ /((?:\b|_)(?:password|passwd|passphrase)(?:[*_~`]{1,3})?\s*[::](?:[*_~]{1,2}(?=\s))?(?:[^\S\r\n]*|[^\S\r\n]*[\r\n]\s*(?![*~`]{0,3}[\w.-]{1,64}[*~`]{0,3}[^\S\r\n]*(?:[=:](?!=)|:(?=[\s'"]))[^\S\r\n]*\S)))(?!process\.env\.)(?!new\s)(?!\w+\()(?!(?:null|undefined|true|false|None|nil|empty|""|''|0)\b)(?![A-Za-z]{1,15}(?=[`*~]*(?:[\s,;'"}\]]|$)))(?:(?!-----BEGIN [A-Z0-9 ]*PRIVATE KEY|\*\*\*PEM_KEY\*\*\*)[^\s,;'"}\]]){6,}/gi,
127
136
  '$1***',
128
137
  ],
129
138
  // 1c. `:` separator, prose-ambiguous nouns → keep the lookbehind ("the token: alicebob"):
130
139
  [
131
- /((?:(?<![A-Za-z][ \t][*_~]{0,3})(?:\b|_)(?:token|bearer|secret)(?:[*_~]{1,3})?|(?=_?(?:token|bearer|secret)`)(?<![A-Za-z][ \t]`[\w-]{0,40})(?<=`[\w-]{0,40})(?:\b|_)(?:token|bearer|secret)`)\s*[::](?:[*_~]{1,2}(?=\s))?\s*)(?!process\.env\.)(?!new\s)(?!\w+\()(?!(?:null|undefined|true|false|None|nil|empty|""|''|0)\b)(?:(?!-----BEGIN [A-Z0-9 ]*PRIVATE KEY|\*\*\*PEM_KEY\*\*\*)[^\s,;'"}\]]){6,}/gi,
140
+ /((?:(?<![A-Za-z][ \t][*_~]{0,3})(?:\b|_)(?:token|bearer|secret)(?:[*_~]{1,3})?|(?=_?(?:token|bearer|secret)`)(?<![A-Za-z][ \t]`[\w-]{0,40})(?<=`[\w-]{0,40})(?:\b|_)(?:token|bearer|secret)`)\s*[::](?:[*_~]{1,2}(?=\s))?(?:[^\S\r\n]*|[^\S\r\n]*[\r\n]\s*(?![*~`]{0,3}[\w.-]{1,64}[*~`]{0,3}[^\S\r\n]*(?:[=:](?!=)|:(?=[\s'"]))[^\S\r\n]*\S)))(?!process\.env\.)(?!new\s)(?!\w+\()(?!(?:null|undefined|true|false|None|nil|empty|""|''|0)\b)(?:(?!-----BEGIN [A-Z0-9 ]*PRIVATE KEY|\*\*\*PEM_KEY\*\*\*)[^\s,;'"}\]]){6,}/gi,
132
141
  '$1***',
133
142
  ],
134
143
  // access_token / refresh_token are the canonical OAuth2 field names — they were
@@ -143,7 +152,7 @@ export const SECRET_PATTERNS = [
143
152
  // low-FP decision that `topsecret=` / `access_token_count:` are non-credentials
144
153
  // (#8283 + utils.test.mjs:1089-1100); bare `pwd` is omitted so `PWD=` (a path) survives.
145
154
  [
146
- /((?:\b|_)(?:api[_-]?key|api[_-]?secret|secret[_-]?key|access[_-]?key|private[_-]?key|client[_-]?secret|auth[_-]?token|access[_-]?token|refresh[_-]?token|pgpassword|pgpass|mysql_pwd)(?:[*_~`]{1,3})?\s*[=::](?:[*_~]{1,2}(?=\s))?\s*)(?!process\.env\.)(?!new\s)(?!\w+\()(?!(?:null|undefined|true|false|None|nil|empty|""|''|0)\b)(?:(?!-----BEGIN [A-Z0-9 ]*PRIVATE KEY|\*\*\*PEM_KEY\*\*\*)[^\s,;'"}\]]){6,}/gi,
155
+ /((?:\b|_)(?:api[_-]?key|api[_-]?secret|secret[_-]?key|access[_-]?key|private[_-]?key|client[_-]?secret|auth[_-]?token|access[_-]?token|refresh[_-]?token|pgpassword|pgpass|mysql_pwd)(?:[*_~`]{1,3})?\s*[=::](?:[*_~]{1,2}(?=\s))?(?:[^\S\r\n]*|[^\S\r\n]*[\r\n]\s*(?![*~`]{0,3}[\w.-]{1,64}[*~`]{0,3}[^\S\r\n]*(?:[=:](?!=)|:(?=[\s'"]))[^\S\r\n]*\S)))(?!process\.env\.)(?!new\s)(?!\w+\()(?!(?:null|undefined|true|false|None|nil|empty|""|''|0)\b)(?:(?!-----BEGIN [A-Z0-9 ]*PRIVATE KEY|\*\*\*PEM_KEY\*\*\*)[^\s,;'"}\]]){6,}/gi,
147
156
  '$1***',
148
157
  ],
149
158
  // Space-separated credential CLI flag: `--password <value>` (long-form). The KV
@@ -170,21 +179,21 @@ export const SECRET_PATTERNS = [
170
179
  // (mirrors the unquoted 1a/1b split — a quoted value doesn't turn `:` prose
171
180
  // into config, but `<word> password="x"` is still a leak):
172
181
  [
173
- /((?:\b|_)(?:password|passwd|passphrase|token|bearer|secret)(?:[*_~`]{1,3})?\s*=(?:[*_~]{1,2}(?=\s))?\s*)(['"])(?!-----BEGIN [A-Z0-9 ]*PRIVATE KEY(?: BLOCK)?-----(?:\\+[nr])*\2)[^'"]{6,}\2/gi,
182
+ /((?:\b|_)(?:password|passwd|passphrase|token|bearer|secret)(?:[*_~`]{1,3})?\s*=(?:[*_~]{1,2}(?=\s))?(?:[^\S\r\n]*|[^\S\r\n]*[\r\n]\s*(?!(?:"[^"\r\n]*"|'[^'\r\n]*')[^\S\r\n]*[:=:])))(['"])(?!-----BEGIN [A-Z0-9 ]*PRIVATE KEY(?: BLOCK)?-----(?:\\+[nr])*\2)[^'"]{6,}\2/gi,
174
183
  '$1$2***$2',
175
184
  ],
176
185
  [
177
- /((?:\b|_)(?:password|passwd|passphrase)(?:[*_~`]{1,3})?\s*[::](?:[*_~]{1,2}(?=\s))?\s*)(['"])(?!-----BEGIN [A-Z0-9 ]*PRIVATE KEY(?: BLOCK)?-----(?:\\+[nr])*\2)[^'"]{6,}\2/gi,
186
+ /((?:\b|_)(?:password|passwd|passphrase)(?:[*_~`]{1,3})?\s*[::](?:[*_~]{1,2}(?=\s))?(?:[^\S\r\n]*|[^\S\r\n]*[\r\n]\s*(?!(?:"[^"\r\n]*"|'[^'\r\n]*')[^\S\r\n]*[:=:])))(['"])(?!-----BEGIN [A-Z0-9 ]*PRIVATE KEY(?: BLOCK)?-----(?:\\+[nr])*\2)[^'"]{6,}\2/gi,
178
187
  '$1$2***$2',
179
188
  ],
180
189
  [
181
- /((?:(?<![A-Za-z][ \t][*_~]{0,3})(?:\b|_)(?:token|bearer|secret)(?:[*_~]{1,3})?|(?=_?(?:token|bearer|secret)`)(?<![A-Za-z][ \t]`[\w-]{0,40})(?<=`[\w-]{0,40})(?:\b|_)(?:token|bearer|secret)`)\s*[::](?:[*_~]{1,2}(?=\s))?\s*)(['"])(?!-----BEGIN [A-Z0-9 ]*PRIVATE KEY(?: BLOCK)?-----(?:\\+[nr])*\2)[^'"]{6,}\2/gi,
190
+ /((?:(?<![A-Za-z][ \t][*_~]{0,3})(?:\b|_)(?:token|bearer|secret)(?:[*_~]{1,3})?|(?=_?(?:token|bearer|secret)`)(?<![A-Za-z][ \t]`[\w-]{0,40})(?<=`[\w-]{0,40})(?:\b|_)(?:token|bearer|secret)`)\s*[::](?:[*_~]{1,2}(?=\s))?(?:[^\S\r\n]*|[^\S\r\n]*[\r\n]\s*(?!(?:"[^"\r\n]*"|'[^'\r\n]*')[^\S\r\n]*[:=:])))(['"])(?!-----BEGIN [A-Z0-9 ]*PRIVATE KEY(?: BLOCK)?-----(?:\\+[nr])*\2)[^'"]{6,}\2/gi,
182
191
  '$1$2***$2',
183
192
  ],
184
193
  // (b) structured keys + named env vars are unambiguous config even after a word
185
194
  // (`see api_key: "x"` DOES scrub, mirroring the unquoted structured-key path):
186
195
  [
187
- /((?:\b|_)(?:pgpassword|pgpass|mysql_pwd|api[_-]?key|api[_-]?secret|secret[_-]?key|access[_-]?key|private[_-]?key|client[_-]?secret|auth[_-]?token|access[_-]?token|refresh[_-]?token)(?:[*_~`]{1,3})?\s*[=::](?:[*_~]{1,2}(?=\s))?\s*)(['"])(?!-----BEGIN [A-Z0-9 ]*PRIVATE KEY(?: BLOCK)?-----(?:\\+[nr])*\2)[^'"]{6,}\2/gi,
196
+ /((?:\b|_)(?:pgpassword|pgpass|mysql_pwd|api[_-]?key|api[_-]?secret|secret[_-]?key|access[_-]?key|private[_-]?key|client[_-]?secret|auth[_-]?token|access[_-]?token|refresh[_-]?token)(?:[*_~`]{1,3})?\s*[=::](?:[*_~]{1,2}(?=\s))?(?:[^\S\r\n]*|[^\S\r\n]*[\r\n]\s*(?!(?:"[^"\r\n]*"|'[^'\r\n]*')[^\S\r\n]*[:=:])))(['"])(?!-----BEGIN [A-Z0-9 ]*PRIVATE KEY(?: BLOCK)?-----(?:\\+[nr])*\2)[^'"]{6,}\2/gi,
188
197
  '$1$2***$2',
189
198
  ],
190
199
  // AWS access keys: AKIA (long-term) + ASIA (STS temp) + AROA (role) + AIDA
@@ -256,7 +265,10 @@ export const SECRET_PATTERNS = [
256
265
  // name and the colon, so a `curl -v` / fetch header dump walked straight through. The
257
266
  // scheme word is optional because a raw token as the whole value is just as common;
258
267
  // `authorization` is not a benign key, and over-scrub is the safe direction here.
259
- [/(['"](?:proxy-)?authorization['"]\s*:\s*)(['"])(?:(?:Bearer|Basic|token)\s+)?[^'"]{6,}\2/gi, '$1$2***$2'],
268
+ [
269
+ /(['"](?:proxy-)?authorization['"]\s*:(?:[^\S\r\n]*|[^\S\r\n]*[\r\n]\s*(?!(?:"[^"\r\n]*"|'[^'\r\n]*')[^\S\r\n]*[:=:])))(['"])(?:(?:Bearer|Basic|token)\s+)?[^'"]{6,}\2/gi,
270
+ '$1$2***$2',
271
+ ],
260
272
  // R10 P1-6: Azure storage. AccountKey= is the account's master credential and sig= is a
261
273
  // live SAS token; neither had any pattern. `sig` is anchored to a URL query position
262
274
  // (`?`/`&`) rather than a word boundary — bare `\bsig=` eats `const sig=computeX(y)`.
@@ -264,7 +276,7 @@ export const SECRET_PATTERNS = [
264
276
  [/([?&]sig=)[^\s;&'"]{16,}/gi, '$1***'],
265
277
  // Supabase / generic long base64 keys (40+ chars, common in env vars)
266
278
  [
267
- /(\b(?:SUPABASE_KEY|SUPABASE_ANON_KEY|SUPABASE_SERVICE_ROLE_KEY|DATABASE_URL|REDIS_URL)\s*[=:]\s*)[^\s,;'"}\]]+/gi,
279
+ /(\b(?:SUPABASE_KEY|SUPABASE_ANON_KEY|SUPABASE_SERVICE_ROLE_KEY|DATABASE_URL|REDIS_URL)\s*[=:](?:[^\S\r\n]*|[^\S\r\n]*[\r\n]\s*(?![*~`]{0,3}[\w.-]{1,64}[*~`]{0,3}[^\S\r\n]*(?:[=:](?!=)|:(?=[\s'"]))[^\S\r\n]*\S)))[^\s,;'"}\]]+/gi,
268
280
  '$1***',
269
281
  ],
270
282
  // Basic auth in URLs (https://user:password@host). ftp/ftps added — file-drop
@@ -305,7 +317,7 @@ export const SECRET_PATTERNS = [
305
317
  // these slip through. Match the value-quoted form explicitly. Length floor
306
318
  // (6) avoids tripping on intentional placeholder shorts ("...", "secret").
307
319
  [
308
- /("(?:password|passwd|token|api[_-]?key|api[_-]?secret|secret[_-]?key|access[_-]?key|access[_-]?token|private[_-]?key|client[_-]?secret|auth[_-]?token|bearer|refresh[_-]?token|session[_-]?id|sessionid)"\s*:\s*")[^"]{6,}(")/gi,
320
+ /("(?:password|passwd|token|api[_-]?key|api[_-]?secret|secret[_-]?key|access[_-]?key|access[_-]?token|private[_-]?key|client[_-]?secret|auth[_-]?token|bearer|refresh[_-]?token|session[_-]?id|sessionid)"\s*:(?:[^\S\r\n]*|[^\S\r\n]*[\r\n]\s*(?!(?:"[^"\r\n]*"|'[^'\r\n]*')[^\S\r\n]*[:=:]))")[^"]{6,}(")/gi,
309
321
  '$1***$2',
310
322
  ],
311
323
  // JSON keys with vendor PREFIX/SUFFIX around the core credential noun —
@@ -318,7 +330,7 @@ export const SECRET_PATTERNS = [
318
330
  // one quote, `\w*` ran to the end of a word run and backtracked through every keyword in it,
319
331
  // each rescanning the run — `"` + `secret` x 33k took 4.6 s. 64 is far past any key name.
320
332
  [
321
- /("\w{0,64}(?:password|passwd|secret|api[_-]?key|auth[_-]?token|access[_-]?token|private[_-]?key)\w{0,64}"\s*:\s*")[^"]{6,}(")/gi,
333
+ /("\w{0,64}(?:password|passwd|secret|api[_-]?key|auth[_-]?token|access[_-]?token|private[_-]?key)\w{0,64}"\s*:(?:[^\S\r\n]*|[^\S\r\n]*[\r\n]\s*(?!(?:"[^"\r\n]*"|'[^'\r\n]*')[^\S\r\n]*[:=:]))")[^"]{6,}(")/gi,
322
334
  '$1***$2',
323
335
  ],
324
336
  // Quoted-KEY credential values — Python dict reprs `{'api_key': '...'}`, single-quoted
@@ -334,7 +346,7 @@ export const SECRET_PATTERNS = [
334
346
  // `'token_count': 123456`); `passphrase` added here too (double-quoted JSON passphrase is
335
347
  // subsumed by this pattern since `['"]` matches `"`). Over-scrub is the safe direction.
336
348
  [
337
- /(['"](?:\w{0,64}(?:password|passwd|passphrase|secret|api[_-]?key|auth[_-]?token|access[_-]?token|private[_-]?key)\w{0,64}|\w{1,64}_token)['"]\s*:\s*)(['"])[^'"]{6,}\2/gi,
349
+ /(['"](?:\w{0,64}(?:password|passwd|passphrase|secret|api[_-]?key|auth[_-]?token|access[_-]?token|private[_-]?key)\w{0,64}|\w{1,64}_token)['"]\s*:(?:[^\S\r\n]*|[^\S\r\n]*[\r\n]\s*(?!(?:"[^"\r\n]*"|'[^'\r\n]*')[^\S\r\n]*[:=:])))(['"])[^'"]{6,}\2/gi,
338
350
  '$1$2***$2',
339
351
  ],
340
352
  // Session cookies in headers / urlencoded bodies (sessionid=, session_id=, JSESSIONID=, PHPSESSID=).