angr 9.2.101__py3-none-manylinux2014_x86_64.whl → 9.2.103__py3-none-manylinux2014_x86_64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of angr might be problematic. Click here for more details.

Files changed (239) hide show
  1. angr/__init__.py +1 -1
  2. angr/analyses/analysis.py +7 -6
  3. angr/analyses/calling_convention.py +33 -35
  4. angr/analyses/cdg.py +2 -4
  5. angr/analyses/cfg/cfb.py +4 -3
  6. angr/analyses/cfg/cfg_base.py +14 -14
  7. angr/analyses/cfg/cfg_emulated.py +3 -4
  8. angr/analyses/cfg/cfg_fast.py +46 -46
  9. angr/analyses/cfg/cfg_fast_soot.py +1 -2
  10. angr/analyses/cfg/cfg_job_base.py +2 -2
  11. angr/analyses/cfg/indirect_jump_resolvers/jumptable.py +14 -13
  12. angr/analyses/cfg/indirect_jump_resolvers/mips_elf_fast.py +5 -5
  13. angr/analyses/cfg_slice_to_sink/cfg_slice_to_sink.py +3 -3
  14. angr/analyses/complete_calling_conventions.py +13 -12
  15. angr/analyses/data_dep/data_dependency_analysis.py +24 -24
  16. angr/analyses/data_dep/dep_nodes.py +3 -3
  17. angr/analyses/ddg.py +1 -2
  18. angr/analyses/decompiler/ail_simplifier.py +35 -34
  19. angr/analyses/decompiler/block_io_finder.py +20 -20
  20. angr/analyses/decompiler/block_similarity.py +4 -6
  21. angr/analyses/decompiler/block_simplifier.py +17 -16
  22. angr/analyses/decompiler/callsite_maker.py +25 -10
  23. angr/analyses/decompiler/ccall_rewriters/amd64_ccalls.py +1 -3
  24. angr/analyses/decompiler/ccall_rewriters/rewriter_base.py +2 -4
  25. angr/analyses/decompiler/clinic.py +250 -45
  26. angr/analyses/decompiler/condition_processor.py +15 -8
  27. angr/analyses/decompiler/decompilation_cache.py +7 -7
  28. angr/analyses/decompiler/decompilation_options.py +4 -4
  29. angr/analyses/decompiler/decompiler.py +19 -15
  30. angr/analyses/decompiler/expression_counters.py +10 -9
  31. angr/analyses/decompiler/goto_manager.py +2 -4
  32. angr/analyses/decompiler/graph_region.py +9 -9
  33. angr/analyses/decompiler/jump_target_collector.py +1 -2
  34. angr/analyses/decompiler/optimization_passes/__init__.py +4 -3
  35. angr/analyses/decompiler/optimization_passes/code_motion.py +5 -6
  36. angr/analyses/decompiler/optimization_passes/const_derefs.py +4 -4
  37. angr/analyses/decompiler/optimization_passes/deadblock_remover.py +73 -0
  38. angr/analyses/decompiler/optimization_passes/engine_base.py +25 -3
  39. angr/analyses/decompiler/optimization_passes/expr_op_swapper.py +6 -5
  40. angr/analyses/decompiler/optimization_passes/flip_boolean_cmp.py +2 -2
  41. angr/analyses/decompiler/optimization_passes/inlined_string_transformation_simplifier.py +3 -0
  42. angr/analyses/decompiler/optimization_passes/ite_expr_converter.py +2 -2
  43. angr/analyses/decompiler/optimization_passes/lowered_switch_simplifier.py +17 -17
  44. angr/analyses/decompiler/optimization_passes/optimization_pass.py +12 -13
  45. angr/analyses/decompiler/optimization_passes/register_save_area_simplifier.py +25 -21
  46. angr/analyses/decompiler/optimization_passes/ret_addr_save_simplifier.py +3 -3
  47. angr/analyses/decompiler/optimization_passes/ret_deduplicator.py +1 -2
  48. angr/analyses/decompiler/optimization_passes/return_duplicator_base.py +7 -7
  49. angr/analyses/decompiler/optimization_passes/spilled_register_finder.py +18 -0
  50. angr/analyses/decompiler/optimization_passes/stack_canary_simplifier.py +2 -3
  51. angr/analyses/decompiler/optimization_passes/win_stack_canary_simplifier.py +1 -2
  52. angr/analyses/decompiler/optimization_passes/x86_gcc_getpc_simplifier.py +2 -2
  53. angr/analyses/decompiler/peephole_optimizations/__init__.py +4 -3
  54. angr/analyses/decompiler/peephole_optimizations/base.py +13 -15
  55. angr/analyses/decompiler/peephole_optimizations/bswap.py +1 -3
  56. angr/analyses/decompiler/peephole_optimizations/cmpord_rewriter.py +72 -0
  57. angr/analyses/decompiler/peephole_optimizations/const_mull_a_shift.py +1 -2
  58. angr/analyses/decompiler/peephole_optimizations/eager_eval.py +1 -1
  59. angr/analyses/decompiler/peephole_optimizations/inlined_strcpy.py +5 -10
  60. angr/analyses/decompiler/peephole_optimizations/inlined_strcpy_consolidation.py +3 -4
  61. angr/analyses/decompiler/peephole_optimizations/inlined_wstrcpy.py +7 -10
  62. angr/analyses/decompiler/peephole_optimizations/rewrite_bit_extractions.py +2 -3
  63. angr/analyses/decompiler/peephole_optimizations/sar_to_signed_div.py +1 -2
  64. angr/analyses/decompiler/peephole_optimizations/tidy_stack_addr.py +4 -4
  65. angr/analyses/decompiler/redundant_label_remover.py +4 -5
  66. angr/analyses/decompiler/region_identifier.py +4 -5
  67. angr/analyses/decompiler/region_simplifiers/cascading_cond_transformer.py +1 -2
  68. angr/analyses/decompiler/region_simplifiers/expr_folding.py +19 -20
  69. angr/analyses/decompiler/region_simplifiers/goto.py +2 -3
  70. angr/analyses/decompiler/region_simplifiers/loop.py +1 -2
  71. angr/analyses/decompiler/region_simplifiers/node_address_finder.py +1 -2
  72. angr/analyses/decompiler/region_simplifiers/region_simplifier.py +1 -3
  73. angr/analyses/decompiler/region_simplifiers/switch_cluster_simplifier.py +19 -19
  74. angr/analyses/decompiler/return_maker.py +1 -2
  75. angr/analyses/decompiler/structured_codegen/base.py +5 -6
  76. angr/analyses/decompiler/structured_codegen/c.py +39 -38
  77. angr/analyses/decompiler/structuring/__init__.py +1 -1
  78. angr/analyses/decompiler/structuring/dream.py +17 -16
  79. angr/analyses/decompiler/structuring/phoenix.py +45 -46
  80. angr/analyses/decompiler/structuring/recursive_structurer.py +4 -4
  81. angr/analyses/decompiler/structuring/structurer_base.py +16 -15
  82. angr/analyses/decompiler/structuring/structurer_nodes.py +10 -9
  83. angr/analyses/decompiler/utils.py +17 -16
  84. angr/analyses/disassembly.py +7 -6
  85. angr/analyses/flirt.py +9 -9
  86. angr/analyses/forward_analysis/forward_analysis.py +15 -14
  87. angr/analyses/forward_analysis/visitors/function_graph.py +1 -2
  88. angr/analyses/forward_analysis/visitors/graph.py +16 -15
  89. angr/analyses/propagator/engine_ail.py +30 -26
  90. angr/analyses/propagator/outdated_definition_walker.py +8 -7
  91. angr/analyses/propagator/propagator.py +11 -13
  92. angr/analyses/proximity_graph.py +21 -21
  93. angr/analyses/reaching_definitions/__init__.py +3 -3
  94. angr/analyses/reaching_definitions/call_trace.py +3 -6
  95. angr/analyses/reaching_definitions/dep_graph.py +41 -48
  96. angr/analyses/reaching_definitions/engine_ail.py +11 -5
  97. angr/analyses/reaching_definitions/engine_vex.py +9 -8
  98. angr/analyses/reaching_definitions/function_handler.py +51 -34
  99. angr/analyses/reaching_definitions/heap_allocator.py +3 -4
  100. angr/analyses/reaching_definitions/rd_initializer.py +8 -8
  101. angr/analyses/reaching_definitions/rd_state.py +57 -58
  102. angr/analyses/reaching_definitions/reaching_definitions.py +18 -17
  103. angr/analyses/reaching_definitions/subject.py +2 -3
  104. angr/analyses/stack_pointer_tracker.py +15 -6
  105. angr/analyses/typehoon/dfa.py +4 -4
  106. angr/analyses/typehoon/simple_solver.py +48 -52
  107. angr/analyses/typehoon/translator.py +3 -6
  108. angr/analyses/typehoon/typeconsts.py +13 -14
  109. angr/analyses/typehoon/typehoon.py +9 -9
  110. angr/analyses/typehoon/typevars.py +18 -17
  111. angr/analyses/variable_recovery/engine_ail.py +5 -5
  112. angr/analyses/variable_recovery/engine_base.py +25 -21
  113. angr/analyses/variable_recovery/irsb_scanner.py +8 -9
  114. angr/analyses/variable_recovery/variable_recovery.py +1 -2
  115. angr/analyses/variable_recovery/variable_recovery_base.py +14 -13
  116. angr/analyses/variable_recovery/variable_recovery_fast.py +8 -8
  117. angr/analyses/veritesting.py +1 -2
  118. angr/analyses/vfg.py +57 -56
  119. angr/analyses/xrefs.py +1 -2
  120. angr/angrdb/db.py +7 -7
  121. angr/angrdb/serializers/kb.py +16 -13
  122. angr/angrdb/serializers/loader.py +1 -2
  123. angr/angrdb/serializers/structured_code.py +2 -2
  124. angr/annocfg.py +1 -2
  125. angr/block.py +16 -6
  126. angr/calling_conventions.py +27 -27
  127. angr/code_location.py +8 -8
  128. angr/codenode.py +1 -2
  129. angr/concretization_strategies/max.py +1 -3
  130. angr/distributed/server.py +1 -3
  131. angr/distributed/worker.py +1 -2
  132. angr/engines/engine.py +2 -3
  133. angr/engines/light/engine.py +4 -4
  134. angr/engines/pcode/behavior.py +20 -2
  135. angr/engines/pcode/emulate.py +1 -1
  136. angr/engines/pcode/engine.py +7 -7
  137. angr/engines/pcode/lifter.py +78 -77
  138. angr/engines/vex/claripy/ccall.py +1 -2
  139. angr/engines/vex/claripy/datalayer.py +1 -2
  140. angr/engines/vex/light/light.py +1 -2
  141. angr/exploration_techniques/tracer.py +4 -4
  142. angr/factory.py +12 -15
  143. angr/flirt/__init__.py +8 -8
  144. angr/flirt/build_sig.py +2 -3
  145. angr/keyed_region.py +2 -2
  146. angr/knowledge_base/knowledge_base.py +3 -3
  147. angr/knowledge_plugins/callsite_prototypes.py +4 -6
  148. angr/knowledge_plugins/cfg/cfg_manager.py +19 -6
  149. angr/knowledge_plugins/cfg/cfg_model.py +26 -27
  150. angr/knowledge_plugins/cfg/cfg_node.py +2 -2
  151. angr/knowledge_plugins/cfg/indirect_jump.py +6 -8
  152. angr/knowledge_plugins/cfg/memory_data.py +8 -9
  153. angr/knowledge_plugins/custom_strings.py +1 -3
  154. angr/knowledge_plugins/debug_variables.py +2 -2
  155. angr/knowledge_plugins/functions/function.py +21 -22
  156. angr/knowledge_plugins/functions/function_manager.py +5 -5
  157. angr/knowledge_plugins/indirect_jumps.py +1 -3
  158. angr/knowledge_plugins/key_definitions/atoms.py +7 -7
  159. angr/knowledge_plugins/key_definitions/definition.py +14 -14
  160. angr/knowledge_plugins/key_definitions/environment.py +5 -7
  161. angr/knowledge_plugins/key_definitions/heap_address.py +1 -3
  162. angr/knowledge_plugins/key_definitions/key_definition_manager.py +3 -2
  163. angr/knowledge_plugins/key_definitions/live_definitions.py +60 -59
  164. angr/knowledge_plugins/key_definitions/liveness.py +16 -16
  165. angr/knowledge_plugins/key_definitions/rd_model.py +15 -15
  166. angr/knowledge_plugins/key_definitions/uses.py +11 -11
  167. angr/knowledge_plugins/patches.py +4 -8
  168. angr/knowledge_plugins/propagations/prop_value.py +10 -9
  169. angr/knowledge_plugins/propagations/propagation_manager.py +3 -5
  170. angr/knowledge_plugins/propagations/propagation_model.py +9 -9
  171. angr/knowledge_plugins/propagations/states.py +52 -22
  172. angr/knowledge_plugins/structured_code/manager.py +2 -2
  173. angr/knowledge_plugins/sync/sync_controller.py +3 -3
  174. angr/knowledge_plugins/variables/variable_access.py +4 -4
  175. angr/knowledge_plugins/variables/variable_manager.py +56 -39
  176. angr/knowledge_plugins/xrefs/xref.py +9 -11
  177. angr/knowledge_plugins/xrefs/xref_manager.py +3 -4
  178. angr/misc/ansi.py +1 -2
  179. angr/misc/autoimport.py +3 -3
  180. angr/misc/plugins.py +9 -9
  181. angr/procedures/definitions/__init__.py +16 -16
  182. angr/procedures/definitions/linux_kernel.py +1 -1
  183. angr/procedures/definitions/parse_win32json.py +1 -1
  184. angr/procedures/java_jni/__init__.py +1 -1
  185. angr/procedures/java_jni/array_operations.py +1 -2
  186. angr/procedures/java_jni/method_calls.py +1 -2
  187. angr/procedures/posix/inet_ntoa.py +1 -2
  188. angr/procedures/stubs/format_parser.py +3 -3
  189. angr/project.py +13 -11
  190. angr/sim_manager.py +12 -12
  191. angr/sim_procedure.py +7 -3
  192. angr/sim_state.py +2 -2
  193. angr/sim_type.py +60 -45
  194. angr/sim_variable.py +5 -5
  195. angr/simos/simos.py +1 -2
  196. angr/simos/userland.py +1 -2
  197. angr/state_plugins/callstack.py +3 -2
  198. angr/state_plugins/history.py +1 -2
  199. angr/state_plugins/solver.py +34 -34
  200. angr/storage/memory_mixins/__init__.py +4 -3
  201. angr/storage/memory_mixins/actions_mixin.py +1 -3
  202. angr/storage/memory_mixins/address_concretization_mixin.py +1 -3
  203. angr/storage/memory_mixins/convenient_mappings_mixin.py +3 -4
  204. angr/storage/memory_mixins/default_filler_mixin.py +1 -1
  205. angr/storage/memory_mixins/label_merger_mixin.py +2 -2
  206. angr/storage/memory_mixins/multi_value_merger_mixin.py +4 -3
  207. angr/storage/memory_mixins/paged_memory/page_backer_mixins.py +9 -8
  208. angr/storage/memory_mixins/paged_memory/paged_memory_mixin.py +12 -11
  209. angr/storage/memory_mixins/paged_memory/pages/cooperation.py +8 -8
  210. angr/storage/memory_mixins/paged_memory/pages/history_tracking_mixin.py +2 -3
  211. angr/storage/memory_mixins/paged_memory/pages/list_page.py +10 -11
  212. angr/storage/memory_mixins/paged_memory/pages/multi_values.py +11 -10
  213. angr/storage/memory_mixins/paged_memory/pages/mv_list_page.py +18 -17
  214. angr/storage/memory_mixins/paged_memory/pages/ultra_page.py +12 -11
  215. angr/storage/memory_mixins/regioned_memory/abstract_address_descriptor.py +3 -3
  216. angr/storage/memory_mixins/regioned_memory/abstract_merger_mixin.py +3 -2
  217. angr/storage/memory_mixins/regioned_memory/region_data.py +1 -2
  218. angr/storage/memory_mixins/regioned_memory/region_meta_mixin.py +2 -2
  219. angr/storage/memory_mixins/regioned_memory/regioned_address_concretization_mixin.py +3 -3
  220. angr/storage/memory_mixins/regioned_memory/regioned_memory_mixin.py +18 -21
  221. angr/storage/memory_mixins/size_resolution_mixin.py +1 -2
  222. angr/storage/memory_mixins/symbolic_merger_mixin.py +3 -2
  223. angr/storage/memory_mixins/top_merger_mixin.py +3 -2
  224. angr/storage/memory_object.py +2 -4
  225. angr/utils/algo.py +3 -2
  226. angr/utils/dynamic_dictlist.py +5 -5
  227. angr/utils/formatting.py +4 -4
  228. angr/utils/funcid.py +1 -2
  229. angr/utils/graph.py +5 -6
  230. angr/utils/library.py +5 -5
  231. angr/utils/mp.py +5 -4
  232. angr/utils/segment_list.py +3 -4
  233. angr/utils/typing.py +3 -2
  234. {angr-9.2.101.dist-info → angr-9.2.103.dist-info}/METADATA +9 -11
  235. {angr-9.2.101.dist-info → angr-9.2.103.dist-info}/RECORD +239 -236
  236. {angr-9.2.101.dist-info → angr-9.2.103.dist-info}/LICENSE +0 -0
  237. {angr-9.2.101.dist-info → angr-9.2.103.dist-info}/WHEEL +0 -0
  238. {angr-9.2.101.dist-info → angr-9.2.103.dist-info}/entry_points.txt +0 -0
  239. {angr-9.2.101.dist-info → angr-9.2.103.dist-info}/top_level.txt +0 -0
