Skip to content

Commit

Permalink
Fix: debloat fails with 'can't set attribute' (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
psrok1 authored May 22, 2023
1 parent f1ae540 commit 41e289d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion karton/archive_extractor/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.4.0"
__version__ = "1.4.1"
16 changes: 9 additions & 7 deletions karton/archive_extractor/archive_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,19 @@ def process(self, task: Task) -> None:
)
continue

if len(child.contents) > self.max_size:
if child.contents[:2] == b"MZ":
debloated = self.debloat_pe(child.contents)
contents = child.contents

if len(contents) > self.max_size:
if contents[:2] == b"MZ":
debloated = self.debloat_pe(contents)
if debloated is not None:
child.contents = debloated
contents = debloated

# Is it still too big?
if len(child.contents) > self.max_size:
if len(contents) > self.max_size:
self.log.warning(
"Child is too big for further processing (%d > %d)",
len(child.contents),
len(contents),
self.max_size,
)
continue
Expand All @@ -177,7 +179,7 @@ def process(self, task: Task) -> None:
"quality": task.headers.get("quality", "high"),
},
payload={
"sample": Resource(fname, child.contents),
"sample": Resource(fname, contents),
"parent": sample,
"extraction_level": extraction_level + 1,
},
Expand Down

0 comments on commit 41e289d

Please sign in to comment.