fix: confirm VM control tasks safely

This commit is contained in:
VAIO73
2026-10-15 04:29:26 +00:00
parent 3e806afe8c
commit 3254ca6d05
5 changed files with 132 additions and 26 deletions
+7 -2
View File
@@ -290,8 +290,13 @@ class CheckOnlyTests(unittest.TestCase):
def test_control_route_uses_same_lock_and_preserves_qemu(self):
app = Flask(__name__)
command = Mock(return_value=subprocess.CompletedProcess(
[], 0, '"UPID:fixture:000A:000B:000C:vzstart:100:root@pam:"\n', ''))
def control_result(argv, **_):
path = argv[2]
vm_type, vmid, action = path.split('/')[3], path.split('/')[4], path.rsplit('/', 1)[1]
task_type = ('vz' if vm_type == 'lxc' else 'qm') + action
return subprocess.CompletedProcess(
[], 0, f'"UPID:fixture:000A:000B:000C:{task_type}:{vmid}:root@pam:"\n', '')
command = Mock(side_effect=control_result)
scope = {'app': app, 'jsonify': jsonify, 'request': request,
'require_auth': lambda fn: fn,
'get_cached_pvesh_cluster_resources_vm': lambda: [