Skip to content

Commit 5928089

Browse files
author
SqlRush
committed
Classify PowerShell shutdown commands
1 parent 4a8b874 commit 5928089

4 files changed

Lines changed: 8 additions & 1 deletion

File tree

docs/cc-100-roadmap.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ M5 补充:PowerShell command canonicalization 现在补齐 mutating ItemProper
185185

186186
M5 补充:PowerShell command canonicalization 现在补齐 mutating service aliases:`sasv`/`spsv`/`rsv`/`ssv` 会分别归入 `Start/Stop/Restart/Set-Service` destructive 分类,避免服务状态或配置变更 alias 被当成未知普通命令。
187187

188+
M5 补充:PowerShell destructive classifier 现在明确覆盖 `Stop-Computer``Suspend-Computer` 和 native `shutdown(.exe)`,这类关机/休眠路径不再落入未知普通命令分类。
189+
188190
M5 补充:WebFetch HTML-to-text rendering 现在会跳过 `hidden``aria-hidden="true"`、CSS `display:none`/`visibility:hidden` 的不可见元素子树,隐藏文本和图片说明不会进入 rendered body 或 prompt-focused excerpt。
189191

190192
M5 补充:WebFetch HTML-to-text rendering 现在会为无可见文本但带 `aria-label`/`title` 的链接保留可访问名称和 resolved href,icon-only 链接可进入 rendered body 与 prompt-focused excerpt。

docs/claude-code-go-rewrite-plan.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ test/parity/ # golden tests against TS/official behavior
254254
- 本轮补充:PowerShell native read-only classifier 收紧 `/FO` 输出格式参数,`systeminfo`/`tasklist`/`whoami`/`getmac` 只接受 `CSV`/`LIST`/`TABLE` literal 值,无效格式和动态值不再进入只读 fast path。
255255
- 本轮补充:PowerShell command canonicalization 现在补齐 mutating ItemProperty aliases:`sp`/`np`/`clp`/`cpp`/`mp`/`rp`/`rnp` 会分别归入 `Set/New/Clear/Copy/Move/Remove/Rename-ItemProperty` destructive 分类,避免属性变更 alias 被当成未知普通命令。
256256
- 本轮补充:PowerShell command canonicalization 现在补齐 mutating service aliases:`sasv`/`spsv`/`rsv`/`ssv` 会分别归入 `Start/Stop/Restart/Set-Service` destructive 分类,避免服务状态或配置变更 alias 被当成未知普通命令。
257+
- 本轮补充:PowerShell destructive classifier 现在明确覆盖 `Stop-Computer``Suspend-Computer` 和 native `shutdown(.exe)`,这类关机/休眠路径不再落入未知普通命令分类。
257258
- 本轮补充:`BashOutput` 现在设置 100k 最大结果大小,和前台 `Bash` 一起覆盖大输出 tool-result preview 截断、完整输出落盘及 `full_output_path` 元数据。
258259
- 本轮补充:Bash/PowerShell 后台命令现在会通过 tool progress 通道发 started/finished 事件,记录后台 ID、shell/status、exit/timed_out/cancelled、duration、时间戳和 stdout/stderr byte count,且 completed、timed_out、cancelled 终态测试确保 progress 不携带 command 文本。
259260
- 本轮补充:WebSearch domain filters 现在在 schema 层声明 array `items:string`,通用 tool schema validator 同步支持 `items` 校验;`allowed_domains`/`blocked_domains` 会拒绝空字符串、URL/port、非法 wildcard 和非域名 label。

internal/tools/powershell/tools.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2146,7 +2146,7 @@ func destructiveWords(words []string) bool {
21462146
switch command {
21472147
case "git":
21482148
return bashtools.IsDestructiveCommand(powerShellGitCommand(words))
2149-
case "remove-item", "set-content", "add-content", "clear-content", "clear-item", "clear-itemproperty", "out-file", "new-item", "move-item", "move-itemproperty", "copy-item", "copy-itemproperty", "rename-item", "rename-itemproperty", "set-item", "set-itemproperty", "stop-process", "start-service", "stop-service", "restart-service", "set-service", "restart-computer", "invoke-expression", "iex", "start-process", "start-transcript", "stop-transcript":
2149+
case "remove-item", "set-content", "add-content", "clear-content", "clear-item", "clear-itemproperty", "out-file", "new-item", "move-item", "move-itemproperty", "copy-item", "copy-itemproperty", "rename-item", "rename-itemproperty", "set-item", "set-itemproperty", "stop-process", "start-service", "stop-service", "restart-service", "set-service", "restart-computer", "stop-computer", "suspend-computer", "shutdown", "invoke-expression", "iex", "start-process", "start-transcript", "stop-transcript":
21502150
return true
21512151
default:
21522152
return strings.HasPrefix(command, "remove-") || strings.HasPrefix(command, "set-") || strings.HasPrefix(command, "new-") || strings.HasPrefix(command, "export-")

internal/tools/powershell/tools_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,10 @@ func TestPowerShellCommandClassification(t *testing.T) {
579579
"rsv -Name spooler",
580580
"Set-Service -Name spooler -StartupType Disabled",
581581
"ssv -Name spooler -StartupType Disabled",
582+
"Restart-Computer -Force",
583+
"Stop-Computer -Force",
584+
"Suspend-Computer",
585+
"shutdown.exe /s /t 0",
582586
"start calc.exe",
583587
"saps calc.exe",
584588
"Invoke-Expression $x",

0 commit comments

Comments
 (0)