@@ -6,7 +6,8 @@
6
6
  # - Fix/remove NotImplementedError's
7
7
 
8
8
  import logging
9
- from typing import Union, Optional, Iterable, Sequence, Tuple
9
+ from typing import Optional
10
+ from collections.abc import Iterable, Sequence
10
11
 
11
12
  import archinfo
12
13
  from archinfo import ArchARM, ArchPcode
@@ -49,10 +50,10 @@ class ExitStatement:
49
50
 
50
51
  __slots__ = ("dst", "jumpkind")
51
52
 
52
- dst: Optional[int]
53
+ dst: int | None
53
54
  jumpkind: str
54
55
 
55
- def __init__(self, dst: Optional[int], jumpkind: str):
56
+ def __init__(self, dst: int | None, jumpkind: str):
56
57
  self.dst = dst
57
58
  self.jumpkind = jumpkind
58
59
 
@@ -125,20 +126,20 @@ class IRSB:
125
126
  "next",
126
127
  )
127
128
 
128
- _direct_next: Optional[bool]
129
- _exit_statements: Sequence[Tuple[int, int, ExitStatement]]
130
- _instruction_addresses: Optional[Sequence[int]]
129
+ _direct_next: bool | None
130
+ _exit_statements: Sequence[tuple[int, int, ExitStatement]]
131
+ _instruction_addresses: Sequence[int] | None
131
132
  _ops: Sequence["pypcode.PcodeOp"] # FIXME: Merge into _statements
