mirror of
https://github.com/samba-team/samba.git
synced 2025-12-20 16:23:51 +03:00
python:tests: Adopt safe_tarfile for extraction_filter raises
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15390 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
This commit is contained in:
committed by
Andrew Bartlett
parent
4952cb88e4
commit
ebaa008162
@@ -43,9 +43,16 @@ class SafeTarFileTestCase(TestCaseInTempDir):
|
||||
|
||||
stf = safe_tarfile.open(tarname)
|
||||
|
||||
self.assertRaises(tarfile.ExtractError,
|
||||
stf.extractall,
|
||||
tarname)
|
||||
# We we have data_filter, we have a patched python to address
|
||||
# CVE-2007-4559.
|
||||
if hasattr(tarfile, "data_filter"):
|
||||
self.assertRaises(tarfile.OutsideDestinationError,
|
||||
stf.extractall,
|
||||
tarname)
|
||||
else:
|
||||
self.assertRaises(tarfile.ExtractError,
|
||||
stf.extractall,
|
||||
tarname)
|
||||
self.rm_files('x', 'tar.tar')
|
||||
|
||||
def test_slash(self):
|
||||
@@ -60,8 +67,16 @@ class SafeTarFileTestCase(TestCaseInTempDir):
|
||||
tf.close()
|
||||
|
||||
stf = safe_tarfile.open(tarname)
|
||||
self.assertRaises(tarfile.ExtractError,
|
||||
stf.extractall,
|
||||
tarname)
|
||||
|
||||
# We we have data_filter, we have a patched python to address
|
||||
# CVE-2007-4559.
|
||||
if hasattr(tarfile, "data_filter"):
|
||||
self.assertRaises(NotADirectoryError,
|
||||
stf.extractall,
|
||||
tarname)
|
||||
else:
|
||||
self.assertRaises(tarfile.ExtractError,
|
||||
stf.extractall,
|
||||
tarname)
|
||||
|
||||
self.rm_files('x', 'tar.tar')
|
||||
|
||||
Reference in New Issue
Block a user