diff --git a/api/python/CMakeLists.txt b/api/python/CMakeLists.txt index 8c6ce45921..1f15296db6 100644 --- a/api/python/CMakeLists.txt +++ b/api/python/CMakeLists.txt @@ -36,8 +36,8 @@ endmacro() if (LIEF_EXTERNAL_NANOBINDS) find_package(nanobind REQUIRED) else() - set(NANOBIND_VERSION 1.6.2.r7.gb4c5af0) - set(NANOBIND_SHA256 SHA256=b0c84f3729ba231b7539ca9484b7cc1bf32cce877cc29fa875e9f7919ef5b874) + set(NANOBIND_VERSION 1.6.2.r20.g46ed29e) + set(NANOBIND_SHA256 SHA256=fd91abf745de6b67edf87f9549df5380b666a66218b0bf170e27313d3a726ee7) set(NANOBIND_URL "${THIRD_PARTY_DIRECTORY}/nanobind-${NANOBIND_VERSION}.zip" CACHE STRING "URL to the Nanobind") FetchContent_Declare(nanobind URL ${NANOBIND_URL} diff --git a/api/python/lief/ART.pyi b/api/python/lief/ART.pyi index 0a3947502e..334cadf53c 100644 --- a/api/python/lief/ART.pyi +++ b/api/python/lief/ART.pyi @@ -1,7 +1,6 @@ -from typing import Any, ClassVar +from typing import Any, ClassVar, Optional from typing import overload -import lief # type: ignore import lief.ART # type: ignore import lief.Android # type: ignore @@ -62,9 +61,9 @@ class STORAGE_MODES: def android_version(art_version: int) -> lief.Android.ANDROID_VERSIONS: ... @overload -def parse(filename: str) -> lief.ART.File: ... +def parse(filename: str) -> Optional[lief.ART.File]: ... @overload -def parse(raw: list[int], name: str = ...) -> lief.ART.File: ... +def parse(raw: list[int], name: str = ...) -> Optional[lief.ART.File]: ... @overload def parse(io: object, name: str = ...) -> object: ... @overload diff --git a/api/python/lief/DEX.pyi b/api/python/lief/DEX.pyi index a3591b731a..797b20f377 100644 --- a/api/python/lief/DEX.pyi +++ b/api/python/lief/DEX.pyi @@ -1,8 +1,13 @@ -from typing import Any, ClassVar +from typing import Any, ClassVar, Optional from typing import overload -import lief # type: ignore import lief.DEX # type: ignore +import lief.DEX.Class # type: ignore +import lief.DEX.File # type: ignore +import lief.DEX.MapItem # type: ignore +import lief.DEX.MapList # type: ignore +import lief.DEX.Prototype # type: ignore +import lief.DEX.Type # type: ignore class ACCESS_FLAGS: ABSTRACT: ClassVar[ACCESS_FLAGS] = ... @@ -336,9 +341,9 @@ class Type(lief.Object): def value(self) -> object: ... @overload -def parse(filename: str) -> lief.DEX.File: ... +def parse(filename: str) -> Optional[lief.DEX.File]: ... @overload -def parse(raw: list[int], name: str = ...) -> lief.DEX.File: ... +def parse(raw: list[int], name: str = ...) -> Optional[lief.DEX.File]: ... @overload def parse(io: object, name: str = ...) -> object: ... @overload diff --git a/api/python/lief/ELF.pyi b/api/python/lief/ELF.pyi index b88547aacf..329d9dea2a 100644 --- a/api/python/lief/ELF.pyi +++ b/api/python/lief/ELF.pyi @@ -1,8 +1,18 @@ -from typing import Any, ClassVar, Iterable, Iterator, Optional +from typing import Any, ClassVar, Iterable, Iterator, Optional, Union from typing import overload +import io import lief # type: ignore import lief.ELF # type: ignore +import lief.ELF.Binary # type: ignore +import lief.ELF.Builder # type: ignore +import lief.ELF.CoreAuxv # type: ignore +import lief.ELF.CoreFile # type: ignore +import lief.ELF.CorePrStatus # type: ignore +import lief.ELF.Section # type: ignore +import lief.ELF.Segment # type: ignore +import lief.ELF.SymbolVersionDefinition # type: ignore +import lief.ELF.SymbolVersionRequirement # type: ignore class ARCH: AARCH64: ClassVar[ARCH] = ... @@ -319,7 +329,7 @@ class Binary(lief.Binary): def __iter__(self) -> lief.ELF.Binary.it_symbols_version_requirement: ... def __len__(self) -> int: ... def __next__(self) -> lief.ELF.SymbolVersionRequirement: ... - interpreter: Any + interpreter: str overlay: memoryview def __init__(self, *args, **kwargs) -> None: ... @overload @@ -466,7 +476,7 @@ class Binary(lief.Binary): @property def has_overlay(self) -> bool: ... @property - def header(self) -> lief.ELF.Header: ... + def header(self) -> lief.ELF.Header: ... # type: ignore @property def imagebase(self) -> int: ... @property @@ -488,13 +498,13 @@ class Binary(lief.Binary): @property def relocations(self) -> lief.ELF.Binary.it_relocations: ... @property - def sections(self) -> lief.ELF.Binary.it_sections: ... + def sections(self) -> lief.ELF.Binary.it_sections: ... # type: ignore @property def segments(self) -> lief.ELF.Binary.it_segments: ... @property def static_symbols(self) -> lief.ELF.Binary.it_symbols: ... @property - def strings(self) -> list[str]: ... + def strings(self) -> list[Union[str,bytes]]: ... @property def symbols(self) -> lief.ELF.Binary.it_dyn_static_symbols: ... @property @@ -2434,7 +2444,7 @@ class Section(lief.Section): entry_size: int file_offset: int flags: int - information: Any + information: int link: int type: lief.ELF.SECTION_TYPES @overload @@ -2525,7 +2535,7 @@ class Symbol(lief.Symbol): @property def is_variable(self) -> bool: ... @property - def section(self) -> Any: ... + def section(self) -> lief.ELF.Section: ... @property def symbol_version(self) -> lief.ELF.SymbolVersion: ... @@ -2601,8 +2611,8 @@ class VERSION: def value(self) -> int: ... @overload -def parse(filename: str, config: lief.ELF.ParserConfig = ...) -> lief.ELF.Binary | None: ... +def parse(filename: str, config: lief.ELF.ParserConfig = ...) -> Optional[lief.ELF.Binary]: ... @overload -def parse(raw: list[int], config: lief.ELF.ParserConfig = ...) -> lief.ELF.Binary | None: ... +def parse(raw: list[int], config: lief.ELF.ParserConfig = ...) -> Optional[lief.ELF.Binary]: ... @overload -def parse(io: object, config: lief.ELF.ParserConfig = ...) -> lief.ELF.Binary | None: ... +def parse(io: io.IOBase, config: lief.ELF.ParserConfig = ...) -> lief.ELF.Binary | None: ... diff --git a/api/python/lief/MachO.pyi b/api/python/lief/MachO.pyi index 712895ce64..e79fa11274 100644 --- a/api/python/lief/MachO.pyi +++ b/api/python/lief/MachO.pyi @@ -1,8 +1,20 @@ -from typing import Any, ClassVar +from typing import Any, ClassVar, Optional from typing import overload +import io import lief # type: ignore import lief.MachO # type: ignore +import lief.MachO.Binary # type: ignore +import lief.MachO.BuildToolVersion # type: ignore +import lief.MachO.BuildVersion # type: ignore +import lief.MachO.Builder # type: ignore +import lief.MachO.DataCodeEntry # type: ignore +import lief.MachO.DyldChainedFixups # type: ignore +import lief.MachO.DyldInfo # type: ignore +import lief.MachO.FatBinary # type: ignore +import lief.MachO.SegmentCommand # type: ignore +import lief.MachO.Symbol # type: ignore +import lief.MachO.TwoLevelHints # type: ignore class ARM64_RELOCATION: ADDEND: ClassVar[ARM64_RELOCATION] = ... @@ -304,13 +316,13 @@ class Binary(lief.Binary): @property def has_version_min(self) -> bool: ... @property - def header(self) -> lief.MachO.Header: ... + def header(self) -> lief.MachO.Header: ... # type: ignore @property def imagebase(self) -> int: ... @property def imported_symbols(self) -> lief.MachO.Binary.it_filter_symbols: ... @property - def libraries(self) -> lief.MachO.Binary.it_libraries: ... + def libraries(self) -> lief.MachO.Binary.it_libraries: ... # type: ignore @property def linker_opt_hint(self) -> lief.MachO.LinkerOptHint: ... @property @@ -326,7 +338,7 @@ class Binary(lief.Binary): @property def rpaths(self) -> lief.MachO.Binary.it_rpaths: ... @property - def sections(self) -> lief.MachO.Binary.it_sections: ... + def sections(self) -> lief.MachO.Binary.it_sections: ... # type: ignore @property def segment_split_info(self) -> lief.MachO.SegmentSplitInfo: ... @property @@ -779,7 +791,7 @@ class FatBinary: def __init__(self, *args, **kwargs) -> None: ... def at(self, index: int) -> lief.MachO.Binary: ... def raw(self) -> list[int]: ... - def take(self, cpu: lief.MachO.CPU_TYPES) -> lief.MachO.Binary: ... + def take(self, cpu: lief.MachO.CPU_TYPES) -> Optional[lief.MachO.Binary]: ... def write(self, filename: str) -> None: ... def __getitem__(self, arg: int, /) -> lief.MachO.Binary: ... def __iter__(self) -> lief.MachO.FatBinary.it_binaries: ... @@ -842,7 +854,7 @@ class Header(lief.Object): cpu_subtype: int cpu_type: lief.MachO.CPU_TYPES file_type: lief.MachO.FILE_TYPES - flags: Any + flags: int magic: lief.MachO.MACHO_TYPES nb_cmds: int reserved: int @@ -1223,17 +1235,17 @@ class SubFramework(LoadCommand): def __init__(self, *args, **kwargs) -> None: ... class Symbol(lief.Symbol): - class TOOLS: - EXTERNAL: ClassVar[Symbol.TOOLS] = ... - INDIRECT_ABS: ClassVar[Symbol.TOOLS] = ... - INDIRECT_LOCAL: ClassVar[Symbol.TOOLS] = ... - LOCAL: ClassVar[Symbol.TOOLS] = ... - NONE: ClassVar[Symbol.TOOLS] = ... - UNDEFINED: ClassVar[Symbol.TOOLS] = ... + class CATEGORY: + EXTERNAL: ClassVar[Symbol.CATEGORY] = ... + INDIRECT_ABS: ClassVar[Symbol.CATEGORY] = ... + INDIRECT_LOCAL: ClassVar[Symbol.CATEGORY] = ... + LOCAL: ClassVar[Symbol.CATEGORY] = ... + NONE: ClassVar[Symbol.CATEGORY] = ... + UNDEFINED: ClassVar[Symbol.CATEGORY] = ... __name__: Any def __init__(self, *args, **kwargs) -> None: ... @staticmethod - def from_value(arg: int, /) -> lief.MachO.Symbol.TOOLS: ... + def from_value(arg: int, /) -> lief.MachO.Symbol.CATEGORY: ... @property def value(self) -> int: ... description: int @@ -1243,6 +1255,8 @@ class Symbol(lief.Symbol): @property def binding_info(self) -> lief.MachO.BindingInfo: ... @property + def category(self) -> lief.MachO.Symbol.CATEGORY: ... + @property def demangled_name(self) -> str: ... @property def export_info(self) -> lief.MachO.ExportInfo: ... @@ -1348,9 +1362,9 @@ def check_layout(file: lief.MachO.FatBinary) -> tuple[bool,str]: ... def is_64(file: str) -> bool: ... def is_fat(file: str) -> bool: ... @overload -def parse(filename: str, config: lief.MachO.ParserConfig = ...) -> lief.MachO.FatBinary | None: ... +def parse(filename: str, config: lief.MachO.ParserConfig = ...) -> Optional[lief.MachO.FatBinary]: ... @overload -def parse(raw: list[int], config: lief.MachO.ParserConfig = ...) -> lief.MachO.FatBinary | None: ... +def parse(raw: list[int], config: lief.MachO.ParserConfig = ...) -> Optional[lief.MachO.FatBinary]: ... @overload -def parse(io: object, config: lief.MachO.ParserConfig = ...) -> lief.MachO.FatBinary | None: ... -def parse_from_memory(address: int, config: lief.MachO.ParserConfig = ...) -> lief.MachO.FatBinary: ... +def parse(io: io.IOBase, config: lief.MachO.ParserConfig = ...) -> lief.MachO.FatBinary | None: ... +def parse_from_memory(address: int, config: lief.MachO.ParserConfig = ...) -> Optional[lief.MachO.FatBinary]: ... diff --git a/api/python/lief/OAT.pyi b/api/python/lief/OAT.pyi index 723c458be3..2f615a3a2f 100644 --- a/api/python/lief/OAT.pyi +++ b/api/python/lief/OAT.pyi @@ -1,11 +1,13 @@ -from typing import Any, ClassVar +from typing import Any, ClassVar, Optional from typing import overload -import lief # type: ignore import lief.Android # type: ignore import lief.DEX # type: ignore import lief.ELF # type: ignore import lief.OAT # type: ignore +import lief.OAT.Binary # type: ignore +import lief.OAT.Class # type: ignore +import lief.OAT.Header # type: ignore class Binary(lief.ELF.Binary): class it_classes: @@ -224,11 +226,11 @@ class OAT_CLASS_TYPES: def android_version(arg: int, /) -> lief.Android.ANDROID_VERSIONS: ... @overload -def parse(oat_file: str) -> lief.OAT.Binary: ... +def parse(oat_file: str) -> Optional[lief.OAT.Binary]: ... @overload -def parse(oat_file: str, vdex_file: str) -> lief.OAT.Binary: ... +def parse(oat_file: str, vdex_file: str) -> Optional[lief.OAT.Binary]: ... @overload -def parse(raw: list[int]) -> lief.OAT.Binary: ... +def parse(raw: list[int]) -> Optional[lief.OAT.Binary]: ... @overload def parse(io: object) -> object: ... @overload diff --git a/api/python/lief/PE.pyi b/api/python/lief/PE.pyi index a4ffabb7da..07f2cf50fc 100644 --- a/api/python/lief/PE.pyi +++ b/api/python/lief/PE.pyi @@ -1,8 +1,30 @@ -from typing import Any, ClassVar, List +from typing import Any, ClassVar, Optional from typing import overload +import io import lief # type: ignore import lief.PE # type: ignore +import lief.PE.Binary # type: ignore +import lief.PE.CodeView # type: ignore +import lief.PE.ContentInfo # type: ignore +import lief.PE.DataDirectory # type: ignore +import lief.PE.Debug # type: ignore +import lief.PE.DelayImport # type: ignore +import lief.PE.Export # type: ignore +import lief.PE.ExportEntry # type: ignore +import lief.PE.Header # type: ignore +import lief.PE.Import # type: ignore +import lief.PE.OptionalHeader # type: ignore +import lief.PE.Pogo # type: ignore +import lief.PE.Relocation # type: ignore +import lief.PE.ResourceDialog # type: ignore +import lief.PE.ResourceNode # type: ignore +import lief.PE.ResourcesManager # type: ignore +import lief.PE.RichHeader # type: ignore +import lief.PE.Section # type: ignore +import lief.PE.Signature # type: ignore +import lief.PE.SignerInfo # type: ignore +import lief.PE.x509 # type: ignore class ACCELERATOR_FLAGS: END: ClassVar[ACCELERATOR_FLAGS] = ... @@ -264,10 +286,10 @@ class Binary(lief.Binary): class it_debug: def __init__(self, *args, **kwargs) -> None: ... - def __getitem__(self, arg: int, /) -> lief.PE.Debug | lief.PE.CodeView | lief.PE.CodeViewPDB | lief.PE.Pogo | lief.PE.Repro : ... + def __getitem__(self, arg: int, /) -> lief.PE.Debug: ... def __iter__(self) -> lief.PE.Binary.it_debug: ... def __len__(self) -> int: ... - def __next__(self) -> lief.PE.Debug | lief.PE.CodeView | lief.PE.CodeViewPDB | lief.PE.Pogo | lief.PE.Repro : ... + def __next__(self) -> lief.PE.Debug: ... class it_delay_imports: def __init__(self, *args, **kwargs) -> None: ... @@ -332,8 +354,6 @@ class Binary(lief.Binary): def verify_signature(self, checks: lief.PE.Signature.VERIFICATION_CHECKS = ...) -> lief.PE.Signature.VERIFICATION_FLAGS: ... @overload def verify_signature(self, signature: lief.PE.Signature, checks: lief.PE.Signature.VERIFICATION_CHECKS = ...) -> lief.PE.Signature.VERIFICATION_FLAGS: ... - @overload - def verify_signature(self, detached) -> lief.PE.Signature.VERIFICATION_FLAGS: ... def write(self, output_path: str) -> None: ... @property def authentihash_md5(self) -> bytes: ... @@ -378,7 +398,7 @@ class Binary(lief.Binary): @property def has_tls(self) -> bool: ... @property - def header(self) -> lief.PE.Header: ... + def header(self) -> lief.PE.Header: ... # type: ignore @property def imports(self) -> lief.PE.Binary.it_imports: ... @property @@ -396,9 +416,9 @@ class Binary(lief.Binary): @property def resources(self) -> lief.PE.ResourceNode: ... @property - def resources_manager(self) -> lief.PE.ResourcesManager | None: ... + def resources_manager(self) -> lief.PE.ResourcesManager | lief.lief_errors: ... @property - def sections(self) -> lief.PE.Binary.it_section: ... + def sections(self) -> lief.PE.Binary.it_section: ... # type: ignore @property def signatures(self) -> lief.PE.Binary.it_const_signatures: ... @property @@ -715,7 +735,7 @@ class Debug(lief.Object): sizeof_data: int timestamp: int def __init__(self) -> None: ... - def copy(self) -> lief.PE.Debug: ... + def copy(self) -> Optional[lief.PE.Debug]: ... @property def type(self) -> lief.PE.Debug.TYPES: ... @@ -1137,7 +1157,7 @@ class LoadConfiguration(lief.Object): @property def size(self) -> int: ... @property - def version(self) -> Any: ... + def version(self) -> lief.PE.WIN_VERSION: ... class LoadConfigurationV0(LoadConfiguration): se_handler_count: int @@ -1315,7 +1335,7 @@ class OptionalHeader(lief.Object): sizeof_stack_commit: int sizeof_stack_reserve: int sizeof_uninitialized_data: int - subsystem: Any + subsystem: lief.PE.OptionalHeader.SUBSYSTEM win32_version_value: int def __init__(self, *args, **kwargs) -> None: ... def add(self, characteristic: lief.PE.OptionalHeader.DLL_CHARACTERISTICS) -> None: ... @@ -1852,7 +1872,7 @@ class ResourceData(ResourceNode): @overload def __init__(self) -> None: ... @overload - def __init__(self, content, std, code_page: int) -> None: ... + def __init__(self, content: list[int], code_page: int) -> None: ... @property def offset(self) -> int: ... @@ -1982,7 +2002,7 @@ class ResourceNode(lief.Object): def __init__(self, *args, **kwargs) -> None: ... def add_data_node(self, resource_data: lief.PE.ResourceData) -> lief.PE.ResourceNode: ... def add_directory_node(self, resource_directory: lief.PE.ResourceDirectory) -> lief.PE.ResourceNode: ... - def copy(self) -> lief.PE.ResourceNode: ... + def copy(self) -> Optional[lief.PE.ResourceNode]: ... @overload def delete_child(self, node: lief.PE.ResourceNode) -> None: ... @overload @@ -2341,13 +2361,13 @@ class Section(lief.Section): @overload def __init__(self) -> None: ... @overload - def __init__(self, content, std, name: str = ..., characteristics: int = ...) -> None: ... + def __init__(self, content: list[int], name: str = ..., characteristics: int = ...) -> None: ... @overload def __init__(self, name: str) -> None: ... def copy(self) -> lief.PE.Section: ... def has_characteristic(self, characteristic: lief.PE.Section.CHARACTERISTICS) -> bool: ... @property - def characteristics_lists(self) -> Any: ... + def characteristics_lists(self) -> list[lief.PE.Section.CHARACTERISTICS]: ... @property def padding(self) -> bytes: ... @@ -2452,7 +2472,7 @@ class Signature(lief.Object): @property def raw_der(self) -> bytes: ... @property - def signers(self) -> List[lief.PE.SignerInfo]: ... + def signers(self) -> lief.PE.Signature.it_const_signers_t: ... @property def version(self) -> int: ... @@ -2666,20 +2686,14 @@ class x509(lief.Object): @property def value(self) -> int: ... def __init__(self, *args, **kwargs) -> None: ... - @overload def is_trusted_by(self, ca_list: list[lief.PE.x509]) -> lief.PE.x509.VERIFICATION_FLAGS: ... @overload - def is_trusted_by(self, microsoft_ca_bundle) -> lief.PE.x509.VERIFICATION_FLAGS: ... - @overload @staticmethod - def parse(path: str) -> lief.PE.Binary | None: ... + def parse(path: str) -> list[lief.PE.x509]: ... @overload @staticmethod - def parse(raw: list[int]) -> lief.PE.Binary | None: ... - @overload + def parse(raw: list[int]) -> list[lief.PE.x509]: ... def verify(self, ca: lief.PE.x509) -> lief.PE.x509.VERIFICATION_FLAGS: ... - @overload - def verify(self, signer) -> lief.PE.x509.VERIFICATION_FLAGS: ... @property def certificate_policies(self) -> list[str]: ... @property @@ -2695,7 +2709,7 @@ class x509(lief.Object): @property def raw(self) -> bytes: ... @property - def rsa_info(self) -> lief.PE.RsaInfo: ... + def rsa_info(self) -> Optional[lief.PE.RsaInfo]: ... @property def serial_number(self) -> bytes: ... @property @@ -2718,9 +2732,9 @@ def get_type(file: str) -> object: ... def get_type(raw: list[int]) -> object: ... def oid_to_string(arg: str, /) -> str: ... @overload -def parse(filename: str, config: lief.PE.ParserConfig = ...) -> lief.PE.Binary | None: ... +def parse(filename: str, config: lief.PE.ParserConfig = ...) -> Optional[lief.PE.Binary]: ... @overload -def parse(raw: list[int], config: lief.PE.ParserConfig = ...) -> lief.PE.Binary | None: ... +def parse(raw: list[int], config: lief.PE.ParserConfig = ...) -> Optional[lief.PE.Binary]: ... @overload -def parse(io: object, config: lief.PE.ParserConfig = ...) -> lief.PE.Binary | None: ... +def parse(io: io.IOBase, config: lief.PE.ParserConfig = ...) -> lief.PE.Binary | None: ... def resolve_ordinals(imp: lief.PE.Import, strict: bool = ..., use_std: bool = ...) -> object: ... diff --git a/api/python/lief/VDEX.pyi b/api/python/lief/VDEX.pyi index ab876dc89f..21ee0f0095 100644 --- a/api/python/lief/VDEX.pyi +++ b/api/python/lief/VDEX.pyi @@ -1,8 +1,9 @@ +from typing import Optional + from typing import overload -import lief # type: ignore import lief.Android # type: ignore import lief.DEX # type: ignore -import lief.OAT # type: ignore +import lief.OAT.Binary # type: ignore import lief.VDEX # type: ignore class File(lief.Object): @@ -37,7 +38,7 @@ class Header(lief.Object): def android_version(vdex_version: int) -> lief.Android.ANDROID_VERSIONS: ... @overload -def parse(filename: str) -> lief.VDEX.File: ... +def parse(filename: str) -> Optional[lief.VDEX.File]: ... @overload def parse(io: object, name: str = ...) -> object: ... @overload diff --git a/api/python/lief/__init__.pyi b/api/python/lief/__init__.pyi index 25bd1cd385..1c391f193c 100644 --- a/api/python/lief/__init__.pyi +++ b/api/python/lief/__init__.pyi @@ -1,8 +1,12 @@ -from typing import Any, ClassVar, List +from typing import Any, ClassVar, Optional, Union -from . import ART, Android, DEX, ELF, MachO, OAT, PE, VDEX, logging # type: ignore from typing import overload import lief # type: ignore +import lief.Binary # type: ignore +import lief.ELF # type: ignore +import lief.Function # type: ignore +import lief.MachO # type: ignore +import lief.PE # type: ignore class ARCHITECTURES: ARM: ClassVar[ARCHITECTURES] = ... @@ -69,7 +73,7 @@ class Binary(Object): @property def concrete(self) -> lief.ELF.Binary | lief.PE.Binary | lief.MachO.Binary: ... @property - def ctor_functions(self) -> List[lief.Function]: ... + def ctor_functions(self) -> list[lief.Function]: ... @property def entrypoint(self) -> int: ... @property @@ -79,7 +83,7 @@ class Binary(Object): @property def has_nx(self) -> bool: ... @property - def header(self) -> Any: ... + def header(self) -> lief.Header: ... @property def imagebase(self) -> int: ... @property @@ -87,11 +91,11 @@ class Binary(Object): @property def is_pie(self) -> bool: ... @property - def libraries(self) -> Any: ... + def libraries(self) -> list[Union[str,bytes]]: ... @property def relocations(self) -> Any: ... @property - def sections(self) -> Any: ... + def sections(self) -> lief.Binary.it_sections: ... @property def symbols(self) -> Any: ... @@ -141,7 +145,7 @@ class Function(Symbol): def flags(self) -> list[lief.Function.FLAGS]: ... class Header(Object): - architecture: Any + architecture: lief.ARCHITECTURES endianness: lief.ENDIANNESS entrypoint: int modes: set[lief.MODES] @@ -212,7 +216,7 @@ class Relocation(Object): class Section(Object): content: memoryview - name: str | bytes + name: bytes | str offset: int size: int virtual_address: int @@ -299,9 +303,9 @@ def is_vdex(path: str) -> bool: ... @overload def is_vdex(raw: list[int]) -> bool: ... @overload -def parse(raw: bytes) -> lief.Binary: ... +def parse(raw: bytes) -> Optional[lief.Binary]: ... @overload -def parse(filepath: str) -> lief.Binary: ... +def parse(filepath: str) -> Optional[lief.Binary]: ... @overload def parse(io: object) -> object: ... def to_json(arg: lief.Object, /) -> str: ... diff --git a/api/python/src/Abstract/pyBinary.cpp b/api/python/src/Abstract/pyBinary.cpp index 19139383aa..cc4aec2963 100644 --- a/api/python/src/Abstract/pyBinary.cpp +++ b/api/python/src/Abstract/pyBinary.cpp @@ -115,7 +115,8 @@ void create(nb::module_& m) { &safe_string); return imported_libraries_encoded; }, - "Return binary's imported libraries (name)"_doc) + "Return binary's imported libraries (name)"_doc, + "(self) -> list[Union[str,bytes]]"_p) .def_prop_ro("symbols", nb::overload_cast<>(&Binary::symbols), @@ -192,6 +193,7 @@ void create(nb::module_& m) { R"delim( Return the abstract representation of the current binary (:class:`lief.Binary`) )delim"_doc, + "abstract(self) -> lief.Binary"_p, nb::rv_policy::reference_internal) .def_prop_ro("concrete", @@ -204,6 +206,7 @@ void create(nb::module_& m) { See also: :attr:`lief.Binary.abstract` )delim"_doc, + "concrete(self) -> lief.ELF.Binary | lief.PE.Binary | lief.MachO.Binary"_p, nb::rv_policy::reference) .def_prop_ro("ctor_functions", diff --git a/api/python/src/Abstract/pySection.cpp b/api/python/src/Abstract/pySection.cpp index c8d6723f4a..784d2dd221 100644 --- a/api/python/src/Abstract/pySection.cpp +++ b/api/python/src/Abstract/pySection.cpp @@ -39,6 +39,7 @@ void create
(nb::module_& m) { return safe_string(obj.name()); }, nb::overload_cast(&Section::name), + "(self) -> bytes | str"_p, "Section's name"_doc) .def_prop_ro("fullname", @@ -86,6 +87,7 @@ void create
(nb::module_& m) { return nb::cast(res); }, "Look for **integer** within the current section"_doc, + "search(self, number: int, pos: int = ..., size: int = ...) -> int | None"_p, "number"_a, "pos"_a = 0, "size"_a = 0) .def("search", @@ -99,6 +101,7 @@ void create
(nb::module_& m) { return nb::cast(res); }, "Look for **string** within the current section"_doc, + "search(self, str: str, pos: int = ...) -> int | None"_p, "str"_a, "pos"_a = 0) .def("search", @@ -117,6 +120,7 @@ void create
(nb::module_& m) { return nb::cast(res); }, "Look for the given bytes within the current section"_doc, + "search(self, bytes: bytes, pos: int = ...) -> int | None"_p, "bytes"_a, "pos"_a = 0) .def("search_all", diff --git a/api/python/src/ELF/objects/pyBinary.cpp b/api/python/src/ELF/objects/pyBinary.cpp index 874deeb3c0..c14534f6ee 100644 --- a/api/python/src/ELF/objects/pyBinary.cpp +++ b/api/python/src/ELF/objects/pyBinary.cpp @@ -640,6 +640,7 @@ void create(nb::module_& m) { }, "Return list of strings used in the current ELF file.\n" "Basically this function looks for strings in the ``.roadata`` section"_doc, + "(self) -> list[Union[str,bytes]]"_p, nb::rv_policy::move) .def("remove_static_symbol", diff --git a/api/python/src/ELF/objects/pyParser.cpp b/api/python/src/ELF/objects/pyParser.cpp index 3247962362..10e5e31519 100644 --- a/api/python/src/ELF/objects/pyParser.cpp +++ b/api/python/src/ELF/objects/pyParser.cpp @@ -39,8 +39,7 @@ void create(nb::module_& m) { The second argument is an optional configuration (:class:`~lief.ELF.ParserConfig`) that can be used to define which part(s) of the ELF should be parsed or skipped. - )delim"_doc, - "filename"_a, "config"_a = ParserConfig::all(), + )delim"_doc, "filename"_a, "config"_a = ParserConfig::all(), nb::rv_policy::take_ownership); m.def("parse", @@ -50,9 +49,7 @@ void create(nb::module_& m) { The second argument is an optional configuration (:class:`~lief.ELF.ParserConfig`) that can be used to define which part(s) of the ELF should be parsed or skipped. - )delim"_doc, - - "raw"_a, "config"_a = ParserConfig::all(), + )delim"_doc, "raw"_a, "config"_a = ParserConfig::all(), nb::rv_policy::take_ownership); @@ -71,6 +68,7 @@ void create(nb::module_& m) { The second argument is an optional configuration (:class:`~lief.ELF.ParserConfig`) that can be used to define which part(s) of the ELF should be parsed or skipped. )delim"_doc, + "parse(io: io.IOBase, config: lief.ELF.ParserConfig = ...) -> lief.ELF.Binary | None"_p, "io"_a, "config"_a = ParserConfig::all(), nb::rv_policy::take_ownership); } diff --git a/api/python/src/MachO/objects/pyParser.cpp b/api/python/src/MachO/objects/pyParser.cpp index 9bacf1524b..c71da87e53 100644 --- a/api/python/src/MachO/objects/pyParser.cpp +++ b/api/python/src/MachO/objects/pyParser.cpp @@ -72,7 +72,9 @@ void create(nb::module_& m) { Parse the given binary from a Python IO interface and return a :class:`~lief.MachO.FatBinary` object One can configure the parsing with the ``config`` parameter. See :class:`~lief.MachO.ParserConfig` - )delim"_doc, "io"_a, "config"_a = ParserConfig::quick(), + )delim"_doc, + "io"_a, "config"_a = ParserConfig::quick(), + "parse(io: io.IOBase, config: lief.MachO.ParserConfig = ...) -> lief.MachO.FatBinary | None"_p, nb::rv_policy::take_ownership); } diff --git a/api/python/src/PE/objects/pyBinary.cpp b/api/python/src/PE/objects/pyBinary.cpp index d9efcd0379..08063b7b01 100644 --- a/api/python/src/PE/objects/pyBinary.cpp +++ b/api/python/src/PE/objects/pyBinary.cpp @@ -359,7 +359,8 @@ void create(nb::module_& m) { [] (Binary& self) { return error_or(&Binary::resources_manager, self); }, - "Return the " RST_CLASS_REF(lief.PE.ResourcesManager) " to manage resources"_doc) + "Return the " RST_CLASS_REF(lief.PE.ResourcesManager) " to manage resources"_doc, + "(self) -> lief.PE.ResourcesManager | lief.lief_errors"_p) .def_prop_ro("resources", nb::overload_cast<>(&Binary::resources), diff --git a/api/python/src/PE/objects/pyParser.cpp b/api/python/src/PE/objects/pyParser.cpp index 074362d555..d2e5ddedc1 100644 --- a/api/python/src/PE/objects/pyParser.cpp +++ b/api/python/src/PE/objects/pyParser.cpp @@ -58,6 +58,7 @@ void create(nb::module_& m) { }, "Parse the PE binary from the given Python IO interface and return a :class:`lief.PE.Binary` object"_doc, "io"_a, "config"_a = ParserConfig::all(), + "parse(io: io.IOBase, config: lief.PE.ParserConfig = ...) -> lief.PE.Binary | None"_p, nb::rv_policy::take_ownership); } diff --git a/api/python/src/PE/objects/signature/pySignature.cpp b/api/python/src/PE/objects/signature/pySignature.cpp index f55ff7e0a9..5b13dde610 100644 --- a/api/python/src/PE/objects/signature/pySignature.cpp +++ b/api/python/src/PE/objects/signature/pySignature.cpp @@ -116,6 +116,7 @@ void create(nb::module_& m) { return nb::cast(sig.value()); }, "Parse the DER PKCS #7 signature from the file path given in the first parameter"_doc, + "parse(path: str) -> lief.PE.Binary | None"_p, "path"_a) .def_static("parse", @@ -127,6 +128,7 @@ void create(nb::module_& m) { return nb::cast(sig.value()); }, "Parse the raw (DER) PKCS #7 signature given in the first parameter"_doc, + "parse(raw: list[int], skip_header: bool = ...) -> lief.PE.Binary | None"_p, "raw"_a, "skip_header"_a = false) .def_prop_ro("version", diff --git a/api/python/src/PE/objects/signature/pyx509.cpp b/api/python/src/PE/objects/signature/pyx509.cpp index 7ca61c8346..6170122da5 100644 --- a/api/python/src/PE/objects/signature/pyx509.cpp +++ b/api/python/src/PE/objects/signature/pyx509.cpp @@ -193,7 +193,7 @@ void create(nb::module_& m) { .. code-block:: python signer = binary.signatures[0].signers[0] - microsoft_ca_bundle lief.PE.x509.parse("bundle.pem") + microsoft_ca_bundle = lief.PE.x509.parse("bundle.pem") print(signer.cert.is_trusted_by(microsoft_ca_bundle)) )delim"_doc, "ca_list"_a) diff --git a/third-party/nanobind-1.6.2.r7.gb4c5af0.zip b/third-party/nanobind-1.6.2.r20.g46ed29e.zip similarity index 85% rename from third-party/nanobind-1.6.2.r7.gb4c5af0.zip rename to third-party/nanobind-1.6.2.r20.g46ed29e.zip index 8bf8bf0424..c392b89d52 100644 Binary files a/third-party/nanobind-1.6.2.r7.gb4c5af0.zip and b/third-party/nanobind-1.6.2.r20.g46ed29e.zip differ