Skip to content

Commit fc434ce

Browse files
author
SqlRush
committed
Guard PowerShell native flag groups
1 parent 0f0d72b commit fc434ce

4 files changed

Lines changed: 7 additions & 1 deletion

File tree

docs/cc-100-roadmap.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,8 @@ M5 补充:PowerShell native read-only classifier 收紧 `ver`,裸命令仍
269269

270270
M5 补充:PowerShell native read-only classifier 补齐 `netstat -p <protocol>` 只读协议查询形态,协议值走 literal guard,缺值和动态表达式值仍拒绝。
271271

272+
M5 补充:PowerShell native read-only classifier 收紧短 flag 合并校验,`netstat -ano` 这类纯开关组合仍允许,但包含 value/path flag 的组合(如 `-anop`)不再绕过缺值校验。
273+
272274
M5 补充:Bash 前台输出和 `BashOutput` 现在都走统一 tool-result budget 截断/落盘路径;`BashOutput` 增加 100k 最大结果限制,大后台输出会保存完整内容并返回 `full_output_path` 元数据。
273275

274276
M5 补充:Bash/PowerShell 后台任务现在会发 `*_background_started``*_background_finished` tool progress 事件,包含后台 ID、shell/status、exit/timed_out/cancelled、duration、时间戳和输出字节数,不携带 command 文本;completed、timed_out、cancelled 终态均已覆盖测试。

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ test/parity/ # golden tests against TS/official behavior
245245
- 本轮补充:PowerShell read-only classifier 收紧 `Get-WinEvent`,普通查询参数拒绝 `$env:`/hashtable 等动态表达式,`-FilterXPath` 走单独 XPath literal guard,允许 `[]`/`@Name` 语法但拒绝 PowerShell 动态表达式形态。
246246
- 本轮补充:PowerShell native read-only classifier 收紧 `ver`,裸命令仍按只读处理,但不再接受任意 flag 或位置参数。
247247
- 本轮补充:PowerShell native read-only classifier 补齐 `netstat -p <protocol>` 只读协议查询形态,协议值走 literal guard,缺值和动态表达式值仍拒绝。
248+
- 本轮补充:PowerShell native read-only classifier 收紧短 flag 合并校验,`netstat -ano` 这类纯开关组合仍允许,但包含 value/path flag 的组合(如 `-anop`)不再绕过缺值校验。
248249
- 本轮补充:`BashOutput` 现在设置 100k 最大结果大小,和前台 `Bash` 一起覆盖大输出 tool-result preview 截断、完整输出落盘及 `full_output_path` 元数据。
249250
- 本轮补充:Bash/PowerShell 后台命令现在会通过 tool progress 通道发 started/finished 事件,记录后台 ID、shell/status、exit/timed_out/cancelled、duration、时间戳和 stdout/stderr byte count,且 completed、timed_out、cancelled 终态测试确保 progress 不携带 command 文本。
250251
- 本轮补充: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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1881,7 +1881,8 @@ func nativeFlagAllowed(name string, config powerShellNativeReadOnlyConfig) bool
18811881
return false
18821882
}
18831883
for _, r := range name[1:] {
1884-
if !config.allowedFlags["-"+string(r)] {
1884+
short := "-" + string(r)
1885+
if !config.allowedFlags[short] || config.valueFlags[short] || config.pathFlags[short] || config.pathListFlags[short] || config.literalValueFlags[short] {
18851886
return false
18861887
}
18871888
}

internal/tools/powershell/tools_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,8 @@ func TestPowerShellCommandClassification(t *testing.T) {
442442
"ver anything",
443443
"route add 10.0.0.0 mask 255.0.0.0 192.168.1.1 print",
444444
"netsh interface ipv4 show addresses",
445+
"netstat -anop",
446+
"netstat -anop tcp",
445447
"netstat -p $env:PROTO",
446448
"netstat -p @{N='tcp'}",
447449
"netstat -p",

0 commit comments

Comments
 (0)