boot_from_disk_device: avoid os/boot plus disk boot conflict#6867
boot_from_disk_device: avoid os/boot plus disk boot conflict#6867BulaYoungR wants to merge 1 commit into
Conversation
When os_attrs_boots is set, remove all //boot nodes then apply os boots. Strip boot/loadparm from cloned disk attrs so inherited per-disk boot does not remain alongside <os><boot> (libvirt unsupported configuration). Committer: Bolatbek Issakh <bissakh@redhat.com>
WalkthroughThis PR modifies the Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
libvirt/tests/src/guest_os_booting/boot_order/boot_from_disk_device.py (1)
63-69:⚠️ Potential issue | 🟠 Major | ⚡ Quick winReplace
eval()in boot parsing path withast.literal_eval().
os_attrs_bootsis parsed from params witheval()at line 63, which allows arbitrary code execution from cfg input. Please switch toast.literal_eval()here and for the same pattern at lines 48 and 50 while touching this flow.Proposed fix
+import ast import copy import os @@ - disk_org_attrs.update(eval(params.get("disk2_attrs", "{}"))) + disk_org_attrs.update(ast.literal_eval(params.get("disk2_attrs", "{}"))) @@ - disk_org_attrs.update(eval(params.get("disk1_attrs", "{}"))) + disk_org_attrs.update(ast.literal_eval(params.get("disk1_attrs", "{}"))) @@ - os_attrs_boots = eval(params.get("os_attrs_boots", "[]")) + os_attrs_boots = ast.literal_eval(params.get("os_attrs_boots", "[]"))🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@libvirt/tests/src/guest_os_booting/boot_order/boot_from_disk_device.py` around lines 63 - 69, The use of eval() when parsing boot attributes (e.g., os_attrs_boots = eval(params.get("os_attrs_boots", "[]"))) is unsafe; replace eval() with ast.literal_eval() and import ast at the top of the module. Update the same pattern found earlier in this flow (the other occurrences that call eval(params.get(...)) around the boot parsing code at the lines referenced) to use ast.literal_eval(params.get(..., "[]")) so only Python literals are parsed; ensure the import ast is added and run tests to confirm behavior unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@libvirt/tests/src/guest_os_booting/boot_order/boot_from_disk_device.py`:
- Around line 63-69: The use of eval() when parsing boot attributes (e.g.,
os_attrs_boots = eval(params.get("os_attrs_boots", "[]"))) is unsafe; replace
eval() with ast.literal_eval() and import ast at the top of the module. Update
the same pattern found earlier in this flow (the other occurrences that call
eval(params.get(...)) around the boot parsing code at the lines referenced) to
use ast.literal_eval(params.get(..., "[]")) so only Python literals are parsed;
ensure the import ast is added and run tests to confirm behavior unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 58479589-db7b-4be5-9e99-e914c418ae09
📒 Files selected for processing (1)
libvirt/tests/src/guest_os_booting/boot_order/boot_from_disk_device.py
|
Closing this PR due to current team constraints. This is part of a broader effort to triage all in-flight work across our upstream repos. If this work is still needed, please feel free to reopen and it will be picked up. Apologies for any inconvenience. |
When os_attrs_boots is set, remove all //boot nodes then apply os boots. Strip boot/loadparm from cloned disk attrs so inherited per-disk boot does not remain alongside (libvirt unsupported configuration).
Committer: Bolatbek Issakh bissakh@redhat.com
Summary by CodeRabbit