whitesymex.path_group module

class whitesymex.path_group.PathGroup(state: State)

Bases: object

Organizes states into stashes for symbolic execution.

active

A list of states that are still active.

deadended

A list of states that are exited gracefully.

avoided

A list of avoided states.

found

A list of found states.

errored

A list of states that encounter an error during execution.

explore(find: Optional[Union[bytes, Callable[[State], bool]]] = None, avoid: Optional[Union[bytes, Callable[[State], bool]]] = None, strategy: type[strategies.Strategy] = <class 'whitesymex.strategies.bfs.BFS'>, loop_limit: Optional[int] = None, num_find: int = 1)

Explores the active states and updates stashes accordingly.

It returns when there is no active states left or num_find states are found.

Parameters
  • find – Either bytes that are expected to be found in a state’s stdout or a function that accepts a state and returns True if the state shall be classified as found.

  • avoid – Either bytes that are expected to be avoided in a state’s stdout or a function that accepts a state and returns True if the state shall be classified as avoided.

  • strategy – A strategies.Strategy subclass that will be used to select states at each iteration.

  • loop_limit – A maximum limit for loops with a symbolic expression as its condition.

  • num_find – Number of states to be found.

Raises

StrategyError – The given strategy is not a subclass of strategies.Strategy class.

whitesymex.path_group.condition_to_lambda(condition: Optional[Union[bytes, Callable[[State], bool]]], default: bool = False)Callable[[State], bool]

Converts condition to lambda function that returns True or False.

Parameters
  • condition – A condition can be a function or bytes that are expected to be found in a state’s stdout.

  • default – A bool value to be returned by lambda function if the condition is None.

Returns

A lambda function that accepts a state as parameter that returns True if the condition is satisfied.