Feature(mcp): allow sc qc/enumdepend/sdshow in default command whitelist

exec_command's read-only default whitelist only listed `sc query`, so service
configuration inspection was rejected even though `sc qc` is a read. Add
`sc qc`, `sc enumdepend` and `sc sdshow`; `sc start/stop/config/create/delete`
stay rejected because matching is prefix based, and a comment says so.

verify_tools.py --live now prints the tools/list response size plus the
description / inputSchema / outputSchema breakdown, so shrinking tools/list can
be measured against a running server.

Verified on an isolated Debug instance (port 6555, local test client): sc
qc/enumdepend/sdshow/query succeed; powershell, icacls, net user, net
localgroup, sc start and `&` chaining still return -32007/-32012; tools.json
still matches the live tools/list (63 tools, PASS).

Co-Authored-By: deepseek-flash
This commit is contained in:
yuanyuanxianganddeepseek-flash committed 2026-11-12 15:41:23 +01:00
1 parent f5ac7ba45f
commit b63c97c5eb
2 files changed
+21 -3

No files matched your search

+2 -1
View File
@@ -3814,9 +3814,10 @@ std::string BuildListRegistry(const Json::Value& id, const Json::Value& args, CM
// exec_command 默认白名单:只读命令前缀(逗号分隔,前缀匹配,大小写不敏感)。
// 只放查询/只读类命令;写命令(del/copy/move/reg add/sc stop/...)一律不在列。
// sc 只放查询类子命令(qc/enumdepend/sdshow);sc start/stop/config/create/delete 都是写。
static const char* kDefaultCmdWhitelist =
"dir,type,cd,chdir,ver,hostname,whoami,where,tasklist,systeminfo,ipconfig,netstat,"
"path,set,find,findstr,reg query,sc query,"
"path,set,find,findstr,reg query,sc query,sc qc,sc enumdepend,sc sdshow,"
"ping,tracert,nslookup,getmac,driverquery,query,gpresult,"
"arp -a,route print,schtasks /query";