fh_tool-cli 0.2.0__tar.gz → 0.2.1__tar.gz

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.
Files changed (53) hide show
  1. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/PKG-INFO +36 -38
  2. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/README.md +35 -37
  3. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/pyproject.toml +1 -1
  4. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/src/fh_tool_cli/__init__.py +1 -1
  5. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/src/fh_tool_cli/backup.py +1 -1
  6. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/src/fh_tool_cli/cli.py +271 -81
  7. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/src/fh_tool_cli/commands/web.py +28 -54
  8. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/src/fh_tool_cli/parser.py +74 -62
  9. fh_tool_cli-0.2.1/src/fh_tool_cli/risk.py +45 -0
  10. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/src/fh_tool_cli/upload.py +1 -1
  11. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/src/fh_tool_cli.egg-info/PKG-INFO +36 -38
  12. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/tests/test_cli_risk.py +52 -50
  13. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/tests/test_config_decrypt.py +7 -0
  14. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/tests/test_extracted_helpers.py +14 -29
  15. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/tests/test_parser_registration.py +15 -17
  16. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/tests/test_web_ajax_post.py +10 -27
  17. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/tests/test_web_write_payloads.py +3 -4
  18. fh_tool_cli-0.2.0/src/fh_tool_cli/risk.py +0 -24
  19. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/setup.cfg +0 -0
  20. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/src/fh_tool_cli/account.py +0 -0
  21. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/src/fh_tool_cli/argparse_utils.py +0 -0
  22. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/src/fh_tool_cli/backends/__init__.py +0 -0
  23. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/src/fh_tool_cli/backends/cfg_cmd.py +0 -0
  24. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/src/fh_tool_cli/backends/fh_tool.py +0 -0
  25. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/src/fh_tool_cli/backends/local_vm.py +0 -0
  26. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/src/fh_tool_cli/backends/telnet.py +0 -0
  27. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/src/fh_tool_cli/backends/web_ajax.py +0 -0
  28. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/src/fh_tool_cli/client.py +0 -0
  29. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/src/fh_tool_cli/commands/__init__.py +0 -0
  30. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/src/fh_tool_cli/config_decrypt.py +0 -0
  31. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/src/fh_tool_cli/config_store.py +0 -0
  32. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/src/fh_tool_cli/credentials.py +0 -0
  33. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/src/fh_tool_cli/crypto.py +0 -0
  34. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/src/fh_tool_cli/diagnostics.py +0 -0
  35. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/src/fh_tool_cli/errors.py +0 -0
  36. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/src/fh_tool_cli/remote.py +0 -0
  37. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/src/fh_tool_cli/web_discovery.py +0 -0
  38. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/src/fh_tool_cli/web_writes.py +0 -0
  39. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/src/fh_tool_cli.egg-info/SOURCES.txt +0 -0
  40. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/src/fh_tool_cli.egg-info/dependency_links.txt +0 -0
  41. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/src/fh_tool_cli.egg-info/entry_points.txt +0 -0
  42. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/src/fh_tool_cli.egg-info/requires.txt +0 -0
  43. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/src/fh_tool_cli.egg-info/top_level.txt +0 -0
  44. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/tests/test_account.py +0 -0
  45. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/tests/test_backup.py +0 -0
  46. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/tests/test_cfg_cmd.py +0 -0
  47. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/tests/test_credentials.py +0 -0
  48. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/tests/test_diagnostics.py +0 -0
  49. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/tests/test_local_vm_integration.py +0 -0
  50. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/tests/test_remote.py +0 -0
  51. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/tests/test_upload.py +0 -0
  52. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/tests/test_web_ajax.py +0 -0
  53. {fh_tool_cli-0.2.0 → fh_tool_cli-0.2.1}/tests/test_web_discovery.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fh_tool-cli
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: 用于本地管理 FiberHome fh_tool 接口的 Python CLI
5
5
  Author: Gxxk
6
6
  License-Expression: AGPL-3.0-or-later
@@ -103,7 +103,8 @@ fh-tool credentials derive --kind hg5143f-telnet --mac AABBCCDDEEFF
103
103
  打开 runtime Telnet:
104
104
 
105
105
  ```bash
106
- fh-tool telnet enable --yes
106
+ fh-tool telnet enable
107
+ fh-tool telnet enable --confirm
107
108
  ```
108
109
 
109
110
  检查端口:
