mirror of https://github.com/CIRCL/PyCIRCLean
Don't mark empty files as dangerous.
This commit stops filecheck from marking empty files as dangerous. The current code sees the MIMETYPE difference between None and the expected mimetype as dangerous. But, empty files are just empty, not dangerous.pull/25/head
parent
0a2c78bd76
commit
c45617c35f
|
@ -192,9 +192,11 @@ class File(FileBase):
|
||||||
expected_mimetypes = [expected_mimetype]
|
expected_mimetypes = [expected_mimetype]
|
||||||
if expected_mimetype in Config.aliases:
|
if expected_mimetype in Config.aliases:
|
||||||
expected_mimetypes.append(Config.aliases[expected_mimetype])
|
expected_mimetypes.append(Config.aliases[expected_mimetype])
|
||||||
|
if (encoding is None) and (os.path.getsize(self.src_path) == 0):
|
||||||
|
is_empty_file = True
|
||||||
|
|
||||||
is_known_extension = self.extension in mimetypes.types_map.keys()
|
is_known_extension = self.extension in mimetypes.types_map.keys()
|
||||||
if is_known_extension and self.mimetype not in expected_mimetypes:
|
if is_known_extension and self.mimetype not in expected_mimetypes and not is_empty_file:
|
||||||
self.make_dangerous('Mimetype does not match expected mimetypes ({}) for this extension'.format(expected_mimetypes))
|
self.make_dangerous('Mimetype does not match expected mimetypes ({}) for this extension'.format(expected_mimetypes))
|
||||||
|
|
||||||
def _check_mimetype(self):
|
def _check_mimetype(self):
|
||||||
|
|
Loading…
Reference in New Issue