Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ LABEL org.opencontainers.image.licenses MIT
LABEL org.opencontainers.image.source https://github.com/alephdata/ingest-file

# Enable non-free archive for `unrar`.
RUN echo "deb http://http.us.debian.org/debian stable non-free" >/etc/apt/sources.list.d/nonfree.list \
RUN echo "deb http://http.us.debian.org/debian bookworm non-free" >/etc/apt/sources.list.d/nonfree.list \
&& apt-get -qq -y update \
&& apt-get -qq -y install build-essential locales \
# python deps (mostly to install their dependencies)
Expand Down
2 changes: 2 additions & 0 deletions ingestors/packages/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ def unpack(self, file_path, entity, temp_dir):
z.extractall(path=temp_dir)
except ArchiveError as e:
raise ProcessingException(f"Error: {e}")
except py7zr.PasswordRequired:
raise ProcessingException("Password protected 7z archive")


class SingleFilePackageIngestor(PackageSupport, Ingestor):
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ py7zr==1.0.0
pytest==8.3.5
pytest-cov==6.1.0
click==8.1.8
fakeredis==2.30.3

# File format support
dbf==0.99.10
Expand Down
Binary file added tests/fixtures/7z_password.7z
Binary file not shown.
9 changes: 9 additions & 0 deletions tests/test_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,12 @@ def test_7zip_symlink_escape(self):
assert len(self.manager.entities) == 1
assert self.manager.entities[0].first("fileName") == "bad7zip.7z"
assert self.manager.entities[0].first("processingStatus") == "failure"

def test_7zip_password(self):
fixture_path, entity = self.fixture("7z_password.7z")

self.manager.ingest(fixture_path, entity)

assert len(self.manager.entities) == 1
assert self.manager.entities[0].first("fileName") == "7z_password.7z"
assert self.manager.entities[0].first("processingStatus") == "failure"