|
|
|
@ -1,5 +1,8 @@ |
|
|
|
|
from mythril.laser.ethereum.state.annotation import StateAnnotation |
|
|
|
|
from mythril.laser.ethereum.svm import LaserEVM |
|
|
|
|
from mythril.laser.ethereum.plugins.signals import PluginSkipWorldState |
|
|
|
|
from mythril.laser.ethereum.state.global_state import GlobalState |
|
|
|
|
from mythril.laser.ethereum.transaction.transaction_models import ContractCreationTransaction |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class MutationAnnotation(StateAnnotation): |
|
|
|
@ -28,4 +31,20 @@ class MutationPruner: |
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
def initialize(self, symbolic_vm: LaserEVM): |
|
|
|
|
pass |
|
|
|
|
"""Initializes the mutation pruner |
|
|
|
|
|
|
|
|
|
Introduces hooks for SSTORE operations |
|
|
|
|
:param symbolic_vm: |
|
|
|
|
:return: |
|
|
|
|
""" |
|
|
|
|
@symbolic_vm.pre_hook("SSTORE") |
|
|
|
|
def mutator_hook(global_state: GlobalState): |
|
|
|
|
global_state.annotate(MutationAnnotation()) |
|
|
|
|
|
|
|
|
|
@symbolic_vm.laser_hook("add_world_state") |
|
|
|
|
def world_state_filter_hook(global_state: GlobalState): |
|
|
|
|
if isinstance(global_state.current_transaction, ContractCreationTransaction): |
|
|
|
|
return |
|
|
|
|
if len(list(global_state.get_annotations(MutationAnnotation))) == 0: |
|
|
|
|
raise PluginSkipWorldState |
|
|
|
|
|
|
|
|
|