132
- _size: Optional[int]
133
+ _size: int | None
133
134
  _statements: Iterable # Note: currently unused
134
- _disassembly: Optional[PcodeDisassemblerBlock]
135
+ _disassembly: PcodeDisassemblerBlock | None
135
136
  addr: int
136
137
  arch: archinfo.Arch
137
- behaviors: Optional[BehaviorFactory]
138
+ behaviors: BehaviorFactory | None
138
139
  data_refs: Sequence # Note: currently unused
139
140
  default_exit_target: Optional # Note: currently used
140
- jumpkind: Optional[str]
141
- next: Optional[int]
141
+ jumpkind: str | None
142
+ next: int | None
142
143
 
143
144
  # The following constants shall match the defs in pyvex.h
144
145
  MAX_EXITS = 400
@@ -146,16 +147,16 @@ class IRSB:
146
147
 
147
148
  def __init__(
148
149
  self,
149
- data: Union[str, bytes, None],
150
+ data: str | bytes | None,
150
151
  mem_addr: int,
151
152
  arch: archinfo.Arch,
152
- max_inst: Optional[int] = None,
153
- max_bytes: Optional[int] = None,
153
+ max_inst: int | None = None,
154
+ max_bytes: int | None = None,
154
155
  bytes_offset: int = 0,
155
156
  traceflags: int = 0,
156
157
  opt_level: int = 1,
157
- num_inst: Optional[int] = None,
158
- num_bytes: Optional[int] = None,
158
+ num_inst: int | None = None,
159
+ num_bytes: int | None = None,
159
160
  strict_block_end: bool = False,
160
161
  skip_stmts: bool = False,
161
162
  collect_data_refs: bool = False,
@@ -230,12 +231,12 @@ class IRSB:
230
231
  def empty_block(
231
232
  arch: archinfo.Arch,
232
233
  addr: int,
233
- statements: Optional[Sequence] = None,
234
- nxt: Optional[int] = None,
234
+ statements: Sequence | None = None,
235
+ nxt: int | None = None,
235
236
  tyenv=None, # Unused, kept for compatibility
236
- jumpkind: Optional[str] = None,
237
- direct_next: Optional[bool] = None,
238
- size: Optional[int] = None,
237
+ jumpkind: str | None = None,
238
+ direct_next: bool | None = None,
239
+ size: int | None = None,
239
240
  ) -> "IRSB":
240
241
  block = IRSB(None, addr, arch)
241
242
  block._set_attributes(statements, nxt, tyenv, jumpkind, direct_next, size=size)
@@ -246,7 +247,7 @@ class IRSB:
246
247
  return self.statements is not None and self.statements
247
248
 
248
249
  @property
249
- def exit_statements(self) -> Sequence[Tuple[int, int, ExitStatement]]:
250
+ def exit_statements(self) -> Sequence[tuple[int, int, ExitStatement]]:
250
251
  return self._exit_statements
251
252
 
252
253
  def copy(self) -> "IRSB":
@@ -457,14 +458,14 @@ class IRSB:
457
458
  def _set_attributes(
458
459
  self: "IRSB",
459
460
  statements: Iterable = None,
460
- nxt: Optional[int] = None,
461
+ nxt: int | None = None,
461
462
  tyenv=None, # Unused, kept for compatibility
462
- jumpkind: Optional[str] = None,
463
- direct_next: Optional[bool] = None,
464
- size: Optional[int] = None,
465
- ops: Optional[Sequence["pypcode.PcodeOp"]] = None,
466
- instruction_addresses: Optional[Iterable[int]] = None,
467
- exit_statements: Sequence[Tuple[int, int, ExitStatement]] = None,
463
+ jumpkind: str | None = None,
464
+ direct_next: bool | None = None,
465
+ size: int | None = None,
466
+ ops: Sequence["pypcode.PcodeOp"] | None = None,
467
+ instruction_addresses: Iterable[int] | None = None,
468
+ exit_statements: Sequence[tuple[int, int, ExitStatement]] = None,
468
469
  default_exit_target: Optional = None,
469
470
  ) -> None:
470
471
  # pylint: disable=unused-argument
@@ -539,15 +540,15 @@ class Lifter:
539
540
  "addr",
540
541
  )
