feat: cat 完全放行,不再限制路径

- 移除 _SAFE_CAT_FILES / _SAFE_CAT_DIRS / _is_safe_cat_path 及相关检查
- cat 在 SHELL_READ_ONLY_COMMANDS 为 None(任意参数均可)
- cat /etc/shadow 等所有路径现在都能正常通过
This commit is contained in:
Your Name
2026-07-25 14:54:19 +08:00
parent 00d95c4c5e
commit 91ab429e5b
2 changed files with 7 additions and 30 deletions
+5 -2
View File
@@ -112,13 +112,16 @@ class ShellCommandPolicyTest(unittest.TestCase):
classify_shell_command("crictl ps -a && sh -c 'echo x'")
def test_cat_only_allows_safe_paths(self):
# cat 完全放行,任意路径均可
decision = classify_shell_command("cat /etc/os-release")
self.assertEqual(decision.mode, "read")
self.assertFalse(decision.requires_approval)
def test_cat_rejects_unsafe_path(self):
with self.assertRaises(ValueError):
classify_shell_command("cat /etc/shadow")
# cat 不再限制路径
decision = classify_shell_command("cat /etc/shadow")
self.assertEqual(decision.mode, "read")
self.assertFalse(decision.requires_approval)
class EtcdCommandPolicyTest(unittest.TestCase):