@@ -146,18 +147,18 @@ fh-tool web discover merge --input web-ajax-catalog.json --input static-web-ajax
146
147
 
147
148
  `live` 只探测只读 `get_*/query_*/show_*` 候选;写候选只进入 catalog,不会自动 POST。`static` 是补充路径,用于从 rootfs/备份目录扫描 HTML/JS/CSS 里的 `ajaxmethod`、参数名和上下文。
148
149
 
149
- Web AJAX 写接口默认只做 dry-run。执行 POST 需要先完成备份,并显式加 `--execute --backup-confirmed --yes --danger`:
150
+ Web AJAX 写接口默认只做 dry-run,并会提示重新运行时加 `--confirm` 才会执行 POST:
150
151
 
151
152
  ```bash
152
153
  fh-tool web ajax post set_wan_info --param VLANID=100
153
154
  fh-tool web ajax replay --catalog web-ajax-catalog.json --method set_wan_info --param VLANID=100
154
155
  fh-tool web port-mapping set --operation add --wan-index 1 --wan-session-index 1 --wan-iporppp ppp --external-port 8080 --protocol tcp --internal-client 192.168.1.2 --internal-port 80
155
156
  fh-tool web vlanbind set --operation add --if-name eth1 --user-vlan 100 --wan-vlan 100
156
- fh-tool web firewall set --enable 1 --level medium --dos-enable 1 --ipv6-enable 1 --execute --backup-confirmed --yes --danger
157
- fh-tool web services set --service telnet --enabled 0 --execute --backup-confirmed --yes --danger
157
+ fh-tool web firewall set --enable 1 --level medium --dos-enable 1 --ipv6-enable 1 --confirm
158
+ fh-tool web services set --service telnet --enabled 0 --confirm
158
159
  ```
159
160
 
160
- 常规 Web 写接口优先使用 typed 参数。`web ajax post` 和 `web ajax replay` 支持任意已知或未知 AJAX method,默认只输出计划,不发 POST;执行同样必须加 `--execute --backup-confirmed --yes --danger`,且默认拒绝空 payload。`--json-payload` 和可重复的 `--param k=v` 仍保留为固件差异逃生口,合并顺序是 typed 参数、JSON、最后 `--param` 覆盖。
161
+ 常规 Web 写接口优先使用 typed 参数。`web ajax post` 和 `web ajax replay` 支持任意已知或未知 AJAX method,默认只输出计划,不发 POST;执行必须加 `--confirm`,且默认拒绝空 payload。`--json-payload` 和可重复的 `--param k=v` 仍保留为固件差异逃生口,合并顺序是 typed 参数、JSON、最后 `--param` 覆盖。旧的确认参数会直接报弃用错误。
161
162
 
162
163
  Telnet/cfg/诊断命令默认不会自动套用派生凭据。如果设备仍是 HG5143F 默认 Telnet 规则,并且已提供或保存 MAC,可以显式加 `--use-derived-credentials` 作为 fallback:
163
164
 
@@ -187,17 +188,16 @@ fh-tool backup verify backup.tgz
187
188
  `restore` 默认只做 dry-run:解析 backup、验证 manifest/sha256,并显示将恢复的文件、目标路径和风险等级,不写入任何文件。
188
189
 
189
190
  ```bash
190
- fh-tool restore backup.tgz --dry-run
191
- fh-tool restore backup.tgz --dry-run --path /fhconf/usrconfig_conf
191
+ fh-tool restore backup.tgz
192
+ fh-tool restore backup.tgz --path /fhconf/usrconfig_conf
192
193
  ```
193
194
 
194
- 执行恢复必须显式指定本地目标根目录,并通过 extreme 风险确认:
195
+ 执行恢复必须显式指定本地目标根目录,并加 `--confirm`:
195
196
 
196
197
  ```bash
197
198
  fh-tool restore backup.tgz \
198
199
  --target-root /tmp/fh-tool-restore-root \
199
- --execute \
200
- --yes --danger --i-know-this-can-break-my-device
200
+ --confirm
201
201
  ```
202
202
 
203
203
  也可以选择真实设备目标。该模式会通过 Telnet 把 allowlist 文件先写入 `/tmp/fh-tool-restore` staging,远端 sha256 校验通过后才覆盖目标路径;仍然不会自动 reboot 或 factory reset:
@@ -206,8 +206,7 @@ fh-tool restore backup.tgz \
206
206
  fh-tool restore backup.tgz \