541
542
 
542
- data: Union[str, bytes, None]
543
- bytes_offset: Optional[int]
543
+ data: str | bytes | None
544
+ bytes_offset: int | None
544
545
  opt_level: int
545
- traceflags: Optional[int]
546
- allow_arch_optimizations: Optional[bool]
547
- strict_block_end: Optional[bool]
546
+ traceflags: int | None
547
+ allow_arch_optimizations: bool | None
548
+ strict_block_end: bool | None
548
549
  collect_data_refs: bool
549
- max_inst: Optional[int]
550
- max_bytes: Optional[int]
550
+ max_inst: int | None
551
+ max_bytes: int | None
551
552
  skip_stmts: bool
552
553
  irsb: IRSB
553
554
  arch: archinfo.Arch
@@ -570,14 +571,14 @@ class Lifter:
570
571
 
571
572
  def _lift(
572
573
  self,
573
- data: Union[str, bytes, None],
574
- bytes_offset: Optional[int] = None,
575
- max_bytes: Optional[int] = None,
576
- max_inst: Optional[int] = None,
574
+ data: str | bytes | None,
575
+ bytes_offset: int | None = None,
576
+ max_bytes: int | None = None,
577
+ max_inst: int | None = None,
577
578
  opt_level: int = 1,
578
- traceflags: Optional[int] = None,
579
- allow_arch_optimizations: Optional[bool] = None,
580
- strict_block_end: Optional[bool] = None,
579
+ traceflags: int | None = None,
580
+ allow_arch_optimizations: bool | None = None,
581
+ strict_block_end: bool | None = None,
581
582
  skip_stmts: bool = False,
582
583
  collect_data_refs: bool = False,
583
584
  ) -> IRSB:
