Skip to content

Commit fbc983c

Browse files
committed
ruff fmt
1 parent f5fb2f6 commit fbc983c

File tree

3 files changed

+34
-10
lines changed

3 files changed

+34
-10
lines changed

crackers_python/crackers/config/library.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
1+
from typing import List
2+
13
from pydantic import BaseModel
24

35

6+
class LoadedLibraryConfig(BaseModel):
7+
"""
8+
Represents an additional library to load alongside the main library.
9+
10+
Attributes:
11+
path (str): Filesystem path of the target binary.
12+
base_address (int | None): Optional base address for loading the library (may be adjusted/aligned on the Rust side).
13+
"""
14+
15+
path: str
16+
base_address: int | None
17+
18+
419
class LibraryConfig(BaseModel):
520
"""
621
Configuration for a binary library used in analysis or exploitation.
@@ -10,9 +25,11 @@ class LibraryConfig(BaseModel):
1025
path (str): Filesystem path of the target binary.
1126
sample_size (int | None): Maximum number of gadgets to randomly sample (None to use all gadgets).
1227
base_address (int | None): Base address for loading the library, or None if not specified.
28+
loaded_libraries (list[LoadedLibraryConfig] | None): Optional additional libraries to load alongside the primary one.
1329
"""
1430

1531
max_gadget_length: int
1632
path: str
1733
sample_size: int | None
1834
base_address: int | None
35+
loaded_libraries: list[LoadedLibraryConfig] | None

crackers_python/crackers/crackers.pyi

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Callable, Iterable, Optional, Union
1+
from typing import Callable, Dict, Iterable, List, Optional, Tuple, Union
22

33
from z3 import z3 # type: ignore
44

@@ -65,11 +65,16 @@ class CrackersLogLevel:
6565
Trace: int
6666
Warn: int
6767

68+
class LoadedLibraryConfig:
69+
path: str
70+
base_address: Optional[int]
71+
6872
class GadgetLibraryConfig:
6973
max_gadget_length: int
7074
path: str
7175
sample_size: Optional[int]
7276
base_address: Optional[int]
77+
loaded_libraries: Optional[List[LoadedLibraryConfig]]
7378

7479
class MemoryEqualityConstraint:
7580
space: str
@@ -91,7 +96,7 @@ class PointerRangeConstraints:
9196
class SleighConfig:
9297
ghidra_path: str
9398

94-
# New: represent the two possible shapes of the specification
99+
# Represent the two possible shapes of the specification
95100
class BinaryFileSpecification:
96101
"""
97102
Represents the binary-file variant of the specification.
@@ -110,7 +115,7 @@ class RawPcodeSpecification:
110115

111116
raw_pcode: str
112117

113-
# SpecificationConfig is now a discriminated union of the two variants above.
118+
# SpecificationConfig is a discriminated union of the two variants above.
114119
SpecificationConfig = Union[BinaryFileSpecification, RawPcodeSpecification]
115120

116121
class StateEqualityConstraint:
@@ -137,7 +142,7 @@ class SelectionFailure:
137142

138143
class PythonDecisionResult_Unsat(DecisionResult):
139144
_0: SelectionFailure
140-
pass
145+
__match_args__ = ("_0",)
141146

142147
class DecisionResult:
143148
AssignmentFound: PythonDecisionResult_AssignmentFound
@@ -151,8 +156,7 @@ StateConstraintGenerator = Callable[[State, int], z3.BoolRef]
151156
TransitionConstraintGenerator = Callable[[ModeledBlock], z3.BoolRef]
152157

153158
class SynthesisParams:
154-
def run(self) -> "DecisionResultType": ...
155-
def add_precondition(self, fn: StateConstraintGenerator): ...
156-
def add_postcondition(self, fn: StateConstraintGenerator): ...
157-
def add_transition_constraint(self, fn: TransitionConstraintGenerator): ...
158-
pass
159+
def run(self) -> DecisionResultType: ...
160+
def add_precondition(self, fn: StateConstraintGenerator) -> None: ...
161+
def add_postcondition(self, fn: StateConstraintGenerator) -> None: ...
162+
def add_transition_constraint(self, fn: TransitionConstraintGenerator) -> None: ...

crackers_python/gh_actions_setup.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,10 @@ def install_z3_glibc(target_platform):
6969
github_token = os.environ.get("READ_ONLY_GITHUB_TOKEN")
7070
if github_token:
7171
request.add_header("Authorization", f"Bearer {github_token}")
72-
print("Using GitHub PAT from READ_ONLY_GITHUB_TOKEN for API authentication.", file=sys.stderr)
72+
print(
73+
"Using GitHub PAT from READ_ONLY_GITHUB_TOKEN for API authentication.",
74+
file=sys.stderr,
75+
)
7376

7477
with urllib.request.urlopen(request) as response:
7578
data = json.loads(response.read().decode())

0 commit comments

Comments
 (0)