claude-mem-lite 6.30.11 → 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.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/lib/import-jsonl.mjs +93 -9
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/secret-scrub.mjs +46 -15
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"plugins": [
|
|
10
10
|
{
|
|
11
11
|
"name": "claude-mem-lite",
|
|
12
|
-
"version": "6.30.
|
|
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.
|
|
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"
|
package/lib/import-jsonl.mjs
CHANGED
|
@@ -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
|
|
164
|
-
// gives: a cap that splits a token leaves a prefix too short for the
|
|
165
|
-
// The body is therefore kept out of the scrubRecord call below
|
|
166
|
-
const
|
|
167
|
-
|
|
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
|
|
175
|
-
|
|
176
|
-
|
|
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
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-mem-lite",
|
|
3
|
-
"version": "6.30.
|
|
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.
|
|
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.
|
|
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
|
@@ -60,9 +60,34 @@ export const SECRET_PATTERNS = [
|
|
|
60
60
|
// v3.61.0 already had to undo exactly that. `| password | <v> |` table rows stay open for a
|
|
61
61
|
// different reason: those 831k lines held 1 such row and none with a credential-shaped
|
|
62
62
|
// value, so a table pattern's false-positive rate cannot be measured here.
|
|
63
|
+
//
|
|
64
|
+
// A KEY'S BEGIN IS NOT A VALUE (D#657). These patterns run before the private key ones below, and
|
|
65
|
+
// a value took the `-----BEGIN` of a key written right after its label (`PRIVATE_KEY=-----BEGIN …`,
|
|
66
|
+
// or `private_key = <<EOT\n-----BEGIN …` in a JSON string, where the escaped break is no space):
|
|
67
|
+
// the key passes then saw no BEGIN and stored every line of a cut-off key. So a value stops before a
|
|
68
|
+
// private key's BEGIN, and the label patterns' values also before `***PEM_KEY***`, or the next pass
|
|
69
|
+
// took that mark and the lines after it up to a space (6.30.11 kept them: it erased such a key from
|
|
70
|
+
// its END).
|
|
71
|
+
// The `--password` flag stops at the BEGIN only: with the mark stop as well, a line that the reading
|
|
72
|
+
// of a cut-off key left after its mark, which the flag's value on the next pass erased in 6.30.11,
|
|
73
|
+
// was kept.
|
|
74
|
+
// A quoted value is left to the key passes when it holds the BEGIN line and nothing else (`'…-----\n'
|
|
75
|
+
// +`: a key concatenated one string per line, Node's util.inspect of an object); a whole key printed
|
|
76
|
+
// that way was stored when the text was in a JSON string. A quoted value with more of the
|
|
77
|
+
// key in it is erased to its closing quote as before: the key passes miss some of what that erases
|
|
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.
|
|
63
88
|
// 1a. `=` assignment → ALWAYS scrub (config syntax, never prose):
|
|
64
89
|
[
|
|
65
|
-
/((?:\b|_)(?:password|passwd|passphrase|token|bearer|secret)(?:[*_~`]{1,3})?\s*=(?:[*_~]{1,2}(?=\s))
|
|
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,
|
|
66
91
|
'$1***',
|
|
67
92
|
],
|
|
68
93
|
// 1b. `:` separator, PASSWORD nouns. Position decides how permissive the value
|
|
@@ -103,16 +128,16 @@ export const SECRET_PATTERNS = [
|
|
|
103
128
|
// Both arms emit `***` (3 chars, under the {6,} floor), so they cannot
|
|
104
129
|
// double-apply.
|
|
105
130
|
[
|
|
106
|
-
/((?:(?<![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))
|
|
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,
|
|
107
132
|
'$1***',
|
|
108
133
|
],
|
|
109
134
|
[
|
|
110
|
-
/((?:\b|_)(?:password|passwd|passphrase)(?:[*_~`]{1,3})?\s*[::](?:[*_~]{1,2}(?=\s))
|
|
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,
|
|
111
136
|
'$1***',
|
|
112
137
|
],
|
|
113
138
|
// 1c. `:` separator, prose-ambiguous nouns → keep the lookbehind ("the token: alicebob"):
|
|
114
139
|
[
|
|
115
|
-
/((?:(?<![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))
|
|
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,
|
|
116
141
|
'$1***',
|
|
117
142
|
],
|
|
118
143
|
// access_token / refresh_token are the canonical OAuth2 field names — they were
|
|
@@ -127,7 +152,7 @@ export const SECRET_PATTERNS = [
|
|
|
127
152
|
// low-FP decision that `topsecret=` / `access_token_count:` are non-credentials
|
|
128
153
|
// (#8283 + utils.test.mjs:1089-1100); bare `pwd` is omitted so `PWD=` (a path) survives.
|
|
129
154
|
[
|
|
130
|
-
/((?:\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))
|
|
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,
|
|
131
156
|
'$1***',
|
|
132
157
|
],
|
|
133
158
|
// Space-separated credential CLI flag: `--password <value>` (long-form). The KV
|
|
@@ -138,7 +163,10 @@ export const SECRET_PATTERNS = [
|
|
|
138
163
|
// `gh auth login --token …` and `op … --secret …` are the shapes that actually appear in
|
|
139
164
|
// Bash output. The {6,} floor is what keeps `--token abc` (a placeholder in a usage line)
|
|
140
165
|
// out, so do not lower it.
|
|
141
|
-
[
|
|
166
|
+
[
|
|
167
|
+
/(--(?:password|passwd|token|api[-_]?key|secret)[=\s]+)(?!-)(?:(?!-----BEGIN [A-Z0-9 ]*PRIVATE KEY)[^\s'"]){6,}/gi,
|
|
168
|
+
'$1***',
|
|
169
|
+
],
|
|
142
170
|
// Bare-key QUOTED values — `api_key="..."`, `password: '...'`. The unquoted KV
|
|
143
171
|
// patterns above stop at `'`/`"` (excluded from their value class), so a quoted
|
|
144
172
|
// value matched 0 chars and slipped through. Consumes the opening quote, the value,
|
|
@@ -151,21 +179,21 @@ export const SECRET_PATTERNS = [
|
|
|
151
179
|
// (mirrors the unquoted 1a/1b split — a quoted value doesn't turn `:` prose
|
|
152
180
|
// into config, but `<word> password="x"` is still a leak):
|
|
153
181
|
[
|
|
154
|
-
/((?:\b|_)(?:password|passwd|passphrase|token|bearer|secret)(?:[*_~`]{1,3})?\s*=(?:[*_~]{1,2}(?=\s))
|
|
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,
|
|
155
183
|
'$1$2***$2',
|
|
156
184
|
],
|
|
157
185
|
[
|
|
158
|
-
/((?:\b|_)(?:password|passwd|passphrase)(?:[*_~`]{1,3})?\s*[::](?:[*_~]{1,2}(?=\s))
|
|
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,
|
|
159
187
|
'$1$2***$2',
|
|
160
188
|
],
|
|
161
189
|
[
|
|
162
|
-
/((?:(?<![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))
|
|
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,
|
|
163
191
|
'$1$2***$2',
|
|
164
192
|
],
|
|
165
193
|
// (b) structured keys + named env vars are unambiguous config even after a word
|
|
166
194
|
// (`see api_key: "x"` DOES scrub, mirroring the unquoted structured-key path):
|
|
167
195
|
[
|
|
168
|
-
/((?:\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))
|
|
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,
|
|
169
197
|
'$1$2***$2',
|
|
170
198
|
],
|
|
171
199
|
// AWS access keys: AKIA (long-term) + ASIA (STS temp) + AROA (role) + AIDA
|
|
@@ -237,7 +265,10 @@ export const SECRET_PATTERNS = [
|
|
|
237
265
|
// name and the colon, so a `curl -v` / fetch header dump walked straight through. The
|
|
238
266
|
// scheme word is optional because a raw token as the whole value is just as common;
|
|
239
267
|
// `authorization` is not a benign key, and over-scrub is the safe direction here.
|
|
240
|
-
[
|
|
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
|
+
],
|
|
241
272
|
// R10 P1-6: Azure storage. AccountKey= is the account's master credential and sig= is a
|
|
242
273
|
// live SAS token; neither had any pattern. `sig` is anchored to a URL query position
|
|
243
274
|
// (`?`/`&`) rather than a word boundary — bare `\bsig=` eats `const sig=computeX(y)`.
|
|
@@ -245,7 +276,7 @@ export const SECRET_PATTERNS = [
|
|
|
245
276
|
[/([?&]sig=)[^\s;&'"]{16,}/gi, '$1***'],
|
|
246
277
|
// Supabase / generic long base64 keys (40+ chars, common in env vars)
|
|
247
278
|
[
|
|
248
|
-
/(\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,
|
|
249
280
|
'$1***',
|
|
250
281
|
],
|
|
251
282
|
// Basic auth in URLs (https://user:password@host). ftp/ftps added — file-drop
|
|
@@ -286,7 +317,7 @@ export const SECRET_PATTERNS = [
|
|
|
286
317
|
// these slip through. Match the value-quoted form explicitly. Length floor
|
|
287
318
|
// (6) avoids tripping on intentional placeholder shorts ("...", "secret").
|
|
288
319
|
[
|
|
289
|
-
/("(?: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
|
|
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,
|
|
290
321
|
'$1***$2',
|
|
291
322
|
],
|
|
292
323
|
// JSON keys with vendor PREFIX/SUFFIX around the core credential noun —
|
|
@@ -299,7 +330,7 @@ export const SECRET_PATTERNS = [
|
|
|
299
330
|
// one quote, `\w*` ran to the end of a word run and backtracked through every keyword in it,
|
|
300
331
|
// each rescanning the run — `"` + `secret` x 33k took 4.6 s. 64 is far past any key name.
|
|
301
332
|
[
|
|
302
|
-
/("\w{0,64}(?:password|passwd|secret|api[_-]?key|auth[_-]?token|access[_-]?token|private[_-]?key)\w{0,64}"\s
|
|
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,
|
|
303
334
|
'$1***$2',
|
|
304
335
|
],
|
|
305
336
|
// Quoted-KEY credential values — Python dict reprs `{'api_key': '...'}`, single-quoted
|
|
@@ -315,7 +346,7 @@ export const SECRET_PATTERNS = [
|
|
|
315
346
|
// `'token_count': 123456`); `passphrase` added here too (double-quoted JSON passphrase is
|
|
316
347
|
// subsumed by this pattern since `['"]` matches `"`). Over-scrub is the safe direction.
|
|
317
348
|
[
|
|
318
|
-
/(['"](?:\w{0,64}(?:password|passwd|passphrase|secret|api[_-]?key|auth[_-]?token|access[_-]?token|private[_-]?key)\w{0,64}|\w{1,64}_token)['"]\s
|
|
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,
|
|
319
350
|
'$1$2***$2',
|
|
320
351
|
],
|
|
321
352
|
// Session cookies in headers / urlencoded bodies (sessionid=, session_id=, JSESSIONID=, PHPSESSID=).
|