dsh-rule-engine 0.4.1 → 0.4.3
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.
|
@@ -73,7 +73,9 @@ export function operationOf(toolName, args) {
|
|
|
73
73
|
const cp = extractCopyPaths(text);
|
|
74
74
|
if (cp && cp.source) pathPrefixes.push(normalizePath(cp.source));
|
|
75
75
|
pathPrefixes = [...new Set(pathPrefixes.filter(Boolean))];
|
|
76
|
-
|
|
76
|
+
// P0-1d:主写目标优先取真实写参数(Copy-Item 的 Destination 等),
|
|
77
|
+
// 避免"源路径比目标长"时最长路径误选源(13A 误拦);授权匹配仍走多候选 pathPrefixes
|
|
78
|
+
pathPrefix = writeTargets[0] || pathPrefixes.sort((a, b) => b.length - a.length)[0] || inferPathPrefixFromText(text);
|
|
77
79
|
} else if (name === "skill") {
|
|
78
80
|
type = "skill";
|
|
79
81
|
pathPrefix = "";
|
package/lib/core/patterns.js
CHANGED
|
@@ -18,6 +18,10 @@ export const SENSITIVE_CMD =
|
|
|
18
18
|
export const CONFIG_FILE_RE =
|
|
19
19
|
/(?:^|[\\/])(?:AGENTS\.md|settings\.yaml|\.credentials\.yaml|workspace\.json|cordis\.patch\.yml|rule-understanding\.json|rule-guard\.json|rule-engine\.json)$/i;
|
|
20
20
|
|
|
21
|
+
/** 受保护文件名(命令文本中出现即需警惕;P0-1c 起仅在写类命令中生效) */
|
|
22
|
+
export const PROTECTED_FILENAME_RE =
|
|
23
|
+
/(?:AGENTS\.md|settings\.yaml|\.credentials\.yaml|workspace\.json|cordis\.patch\.yml|rule-understanding\.json|rule-engine\.json)/i;
|
|
24
|
+
|
|
21
25
|
export const DATA_DIR_RE =
|
|
22
26
|
/(?:^|[\\/])\.dsh[\\/](?:sessions|storages|\.backups)[\\/]/i;
|
|
23
27
|
|
|
@@ -373,7 +377,10 @@ export function isSensitiveToolCall(toolName, args) {
|
|
|
373
377
|
if (name === "edit" || name === "write" || name === "pwsh" || name === "bash") return true;
|
|
374
378
|
}
|
|
375
379
|
if (name === "pwsh" || name === "bash") {
|
|
376
|
-
|
|
380
|
+
// P0-1c:受保护文件名检查必须配合「写类命令」——纯描述性文本(如 gh release --notes 里的
|
|
381
|
+
// "AGENTS.md" 字样、echo 输出内容)不再触发敏感判定;真写类命令(Set-Content/Remove-Item 等
|
|
382
|
+
// 命中 MUTATING_CMD_RE)提到受保护文件仍判敏感。
|
|
383
|
+
if (cmd && (SENSITIVE_CMD.test(cmd) || (MUTATING_CMD_RE.test(cmd) && PROTECTED_FILENAME_RE.test(cmd)) || commandHasOutsideWrite(cmd))) return true;
|
|
377
384
|
}
|
|
378
385
|
if (name === "edit" || name === "write") {
|
|
379
386
|
if (p && (isProtectedConfigPath(p) || isOutsideWorkspace(p))) return true;
|