207
207
  --target device \
208
208
  --path /fhconf/usrconfig_conf \
209
- --execute \
210
- --yes --danger --i-know-this-can-break-my-device
209
+ --confirm
211
210
  ```
212
211
 
213
212
  当前 restore 只恢复 allowlist 内的配置文件,且会拒绝路径穿越、绝对路径逃逸和未知文件写入。`/proc/mtd`、runtime password 文件、restore/factory reset flag 等备份内容不会被恢复。恢复后会 read-back/hash verify;不会自动 reboot,也不会自动 factory reset。
@@ -222,12 +221,10 @@ fh-tool cloud audit --output cloud-report.md
222
221
  fh-tool cloud plan
223
222
  ```
224
223
 
225
- `cloud status/audit/plan` 会结构化显示 SmartSwitch 当前值、配置路径、禁用值、影响面和禁止改动项。禁用 SmartSwitch 只会写入 `InternetGatewayDevice.X_CT-COM_SmartSwitch.Enable=0`,需要先完成备份,并在写入后 read-back verify:
224
+ `cloud status/audit/plan` 会结构化显示 SmartSwitch 当前值、配置路径、禁用值、影响面和禁止改动项。禁用 SmartSwitch 只会写入 `InternetGatewayDevice.X_CT-COM_SmartSwitch.Enable=0`,不加 `--confirm` 只输出 dry-run 计划;确认写入后会 read-back verify:
226
225
 
227
226
  ```bash
228
- fh-tool cloud disable-smartswitch \
229
- --backup-confirmed \
230
- --yes --danger
227
+ fh-tool cloud disable-smartswitch --confirm
231
228
  ```
232
229
 
233
230
  该命令不会修改 LOID、PON、WAN VLAN、ServiceList 或 TR-069 VLAN。
@@ -239,33 +236,33 @@ fh-tool cloud disable-smartswitch \
239
236
  | func | command |
240
237
  |---|---|
241
238
  | `GetResult` | `fh-tool get-result` |
242
- | `SetResult` | `fh-tool set-result --result VALUE --yes` |
239
+ | `SetResult` | `fh-tool set-result --result VALUE [--confirm]` |
243
240
  | `GetPortMirror` | `fh-tool get-port-mirror` |
244
- | `SetPortMirror` | `fh-tool set-port-mirror --enable ... --direction ... --srcport ... --dstport ... --yes` |
241
+ | `SetPortMirror` | `fh-tool set-port-mirror --enable ... --direction ... --srcport ... --dstport ... [--confirm]` |
245
242
  | `LogDownload` | `fh-tool log-download [--output log.tar.gz]` |
246
243
  | `GetDevInfo` | `fh-tool dev-info` |
247
244
  | `GetAdminAccount` | `fh-tool admin-account` |
248
245
  | `GetRegAccount` | `fh-tool reg-account` |
249
- | `SetRegAccount` | `fh-tool set-reg-account --regname ... --regpwd ... --yes` |
246
+ | `SetRegAccount` | `fh-tool set-reg-account --regname ... --regpwd ... [--confirm]` |
250
247
  | `GetPwdRegPassword` | `fh-tool pwd-reg-password` |
251
- | `SetPwdRegPassword` | `fh-tool set-pwd-reg-password --password ... --yes` |
252
- | `DownloadFile` | `fh-tool download-file --file-name /var/... --output out.tar.gz --yes` |
253
- | `RestoreDefaultSettings` | `fh-tool restore-default-settings --yes --danger --i-know-this-can-break-my-device` |
248
+ | `SetPwdRegPassword` | `fh-tool set-pwd-reg-password --password ... [--confirm]` |
249
+ | `DownloadFile` | `fh-tool download-file --file-name /var/... --output out.tar.gz [--confirm]` |
250
+ | `RestoreDefaultSettings` | `fh-tool restore-default-settings [--confirm]` |
254
251
  | `UploadPrepare` | `fh-tool upload-prepare` |
255
- | `DeviceReboot` | `fh-tool reboot --yes --danger --i-know-this-can-break-my-device` |
252
+ | `DeviceReboot` | `fh-tool reboot [--confirm]` |
256
253
  | `GetPreconfig` | `fh-tool get-preconfig` |
