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:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user