Commit 98a9a66 1 parent 4f8dae8 commit 98a9a66 Copy full SHA for 98a9a66
File tree 2 files changed +24
-5
lines changed
dissect/hypervisor/descriptor
2 files changed +24
-5
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ def __init__(self, fh: IO):
11
11
self ._xml : Element = ElementTree .fromstring (fh .read ())
12
12
13
13
def disks (self ) -> Iterator [str ]:
14
- for hdd_elem in self ._xml .findall (
15
- f".// { self . VBOX_XML_NAMESPACE } HardDisk[@location][@format=' VDI'][@type='Normal']"
16
- ) :
17
- yield hdd_elem .attrib ["location" ]
14
+ for hdd_elem in self ._xml .findall (f".// { self . VBOX_XML_NAMESPACE } HardDisk[@location][@type='Normal']" ):
15
+ # Allow format specifier to be case-insensitive (i.e. VDI, vdi)
16
+ if ( format := hdd_elem . get ( "format" )) and format . lower () == "vdi" :
17
+ yield hdd_elem .attrib ["location" ]
Original file line number Diff line number Diff line change 3
3
from dissect .hypervisor .descriptor .vbox import VBox
4
4
5
5
6
- def test_vbox ():
6
+ def test_vbox () -> None :
7
7
xml = """
8
8
<?xml version="1.0"?>
9
9
<VirtualBox xmlns="http://www.virtualbox.org/">
@@ -20,3 +20,22 @@ def test_vbox():
20
20
with StringIO (xml .strip ()) as fh :
21
21
vbox = VBox (fh )
22
22
assert next (vbox .disks ()) == "os2warp4.vdi"
23
+
24
+
25
+ def test_vbox_lowercase_disk_format () -> None :
26
+ xml = """
27
+ <?xml version="1.0"?>
28
+ <VirtualBox xmlns="http://www.virtualbox.org/">
29
+ <Machine>
30
+ <MediaRegistry>
31
+ <HardDisks>
32
+ <HardDisk location="WinDev2407Eval-disk001.vdi" format="vdi" type="Normal" />
33
+ </HardDisks>
34
+ </MediaRegistry>
35
+ </Machine>
36
+ </VirtualBox>
37
+ """
38
+
39
+ with StringIO (xml .strip ()) as fh :
40
+ vbox = VBox (fh )
41
+ assert next (vbox .disks ()) == "WinDev2407Eval-disk001.vdi"
You can’t perform that action at this time.
0 commit comments