chore: 移除不存在的 etcdutl 命令及其相关逻辑和测试
This commit is contained in:
+1
-20
@@ -137,7 +137,7 @@ SHELL_READ_ONLY_COMMANDS: dict[str, set[str] | None] = {
|
||||
"lspci": None, "lsusb": None, "dmidecode": None, "sysctl": None, "udevadm": None,
|
||||
}
|
||||
|
||||
# etcdctl / etcdutl 由 classify_shell_command 中的专用块处理 (两段式命令)
|
||||
# etcdctl 由 classify_shell_command 中的专用块处理 (两段式命令)
|
||||
# 从通用白名单中移除,避免被单段式逻辑误判
|
||||
|
||||
# etcdctl 单段式只读 verb
|
||||
@@ -162,11 +162,6 @@ _ETCDCTL_WRITE_SUBVERBS = {
|
||||
"user": {"add", "delete", "grant-role", "revoke-role", "passwd"},
|
||||
"role": {"add", "delete", "grant-permission", "revoke-permission"},
|
||||
}
|
||||
# etcdutl snapshot 只读子命令
|
||||
_ETCDUTL_SNAPSHOT_READ = {"status", "hash"}
|
||||
# etcdutl snapshot 写子命令 (需人工审批)
|
||||
_ETCDUTL_SNAPSHOT_WRITE = {"restore", "make"}
|
||||
|
||||
# 系统修改命令白名单:需要人工审批
|
||||
SHELL_WRITE_COMMANDS: dict[str, set[str] | None] = {
|
||||
"systemctl": {"restart", "start", "stop", "reload", "enable", "disable", "daemon-reload"},
|
||||
@@ -238,20 +233,6 @@ def classify_shell_command(command: str) -> CommandDecision:
|
||||
raise ValueError(f"etcdctl {ev} 不支持子命令: {esub}")
|
||||
raise ValueError(f"etcdctl 不支持该子命令: {ev}")
|
||||
|
||||
if binary == "etcdutl":
|
||||
non_flags = [a for a in parts[1:] if not a.startswith("-")]
|
||||
ev = non_flags[0].lower() if non_flags else None
|
||||
esub = non_flags[1].lower() if len(non_flags) > 1 else None
|
||||
if ev == "snapshot":
|
||||
if esub in _ETCDUTL_SNAPSHOT_READ:
|
||||
return CommandDecision("read", False, ev, parts[1:])
|
||||
if esub in _ETCDUTL_SNAPSHOT_WRITE:
|
||||
return CommandDecision("write", True, ev, parts[1:])
|
||||
raise ValueError(f"etcdutl snapshot 不支持子命令: {esub}")
|
||||
if ev == "version":
|
||||
return CommandDecision("read", False, ev, parts[1:])
|
||||
raise ValueError(f"etcdutl 不支持该子命令: {ev}")
|
||||
|
||||
if binary in SHELL_READ_ONLY_COMMANDS:
|
||||
allowed = SHELL_READ_ONLY_COMMANDS[binary]
|
||||
if allowed is not None and (verb is None or verb not in allowed):
|
||||
|
||||
Reference in New Issue
Block a user