257
- | `SetPreconfig` | `fh-tool set-preconfig --fullname ... --yes --danger` |
258
- | `TelnetEnable` | `fh-tool telnet enable --yes` / `fh-tool telnet disable --yes --danger` |
254
+ | `SetPreconfig` | `fh-tool set-preconfig --fullname ... [--confirm]` |
255
+ | `TelnetEnable` | `fh-tool telnet enable [--confirm]` / `fh-tool telnet disable [--confirm]` |
259
256
  | `GetPppoeAccount` | `fh-tool pppoe-account` |
260
- | `SetFHDebugLog` | `fh-tool set-fh-debug-log --module tr069 --data ... --yes --danger` |
261
- | `CloseFHDebugLog` | `fh-tool close-fh-debug-log --yes` |
262
- | `OpenFHDebugLog` | `fh-tool open-fh-debug-log --yes` |
257
+ | `SetFHDebugLog` | `fh-tool set-fh-debug-log --module tr069 --data ... [--confirm]` |
258
+ | `CloseFHDebugLog` | `fh-tool close-fh-debug-log [--confirm]` |
259
+ | `OpenFHDebugLog` | `fh-tool open-fh-debug-log [--confirm]` |
263
260
 
264
261
  原始调用入口:
265
262
 
266
263
  ```bash
267
264
  fh-tool call --func GetDevInfo
268
- fh-tool call --func TelnetEnable --param telnet=1 --allow-risky
265
+ fh-tool call --func TelnetEnable --param telnet=1 --confirm
269
266
  ```
270
267
 
271
268
  ## upload / download endpoint
@@ -284,10 +281,10 @@ fh-tool upload-prepare
284
281
  fh-tool upload-prepare --reveal-secrets
285
282
  ```
286
283
 
287
- 上传 firmware/preconfig 前先 dry-run:
284
+ 上传 firmware/preconfig 默认先 dry-run:
288
285
 
289
286
  ```bash
290
- fh-tool upload --action preconfig --file sysinfo_conf --sessionid TOKEN --dry-run
287
+ fh-tool upload --action preconfig --file sysinfo_conf --sessionid TOKEN
291
288
  ```
292
289
 
293
290
  真正上传属于 extreme 风险,只上传文件到 staging path,不会自动 reboot、restore 或切换 preconfig:
@@ -297,21 +294,22 @@ fh-tool upload \
297
294
  --action preconfig \
298
295
  --file sysinfo_conf \
299
296
  --sessionid TOKEN \
300
- --yes --danger --i-know-this-can-break-my-device
297
+ --confirm
301
298
  ```
302
299
 
303
300
  ## 风险边界
304
301
 
305
- 这些命令默认不会执行,必须显式确认:
302
+ 写入型命令默认不会执行,只输出 dry-run 计划和提示。确认执行只使用一个参数:
306
303
 
307
- - `--yes`: 会写设备状态或创建下载文件。
308
- - `--danger`: 高风险写入、关闭 Telnet、执行 debug script。
309
- - `--i-know-this-can-break-my-device`: restore、firmware/preconfig upload、恢复出厂或重启。
304
+ - `--confirm`: 执行写入、上传、恢复、重启等会改变设备状态的动作。
305
+ - `--reveal-secrets`: 只控制敏感字段是否明文输出,不代表写入确认。
306
+
307
+ 旧确认参数 `--yes`、`--danger`、`--backup-confirmed`、`--execute`、`--dry-run`、`--allow-risky` 和 `--i-know-this-can-break-my-device` 已弃用,传入会直接报错。
310
308
 
311
309
  当前设备如果需要保持 Telnet 打开,不要运行:
312
310
 
313
311
  ```bash
314
- fh-tool telnet disable --yes --danger
312
+ fh-tool telnet disable --confirm
315
313
  ```
316
314
 
317
315
  ## License
@@ -89,7 +89,8 @@ fh-tool credentials derive --kind hg5143f-telnet --mac AABBCCDDEEFF
89
89
  打开 runtime Telnet:
90
90
 
91
91
  ```bash
92
- fh-tool telnet enable --yes
92
+ fh-tool telnet enable
93
+ fh-tool telnet enable --confirm
93
94
  ```
94
95
 
95
96
  检查端口:
@@ -132,18 +133,18 @@ fh-tool web discover merge --input web-ajax-catalog.json --input static-web-ajax
132
133
 
