Skip to content

Commit

Permalink
Add support for LIEF >= v0.14.0
Browse files Browse the repository at this point in the history
  • Loading branch information
cnheitman committed May 30, 2024
1 parent 67a007e commit 9e1938f
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions libpastis/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@
from typing import Tuple, Optional, Union

# third-party imports
import lief
import magic
import shutil
import stat
import lief
try:
# LIEF <= v0.13.2
EXE_FORMATS = lief.EXE_FORMATS
except AttributeError:
# LIEF >= v0.14.0
EXE_FORMATS = lief.Binary.FORMATS

# local imports
from libpastis.types import Arch, Platform
Expand Down Expand Up @@ -270,9 +276,9 @@ def _read_binary_infos(file: Path) -> Optional[Tuple[Platform, Arch]]:
arch = mapping.get(p.header.machine_type)

# Determine the platform from its format
mapping_elf = {lief.EXE_FORMATS.ELF: Platform.LINUX,
lief.EXE_FORMATS.PE: Platform.WINDOWS,
lief.EXE_FORMATS.MACHO: Platform.MACOS}
mapping_elf = {EXE_FORMATS.ELF: Platform.LINUX,
EXE_FORMATS.PE: Platform.WINDOWS,
EXE_FORMATS.MACHO: Platform.MACOS}
# FIXME: differentiating between ELF (Linux, Android ..) and MACHO (MacOS, iOS..)
fmt = mapping_elf.get(p.format)

Expand Down

0 comments on commit 9e1938f

Please sign in to comment.