@@ -315,62 +315,6 @@ def test_qcow2_feature_flag_checks(self):
315
315
data [0x4F ] = 0x80
316
316
self .assertTrue (inspector .has_unknown_features )
317
317
318
- def test_vmdk_safety_checks (self ):
319
- region = format_inspector .CaptureRegion (0 , 0 )
320
- inspector = format_inspector .VMDKInspector ()
321
- inspector .new_region ('descriptor' , region )
322
-
323
- # This should be a legit VMDK descriptor which comments, blank lines,
324
- # an extent, some ddb content, and some header values.
325
- legit_desc = ['# This is a comment' ,
326
- '' ,
327
- ' ' ,
328
- 'createType=monolithicSparse' ,
329
- 'RW 1234 SPARSE "foo.vmdk"' ,
330
- 'ddb.adapterType = "MFM' ,
331
- '# EOF' ]
332
- region .data = ('\n ' .join (legit_desc )).encode ('ascii' )
333
- region .length = len (region .data )
334
- self .assertTrue (inspector .safety_check ())
335
-
336
- # Any of these lines should trigger an error indicating that there is
337
- # something in the descriptor we don't understand
338
- bad_lines = [
339
- '#\U0001F4A9 ' ,
340
- 'header Name=foo' ,
341
- 'foo bar' ,
342
- 'WR 123 SPARSE "foo.vmdk"' ,
343
- ]
344
-
345
- for bad_line in bad_lines :
346
- # Encode as UTF-8 purely so we can test that anything non-ASCII
347
- # will trigger the decode check
348
- region .data = bad_line .encode ('utf-8' )
349
- region .length = len (region .data )
350
- self .assertRaisesRegex (format_inspector .ImageFormatError ,
351
- 'Invalid VMDK descriptor' ,
352
- inspector .safety_check )
353
-
354
- # Extents with slashes in the name fail the safety check
355
- region .data = b'RW 123 SPARSE "/etc/shadow"'
356
- region .length = len (region .data )
357
- self .assertFalse (inspector .safety_check ())
358
-
359
- # A descriptor that specifies no extents fails the safety check
360
- region .data = b'# Nothing'
361
- region .length = len (region .data )
362
- self .assertFalse (inspector .safety_check ())
363
-
364
- def test_vmdk_reject_footer (self ):
365
- data = struct .pack ('<4sIIQQQQIQQ' , b'KDMV' , 3 , 0 , 0 , 0 , 0 , 1 , 0 , 0 ,
366
- format_inspector .VMDKInspector .GD_AT_END )
367
- inspector = format_inspector .VMDKInspector ()
368
- inspector .region ('header' ).data = data
369
- inspector .region ('header' ).length = len (data )
370
- self .assertRaisesRegex (format_inspector .ImageFormatError ,
371
- 'footer' ,
372
- inspector .post_process )
373
-
374
318
def test_vdi (self ):
375
319
self ._test_format ('vdi' )
376
320
0 commit comments