-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_zip.py
36 lines (26 loc) · 1.35 KB
/
test_zip.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from unittest import TestCase
from polydet import PolyglotLevel
from polydet.plugins import zip
class TestZIPDetector(TestCase):
def test_check_regular_file(self):
self.assertEqual(PolyglotLevel(),
zip.check('tests/samples/zip/regular.zip'))
def test_check_garbage_at_the_beginning(self):
self.assertEqual(PolyglotLevel(suspicious_chunks=[(0, 0x8F)]),
zip.check('tests/samples/zip/garbage_at_beginning.zip'))
def test_check_garbage_at_the_end(self):
self.assertEqual(PolyglotLevel(suspicious_chunks=[(0xB5, 0x10)]),
zip.check('tests/samples/zip/garbage_at_end.zip'))
def test_check_docx(self):
self.assertEqual(PolyglotLevel(embedded={'docx'}),
zip.check('tests/samples/zip/docx.docx'))
def test_check_jar(self):
self.assertEqual(PolyglotLevel(embedded={'jar'}),
zip.check('tests/samples/zip/jar.jar'))
def test_check_apk(self):
self.assertEqual(PolyglotLevel(embedded={'apk', 'jar'}),
zip.check('tests/samples/zip/apk.apk'))
def test_too_short(self):
self.assertIsNone(zip.check('tests/samples/zip/too_short'))
def test_fake_docx_or_jar(self):
self.assertEqual(PolyglotLevel(), zip.check('tests/samples/zip/false-docx-jar.zip'))