diff --git a/src/patcherex2/__init__.py b/src/patcherex2/__init__.py index 345f074..ef5554d 100644 --- a/src/patcherex2/__init__.py +++ b/src/patcherex2/__init__.py @@ -1,2 +1,5 @@ +# ruff: noqa from .patcherex import Patcherex from .patches import * + +__all__ = ["Patcherex"] + patches.__all__ diff --git a/src/patcherex2/components/allocation_managers/__init__.py b/src/patcherex2/components/allocation_managers/__init__.py index fed4d62..e69de29 100644 --- a/src/patcherex2/components/allocation_managers/__init__.py +++ b/src/patcherex2/components/allocation_managers/__init__.py @@ -1 +0,0 @@ -from .allocation_manager import * diff --git a/src/patcherex2/components/binfmt_tools/elf.py b/src/patcherex2/components/binfmt_tools/elf.py index 8387972..e202234 100644 --- a/src/patcherex2/components/binfmt_tools/elf.py +++ b/src/patcherex2/components/binfmt_tools/elf.py @@ -5,7 +5,12 @@ from elftools.elf.constants import P_FLAGS, SH_FLAGS from elftools.elf.elffile import ELFFile -from ..allocation_managers import * +from ..allocation_managers.allocation_manager import ( + FileBlock, + MappedBlock, + MemoryBlock, + MemoryFlag, +) from .binfmt_tool import BinFmtTool logger = logging.getLogger(__name__) diff --git a/src/patcherex2/components/binfmt_tools/ihex.py b/src/patcherex2/components/binfmt_tools/ihex.py index 9b5ec71..6303a72 100644 --- a/src/patcherex2/components/binfmt_tools/ihex.py +++ b/src/patcherex2/components/binfmt_tools/ihex.py @@ -3,7 +3,6 @@ import intelhex -from ..allocation_managers import * from .binfmt_tool import BinFmtTool logger = logging.getLogger(__name__) diff --git a/src/patcherex2/components/patch_managers/__init__.py b/src/patcherex2/components/patch_managers/__init__.py index 9ea2376..2917eaf 100644 --- a/src/patcherex2/components/patch_managers/__init__.py +++ b/src/patcherex2/components/patch_managers/__init__.py @@ -1,3 +1,5 @@ from .builtin import BuiltIn from .imp import Imp from .patch_manager import PatchManager + +__all__ = ["BuiltIn", "Imp", "PatchManager"] diff --git a/src/patcherex2/patcherex.py b/src/patcherex2/patcherex.py index 89c7a77..33efb9b 100644 --- a/src/patcherex2/patcherex.py +++ b/src/patcherex2/patcherex.py @@ -1,7 +1,6 @@ import logging -from .components.allocation_managers import * -from .patches import * +from .patches import InsertDataPatch, ModifyDataPatch, RemoveDataPatch from .targets import Target logger = logging.getLogger(__name__) diff --git a/src/patcherex2/patches/__init__.py b/src/patcherex2/patches/__init__.py index 7b7a8d9..183166b 100644 --- a/src/patcherex2/patches/__init__.py +++ b/src/patcherex2/patches/__init__.py @@ -1,8 +1,33 @@ -from .data_patches import * -from .dummy_patches import * -from .function_patches import * -from .instruction_patches import * -from .raw_patches import * +from .data_patches import InsertDataPatch, ModifyDataPatch, RemoveDataPatch +from .dummy_patches import InsertLabelPatch, ModifyLabelPatch, RemoveLabelPatch +from .function_patches import ( + InsertFunctionPatch, + ModifyFunctionPatch, + RemoveFunctionPatch, +) +from .instruction_patches import ( + InsertInstructionPatch, + ModifyInstructionPatch, + RemoveInstructionPatch, +) +from .patch import Patch +from .raw_patches import ModifyRawBytesPatch + +__all__ = [ + "ModifyDataPatch", + "InsertDataPatch", + "RemoveDataPatch", + "InsertLabelPatch", + "ModifyLabelPatch", + "RemoveLabelPatch", + "ModifyFunctionPatch", + "InsertFunctionPatch", + "RemoveFunctionPatch", + "ModifyInstructionPatch", + "InsertInstructionPatch", + "RemoveInstructionPatch", + "ModifyRawBytesPatch", +] # Other Patches diff --git a/src/patcherex2/targets/__init__.py b/src/patcherex2/targets/__init__.py index 176df61..f03d57a 100644 --- a/src/patcherex2/targets/__init__.py +++ b/src/patcherex2/targets/__init__.py @@ -4,3 +4,12 @@ from .elf_leon3_bare import ElfLeon3Bare from .ihex_ppc_bare import IHex_PPC_Bare from .target import Target + +__all__ = [ + "ElfAArch64Linux", + "ElfArmLinux", + "ElfArmMimxrt1052", + "ElfLeon3Bare", + "IHex_PPC_Bare", + "Target", +] diff --git a/src/patcherex2/targets/elf_aarch64_linux.py b/src/patcherex2/targets/elf_aarch64_linux.py index d234917..b67b7db 100644 --- a/src/patcherex2/targets/elf_aarch64_linux.py +++ b/src/patcherex2/targets/elf_aarch64_linux.py @@ -1,5 +1,4 @@ -from ..components.allocation_managers.allocation_manager import \ - AllocationManager +from ..components.allocation_managers.allocation_manager import AllocationManager from ..components.assemblers.keystone import Keystone, keystone from ..components.binary_analyzers.angr import Angr from ..components.binfmt_tools.elf import ELF diff --git a/src/patcherex2/targets/elf_arm_linux.py b/src/patcherex2/targets/elf_arm_linux.py index ea12f70..5d7efb5 100644 --- a/src/patcherex2/targets/elf_arm_linux.py +++ b/src/patcherex2/targets/elf_arm_linux.py @@ -1,5 +1,4 @@ -from ..components.allocation_managers.allocation_manager import \ - AllocationManager +from ..components.allocation_managers.allocation_manager import AllocationManager from ..components.assemblers.keystone_arm import KeystoneArm from ..components.binary_analyzers.angr import Angr from ..components.binfmt_tools.elf import ELF diff --git a/src/patcherex2/targets/elf_arm_mimxrt1052.py b/src/patcherex2/targets/elf_arm_mimxrt1052.py index ff78337..19bc492 100644 --- a/src/patcherex2/targets/elf_arm_mimxrt1052.py +++ b/src/patcherex2/targets/elf_arm_mimxrt1052.py @@ -1,6 +1,6 @@ import copy -from ..components.allocation_managers.allocation_manager import * +from ..components.allocation_managers.allocation_manager import MappedBlock, MemoryFlag from ..components.binfmt_tools.elf import ELF from .elf_arm_linux import ElfArmLinux diff --git a/src/patcherex2/targets/elf_leon3_bare.py b/src/patcherex2/targets/elf_leon3_bare.py index 7cd41cc..9e447b4 100644 --- a/src/patcherex2/targets/elf_leon3_bare.py +++ b/src/patcherex2/targets/elf_leon3_bare.py @@ -1,6 +1,10 @@ import logging -from ..components.allocation_managers.allocation_manager import * +from ..components.allocation_managers.allocation_manager import ( + AllocationManager, + MappedBlock, + MemoryFlag, +) from ..components.assemblers.bcc import Bcc as BccAssembler from ..components.assemblers.keystone_sparc import KeystoneSparc, keystone from ..components.binary_analyzers.angr import Angr diff --git a/src/patcherex2/targets/ihex_ppc_bare.py b/src/patcherex2/targets/ihex_ppc_bare.py index 7a20ede..51a5da4 100644 --- a/src/patcherex2/targets/ihex_ppc_bare.py +++ b/src/patcherex2/targets/ihex_ppc_bare.py @@ -1,6 +1,8 @@ import logging -from ..components.allocation_managers.allocation_manager import * +import archinfo + +from ..components.allocation_managers.allocation_manager import AllocationManager from ..components.assemblers.ppc_vle import PpcVle as PpcVleAssembler from ..components.binary_analyzers.angr import Angr from ..components.binfmt_tools.ihex import IHex diff --git a/tests/test_aarch64.py b/tests/test_aarch64.py index ea99276..3ef1001 100755 --- a/tests/test_aarch64.py +++ b/tests/test_aarch64.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +# ruff: noqa import logging import os import shutil diff --git a/tests/test_arm.py b/tests/test_arm.py index 5ae9ef9..bda7c0f 100755 --- a/tests/test_arm.py +++ b/tests/test_arm.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +# ruff: noqa import logging import os import shutil