@@ -336,8 +336,8 @@ def test_unpack_evil_tar_link1_no_data_filter(
336
336
with pytest .raises (InstallationError ) as e :
337
337
untar_file (tar_filepath , extract_path )
338
338
339
- assert " trying to install outside target directory" in str ( e . value )
340
- assert "import_file" in str (e .value )
339
+ msg = "The tar file ({}) has a file ({}) trying to install outside target directory ({})"
340
+ assert msg . format ( tar_filepath , "evil_symlink" , import_filepath ) in str (e .value )
341
341
342
342
assert not os .path .exists (os .path .join (extract_path , "evil_symlink" ))
343
343
@@ -359,18 +359,19 @@ def test_unpack_evil_tar_link2_no_data_filter(
359
359
360
360
extract_path = os .path .join (self .tempdir , "extract_path" )
361
361
362
+ link_path = ".." + os .sep + import_filename
363
+
362
364
with tarfile .open (tar_filepath , "w" ) as tar :
363
365
info = tarfile .TarInfo ("evil_symlink" )
364
366
info .type = tarfile .SYMTYPE
365
- info .linkpath = ".." + os . sep + import_filename
367
+ info .linkpath = link_path
366
368
tar .addfile (info )
367
369
368
370
with pytest .raises (InstallationError ) as e :
369
371
untar_file (tar_filepath , extract_path )
370
372
371
- assert "trying to install outside target directory" in str (e .value )
372
- assert ".." in str (e .value )
373
- assert import_filename in str (e .value )
373
+ msg = "The tar file ({}) has a file ({}) trying to install outside target directory ({})"
374
+ assert msg .format (tar_filepath , "evil_symlink" , link_path ) in str (e .value )
374
375
375
376
assert not os .path .exists (os .path .join (extract_path , "evil_symlink" ))
376
377
0 commit comments