133
134
  `live` 只探测只读 `get_*/query_*/show_*` 候选;写候选只进入 catalog,不会自动 POST。`static` 是补充路径,用于从 rootfs/备份目录扫描 HTML/JS/CSS 里的 `ajaxmethod`、参数名和上下文。
134
135
 
135
- Web AJAX 写接口默认只做 dry-run。执行 POST 需要先完成备份,并显式加 `--execute --backup-confirmed --yes --danger`:
136
+ Web AJAX 写接口默认只做 dry-run,并会提示重新运行时加 `--confirm` 才会执行 POST:
136
137
 
137
138
  ```bash
138
139
  fh-tool web ajax post set_wan_info --param VLANID=100
139
140
  fh-tool web ajax replay --catalog web-ajax-catalog.json --method set_wan_info --param VLANID=100
140
141
  fh-tool web port-mapping set --operation add --wan-index 1 --wan-session-index 1 --wan-iporppp ppp --external-port 8080 --protocol tcp --internal-client 192.168.1.2 --internal-port 80
141
142
  fh-tool web vlanbind set --operation add --if-name eth1 --user-vlan 100 --wan-vlan 100
142
- fh-tool web firewall set --enable 1 --level medium --dos-enable 1 --ipv6-enable 1 --execute --backup-confirmed --yes --danger
143
- fh-tool web services set --service telnet --enabled 0 --execute --backup-confirmed --yes --danger
143
+ fh-tool web firewall set --enable 1 --level medium --dos-enable 1 --ipv6-enable 1 --confirm
144
+ fh-tool web services set --service telnet --enabled 0 --confirm
144
145
  ```
145
146
 
146
- 常规 Web 写接口优先使用 typed 参数。`web ajax post` 和 `web ajax replay` 支持任意已知或未知 AJAX method,默认只输出计划,不发 POST;执行同样必须加 `--execute --backup-confirmed --yes --danger`,且默认拒绝空 payload。`--json-payload` 和可重复的 `--param k=v` 仍保留为固件差异逃生口,合并顺序是 typed 参数、JSON、最后 `--param` 覆盖。
147
+ 常规 Web 写接口优先使用 typed 参数。`web ajax post` 和 `web ajax replay` 支持任意已知或未知 AJAX method,默认只输出计划,不发 POST;执行必须加 `--confirm`,且默认拒绝空 payload。`--json-payload` 和可重复的 `--param k=v` 仍保留为固件差异逃生口,合并顺序是 typed 参数、JSON、最后 `--param` 覆盖。旧的确认参数会直接报弃用错误。
147
148
 
148
149
  Telnet/cfg/诊断命令默认不会自动套用派生凭据。如果设备仍是 HG5143F 默认 Telnet 规则,并且已提供或保存 MAC,可以显式加 `--use-derived-credentials` 作为 fallback:
149
150
 
@@ -173,17 +174,16 @@ fh-tool backup verify backup.tgz
173
174
  `restore` 默认只做 dry-run:解析 backup、验证 manifest/sha256,并显示将恢复的文件、目标路径和风险等级,不写入任何文件。
174
175
 
175
176
  ```bash
176
- fh-tool restore backup.tgz --dry-run
177
- fh-tool restore backup.tgz --dry-run --path /fhconf/usrconfig_conf
177
+ fh-tool restore backup.tgz
178
+ fh-tool restore backup.tgz --path /fhconf/usrconfig_conf
178
179
  ```
179
180
 
180
- 执行恢复必须显式指定本地目标根目录,并通过 extreme 风险确认:
181
+ 执行恢复必须显式指定本地目标根目录,并加 `--confirm`:
181
182
 
182
183
  ```bash
183
184
  fh-tool restore backup.tgz \
184
185
  --target-root /tmp/fh-tool-restore-root \
185
- --execute \
186
- --yes --danger --i-know-this-can-break-my-device
186
+ --confirm
187
187
  ```
188
188
 
189
189
  也可以选择真实设备目标。该模式会通过 Telnet 把 allowlist 文件先写入 `/tmp/fh-tool-restore` staging,远端 sha256 校验通过后才覆盖目标路径;仍然不会自动 reboot 或 factory reset:
@@ -192,8 +192,7 @@ fh-tool restore backup.tgz \
192
192
  fh-tool restore backup.tgz \
193
193
  --target device \
194
194
  --path /fhconf/usrconfig_conf \
