@netcatty/dsh-guard 0.2.0 → 0.2.2
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/CHANGELOG.md +19 -0
- package/README.md +7 -5
- package/lib/index.js +13 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.2
|
|
4
|
+
|
|
5
|
+
### 修复
|
|
6
|
+
|
|
7
|
+
- 脱敏漏掉 JSON 形态的复合键名:`"OXIDETERM_MCP_TOKEN": "..."`、`"sessionToken": "..."` 这类键名前/后缀带词的凭据值会原样落盘,只有精确等于 `token`/`secret`/`password` 等白名单键名的才被遮。规则改为键名任意位置命中 `token|api_key|apikey|secret|password|passwd|authorization|private_key|access_key` 即脱敏,与 `KEY=value` 那条口径对齐。
|
|
8
|
+
|
|
9
|
+
## 0.2.1
|
|
10
|
+
|
|
11
|
+
Windows 实机验证后的一轮修复。
|
|
12
|
+
|
|
13
|
+
### 修复
|
|
14
|
+
|
|
15
|
+
- `expand` 不识别 `~\` 前缀,`~\Documents` 被当成相对路径拼到 cwd 下,路径规则漏判。
|
|
16
|
+
- `~\` 展开后未归一化分隔符,POSIX 上会得到 `/home/u/\secret` 这种带反斜杠的路径,`~/secret*` 规则照样匹配不上。
|
|
17
|
+
|
|
18
|
+
### 变更
|
|
19
|
+
|
|
20
|
+
- README 的 Windows 章节从「待实机验证」改为已验证:安装、`node --test`、`%USERPROFILE%` 展开、盘符相对路径、PowerShell 引号处理。
|
|
21
|
+
|
|
3
22
|
## 0.2.0
|
|
4
23
|
|
|
5
24
|
首个功能完整的版本。0.1.0 只有 `path` / `bash` 两个规则面和基础审批,此后每一轮都在补面。
|
package/README.md
CHANGED
|
@@ -443,10 +443,10 @@ write-direction path surface, so `echo x > secret.env` is denied by path rules.
|
|
|
443
443
|
an escape character.
|
|
444
444
|
- Tool basenames are split on both `/` and `\`.
|
|
445
445
|
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
446
|
+
Verified on a real Windows machine: install, `node --test`, `%USERPROFILE%`
|
|
447
|
+
expansion (both `~/` and `~\`), drive-relative paths, and PowerShell quoting.
|
|
448
|
+
Separators and drive letters are normalized before matching; matching is
|
|
449
|
+
case-insensitive on win32 by default.
|
|
450
450
|
|
|
451
451
|
## Settings page
|
|
452
452
|
|
|
@@ -540,7 +540,9 @@ Client treats `/name args` as ordinary chat — the reason all three ship an
|
|
|
540
540
|
`tools/post-execute` replaces credential-shaped text in every tool result before
|
|
541
541
|
it is persisted: `sk-*`/`rk-*`/`pk-*` keys, GitHub tokens (`ghp_`, `gho_`,
|
|
542
542
|
`github_pat_`), Slack tokens, AWS access keys, Google API keys, JWTs, `Bearer`
|
|
543
|
-
tokens, PEM private-key blocks,
|
|
543
|
+
tokens, PEM private-key blocks, `SECRET|TOKEN|PASSWORD|API_KEY=...` values, and
|
|
544
|
+
JSON string fields whose key name contains `TOKEN` / `SECRET` / `PASSWORD` /
|
|
545
|
+
`API_KEY` / `AUTHORIZATION` anywhere (`"OXIDETERM_MCP_TOKEN": "..."` included).
|
|
544
546
|
Only text blocks change; images and structured blocks pass through. Set
|
|
545
547
|
`redact: false` to disable.
|
|
546
548
|
|
package/lib/index.js
CHANGED
|
@@ -133,7 +133,15 @@ const REDACTIONS = [
|
|
|
133
133
|
[/\bBearer\s+[A-Za-z0-9._~+/-]{8,}=*/gi, 'Bearer ***'],
|
|
134
134
|
[/([A-Z0-9_]*(?:SECRET|TOKEN|PASSWORD|PASSWD|API_KEY|PRIVATE_KEY|ACCESS_KEY)[A-Z0-9_]*\s*=\s*)(?:"[^"]{6,}"|'[^']{6,}'|[^\s"']{6,})/g, '$1***'],
|
|
135
135
|
[/([?&](?:token|access_token|api_key|apikey|key|secret|password)=)[^&\s"']+/gi, '$1***'],
|
|
136
|
-
|
|
136
|
+
// JSON string values whose key mentions a credential, anywhere in the name
|
|
137
|
+
// (`OXIDETERM_MCP_TOKEN`, `settings.token`, `x-api-key`). The character class
|
|
138
|
+
// covers the separators JSON keys actually use, and the keyword list carries
|
|
139
|
+
// the hyphenated spellings so `x-api-key` does not slip through.
|
|
140
|
+
[/"([A-Za-z0-9_.-]*(?:token|api_key|apikey|api-key|secret|password|passwd|authorization|private_key|private-key|access_key|access-key)[A-Za-z0-9_.-]*)"\s*:\s*"[^"]{4,}"/gi, '"$1":"***"'],
|
|
141
|
+
// The same shape after the quotes were escaped, which is how JSON shows up
|
|
142
|
+
// inside a shell command: `echo "{\"token\":\"secret\"}"`. Escapes are kept so
|
|
143
|
+
// the surrounding text stays parseable after masking.
|
|
144
|
+
[/\\"([A-Za-z0-9_.-]*(?:token|api_key|apikey|api-key|secret|password|passwd|authorization|private_key|private-key|access_key|access-key)[A-Za-z0-9_.-]*)\\"\s*:\s*\\"(?![*]{3}\\")[^"\\]{4,}\\"/gi, '\\"$1\\":\\"***\\"'],
|
|
137
145
|
[/^\s*(set-)?cookie\s*:\s*.*$/gim, 'Cookie: ***'],
|
|
138
146
|
];
|
|
139
147
|
|
|
@@ -175,6 +183,10 @@ function matchParam(pattern, value, permission) {
|
|
|
175
183
|
export function expand(p, cwd) {
|
|
176
184
|
if (typeof p !== 'string' || p === '') return undefined;
|
|
177
185
|
if (p === '~') return homedir();
|
|
186
|
+
// `~\x` is how Windows users write the home prefix. Normalising the tail
|
|
187
|
+
// matters on POSIX too: `resolve` keeps a backslash as part of the file name,
|
|
188
|
+
// so `/home/u/\secret` would never match a `~/secret*` rule.
|
|
189
|
+
if (p.startsWith('~\\')) return resolve(homedir(), toPosix(p.slice(2)));
|
|
178
190
|
if (p.startsWith('~/')) return resolve(homedir(), p.slice(2));
|
|
179
191
|
return isAbsolute(p) ? resolve(p) : resolve(cwd, p);
|
|
180
192
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netcatty/dsh-guard",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "allow/ask/deny permission gates for DeepSeek Harness tools: path/params/agents surfaces, argv decomposition, network rules, redaction, grants, dry-run, fail-closed config",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|