fdg.control package

Submodules

fdg.control.ftn_search_strategy module

class fdg.control.ftn_search_strategy.BFS[source]

Bases: FunctionSearchStrategy

no need to save states

assign_states(dk_functions: list | None = None, current_state_key: str | None = None, fwrg: FWRG_manager | None = None, states_dict: dict = {}, iteration: int = 0) list[source]

assign functions for multiple states at the same time. :param deep_functions: :param current_state_key: :param fwrg: :param states_dict: :return:

initialize(flag_one_start_function: bool, preprocess_timeout: bool, preprocess_coverage: float, all_functions: list, fwrg_manager: FWRG_manager)[source]
termination(states_num: int = 0, current_seq_length: int = 0, sequence_depth_limit: int = 0, iteration: int = 0) bool[source]
class fdg.control.ftn_search_strategy.DFS[source]

Bases: FunctionSearchStrategy

assign_states(dk_functions: list | None = None, states_dict: dict = {}, iteration: int = 0) list[source]

save states, push state keys to the stack select a state by poping an item from the stack assign functions to be executed on the selected state

Parameters:
  • dk_functions

  • current_state_key

  • fdfg

  • states_dict

Returns:

initialize(flag_one_start_function: bool, preprocess_timeout: bool, preprocess_coverage: float, all_functions: list, fwrg_manager: FWRG_manager)[source]
termination(states_num: int = 0, current_seq_length: int = 0, sequence_depth_limit: int = 0, iteration: int = 0) bool[source]
class fdg.control.ftn_search_strategy.FunctionSearchStrategy(strategy_name: str)[source]

Bases: object

assign_states(dk_functions: list | None = None, current_state_key: str | None = None, fdfg: FWRG_manager | None = None, states_dict: dict = {}, iteration: int = 0) list[source]
delete_state(key: str)[source]
get_states(key: str)[source]
save_states(key: str, states: list)[source]
termination(states_num: int = 0, current_seq_length: int = 0, sequence_depth_limit: int = 0, iteration: int = 0) bool[source]
class fdg.control.ftn_search_strategy.RandomBaseline(percent_of_functions: int, functions: list)[source]

Bases: FunctionSearchStrategy

no need to save states

assign_states(dk_functions: list | None = None, states_dict: dict = {}) list[source]

apply BFS :param dk_functions: :param current_state_key: :param fwrg: :param states_dict: :return:

initialize(flag_one_start_function: bool)[source]
termination(states_num: int | None = None, current_seq_length: int = 0, sequence_depth_limit: int = 0, iteration: int = 0) bool[source]
class fdg.control.ftn_search_strategy.Seq[source]

Bases: FunctionSearchStrategy

assign_states(dk_functions: list | None = None, current_state_key: str | None = None, fdfg: FWRG_manager | None = None, states_dict: dict = {}, iteration: int = 0) list[source]
Parameters:
  • dk_functions

  • current_state_key

  • fdfg

  • states_dict

Returns:

initialize()[source]
termination(states_num: int = 0, current_seq_length: int = 0, sequence_depth_limit: int = 0, iteration: int = 0) bool[source]

fdg.control.function_assignment module

class fdg.control.function_assignment.FunctionAssignment(all_functions: list, fwrg_manager: FWRG_manager, select_percent: int = 0)[source]

Bases: object

assign_all_functions()[source]
assign_functions(state_key: str, dk_functions: list, to_execute_functions: list = [], not_to_execute: list = [])[source]
assign_functions_for_baseline() list[source]
assign_functions_timeout(state_key: str, dk_functions: list, percent_of_functions: int = 1)[source]
assign_functions_timeout_mine(state_key: str, dk_functions: list, randomly_selected_functions: list)[source]
can_reach_targets(ftn: str, targets: list, max_depth: int) bool[source]

check there is a path from ftn to one of the targets the max length of such a path should be no larger than max_depth

consider_dk_functions_not_reachable() list[source]

unreachable: the reads in a condition are not recognized, or no reads in a condition. handle: consider all the reads in a function

symbol(),name(),version() are functions that are not reachable.

fallback_case(ftn_seq: list)[source]
get_targets_be_reached(ftn: str, targets: list, max_depth: int) int[source]
record_assignment(assigned_functions: list)[source]
select_functions_randomly(percentage: int) list[source]
when_no_children_assigned(dk_functions: list)[source]

fdg.control.guider module

class fdg.control.guider.Guider(ftn_search_strategy: FunctionSearchStrategy, functions: list)[source]

Bases: object

end_iteration(laserEVM: LaserEVM, iteration: int)[source]
get_start_sequence(laserEVM: LaserEVM)[source]

get the sequences used to annotate the states (world states) at the end of Phase 1

init(start_functions: list, depth_k_functions: list, preprocess: Preprocessing)[source]
organize_states(states: [<class 'mythril.laser.ethereum.state.world_state.WorldState'>])[source]
save_genesis_states(states: list)[source]
should_terminate()[source]
start_iteration(laserEVM: LaserEVM | None = None, dk_functions: list | None = None, iteration: int = 0)[source]

prepare for states and functions to be executed on the states

Parameters:
  • laserEVM

  • deep_function

  • iteration

Returns:

fdg.control.mine module

class fdg.control.mine.Mine[source]

Bases: FunctionSearchStrategy

assign_states(dk_functions: list | None = None, states_dict: dict = {}, iteration: int = 0) list[source]
Parameters:
  • dk_functions

  • fwrg

  • states_dict

Returns:

assign_states_normal(dk_functions: list | None = None, states_dict: dict = {}) list[source]
Parameters:
  • dk_functions

  • fwrg

  • states_dict

Returns:

a state and the functions to be executed on it

a flag indicating whether this state can be deleted or not.

assign_states_timeout(dk_functions: list | None = None, states_dict: dict = {}, percent_of_functions: int = 1) list[source]
Parameters:
  • dk_functions

  • fwrg

  • states_dict

Returns:

break_a_tie(index_key_pairs: list, targets: list) int[source]
filter_states()[source]

for states generated from the same function sequence, only one is considered if two or more write the same state variables in the last step

get_written_slots_in_depth_str(state_key: str)[source]
initialize(flag_one_start_function: bool, preprocess_timeout: bool, preprocess_coverage: float, all_functions: list, fwrg_manager: FWRG_manager)[source]
pickup_a_state(targets: list)[source]

order states in self.queue return the first state in self.queue

termination(states_num: int = 0, current_seq_length: int = 0, sequence_depth_limit: int = 0, iteration: int = 0) bool[source]
update_states(states_dict: dict) list[source]

save states

fdg.control.weight_computation module

fdg.control.weight_computation.compute(weights: list) float[source]
fdg.control.weight_computation.compute_mine(weights: list) float[source]
fdg.control.weight_computation.simple_mean(weights: list) float[source]
fdg.control.weight_computation.turn_write_features_to_a_value(data: [<class 'bool'>]) float[source]

three featues:[primitive type,concrete write, new write)

fdg.control.weight_computation.weighted_mean(weights: list) float[source]

Module contents