195
- --execute \
196
- --yes --danger --i-know-this-can-break-my-device
195
+ --confirm
197
196
  ```
198
197
 
199
198
  当前 restore 只恢复 allowlist 内的配置文件,且会拒绝路径穿越、绝对路径逃逸和未知文件写入。`/proc/mtd`、runtime password 文件、restore/factory reset flag 等备份内容不会被恢复。恢复后会 read-back/hash verify;不会自动 reboot,也不会自动 factory reset。
@@ -208,12 +207,10 @@ fh-tool cloud audit --output cloud-report.md
208
207
  fh-tool cloud plan
209
208
  ```
210
209
 
211
- `cloud status/audit/plan` 会结构化显示 SmartSwitch 当前值、配置路径、禁用值、影响面和禁止改动项。禁用 SmartSwitch 只会写入 `InternetGatewayDevice.X_CT-COM_SmartSwitch.Enable=0`,需要先完成备份,并在写入后 read-back verify:
210
+ `cloud status/audit/plan` 会结构化显示 SmartSwitch 当前值、配置路径、禁用值、影响面和禁止改动项。禁用 SmartSwitch 只会写入 `InternetGatewayDevice.X_CT-COM_SmartSwitch.Enable=0`,不加 `--confirm` 只输出 dry-run 计划;确认写入后会 read-back verify:
212
211
 
213
212
  ```bash
214
- fh-tool cloud disable-smartswitch \
215
- --backup-confirmed \
216
- --yes --danger
213
+ fh-tool cloud disable-smartswitch --confirm
217
214
  ```
218
215
 
219
216
  该命令不会修改 LOID、PON、WAN VLAN、ServiceList 或 TR-069 VLAN。
@@ -225,33 +222,33 @@ fh-tool cloud disable-smartswitch \
225
222
  | func | command |
226
223
  |---|---|
227
224
  | `GetResult` | `fh-tool get-result` |
228
- | `SetResult` | `fh-tool set-result --result VALUE --yes` |
225
+ | `SetResult` | `fh-tool set-result --result VALUE [--confirm]` |
229
226
  | `GetPortMirror` | `fh-tool get-port-mirror` |
230
- | `SetPortMirror` | `fh-tool set-port-mirror --enable ... --direction ... --srcport ... --dstport ... --yes` |
227
+ | `SetPortMirror` | `fh-tool set-port-mirror --enable ... --direction ... --srcport ... --dstport ... [--confirm]` |
231
228
  | `LogDownload` | `fh-tool log-download [--output log.tar.gz]` |
232
229
  | `GetDevInfo` | `fh-tool dev-info` |
233
230
  | `GetAdminAccount` | `fh-tool admin-account` |
234
231
  | `GetRegAccount` | `fh-tool reg-account` |
235
- | `SetRegAccount` | `fh-tool set-reg-account --regname ... --regpwd ... --yes` |
232
+ | `SetRegAccount` | `fh-tool set-reg-account --regname ... --regpwd ... [--confirm]` |
236
233
  | `GetPwdRegPassword` | `fh-tool pwd-reg-password` |
237
- | `SetPwdRegPassword` | `fh-tool set-pwd-reg-password --password ... --yes` |
238
- | `DownloadFile` | `fh-tool download-file --file-name /var/... --output out.tar.gz --yes` |
239
- | `RestoreDefaultSettings` | `fh-tool restore-default-settings --yes --danger --i-know-this-can-break-my-device` |
234
+ | `SetPwdRegPassword` | `fh-tool set-pwd-reg-password --password ... [--confirm]` |
235
+ | `DownloadFile` | `fh-tool download-file --file-name /var/... --output out.tar.gz [--confirm]` |
236
+ | `RestoreDefaultSettings` | `fh-tool restore-default-settings [--confirm]` |
240
237
  | `UploadPrepare` | `fh-tool upload-prepare` |
241
- | `DeviceReboot` | `fh-tool reboot --yes --danger --i-know-this-can-break-my-device` |
238
+ | `DeviceReboot` | `fh-tool reboot [--confirm]` |
242
239
  | `GetPreconfig` | `fh-tool get-preconfig` |
243
- | `SetPreconfig` | `fh-tool set-preconfig --fullname ... --yes --danger` |
244
- | `TelnetEnable` | `fh-tool telnet enable --yes` / `fh-tool telnet disable --yes --danger` |
240
+ | `SetPreconfig` | `fh-tool set-preconfig --fullname ... [--confirm]` |
241
+ | `TelnetEnable` | `fh-tool telnet enable [--confirm]` / `fh-tool telnet disable [--confirm]` |
245
242
  | `GetPppoeAccount` | `fh-tool pppoe-account` |