@@ -627,11 +628,11 @@ class Lifter:
627
628
 
628
629
  # pylint:disable=unused-argument
629
630
  def lift(
630
- data: Union[str, bytes, None],
631
+ data: str | bytes | None,
631
632
  addr: int,
632
633
  arch: archinfo.Arch,
633
- max_bytes: Optional[int] = None,
634
- max_inst: Optional[int] = None,
634
+ max_bytes: int | None = None,
635
+ max_inst: int | None = None,
635
636
  bytes_offset: int = 0,
636
637
  opt_level: int = 1,
637
638
  traceflags: int = 0,
@@ -837,10 +838,10 @@ class PcodeBasicBlockLifter:
837
838
  self,
838
839
  irsb: IRSB,
839
840
  baseaddr: int,
840
- data: Union[bytes, bytearray],
841
+ data: bytes | bytearray,
841
842
  bytes_offset: int = 0,
842
- max_bytes: Optional[int] = None,
843
- max_inst: Optional[int] = None,
843
+ max_bytes: int | None = None,
844
+ max_inst: int | None = None,
844
845
  branch_delay_slot: bool = False,
845
846
  is_sparc32: bool = False,
846
847
  ) -> None:
@@ -994,10 +995,10 @@ class PcodeLifterEngineMixin(SimEngineBase):
994
995
  def __init__(
995
996
  self,
996
997
  project=None,
997
- use_cache: Optional[bool] = None,
998
+ use_cache: bool | None = None,
998
999
  cache_size: int = 50000,
999
1000
  default_opt_level: int = 1,
1000
- selfmodifying_code: Optional[bool] = None,
1001
+ selfmodifying_code: bool | None = None,
1001
1002
  single_step: bool = False,
1002
1003
  default_strict_block_end: bool = False,
1003
1004
  **kwargs,
@@ -1041,22 +1042,22 @@ class PcodeLifterEngineMixin(SimEngineBase):
1041
1042
  # FIXME: Consider moving to higher abstraction layer to reduce duplication with vex
1042
1043
  def lift_vex(
1043
1044
  self,
1044
- addr: Optional[int] = None,
1045
- state: Optional[SimState] = None,
1046
- clemory: Optional[cle.Clemory] = None,
1047
- insn_bytes: Optional[bytes] = None,
1048
- arch: Optional[archinfo.Arch] = None,
1049
- size: Optional[int] = None,
1050
- num_inst: Optional[int] = None,
1045
+ addr: int | None = None,
1046
+ state: SimState | None = None,
1047
+ clemory: cle.Clemory | None = None,
1048
+ insn_bytes: bytes | None = None,
1049
+ arch: archinfo.Arch | None = None,
1050
+ size: int | None = None,
1051
+ num_inst: int | None = None,
1051
1052
  traceflags: int = 0,
1052
1053
  thumb: bool = False,
1053
- extra_stop_points: Optional[Iterable[int]] = None,
1054
- opt_level: Optional[int] = None,
1055
- strict_block_end: Optional[bool] = None,
1054
+ extra_stop_points: Iterable[int] | None = None,
1055
+ opt_level: int | None = None,
1056
+ strict_block_end: bool | None = None,
1056
1057
  skip_stmts: bool = False,
1057
1058
  collect_data_refs: bool = False,
1058
1059
  load_from_ro_regions: bool = False,
1059
- cross_insn_opt: Optional[bool] = None,
1060
+ cross_insn_opt: bool | None = None,
1060
1061
  ):
1061
1062
  """
1062
1063
  Temporary compatibility interface for integration with block code.
@@ -1082,22 +1083,22 @@ class PcodeLifterEngineMixin(SimEngineBase):
1082
1083
 
1083
1084
  def lift_pcode(
1084
1085
  self,
1085
- addr: Optional[int] = None,
1086
- state: Optional[SimState] = None,
1087
- clemory: Optional[cle.Clemory] = None,
1088
- insn_bytes: Optional[bytes] = None,
1089
- arch: Optional[archinfo.Arch] = None,
1090
- size: Optional[int] = None,
1091
- num_inst: Optional[int] = None,
1086
+ addr: int | None = None,
1087
+ state: SimState | None = None,
1088
+ clemory: cle.Clemory | None = None,
1089
+ insn_bytes: bytes | None = None,
1090
+ arch: archinfo.Arch | None = None,
1091
+ size: int | None = None,
1092
+ num_inst: int | None = None,
1092
1093
  traceflags: int = 0,
1093
1094
  thumb: bool = False,
1094
- extra_stop_points: Optional[Iterable[int]] = None,
1095
- opt_level: Optional[int] = None,
1096
- strict_block_end: Optional[bool] = None,
1095
+ extra_stop_points: Iterable[int] | None = None,
1096
+ opt_level: int | None = None,
1097
+ strict_block_end: bool | None = None,
1097
1098
  skip_stmts: bool = False,
1098
1099
  collect_data_refs: bool = False,
1099
1100
  load_from_ro_regions: bool = False,
1100
- cross_insn_opt: Optional[bool] = None,
1101
+ cross_insn_opt: bool | None = None,
1101
1102
  ):
1102
1103
  """
1103
1104
  Lift an IRSB.
@@ -1296,8 +1297,8 @@ class PcodeLifterEngineMixin(SimEngineBase):
1296
1297
  raise SimTranslationError("Unable to translate bytecode") from e
1297
1298
 
1298
1299
  def _load_bytes(
1299
- self, addr: int, max_size: int, state: Optional[SimState] = None, clemory: Optional[cle.Clemory] = None
1300
- ) -> Tuple[bytes, int, int]:
1300
+ self, addr: int, max_size: int, state: SimState | None = None, clemory: cle.Clemory | None = None
1301
+ ) -> tuple[bytes, int, int]:
1301
1302
  if clemory is None and state is None:
