Commit 068e7c56 authored by jvoisin's avatar jvoisin
Browse files
parent ffb4e889
......@@ -5,6 +5,7 @@ import datetime
import logging
import os
import shutil
import stat
import tarfile
import tempfile
import zipfile
......@@ -160,7 +161,10 @@ class ZipStripper(GenericArchiveStripper):
if os.path.isfile(name) and not beginning and not ending:
cfile = mat.create_class_file(name, False, add2archive=self.add2archive)
if cfile is not None:
old_stat = os.stat(name).st_mode
os.chmod(name, old_stat|stat.S_IWUSR)
cfile.remove_all()
os.chmod(name, old_stat)
logging.debug('Processing %s from %s' % (item.filename, self.filename))
elif item.filename not in whitelist:
logging.info('%s\'s format is not supported or harmless' % item.filename)
......@@ -244,10 +248,10 @@ class TarStripper(GenericArchiveStripper):
class_file = mat.create_class_file(complete_name,
False, add2archive=self.add2archive)
if class_file:
# Nested archives are treated like unsupported ones
if not class_file.is_clean():
if not list_unsupported:
return False
# Nested archives are treated like unsupported files
elif isinstance(class_file, GenericArchiveStripper):
ret_list.append(item.name)
else:
......
......@@ -7,6 +7,7 @@
import os
import sys
import shutil
import tarfile
import tempfile
import test
......@@ -157,6 +158,13 @@ class TestArchiveProcessing(test.MATTest):
unsupported_files = set(current_file.is_clean(list_unsupported=True))
self.assertEqual(unsupported_files, set(('mat.desktop', 'README.security', 'setup.py')))
def test_archive_unwritable_content(self):
path = os.path.join(self.tmpdir, './unwritable_content.zip')
shutil.copy2('./unwritable_content.zip', self.tmpdir)
current_file = MAT.mat.create_class_file(path, False, add2archive=False)
current_file.remove_all()
current_file = MAT.mat.create_class_file(path, False, add2archive=False)
self.assertTrue(current_file.is_clean())
def get_tests():
''' Returns every libtests'''
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment