angr 9.2.102__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 +39 -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.102.dist-info → angr-9.2.103.dist-info}/METADATA +9 -11
  235. {angr-9.2.102.dist-info → angr-9.2.103.dist-info}/RECORD +239 -236
  236. {angr-9.2.102.dist-info → angr-9.2.103.dist-info}/LICENSE +0 -0
  237. {angr-9.2.102.dist-info → angr-9.2.103.dist-info}/WHEEL +0 -0
  238. {angr-9.2.102.dist-info → angr-9.2.103.dist-info}/entry_points.txt +0 -0
  239. {angr-9.2.102.dist-info → angr-9.2.103.dist-info}/top_level.txt +0 -0
@@ -1,7 +1,8 @@
1
1
  # pylint:disable=no-member
2
2
  import pickle
3
3
  import logging
4
- from typing import Optional, List, Dict, Tuple, DefaultDict, Callable, TYPE_CHECKING, Set
4
+ from typing import Optional, DefaultDict, TYPE_CHECKING
5
+ from collections.abc import Callable
5
6
  from collections import defaultdict
6
7
  import bisect
7
8
  import string
@@ -65,20 +66,20 @@ class CFGModel(Serializable):
65
66
  self.graph = networkx.DiGraph()
66
67
 
67
68
  # Jump tables
68
- self.jump_tables: Dict[int, IndirectJump] = {}
69
+ self.jump_tables: dict[int, IndirectJump] = {}
69
70
 
70
71
  # Memory references
71
72
  # A mapping between address and the actual data in memory
72
- self.memory_data: Dict[int, MemoryData] = {}
73
+ self.memory_data: dict[int, MemoryData] = {}
73
74
  # A mapping between address of the instruction that's referencing the memory data and the memory data itself
74
- self.insn_addr_to_memory_data: Dict[int, MemoryData] = {}
75
+ self.insn_addr_to_memory_data: dict[int, MemoryData] = {}
75
76
 
76
77
  # Lists of CFGNodes indexed by the address of each block. Don't serialize
77
- self._nodes_by_addr: DefaultDict[int, List[CFGNode]] = defaultdict(list)
78
+ self._nodes_by_addr: DefaultDict[int, list[CFGNode]] = defaultdict(list)
78
79
  # CFGNodes dict indexed by block ID. Don't serialize
79
- self._nodes: Dict[int, CFGNode] = {}
80
+ self._nodes: dict[int, CFGNode] = {}
80
81
  # addresses of CFGNodes to speed up get_any_node(..., anyaddr=True). Don't serialize
81
- self._node_addrs: List[int] = []
82
+ self._node_addrs: list[int] = []
82
83
 
83
84
  self.normalized = False
84
85
 
@@ -273,8 +274,8 @@ class CFGModel(Serializable):
273
274
  return None
274
275
 
275
276
  def get_any_node(
276
- self, addr: int, is_syscall: Optional[bool] = None, anyaddr: bool = False, force_fastpath: bool = False
277
- ) -> Optional[CFGNode]:
277
+ self, addr: int, is_syscall: bool | None = None, anyaddr: bool = False, force_fastpath: bool = False
278
+ ) -> CFGNode | None:
278
279
  """
279
280
  Get an arbitrary CFGNode (without considering their contexts) from our graph.
280
281
 
@@ -333,7 +334,7 @@ class CFGModel(Serializable):
333
334
 
334
335
  return None
335
336
 
336
- def get_all_nodes(self, addr: int, is_syscall: bool = None, anyaddr: bool = False) -> List[CFGNode]:
337
+ def get_all_nodes(self, addr: int, is_syscall: bool = None, anyaddr: bool = False) -> list[CFGNode]:
337
338
  """
338
339
  Get all CFGNodes whose address is the specified one.
339
340
 
@@ -352,7 +353,7 @@ class CFGModel(Serializable):
352
353
 
353
354
  return results
354
355
 
355
- def get_all_nodes_intersecting_region(self, addr: int, size: int = 1) -> Set[CFGNode]:
356
+ def get_all_nodes_intersecting_region(self, addr: int, size: int = 1) -> set[CFGNode]:
356
357
  """
357
358
  Get all CFGNodes that intersect the given region.
358
359
 
@@ -373,8 +374,8 @@ class CFGModel(Serializable):
373
374
  return self.graph.nodes()
374
375
 
375
376
  def get_predecessors(
376
- self, cfgnode: CFGNode, excluding_fakeret: bool = True, jumpkind: Optional[str] = None
377
- ) -> List[CFGNode]:
377
+ self, cfgnode: CFGNode, excluding_fakeret: bool = True, jumpkind: str | None = None
378
+ ) -> list[CFGNode]:
378
379
  """
379
380
  Get predecessors of a node in the control flow graph.
380
381
 
@@ -409,8 +410,8 @@ class CFGModel(Serializable):
409
410
  return predecessors
410
411
 
411
412
  def get_successors(
412
- self, node: CFGNode, excluding_fakeret: bool = True, jumpkind: Optional[str] = None
413
- ) -> List[CFGNode]:
413
+ self, node: CFGNode, excluding_fakeret: bool = True, jumpkind: str | None = None
414
+ ) -> list[CFGNode]:
414
415
  """
415
416
  Get successors of a node in the control flow graph.
416
417
 
@@ -467,7 +468,7 @@ class CFGModel(Serializable):
467
468
 
468
469
  def get_predecessors_and_jumpkinds(
469
470
  self, node: CFGNode, excluding_fakeret: bool = True
470
- ) -> List[Tuple[CFGNode, str]]:
471
+ ) -> list[tuple[CFGNode, str]]:
471
472
  """
472
473
  Get a list of tuples where the first element is the predecessor of the CFG node and the second element is the
473
474
  jumpkind of the predecessor.
@@ -540,9 +541,7 @@ class CFGModel(Serializable):
540
541
  # Memory data
541
542
  #
542
543
 
543
- def add_memory_data(
544
- self, data_addr: int, data_type: Optional[MemoryDataSort], data_size: Optional[int] = None
545
- ) -> bool:
544
+ def add_memory_data(self, data_addr: int, data_type: MemoryDataSort | None, data_size: int | None = None) -> bool:
546
545
  """
547
546
  Add a MemoryData entry to self.memory_data.
548
547
 
@@ -563,11 +562,11 @@ class CFGModel(Serializable):
563
562
 
564
563
  def tidy_data_references(
565
564
  self,
566
- memory_data_addrs: Optional[List[int]] = None,
567
- exec_mem_regions: Optional[List[Tuple[int, int]]] = None,
565
+ memory_data_addrs: list[int] | None = None,
566
+ exec_mem_regions: list[tuple[int, int]] | None = None,
568
567
  xrefs: Optional["XRefManager"] = None,
569
568
  seg_list: Optional["SegmentList"] = None,
570
- data_type_guessing_handlers: Optional[List[Callable]] = None,
569
+ data_type_guessing_handlers: list[Callable] | None = None,
571
570
  ) -> bool:
572
571
  """
573
572
  Go through all data references (or the ones as specified by memory_data_addrs) and determine their sizes and
@@ -748,8 +747,8 @@ class CFGModel(Serializable):
748
747
  content_holder=None,
749
748
  xrefs: Optional["XRefManager"] = None,
750
749
  seg_list: Optional["SegmentList"] = None,
751
- data_type_guessing_handlers: Optional[List[Callable]] = None,
752
- extra_memory_regions: Optional[List[Tuple[int, int]]] = None,
750
+ data_type_guessing_handlers: list[Callable] | None = None,
751
+ extra_memory_regions: list[tuple[int, int]] | None = None,
753
752
  ):
754
753
  """
755
754
  Make a guess to the data type.
@@ -887,7 +886,7 @@ class CFGModel(Serializable):
887
886
  data_addr: int,
888
887
  pointer_size: int,
889
888
  max_size: int,
890
- extra_memory_regions: Optional[List[Tuple[int, int]]] = None,
889
+ extra_memory_regions: list[tuple[int, int]] | None = None,
891
890
  ):
892
891
  pointers_count = 0
893
892
 
@@ -948,7 +947,7 @@ class CFGModel(Serializable):
948
947
  #
949
948
 
950
949
  @staticmethod
951
- def _addr_in_exec_memory_regions(addr: int, exec_mem_regions: List[Tuple[int, int]]) -> bool:
950
+ def _addr_in_exec_memory_regions(addr: int, exec_mem_regions: list[tuple[int, int]]) -> bool:
952
951
  for start, end in exec_mem_regions:
953
952
  if start <= addr < end:
954
953
  return True
@@ -968,7 +967,7 @@ class CFGModel(Serializable):
968
967
  addr: int,
969
968
  size: int = 1,
970
969
  kb: Optional["KnowledgeBase"] = None,
971
- ) -> Set["Function"]:
970
+ ) -> set["Function"]:
972
971
  """
973
972
  Find all functions with nodes intersecting [addr, addr + size).
974
973
 
@@ -1,6 +1,6 @@
1
1
  import traceback
2
2
  import logging
3
- from typing import TYPE_CHECKING, Union, Optional
3
+ from typing import TYPE_CHECKING, Union
4
4
 
5
5
  from archinfo.arch_soot import SootAddressDescriptor
6
6
  import archinfo
@@ -95,7 +95,7 @@ class CFGNode(Serializable):
95
95
  self.function_address = function_address
96
96
  self.block_id: Union["angr.analyses.cfg.cfg_job_base.BlockID", int] = block_id
97
97
  self.thumb = thumb
98
- self.byte_string: Optional[bytes] = byte_string
98
+ self.byte_string: bytes | None = byte_string
99
99
 
100
100
  self._name = None
101
101
  if name is not None:
@@ -1,5 +1,3 @@
1
- from typing import List, Optional
2
-
3
1
  from ...serializable import Serializable
4
2
 
5
3
 
@@ -33,13 +31,13 @@ class IndirectJump(Serializable):
33
31
  func_addr: int,
34
32
  jumpkind: str,
35
33
  stmt_idx: int,
36
- resolved_targets: Optional[List[int]] = None,
34
+ resolved_targets: list[int] | None = None,
37
35
  jumptable: bool = False,
38
- jumptable_addr: Optional[int] = None,
39
- jumptable_size: Optional[int] = None,
40
- jumptable_entry_size: Optional[int] = None,
41
- jumptable_entries: Optional[List[int]] = None,
42
- type_: Optional[int] = IndirectJumpType.Unknown,
36
+ jumptable_addr: int | None = None,
37
+ jumptable_size: int | None = None,
38
+ jumptable_entry_size: int | None = None,
39
+ jumptable_entries: list[int] | None = None,
40
+ type_: int | None = IndirectJumpType.Unknown,
43
41
  ):
44
42
  self.addr = addr
45
43
  self.ins_addr = ins_addr
@@ -1,5 +1,4 @@
1
1
  # pylint:disable=no-member
2
- from typing import Optional
3
2
  from ...protos import cfg_pb2
4
3
  from ...serializable import Serializable
5
4
 
@@ -57,20 +56,20 @@ class MemoryData(Serializable):
57
56
  self,
58
57
  address: int,
59
58
  size: int,
60
- sort: Optional[str], # temporary type
61
- pointer_addr: Optional[int] = None,
62
- max_size: Optional[int] = None,
63
- reference_size: Optional[int] = None,
59
+ sort: str | None, # temporary type
60
+ pointer_addr: int | None = None,
61
+ max_size: int | None = None,
62
+ reference_size: int | None = None,
64
63
  ):
65
64
  self.addr: int = address
66
65
  self.size: int = size
67
66
  self.reference_size: int = reference_size
68
- self.sort: Optional[str] = sort
67
+ self.sort: str | None = sort
69
68
 
70
- self.max_size: Optional[int] = max_size
71
- self.pointer_addr: Optional[int] = pointer_addr
69
+ self.max_size: int | None = max_size
70
+ self.pointer_addr: int | None = pointer_addr
72
71
 
73
- self.content: Optional[bytes] = None # temporary annotation
72
+ self.content: bytes | None = None # temporary annotation
74
73
 
75
74
  def __eq__(self, other: "MemoryData"):
76
75
  return (
@@ -1,5 +1,3 @@
1
- from typing import Dict
2
-
3
1
  from .plugin import KnowledgeBasePlugin
4
2
 
5
3
 
@@ -12,7 +10,7 @@ class CustomStrings(KnowledgeBasePlugin):
12
10
  super().__init__(kb=kb)
13
11
 
14
12
  self.string_id = 0
15
- self.strings: Dict[int, bytes] = {}
13
+ self.strings: dict[int, bytes] = {}
16
14
 
17
15
  def allocate(self, s: bytes) -> int:
18
16
  # de-duplication
@@ -1,4 +1,4 @@
1
- from typing import List, TYPE_CHECKING
1
+ from typing import TYPE_CHECKING
2
2
  import logging
3
3
 
4
4
  import claripy
@@ -174,7 +174,7 @@ class DebugVariableManager(KnowledgeBasePlugin):
174
174
  return self.add_variable(cle_var, index.start, index.stop)
175
175
 
176
176
  # Methods similar to the once in VariableManager
177
- def add_variable_list(self, vlist: List[Variable], low_pc: int, high_pc: int):
177
+ def add_variable_list(self, vlist: list[Variable], low_pc: int, high_pc: int):
178
178
  """
179
179
  Add all variables in a list with the same visibility range
180
180
 
@@ -3,8 +3,7 @@ import logging
3
3
  import networkx
4
4
  import itertools
5
5
  from collections import defaultdict
6
- from typing import Union, Optional, Iterable, Set
7
- from typing import Type
6
+ from collections.abc import Iterable
8
7
 
9
8
  from itanium_demangler import parse
10
9
 
@@ -90,9 +89,9 @@ class Function(Serializable):
90
89
  addr,
91
90
  name=None,
92
91
  syscall=None,
93
- is_simprocedure: Optional[bool] = None,
92
+ is_simprocedure: bool | None = None,
94
93
  binary_name=None,
95
- is_plt: Optional[bool] = None,
94
+ is_plt: bool | None = None,
96
95
  returning=None,
97
96
  alignment=False,
98
97
  ):
@@ -117,13 +116,13 @@ class Function(Serializable):
117
116
  self.normalized = False
118
117
 
119
118
  # block nodes at whose ends the function returns
120
- self._ret_sites: Set[BlockNode] = set()
119
+ self._ret_sites: set[BlockNode] = set()
121
120
  # block nodes at whose ends the function jumps out to another function (jumps outside)
122
- self._jumpout_sites: Set[BlockNode] = set()
121
+ self._jumpout_sites: set[BlockNode] = set()
123
122
  # block nodes at whose ends the function calls out to another non-returning function
124
- self._callout_sites: Set[BlockNode] = set()
123
+ self._callout_sites: set[BlockNode] = set()
125
124
  # block nodes that ends the function by returning out to another function (returns outside). This is rare.
126
- self._retout_sites: Set[BlockNode] = set()
125
+ self._retout_sites: set[BlockNode] = set()
127
126
  # block nodes (basic block nodes) at whose ends the function terminates
128
127
  # in theory, if everything works fine, endpoints == ret_sites | jumpout_sites | callout_sites
129
128
  self._endpoints = defaultdict(set)
@@ -142,10 +141,10 @@ class Function(Serializable):
142
141
  self.retaddr_on_stack = False
143
142
  self.sp_delta = 0
144
143
  # Calling convention
145
- self.calling_convention: Optional[SimCC] = None
144
+ self.calling_convention: SimCC | None = None
146
145
  # Function prototype
147
- self.prototype: Optional[SimTypeFunction] = None
148
- self.prototype_libname: Optional[str] = None
146
+ self.prototype: SimTypeFunction | None = None
147
+ self.prototype_libname: str | None = None
149
148
  self.is_prototype_guessed: bool = True
150
149
  # Whether this function returns or not. `None` means it's not determined yet
151
150
  self._returning = None
@@ -173,7 +172,7 @@ class Function(Serializable):
173
172
  # Stack offsets of those arguments passed in stack variables
174
173
  self._argument_stack_variables = []
175
174
 
176
- self._project: Optional[Project] = None # will be initialized upon the first access to self.project
175
+ self._project: Project | None = None # will be initialized upon the first access to self.project
177
176
 
178
177
  self.ran_cca = False # this is set by CompleteCallingConventions to avoid reprocessing failed functions
179
178
 
@@ -254,9 +253,9 @@ class Function(Serializable):
254
253
  arch.name, platform=self.project.simos.name if self.project.simos is not None else None
255
254
  )(arch)
256
255
 
257
- self.calling_convention: Optional[SimCC] = cc
256
+ self.calling_convention: SimCC | None = cc
258
257
  else:
259
- self.calling_convention: Optional[SimCC] = None
258
+ self.calling_convention: SimCC | None = None
260
259
 
261
260
  @property
262
261
  @deprecated(".is_alignment")
@@ -281,7 +280,7 @@ class Function(Serializable):
281
280
  if self._project is None:
282
281
  # try to set it from function manager
283
282
  if self._function_manager is not None:
284
- self._project: Optional[Project] = self._function_manager._kb._project
283
+ self._project: Project | None = self._function_manager._kb._project
285
284
  return self._project
286
285
 
287
286
  @property
@@ -365,7 +364,7 @@ class Function(Serializable):
365
364
 
366
365
  return self._local_block_addrs
367
366
 
368
- def get_block(self, addr: int, size: Optional[int] = None, byte_string: Optional[bytes] = None):
367
+ def get_block(self, addr: int, size: int | None = None, byte_string: bytes | None = None):
369
368
  """
370
369
  Getting a block out of the current function.
371
370
 
@@ -396,7 +395,7 @@ class Function(Serializable):
396
395
  # compatibility
397
396
  _get_block = get_block
398
397
 
399
- def get_block_size(self, addr: int) -> Optional[int]:
398
+ def get_block_size(self, addr: int) -> int | None:
400
399
  return self._block_sizes.get(addr, None)
401
400
 
402
401
  @property
@@ -587,7 +586,7 @@ class Function(Serializable):
587
586
  return False
588
587
 
589
588
  def __str__(self):
590
- s = f"Function {self.name} [{self.addr}]\n"
589
+ s = f"Function {self.name} [{self.addr:#x}]\n"
591
590
  s += " Syscall: %s\n" % self.is_syscall
592
591
  s += " SP difference: %d\n" % self.sp_delta
593
592
  s += " Has return: %s\n" % self.has_return
@@ -664,7 +663,7 @@ class Function(Serializable):
664
663
  return self.addr - self.binary.mapped_base
665
664
 
666
665
  @property
667
- def symbol(self) -> Union[None, Symbol]:
666
+ def symbol(self) -> None | Symbol:
668
667
  """
669
668
  :return: the function's Symbol, if any
670
669
  """
@@ -1586,7 +1585,7 @@ class Function(Serializable):
1586
1585
  return ast.__str__()
1587
1586
  return self.name
1588
1587
 
1589
- def get_unambiguous_name(self, display_name: Optional[str] = None) -> str:
1588
+ def get_unambiguous_name(self, display_name: str | None = None) -> str:
1590
1589
  """
1591
1590
  Get a disambiguated function name.
1592
1591
 
@@ -1614,7 +1613,7 @@ class Function(Serializable):
1614
1613
  n += self.binary_name + separator
1615
1614
  return n + (display_name or self.name)
1616
1615
 
1617
- def apply_definition(self, definition: str, calling_convention: Optional[Union[SimCC, Type[SimCC]]] = None) -> None:
1616
+ def apply_definition(self, definition: str, calling_convention: SimCC | type[SimCC] | None = None) -> None:
1618
1617
  if not definition.endswith(";"):
1619
1618
  definition += ";"
1620
1619
  func_def = parse_defns(definition, arch=self.project.arch)
@@ -1642,7 +1641,7 @@ class Function(Serializable):
1642
1641
  else:
1643
1642
  raise TypeError("calling_convention has to be one of: [SimCC, type(SimCC), None]")
1644
1643
 
1645
- def functions_called(self) -> Set["Function"]:
1644
+ def functions_reachable(self) -> set["Function"]:
1646
1645
  """
1647
1646
  :return: The set of all functions that can be reached from the function represented by self.
1648
1647
  """
@@ -1,5 +1,5 @@
1
1
  # pylint:disable=raise-missing-from
2
- from typing import Dict, Generator, Optional, Set
2
+ from collections.abc import Generator
3
3
  import logging
4
4
  import collections.abc
5
5
  import re
@@ -83,8 +83,8 @@ class FunctionManager(KnowledgeBasePlugin, collections.abc.Mapping):
83
83
  super().__init__(kb=kb)
84
84
  self.function_address_types = self._kb._project.arch.function_address_types
85
85
  self.address_types = self._kb._project.arch.address_types
86
- self._function_map: Dict[int, Function] = FunctionDict(self, key_types=self.function_address_types)
87
- self.function_addrs_set: Set = set()
86
+ self._function_map: dict[int, Function] = FunctionDict(self, key_types=self.function_address_types)
87
+ self.function_addrs_set: set = set()
88
88
  self.callgraph = networkx.MultiDiGraph()
89
89
  self.block_map = {}
90
90
 
@@ -411,7 +411,7 @@ class FunctionManager(KnowledgeBasePlugin, collections.abc.Mapping):
411
411
  except KeyError:
412
412
  return None
413
413
 
414
- def query(self, query: str) -> Optional[Function]:
414
+ def query(self, query: str) -> Function | None:
415
415
  """
416
416
  Query for a function using selectors to disambiguate. Supported variations:
417
417
 
@@ -442,7 +442,7 @@ class FunctionManager(KnowledgeBasePlugin, collections.abc.Mapping):
442
442
 
443
443
  return None
444
444
 
445
- def function(self, addr=None, name=None, create=False, syscall=False, plt=None) -> Optional[Function]:
445
+ def function(self, addr=None, name=None, create=False, syscall=False, plt=None) -> Function | None:
446
446
  """
447
447
  Get a function object from the function manager.
448
448
 
@@ -1,5 +1,3 @@
1
- from typing import List
2
-
3
1
  from .plugin import KnowledgeBasePlugin
4
2
 
5
3
 
@@ -22,7 +20,7 @@ class IndirectJumps(KnowledgeBasePlugin, dict):
22
20
  for k, v in self.resolved.items():
23
21
  o.resolved[k] = v
24
22
 
25
- def update_resolved_addrs(self, indirect_address: int, resolved_addresses: List[int]):
23
+ def update_resolved_addrs(self, indirect_address: int, resolved_addresses: list[int]):
26
24
  # sanity check on usage
27
25
  if indirect_address is None:
28
26
  return
@@ -1,4 +1,4 @@
1
- from typing import Union, Optional
1
+ from typing import Union
2
2
  from enum import Enum, auto
3
3
 
4
4
  import claripy
@@ -65,7 +65,7 @@ class Atom:
65
65
 
66
66
  @staticmethod
67
67
  def from_argument(
68
- argument: SimFunctionArgument, arch: Arch, full_reg=False, sp: Optional[int] = None
68
+ argument: SimFunctionArgument, arch: Arch, full_reg=False, sp: int | None = None
69
69
  ) -> Union["Register", "MemoryLocation"]:
70
70
  """
71
71
  Instanciate an `Atom` from a given argument.
@@ -91,7 +91,7 @@ class Atom:
91
91
  raise TypeError("Argument type %s is not yet supported." % type(argument))
92
92
 
93
93
  @staticmethod
94
- def reg(thing: Union[str, RegisterOffset], size: Optional[int] = None, arch: Optional[Arch] = None) -> "Register":
94
+ def reg(thing: str | RegisterOffset, size: int | None = None, arch: Arch | None = None) -> "Register":
95
95
  """
96
96
  Create a Register atom.
97
97
 
@@ -126,7 +126,7 @@ class Atom:
126
126
  register = reg
127
127
 
128
128
  @staticmethod
129
- def mem(addr: Union[SpOffset, HeapAddress, int], size: int, endness: Optional[str] = None) -> "MemoryLocation":
129
+ def mem(addr: SpOffset | HeapAddress | int, size: int, endness: str | None = None) -> "MemoryLocation":
130
130
  """
131
131
  Create a MemoryLocation atom,
132
132
 
@@ -223,7 +223,7 @@ class Register(Atom):
223
223
  "arch",
224
224
  )
225
225
 
226
- def __init__(self, reg_offset: RegisterOffset, size: int, arch: Optional[Arch] = None):
226
+ def __init__(self, reg_offset: RegisterOffset, size: int, arch: Arch | None = None):
227
227
  super().__init__(size)
228
228
 
229
229
  self.reg_offset = reg_offset
@@ -254,14 +254,14 @@ class MemoryLocation(Atom):
254
254
  "endness",
255
255
  )
256
256
 
257
- def __init__(self, addr: Union[SpOffset, HeapAddress, int], size: int, endness: Optional[str] = None):
257
+ def __init__(self, addr: SpOffset | HeapAddress | int, size: int, endness: str | None = None):
258
258
  """
259
259
  :param int addr: The address of the beginning memory location slice.
260
260
  :param int size: The size of the represented memory location, in bytes.
261
261
  """
262
262
  super().__init__(size)
263
263
 
264
- self.addr: Union[SpOffset, int, claripy.ast.BV] = addr
264
+ self.addr: SpOffset | int | claripy.ast.BV = addr
265
265
  self.endness = endness
266
266
 
267
267
  def __repr__(self):
@@ -1,4 +1,4 @@
1
- from typing import Set, Optional, Literal, Type, TypeVar, Union, Generic
1
+ from typing import Optional, Literal, TypeVar, Generic
2
2
  from dataclasses import dataclass
3
3
  import logging
4
4
 
@@ -25,18 +25,18 @@ class DefinitionMatchPredicate:
25
25
  internal class; don't worry about this.
26
26
  """
27
27
 
28
- kind: Union[AtomKind, Type[Atom], None] = None
29
- bbl_addr: Optional[int] = None
30
- ins_addr: Optional[int] = None
31
- variable: Optional[SimVariable] = None
32
- variable_manager: Union[VariableManagerInternal, None, Literal[False]] = None
33
- stack_offset: Optional[int] = None
34
- reg_name: Optional[Union[str, int]] = None
35
- heap_offset: Optional[int] = None
36
- global_addr: Optional[int] = None
37
- tmp_idx: Optional[int] = None
38
- const_val: Optional[int] = None
39
- extern: Optional[bool] = None
28
+ kind: AtomKind | type[Atom] | None = None
29
+ bbl_addr: int | None = None
30
+ ins_addr: int | None = None
31
+ variable: SimVariable | None = None
32
+ variable_manager: VariableManagerInternal | None | Literal[False] = None
33
+ stack_offset: int | None = None
34
+ reg_name: str | int | None = None
35
+ heap_offset: int | None = None
36
+ global_addr: int | None = None
37
+ tmp_idx: int | None = None
38
+ const_val: int | None = None
39
+ extern: bool | None = None
40
40
 
41
41
  @staticmethod
42
42
  def construct(predicate: Optional["DefinitionMatchPredicate"] = None, **kwargs) -> "DefinitionMatchPredicate":
@@ -159,7 +159,7 @@ class Definition(Generic[A]):
159
159
  "_hash",
160
160
  )
161
161
 
162
- def __init__(self, atom: A, codeloc: CodeLocation, dummy: bool = False, tags: Optional[Set[Tag]] = None):
162
+ def __init__(self, atom: A, codeloc: CodeLocation, dummy: bool = False, tags: set[Tag] | None = None):
163
163
  self.atom: A = atom
164
164
  self.codeloc: CodeLocation = codeloc
165
165
  self.dummy: bool = dummy
@@ -1,5 +1,3 @@
1
- from typing import Dict, Tuple, Union, Set
2
-
3
1
  import claripy
4
2
 
5
3
  from .undefined import Undefined, UNDEFINED
@@ -16,10 +14,10 @@ class Environment:
16
14
 
17
15
  __slots__ = ("_environment",)
18
16
 
19
- def __init__(self, environment: Dict[Union[str, Undefined], Set[claripy.ast.Base]] = None):
20
- self._environment: Dict[Union[str, Undefined], Set[claripy.ast.Base]] = environment or {}
17
+ def __init__(self, environment: dict[str | Undefined, set[claripy.ast.Base]] = None):
18
+ self._environment: dict[str | Undefined, set[claripy.ast.Base]] = environment or {}
21
19
 
22
- def get(self, names: Set[str]) -> Tuple[Set[claripy.ast.Base], bool]:
20
+ def get(self, names: set[str]) -> tuple[set[claripy.ast.Base], bool]:
23
21
  """