1302
1303
  raise SimEngineError("state and clemory cannot both be None in _load_bytes().")
1303
1304
 
@@ -1371,7 +1372,7 @@ class PcodeLifterEngineMixin(SimEngineBase):
1371
1372
  size = min(max_size, size)
1372
1373
  return buff, size, offset
1373
1374
 
1374
- def _first_stoppoint(self, irsb: IRSB, extra_stop_points: Optional[Sequence[int]] = None) -> Optional[int]:
1375
+ def _first_stoppoint(self, irsb: IRSB, extra_stop_points: Sequence[int] | None = None) -> int | None:
1375
1376
  """
1376
1377
  Enumerate the imarks in the block. If any of them (after the first one) are at a stop point, returns the address
1377
1378
  of the stop point. None is returned otherwise.
@@ -1388,7 +1389,7 @@ class PcodeLifterEngineMixin(SimEngineBase):
1388
1389
  first_imark = False
1389
1390
  return None
1390
1391
 
1391
- def __is_stop_point(self, addr: int, extra_stop_points: Optional[Sequence[int]] = None) -> bool:
1392
+ def __is_stop_point(self, addr: int, extra_stop_points: Sequence[int] | None = None) -> bool:
1392
1393
  if self.project is not None and addr in self.project._sim_procedures:
1393
1394
  return True
1394
1395
  elif extra_stop_points is not None and addr in extra_stop_points:
@@ -1,4 +1,3 @@
1
- from typing import Dict, Optional
2
1
  import logging
3
2
 
4
3
  import claripy
@@ -74,7 +73,7 @@ class CCallMultivaluedException(Exception):
74
73
  ### x86* data ###
75
74
  ##################
76
75
 
77
- data: Dict[str, Dict[str, Dict[str, Optional[int]]]] = {
76
+ data: dict[str, dict[str, dict[str, int | None]]] = {
78
77
  "AMD64": {
79
78
  "CondTypes": {},
80
79
  "CondBitOffsets": {},
@@ -1,4 +1,3 @@
1
- from typing import Optional
2
1
  import logging
3
2
 
4
3
  import claripy
@@ -14,7 +13,7 @@ l = logging.getLogger(__name__)
14
13
  zero = claripy.BVV(0, 32)
15
14
 
16
15
 
17
- def value(ty, val, size: Optional[int] = None):
16
+ def value(ty, val, size: int | None = None):
18
17
  if ty == "Ity_F32":
19
18
  return claripy.FPV(float(val), claripy.FSORT_FLOAT)
20
19
  elif ty == "Ity_F64":
@@ -1,5 +1,4 @@
1
1
  import logging
2
- from typing import Optional
3
2
 
4
3
  import pyvex
5
4
 
@@ -549,7 +548,7 @@ class VEXMixin(SimEngineBase):
549
548
  self.stmt_idx = DEFAULT_STATEMENT
550
549
  self._handle_vex_defaultexit(irsb.next, irsb.jumpkind)
551
550
 
552
- def _handle_vex_defaultexit(self, expr: Optional[pyvex.expr.IRExpr], jumpkind: str):
551
+ def _handle_vex_defaultexit(self, expr: pyvex.expr.IRExpr | None, jumpkind: str):
553
552
  self._perform_vex_defaultexit(self._analyze_vex_defaultexit(expr) if expr is not None else None, jumpkind)
554
553
 
555
554
  def _perform_vex_defaultexit(self, expr, jumpkind):
@@ -1,4 +1,4 @@
1
- from typing import List, Dict, TYPE_CHECKING
1
+ from typing import TYPE_CHECKING
2
2
  import logging
3
3
  import cle
4
4
 
@@ -179,13 +179,13 @@ class Tracer(ExplorationTechnique):
179
179
  self._follow_unsat = follow_unsat
180
180
  self._fast_forward_to_entry = fast_forward_to_entry
181
181
 
182
- self._aslr_slides: Dict[cle.Backend, int] = {}
182
+ self._aslr_slides: dict[cle.Backend, int] = {}
183
183
  self._current_slide = None
184
184
 
185
185
  self._fd_bytes = None
186
186
 
187
187
  # keep track of the last basic block we hit
188
- self.predecessors: List["SimState"] = [None] * keep_predecessors
188
+ self.predecessors: list["SimState"] = [None] * keep_predecessors
189
189
  self.last_state = None
190
190
 
191
191
  # whether we should follow the trace
@@ -284,7 +284,7 @@ class Tracer(ExplorationTechnique):
284
284
  # this is an awful fucking heuristic but it's as good as we've got
285
285
  return abs(self._trace[idx] - self._trace[idx + 1]) > 0x1000
286
286
 
287
- def set_fd_data(self, fd_data: Dict[int, bytes]):
287
+ def set_fd_data(self, fd_data: dict[int, bytes]):
288
288
  """
289
289
  Set concrete bytes of various fds read by the program
290
290
  """
angr/factory.py CHANGED
@@ -1,4 +1,4 @@
1
- from typing import List, Optional, Union, overload, Type
1
+ from typing import overload
2
2
  import logging
3
3
  import archinfo
4
4
  from archinfo.arch_soot import ArchSoot, SootAddressDescriptor
@@ -6,9 +6,12 @@ from archinfo.arch_soot import ArchSoot, SootAddressDescriptor
6
6
  from .sim_state import SimState
7
7
  from .calling_conventions import default_cc, SimRegArg, SimStackArg, PointerWrapper, SimCCUnknown
8
8
  from .callable import Callable
9
- from .errors import AngrAssemblyError
9
+ from .errors import AngrAssemblyError, AngrError
10
10
  from .engines import UberEngine, ProcedureEngine, SimEngineConcrete, SimEngine
11
11
  from .sim_type import SimTypeFunction, SimTypeInt
12
+ from .codenode import HookNode, SyscallNode
13
+ from .block import Block, SootBlock
14
+ from .sim_manager import SimulationManager
12
15
 
13
16
  try:
14
17
  from .engines import UberEnginePcode
@@ -25,7 +28,7 @@ class AngrObjectFactory:
25
28
  This factory provides access to important analysis elements.
26
29
  """
