Skip to content

Commit b1f371e

Browse files
authored
Merge pull request #743 from alephdata/bugfix/7z-password-protection
Properly handle 7z archives with password protection
2 parents c334bd0 + 72fbf9b commit b1f371e

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

ingestors/packages/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ def unpack(self, file_path, entity, temp_dir):
3232
z.extractall(path=temp_dir)
3333
except ArchiveError as e:
3434
raise ProcessingException(f"Error: {e}")
35+
except py7zr.PasswordRequired:
36+
raise ProcessingException("Password protected 7z archive")
3537

3638

3739
class SingleFilePackageIngestor(PackageSupport, Ingestor):

tests/fixtures/7z_password.7z

178 Bytes
Binary file not shown.

tests/test_packages.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,12 @@ def test_7zip_symlink_escape(self):
8989
assert len(self.manager.entities) == 1
9090
assert self.manager.entities[0].first("fileName") == "bad7zip.7z"
9191
assert self.manager.entities[0].first("processingStatus") == "failure"
92+
93+
def test_7zip_password(self):
94+
fixture_path, entity = self.fixture("7z_password.7z")
95+
96+
self.manager.ingest(fixture_path, entity)
97+
98+
assert len(self.manager.entities) == 1
99+
assert self.manager.entities[0].first("fileName") == "7z_password.7z"
100+
assert self.manager.entities[0].first("processingStatus") == "failure"

0 commit comments

Comments
 (0)