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