24
22
  :param names: Potential values for the name of the environment variable to get the pointers of.
25
23
  :return:
@@ -40,7 +38,7 @@ class Environment:
40
38
 
41
39
  return pointers, has_unknown
42
40
 
43
- def set(self, name: Union[str, Undefined], pointers: Set[claripy.ast.Base]):
41
+ def set(self, name: str | Undefined, pointers: set[claripy.ast.Base]):
44
42
  """
45
43
  :param name: Name of the environment variable to which we will associate the pointers.
46
44
  :param pointers: New addresses where the new values of the environment variable are located.
@@ -59,7 +57,7 @@ class Environment:
59
57
  assert isinstance(other, Environment), "Cannot compare Environment with %s" % type(other).__name__
60
58
  return self._environment == other._environment
61
59
 
62
- def merge(self, *others: "Environment") -> Tuple["Environment", bool]:
60
+ def merge(self, *others: "Environment") -> tuple["Environment", bool]:
63
61
  new_env = self._environment
64
62
 
65
63
  for other in others:
@@ -1,5 +1,3 @@
1
- from typing import Union
2
-
3
1
  from .undefined import Undefined
4
2
 
5
3
 
@@ -8,7 +6,7 @@ class HeapAddress:
8
6
  The representation of an address on the heap.
9
7
  """
10
8
 
11
- def __init__(self, value: Union[int, Undefined]):
9
+ def __init__(self, value: int | Undefined):
12
10
  self._value = value
13
11
 
14
12
  @property
@@ -1,4 +1,5 @@
1
- from typing import Dict, Iterable, TYPE_CHECKING
1
+ from typing import TYPE_CHECKING
2
+ from collections.abc import Iterable
2
3
 
3
4
  from .. import KnowledgeBasePlugin
4
5
  from .rd_model import ReachingDefinitionsModel
@@ -39,7 +40,7 @@ class KeyDefinitionManager(KnowledgeBasePlugin):
39
40
 
40
41
  def __init__(self, kb: "KnowledgeBase"):
41
42
  super().__init__(kb=kb)
42
- self.model_by_funcaddr: Dict[int, ReachingDefinitionsModel] = {}
43
+ self.model_by_funcaddr: dict[int, ReachingDefinitionsModel] = {}
43
44
 
44
45
  def has_model(self, func_addr: int):
45
46
  return func_addr in self.model_by_funcaddr