27
30
 
28
- def __init__(self, project, default_engine: Optional[Type[SimEngine]] = None):
31
+ def __init__(self, project, default_engine: type[SimEngine] | None = None):
29
32
  if default_engine is None:
30
33
  if isinstance(project.arch, archinfo.ArchPcode) and UberEnginePcode is not None:
31
34
  l.warning("Creating project with the experimental 'UberEnginePcode' engine")
@@ -171,9 +174,7 @@ class AngrObjectFactory:
171
174
  """
172
175
  return self.project.simos.state_call(addr, *args, **kwargs)
173
176
 
174
- def simulation_manager(
175
- self, thing: Optional[Union[List[SimState], SimState]] = None, **kwargs
176
- ) -> "SimulationManager":
177
+ def simulation_manager(self, thing: list[SimState] | SimState | None = None, **kwargs) -> "SimulationManager":
177
178
  """
178
179
  Constructs a new simulation manager.
179
180
 
@@ -289,6 +290,7 @@ class AngrObjectFactory:
289
290
  cross_insn_opt=True,
290
291
  load_from_ro_regions=False,
291
292
  initial_regs=None,
293
+ skip_stmts=False,
292
294
  ) -> "Block": ...
293
295
 
294
296
  # pylint: disable=unused-argument, no-self-use, function-redefined
@@ -311,6 +313,7 @@ class AngrObjectFactory:
311
313
  strict_block_end=None,
312
314
  collect_data_refs=False,
313
315
  cross_insn_opt=True,
316
+ skip_stmts=False,
314
317
  ) -> "SootBlock": ...
315
318
 
316
319
  def block(
@@ -333,6 +336,7 @@ class AngrObjectFactory:
333
336
  cross_insn_opt=True,
334
337
  load_from_ro_regions=False,
335
338
  initial_regs=None,
339
+ skip_stmts=False,
336
340
  ):
337
341
  if isinstance(self.project.arch, ArchSoot) and isinstance(addr, SootAddressDescriptor):
338
342
  return SootBlock(addr, arch=self.project.arch, project=self.project)
@@ -351,13 +355,11 @@ class AngrObjectFactory:
351
355
  "Assembling failed. Please make sure keystone is installed, and the assembly string is correct."
352
356
  )
353
357
 
354
- if max_size is not None:
355
- l.warning('Keyword argument "max_size" has been deprecated for block(). Please use "size" instead.')
356
- size = max_size
357
358
  return Block(
358
359
  addr,
359
360
  project=self.project,
360
361
  size=size,
362
+ max_size=max_size,
361
363
  byte_string=byte_string,
362
364
  vex=vex,
363
365
  extra_stop_points=extra_stop_points,
@@ -371,6 +373,7 @@ class AngrObjectFactory:
371
373
  cross_insn_opt=cross_insn_opt,
372
374
  load_from_ro_regions=load_from_ro_regions,
373
375
  initial_regs=initial_regs,
376
+ skip_stmts=skip_stmts,
374
377
  )
375
378
 
376
379
  def fresh_block(self, addr, size, backup_state=None):
@@ -380,9 +383,3 @@ class AngrObjectFactory:
380
383
  cc.SimStackArg = SimStackArg
381
384
  callable.PointerWrapper = PointerWrapper
382
385
  call_state.PointerWrapper = PointerWrapper
383
-
384
-
385
- from .errors import AngrError
386
- from .sim_manager import SimulationManager
387
- from .codenode import HookNode, SyscallNode
388
- from .block import Block, SootBlock
angr/flirt/__init__.py CHANGED
@@ -22,11 +22,11 @@ class FlirtSignature:
22
22
  platform: str,
23
23
  sig_name: str,
24
24
  sig_path: str,
25
- unique_strings: Optional[Set[str]] = None,
26
- compiler: Optional[str] = None,
27
- compiler_version: Optional[str] = None,
28
- os_name: Optional[str] = None,
29
- os_version: Optional[str] = None,
25
+ unique_strings: set[str] | None = None,
26
+ compiler: str | None = None,
27
+ compiler_version: str | None = None,
28
+ os_name: str | None = None,
29
+ os_version: str | None = None,
30
30
  ):
31
31
  self.arch = arch
32
32
  self.platform = platform
@@ -49,9 +49,9 @@ class FlirtSignature:
49
49
  FS = FlirtSignature
50
50
 
51
51
  # A dict from architecture names to FLIRT signatures under that architecture. Arch names are always in lower case.
52
- FLIRT_SIGNATURES_BY_ARCH: Dict[str, List[FlirtSignature]] = defaultdict(list)
53
- LIBRARY_TO_SIGNATURES: Dict[str, List[FlirtSignature]] = defaultdict(list)
54
- STRING_TO_LIBRARIES: Dict[str, Set[str]] = defaultdict(set)
52
+ FLIRT_SIGNATURES_BY_ARCH: dict[str, list[FlirtSignature]] = defaultdict(list)
53
+ LIBRARY_TO_SIGNATURES: dict[str, list[FlirtSignature]] = defaultdict(list)
54
+ STRING_TO_LIBRARIES: dict[str, set[str]] = defaultdict(set)
55
55
 
56
56
 
57
57
  def load_signatures(path: str) -> None:
angr/flirt/build_sig.py CHANGED
@@ -1,5 +1,4 @@
1
1
  # pylint:disable=consider-using-with
2
- from typing import List, Dict
3
2
  import json
4
3
  import subprocess
5
4
  import argparse
@@ -16,7 +15,7 @@ UNIQUE_STRING_COUNT = 20
16
15
  MAX_UNIQUE_STRING_LEN = 70
17
16
 
18
17
 
19
- def get_basic_info(ar_path: str) -> Dict[str, str]:
18
+ def get_basic_info(ar_path: str) -> dict[str, str]:
20
19
  """
21
20
  Get basic information of the archive file.
22
21
  """
@@ -41,7 +40,7 @@ def get_basic_info(ar_path: str) -> Dict[str, str]:
41
40
  }
42
41
 
43
42
 