246
- | `SetFHDebugLog` | `fh-tool set-fh-debug-log --module tr069 --data ... --yes --danger` |
247
- | `CloseFHDebugLog` | `fh-tool close-fh-debug-log --yes` |
248
- | `OpenFHDebugLog` | `fh-tool open-fh-debug-log --yes` |
243
+ | `SetFHDebugLog` | `fh-tool set-fh-debug-log --module tr069 --data ... [--confirm]` |
244
+ | `CloseFHDebugLog` | `fh-tool close-fh-debug-log [--confirm]` |
245
+ | `OpenFHDebugLog` | `fh-tool open-fh-debug-log [--confirm]` |
249
246
 
250
247
  原始调用入口:
251
248
 
252
249
  ```bash
253
250
  fh-tool call --func GetDevInfo
254
- fh-tool call --func TelnetEnable --param telnet=1 --allow-risky
251
+ fh-tool call --func TelnetEnable --param telnet=1 --confirm
255
252
  ```
256
253
 
257
254
  ## upload / download endpoint
@@ -270,10 +267,10 @@ fh-tool upload-prepare
270
267
  fh-tool upload-prepare --reveal-secrets
271
268
  ```
272
269
 
273
- 上传 firmware/preconfig 前先 dry-run:
270
+ 上传 firmware/preconfig 默认先 dry-run:
274
271
 
275
272
  ```bash
276
- fh-tool upload --action preconfig --file sysinfo_conf --sessionid TOKEN --dry-run
273
+ fh-tool upload --action preconfig --file sysinfo_conf --sessionid TOKEN
277
274
  ```
278
275
 
279
276
  真正上传属于 extreme 风险,只上传文件到 staging path,不会自动 reboot、restore 或切换 preconfig:
@@ -283,21 +280,22 @@ fh-tool upload \
283
280
  --action preconfig \
284
281
  --file sysinfo_conf \
285
282
  --sessionid TOKEN \
286
- --yes --danger --i-know-this-can-break-my-device
283
+ --confirm
287
284
  ```
288
285
 
289
286
  ## 风险边界
290
287
 
291
- 这些命令默认不会执行,必须显式确认:
288
+ 写入型命令默认不会执行,只输出 dry-run 计划和提示。确认执行只使用一个参数:
292
289
 
293
- - `--yes`: 会写设备状态或创建下载文件。
294
- - `--danger`: 高风险写入、关闭 Telnet、执行 debug script。
295
- - `--i-know-this-can-break-my-device`: restore、firmware/preconfig upload、恢复出厂或重启。
290
+ - `--confirm`: 执行写入、上传、恢复、重启等会改变设备状态的动作。
291
+ - `--reveal-secrets`: 只控制敏感字段是否明文输出,不代表写入确认。
292
+
293
+ 旧确认参数 `--yes`、`--danger`、`--backup-confirmed`、`--execute`、`--dry-run`、`--allow-risky` 和 `--i-know-this-can-break-my-device` 已弃用,传入会直接报错。
296
294
 
297
295
  当前设备如果需要保持 Telnet 打开,不要运行:
298
296
 
299
297
  ```bash
300
- fh-tool telnet disable --yes --danger
298
+ fh-tool telnet disable --confirm
301
299
  ```
302
300
 
303
301
  ## License
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "fh_tool-cli"
7
- version = "0.2.0"
7
+ version = "0.2.1"
8
8
  description = "用于本地管理 FiberHome fh_tool 接口的 Python CLI"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -1,3 +1,3 @@
1
1
  """Local CLI for FiberHome fh_tool endpoints."""
2
2
 
3
- __version__ = "0.2.0"
3
+ __version__ = "0.2.1"
@@ -341,7 +341,7 @@ def restore_backup_archive(
341
341
  allowlist: list[str] | None = None,
342
342
  ) -> dict[str, Any]:
343
343
  if not dry_run and target_root is None:
344
- raise CliError("restore --execute 需要显式指定 --target-root")
344
+ raise CliError("restore --confirm 需要显式指定 --target-root")
345
345
 
346
346
  allowed = set(allowlist or RESTORE_ALLOWLIST)
347
347
  requested = {_normalize_device_path(path) for path in paths or []}