diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/scanner/data/bad/bad_compression.zip | bin | 0 -> 28046 bytes | |||
-rw-r--r-- | tests/scanner/data/bad/bad_entry.zip | bin | 0 -> 126 bytes | |||
-rw-r--r-- | tests/scanner/test_scanner.py | 18 |
3 files changed, 17 insertions, 1 deletions
diff --git a/tests/scanner/data/bad/bad_compression.zip b/tests/scanner/data/bad/bad_compression.zip Binary files differnew file mode 100644 index 0000000..4dbbc1f --- /dev/null +++ b/tests/scanner/data/bad/bad_compression.zip diff --git a/tests/scanner/data/bad/bad_entry.zip b/tests/scanner/data/bad/bad_entry.zip Binary files differnew file mode 100644 index 0000000..0bf6e13 --- /dev/null +++ b/tests/scanner/data/bad/bad_entry.zip diff --git a/tests/scanner/test_scanner.py b/tests/scanner/test_scanner.py index 6fc6650..141698c 100644 --- a/tests/scanner/test_scanner.py +++ b/tests/scanner/test_scanner.py @@ -3,7 +3,7 @@ import os import shutil from datetime import datetime, timezone from pathlib import Path -from zipfile import ZipFile +from zipfile import BadZipFile, ZipFile import pytest from conftest import DB @@ -309,3 +309,19 @@ async def test_scanner_reprocess(archive, data, scanner, capsys): captured = capsys.readouterr() assert captured.out == "[~] archive.zip\n" + + +@pytest.mark.anyio +async def test_scanner_handles_bad_zip_entry(data, scanner): + Path(data("bad/bad_entry.zip")).rename(data("contents/bad_entry.zip")) + + with pytest.raises(BadZipFile): + await scanner.scan() + + +@pytest.mark.anyio +async def test_scanner_handles_bad_zip_compression(data, scanner): + Path(data("bad/bad_compression.zip")).rename(data("contents/bad_compression.zip")) + + with pytest.raises(BadZipFile): + await scanner.scan() |