44
- def get_unique_strings(ar_path: str) -> List[str]:
43
+ def get_unique_strings(ar_path: str) -> list[str]:
45
44
  """
46
45
  For Linux libraries, this method requires ar (from binutils), nm (from binutils), and strings.
47
46
  """
angr/keyed_region.py CHANGED
@@ -1,6 +1,6 @@
1
1
  import logging
2
2
  import weakref
3
- from typing import Union, Optional, Tuple, TYPE_CHECKING
3
+ from typing import Union, TYPE_CHECKING
4
4
 
5
5
  from sortedcontainers import SortedDict
6
6
 
@@ -133,7 +133,7 @@ class KeyedRegion:
133
133
  self._storage, om, self._phi_node_contains = s
134
134
  self._object_mapping = weakref.WeakValueDictionary(om)
135
135
 
136
- def _get_container(self, offset) -> Tuple[int, Optional[RegionObject]]:
136
+ def _get_container(self, offset) -> tuple[int, RegionObject | None]:
137
137
  try:
138
138
  base_offset = next(self._storage.irange(maximum=offset, reverse=True))
139
139
  except StopIteration:
@@ -3,7 +3,7 @@
3
3
  from itertools import count
4
4
  import logging
5
5
 
6
- from typing import TYPE_CHECKING, TypeVar, Type, Optional
6
+ from typing import TYPE_CHECKING, TypeVar
7
7
 
8
8
  if TYPE_CHECKING:
9
9
  from ..project import Project
@@ -116,7 +116,7 @@ class KnowledgeBase:
116
116
 
117
117
  K = TypeVar("K", bound=KnowledgeBasePlugin)
118
118
 
119
- def get_knowledge(self, requested_plugin_cls: Type[K]) -> Optional[K]:
119
+ def get_knowledge(self, requested_plugin_cls: type[K]) -> K | None:
120
120
  """
121
121
  Type inference safe method to request a knowledge base plugin
122
122
  Explicitly passing the type of the requested plugin achieves two things:
@@ -135,7 +135,7 @@ class KnowledgeBase:
135
135
  None,
136
136
  )
137
137
 
138
- def request_knowledge(self, requested_plugin_cls: Type[K]) -> K:
138
+ def request_knowledge(self, requested_plugin_cls: type[K]) -> K:
139
139
  existing = self.get_knowledge(requested_plugin_cls)
140
140
  if existing is not None:
141
141
  return existing
@@ -1,5 +1,3 @@
1
- from typing import Dict, Tuple, Optional
2
-
3
1
  from .plugin import KnowledgeBasePlugin
4
2
  from ..sim_type import SimTypeFunction
5
3
  from ..calling_conventions import SimCC
@@ -13,7 +11,7 @@ class CallsitePrototypes(KnowledgeBasePlugin):
13
11
  def __init__(self, kb):
14
12
  super().__init__(kb=kb)
15
13
 
16
- self._prototypes: Dict[int, Tuple[SimCC, SimTypeFunction, bool]] = {}
14
+ self._prototypes: dict[int, tuple[SimCC, SimTypeFunction, bool]] = {}
17
15
 
18
16
  def set_prototype(
19
17
  self,
@@ -24,19 +22,19 @@ class CallsitePrototypes(KnowledgeBasePlugin):
24
22
  ) -> None:
25
23
  self._prototypes[callsite_block_addr] = cc, prototype, manual
26
24
 
27
- def get_cc(self, callsite_block_addr: int) -> Optional[SimCC]:
25
+ def get_cc(self, callsite_block_addr: int) -> SimCC | None:
28
26
  try:
29
27
  return self._prototypes[callsite_block_addr][0]
30
28
  except KeyError:
31
29
  return None
32
30
 
33
- def get_prototype(self, callsite_block_addr: int) -> Optional[SimTypeFunction]:
31
+ def get_prototype(self, callsite_block_addr: int) -> SimTypeFunction | None:
34
32
  try:
35
33
  return self._prototypes[callsite_block_addr][1]
36
34
  except KeyError:
37
35
  return None
38
36
 
39
- def get_prototype_type(self, callsite_block_addr: int) -> Optional[bool]:
37
+ def get_prototype_type(self, callsite_block_addr: int) -> bool | None:
40
38
  try:
41
39
  return self._prototypes[callsite_block_addr][2]
42
40
  except KeyError:
@@ -1,5 +1,4 @@
1
- from typing import Optional
2
- from functools import reduce
1
+ from collections import defaultdict
3
2
 
4
3
  from archinfo.arch_arm import is_arm_arch
5
4
 
@@ -53,15 +52,29 @@ class CFGManager(KnowledgeBasePlugin):
53
52
  cm.cfgs = dict(map(lambda x: (x[0], x[1].copy()), self.cfgs.items()))
54
53
  return cm
55
54
 
56
- def get_most_accurate(self) -> Optional[CFGModel]:
55
+ def get_most_accurate(self) -> CFGModel | None:
57
56
  """
58
57
  :return: The most accurate CFG present in the CFGManager, or None if it does not hold any.
59
58
  """
60
59
  less_accurate_to_most_accurate = ["CFGFast", "CFGEmulated"]
61
60
 
62
- # Try to get the most accurate first, then default to the next, ... all the way down to `None`.
63
- # Equivalent to `self.cfgs.get(<LAST>, self.cfgs.get(<SECOND LAST>, ... self.cfgs.get(<FIRST>, None)))`.
64
- return reduce(lambda acc, cfg: self.cfgs.get(cfg, acc), less_accurate_to_most_accurate, None)
61
+ sorted_cfgs_by_prefix = defaultdict(list)
62
+ for key, cfg_model in self.cfgs.items():
63
+ for prefix in less_accurate_to_most_accurate:
64
+ if key.startswith(prefix):
65
+ the_prefix = prefix
66
+ break
67
+ else:
68
+ # not found
69
+ continue
70
+
71
+ sorted_cfgs_by_prefix[the_prefix].append((key, cfg_model))
72
+
73
+ for key in reversed(less_accurate_to_most_accurate):
74
+ if key in sorted_cfgs_by_prefix:
75
+ lst = sorted(sorted_cfgs_by_prefix[key], key=lambda item: item[0])
76
+ return lst[-1][-1]
77
+ return None
65
78
 
66
79
  #
67
80
  # Pickling