dsh-perm-gate 5.4.4 → 5.5.0
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 +6 -0
- package/README.ja.md +1 -1
- package/README.ko.md +1 -1
- package/README.md +1 -1
- package/README.zh.md +1 -1
- package/dsh.plugin.json +2 -2
- package/lib/client.js +26 -1
- package/lib/client.js.map +1 -1
- package/lib/engine.d.ts +1 -1
- package/lib/engine.js +4 -4
- package/lib/rule.js +12 -0
- package/lib/tool-names.d.ts +6 -0
- package/lib/tool-names.js +7 -1
- package/package.json +7 -7
package/lib/engine.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Decision, type ToolCallContext } from './evaluate.js';
|
|
2
2
|
export type EngineStage = 'hard-deny' | 'grant' | 'rule' | 'default' | 'ask' | 'classifier';
|
|
3
|
-
/** The built-in read-only / internal classification, for diagnostics and docs. */
|
|
3
|
+
/** The built-in read-only / path-aware-allow / internal classification, for diagnostics and docs. */
|
|
4
4
|
export declare const AUTO_ALLOW_TOOLS: ReadonlySet<string>;
|
|
5
5
|
/**
|
|
6
6
|
* The document-body keys the screens skip live in `scan-text.ts`, shared with the
|
package/lib/engine.js
CHANGED
|
@@ -15,15 +15,15 @@ import { executableVariants, normalizeCommandText } from './command-normalize.js
|
|
|
15
15
|
// 工具名名单归 `tool-names.ts` 所有(不得在此处再抄一份)。P0 **不看工具名白名单**:
|
|
16
16
|
// 它看 `executableCommandOf`——已知非执行器(read/write/内部工具)的 `command` 参数是数据,
|
|
17
17
|
// 其余任何带命令串的调用都按命令对待,所以工具叫什么(包括模型打错的 `pash`)都不是绕过面。
|
|
18
|
-
import { INTERNAL_TOOLS, READ_TOOLS, executableCommandOf } from './tool-names.js';
|
|
18
|
+
import { INTERNAL_TOOLS, PATH_AWARE_AUTO_ALLOW, READ_TOOLS, executableCommandOf } from './tool-names.js';
|
|
19
19
|
import { familyOfPath } from './cred-families.js';
|
|
20
20
|
import { decomposeShellCommand } from './shell.js';
|
|
21
21
|
import { dispatchCommand } from './command-dispatcher.js';
|
|
22
22
|
const DESTRUCTIVE_TOOL = /(?:^|[_-])(?:delete|remove|rm|destroy|erase|purge|wipe|unlink|rmdir|reset)(?:$|[_-]|recursive)/i;
|
|
23
23
|
/** No user-configured extra auto-allow names. */
|
|
24
24
|
const NO_EXTRA_AUTO_ALLOW = new Set();
|
|
25
|
-
/** The built-in read-only / internal classification, for diagnostics and docs. */
|
|
26
|
-
export const AUTO_ALLOW_TOOLS = new Set([...READ_TOOLS, ...INTERNAL_TOOLS]);
|
|
25
|
+
/** The built-in read-only / path-aware-allow / internal classification, for diagnostics and docs. */
|
|
26
|
+
export const AUTO_ALLOW_TOOLS = new Set([...READ_TOOLS, ...PATH_AWARE_AUTO_ALLOW, ...INTERNAL_TOOLS]);
|
|
27
27
|
/**
|
|
28
28
|
* The document-body keys the screens skip live in `scan-text.ts`, shared with the
|
|
29
29
|
* deny-keyword layer so the two cannot drift. Re-exported here because this was their
|
|
@@ -262,7 +262,7 @@ autoAllowExtra = NO_EXTRA_AUTO_ALLOW) {
|
|
|
262
262
|
// A miss still auto-allows silently, so the popup budget is unchanged. INTERNAL
|
|
263
263
|
// tools are deliberately NOT pre-queried: session/memory tools reading their own
|
|
264
264
|
// stores is how the host works; a path rule blocking them would be host self-harm.
|
|
265
|
-
if (READ_TOOLS.has(ctx.tool) || autoAllowExtra.has(ctx.tool)) {
|
|
265
|
+
if (READ_TOOLS.has(ctx.tool) || PATH_AWARE_AUTO_ALLOW.has(ctx.tool) || autoAllowExtra.has(ctx.tool)) {
|
|
266
266
|
const pre = ruleset.decide(ctx);
|
|
267
267
|
if (pre.ruleIndex !== undefined) {
|
|
268
268
|
if (pre.action === 'deny')
|
package/lib/rule.js
CHANGED
|
@@ -234,6 +234,8 @@ export function compileRulesObject(root, opts = {}) {
|
|
|
234
234
|
export function documentHash(text) {
|
|
235
235
|
return hashText(text);
|
|
236
236
|
}
|
|
237
|
+
// Codex patch path markers: lines like `*** Update File: path` inside `input`.
|
|
238
|
+
const CODEX_PATCH_PATH_RE = /^\*{3}\s+(?:(?:Add|Update|Delete)\s+File|Move\s+to):\s*(.+)$/gim;
|
|
237
239
|
// Candidate extraction (shared by evaluate + path rules).
|
|
238
240
|
export function extractPathCandidates(args) {
|
|
239
241
|
const out = [];
|
|
@@ -256,6 +258,16 @@ export function extractPathCandidates(args) {
|
|
|
256
258
|
if (typeof e === 'string')
|
|
257
259
|
out.push(e);
|
|
258
260
|
}
|
|
261
|
+
// Codex-style apply_patch embeds target paths in the `input` text body.
|
|
262
|
+
if (k === 'input' && typeof v === 'string' && v.includes('***')) {
|
|
263
|
+
CODEX_PATCH_PATH_RE.lastIndex = 0;
|
|
264
|
+
let m;
|
|
265
|
+
while ((m = CODEX_PATCH_PATH_RE.exec(v)) !== null) {
|
|
266
|
+
const p = m[1].trim();
|
|
267
|
+
if (p)
|
|
268
|
+
out.push(p);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
259
271
|
walk(v, depth + 1);
|
|
260
272
|
}
|
|
261
273
|
};
|
package/lib/tool-names.d.ts
CHANGED
|
@@ -15,6 +15,12 @@
|
|
|
15
15
|
export declare const SHELL_TOOLS: Set<string>;
|
|
16
16
|
/** File mutation tools: they write paths, they do not execute their arguments. */
|
|
17
17
|
export declare const WRITE_TOOLS: Set<string>;
|
|
18
|
+
/**
|
|
19
|
+
* Mutation tools that auto-allow (like READ_TOOLS) but still consult path rules.
|
|
20
|
+
* P0 hard-deny and credentialPaths still fire; only the human/model ask is skipped.
|
|
21
|
+
* Introduced for `apply_patch` (DSH 0.2.2 host built-in tool).
|
|
22
|
+
*/
|
|
23
|
+
export declare const PATH_AWARE_AUTO_ALLOW: ReadonlySet<string>;
|
|
18
24
|
/**
|
|
19
25
|
* Read-only tools that can never modify the workspace or execute anything. P0
|
|
20
26
|
* still protects sensitive path reads outside the workspace root, and the
|
package/lib/tool-names.js
CHANGED
|
@@ -14,7 +14,13 @@
|
|
|
14
14
|
/** Names the harness uses for "run this shell command". */
|
|
15
15
|
export const SHELL_TOOLS = new Set(['shell', 'terminal', 'bash', 'pwsh', 'sh', 'cmd', 'powershell']);
|
|
16
16
|
/** File mutation tools: they write paths, they do not execute their arguments. */
|
|
17
|
-
export const WRITE_TOOLS = new Set(['write', 'edit']);
|
|
17
|
+
export const WRITE_TOOLS = new Set(['write', 'edit', 'apply_patch']);
|
|
18
|
+
/**
|
|
19
|
+
* Mutation tools that auto-allow (like READ_TOOLS) but still consult path rules.
|
|
20
|
+
* P0 hard-deny and credentialPaths still fire; only the human/model ask is skipped.
|
|
21
|
+
* Introduced for `apply_patch` (DSH 0.2.2 host built-in tool).
|
|
22
|
+
*/
|
|
23
|
+
export const PATH_AWARE_AUTO_ALLOW = new Set(['apply_patch']);
|
|
18
24
|
/**
|
|
19
25
|
* Read-only tools that can never modify the workspace or execute anything. P0
|
|
20
26
|
* still protects sensitive path reads outside the workspace root, and the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-perm-gate",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.5.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org",
|
|
6
6
|
"tag": "latest"
|
|
@@ -69,15 +69,15 @@
|
|
|
69
69
|
},
|
|
70
70
|
"engines": {
|
|
71
71
|
"node": ">=24",
|
|
72
|
-
"dsh": "0.1.0-rc.2 || 0.1.0-rc.3 || 0.1.0-rc.6 || 0.1.0-rc.7 || 0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5"
|
|
72
|
+
"dsh": "0.1.0-rc.2 || 0.1.0-rc.3 || 0.1.0-rc.6 || 0.1.0-rc.7 || 0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5 || 0.2.2-rc.1"
|
|
73
73
|
},
|
|
74
74
|
"peerDependencies": {
|
|
75
75
|
"@deepseek-ai/cordis": "^4.0.1",
|
|
76
|
-
"@deepseek-ai/dsh-client-locale": "0.1.0-rc.2 || 0.1.0-rc.3 || 0.1.0-rc.6 || 0.1.0-rc.7 || 0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5",
|
|
77
|
-
"@deepseek-ai/dsh-client-ui-renderer": "0.1.0-rc.2 || 0.1.0-rc.3 || 0.1.0-rc.6 || 0.1.0-rc.7 || 0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5",
|
|
78
|
-
"@deepseek-ai/dsh-client-ui-settings": "0.1.0-rc.2 || 0.1.0-rc.3 || 0.1.0-rc.6 || 0.1.0-rc.7 || 0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5",
|
|
79
|
-
"@deepseek-ai/dsh-settings": "0.1.0-rc.2 || 0.1.0-rc.3 || 0.1.0-rc.6 || 0.1.0-rc.7 || 0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5",
|
|
80
|
-
"@deepseek-ai/dsh-client-ui-conversation": "0.1.0-rc.2 || 0.1.0-rc.3 || 0.1.0-rc.6 || 0.1.0-rc.7 || 0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5"
|
|
76
|
+
"@deepseek-ai/dsh-client-locale": "0.1.0-rc.2 || 0.1.0-rc.3 || 0.1.0-rc.6 || 0.1.0-rc.7 || 0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5 || 0.2.2-rc.1",
|
|
77
|
+
"@deepseek-ai/dsh-client-ui-renderer": "0.1.0-rc.2 || 0.1.0-rc.3 || 0.1.0-rc.6 || 0.1.0-rc.7 || 0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5 || 0.2.2-rc.1",
|
|
78
|
+
"@deepseek-ai/dsh-client-ui-settings": "0.1.0-rc.2 || 0.1.0-rc.3 || 0.1.0-rc.6 || 0.1.0-rc.7 || 0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5 || 0.2.2-rc.1",
|
|
79
|
+
"@deepseek-ai/dsh-settings": "0.1.0-rc.2 || 0.1.0-rc.3 || 0.1.0-rc.6 || 0.1.0-rc.7 || 0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5 || 0.2.2-rc.1",
|
|
80
|
+
"@deepseek-ai/dsh-client-ui-conversation": "0.1.0-rc.2 || 0.1.0-rc.3 || 0.1.0-rc.6 || 0.1.0-rc.7 || 0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5 || 0.2.2-rc.1"
|
|
81
81
|
},
|
|
82
82
|
"dependencies": {
|
|
83
83
|
"@deepseek-ai/schemastery": "^3.18.4",
|