@@ -208,62 +208,6 @@ def test_qcow2_feature_flag_checks(self):
208
208
data [0x4F ] = 0x80
209
209
self .assertTrue (inspector .has_unknown_features )
210
210
211
- def test_vmdk_safety_checks (self ):
212
- region = format_inspector .CaptureRegion (0 , 0 )
213
- inspector = format_inspector .VMDKInspector ()
214
- inspector .new_region ('descriptor' , region )
215
-
216
- # This should be a legit VMDK descriptor which comments, blank lines,
217
- # an extent, some ddb content, and some header values.
218
- legit_desc = ['# This is a comment' ,
219
- '' ,
220
- ' ' ,
221
- 'createType=monolithicSparse' ,
222
- 'RW 1234 SPARSE "foo.vmdk"' ,
223
- 'ddb.adapterType = "MFM' ,
224
- '# EOF' ]
225
- region .data = ('\n ' .join (legit_desc )).encode ('ascii' )
226
- region .length = len (region .data )
227
- self .assertTrue (inspector .safety_check ())
228
-
229
- # Any of these lines should trigger an error indicating that there is
230
- # something in the descriptor we don't understand
231
- bad_lines = [
232
- '#\U0001F4A9 ' ,
233
- 'header Name=foo' ,
234
- 'foo bar' ,
235
- 'WR 123 SPARSE "foo.vmdk"' ,
236
- ]
237
-
238
- for bad_line in bad_lines :
239
- # Encode as UTF-8 purely so we can test that anything non-ASCII
240
- # will trigger the decode check
241
- region .data = bad_line .encode ('utf-8' )
242
- region .length = len (region .data )
243
- self .assertRaisesRegex (format_inspector .ImageFormatError ,
244
- 'Invalid VMDK descriptor' ,
245
- inspector .safety_check )
246
-
247
- # Extents with slashes in the name fail the safety check
248
- region .data = b'RW 123 SPARSE "/etc/shadow"'
249
- region .length = len (region .data )
250
- self .assertFalse (inspector .safety_check ())
251
-
252
- # A descriptor that specifies no extents fails the safety check
253
- region .data = b'# Nothing'
254
- region .length = len (region .data )
255
- self .assertFalse (inspector .safety_check ())
256
-
257
- def test_vmdk_reject_footer (self ):
258
- data = struct .pack ('<4sIIQQQQIQQ' , b'KDMV' , 3 , 0 , 0 , 0 , 0 , 1 , 0 , 0 ,
259
- format_inspector .VMDKInspector .GD_AT_END )
260
- inspector = format_inspector .VMDKInspector ()
261
- inspector .region ('header' ).data = data
262
- inspector .region ('header' ).length = len (data )
263
- self .assertRaisesRegex (format_inspector .ImageFormatError ,
264
- 'footer' ,
265
- inspector .post_process )
266
-
267
211
def test_vdi (self ):
268
212
self ._test_format ('vdi' )
269
213
0 commit comments