Struct cwe_checker_lib::analysis::string_abstraction::state::State
source · pub struct State<T: AbstractDomain + DomainInsertion + HasTop + Eq + From<String>> { /* private fields */ }
Expand description
Contains all information known about the state of a program at a specific point of time.
Implementations§
source§impl<T: AbstractDomain + DomainInsertion + HasTop + Eq + From<String>> State<T>
impl<T: AbstractDomain + DomainInsertion + HasTop + Eq + From<String>> State<T>
sourcepub fn new(
node_index: NodeIndex,
pointer_inference_results: &PointerInferenceComputation<'_>
) -> State<T>
pub fn new( node_index: NodeIndex, pointer_inference_results: &PointerInferenceComputation<'_> ) -> State<T>
Creates a new state.
sourcepub fn set_all_maps_empty(&mut self)
pub fn set_all_maps_empty(&mut self)
Removes all entries from the string maps.
sourcepub fn add_unassigned_return_pointer(
&mut self,
pointer: DataDomain<IntervalDomain>
)
pub fn add_unassigned_return_pointer( &mut self, pointer: DataDomain<IntervalDomain> )
Adds a return pointer to the unassigned return pointer set.
sourcepub fn get_unassigned_return_pointer(
&self
) -> &HashSet<DataDomain<IntervalDomain>>
pub fn get_unassigned_return_pointer( &self ) -> &HashSet<DataDomain<IntervalDomain>>
Returns the set of function return pointer that have not yet been assigned to a memory location or register.
sourcepub fn add_new_variable_to_pointer_entry(
&mut self,
variable: Variable,
pointer: DataDomain<IntervalDomain>
)
pub fn add_new_variable_to_pointer_entry( &mut self, variable: Variable, pointer: DataDomain<IntervalDomain> )
Adds a new variable to pointer entry to the map.
sourcepub fn add_new_stack_offset_to_string_entry(
&mut self,
offset: i64,
string_domain: T
)
pub fn add_new_stack_offset_to_string_entry( &mut self, offset: i64, string_domain: T )
Adds a new offset to string entry to the map.
sourcepub fn add_new_heap_to_string_entry(
&mut self,
heap_id: AbstractIdentifier,
string_domain: T
)
pub fn add_new_heap_to_string_entry( &mut self, heap_id: AbstractIdentifier, string_domain: T )
Adds a new heap id to string entry to the map.
sourcepub fn remove_heap_to_string_entry(&mut self, heap_id: &AbstractIdentifier)
pub fn remove_heap_to_string_entry(&mut self, heap_id: &AbstractIdentifier)
Removes a string from the heap to string map for the given abstract id.
sourcepub fn get_variable_to_pointer_map(
&self
) -> &HashMap<Variable, DataDomain<IntervalDomain>>
pub fn get_variable_to_pointer_map( &self ) -> &HashMap<Variable, DataDomain<IntervalDomain>>
Returns a reference to the variable to pointer map.
sourcepub fn set_variable_to_pointer_map(
&mut self,
map: HashMap<Variable, DataDomain<IntervalDomain>>
)
pub fn set_variable_to_pointer_map( &mut self, map: HashMap<Variable, DataDomain<IntervalDomain>> )
Sets the variable to pointer map to a new value.
sourcepub fn get_stack_offset_to_pointer_map(
&self
) -> &HashMap<i64, DataDomain<IntervalDomain>>
pub fn get_stack_offset_to_pointer_map( &self ) -> &HashMap<i64, DataDomain<IntervalDomain>>
Returns a reference to the variable to pointer map.
sourcepub fn get_stack_offset_to_string_map(&self) -> &HashMap<i64, T>
pub fn get_stack_offset_to_string_map(&self) -> &HashMap<i64, T>
Returns a reference to the stack offset to string map.
sourcepub fn get_heap_to_string_map(&self) -> &HashMap<AbstractIdentifier, T>
pub fn get_heap_to_string_map(&self) -> &HashMap<AbstractIdentifier, T>
Returns a reference to the heap to string map.
sourcepub fn get_current_sub(&self) -> Option<&Term<Sub>>
pub fn get_current_sub(&self) -> Option<&Term<Sub>>
Gets the current subroutine since the analysis is interprocedural.
sourcepub fn get_pointer_inference_state(&self) -> Option<&PointerInferenceState>
pub fn get_pointer_inference_state(&self) -> Option<&PointerInferenceState>
Get the current pointer inference state if it is contained as an intermediate value in the state.
sourcepub fn set_pointer_inference_state(
&mut self,
pi_state: Option<PointerInferenceState>
)
pub fn set_pointer_inference_state( &mut self, pi_state: Option<PointerInferenceState> )
Set the current pointer inference state for self
.
sourcepub fn delete_string_map_entries_if_no_pointer_targets_are_tracked(
&self
) -> Self
pub fn delete_string_map_entries_if_no_pointer_targets_are_tracked( &self ) -> Self
Deletes all entries in the string maps that do not have corresponding pointers in the pointer maps.
sourcepub fn collect_all_tracked_pointers(&self) -> Vec<DataDomain<IntervalDomain>>
pub fn collect_all_tracked_pointers(&self) -> Vec<DataDomain<IntervalDomain>>
Returns a vector of all currently tracked pointers.
sourcepub fn filter_string_map_entries(
&self,
pi_state: &PointerInferenceState
) -> (HashMap<i64, T>, HashMap<AbstractIdentifier, T>)
pub fn filter_string_map_entries( &self, pi_state: &PointerInferenceState ) -> (HashMap<i64, T>, HashMap<AbstractIdentifier, T>)
Removes all string entries for which the pointers are not tracked anymore.
sourcepub fn evaluate_constant(
&self,
runtime_memory_image: &RuntimeMemoryImage,
block_first_def_set: &HashSet<(Tid, Tid)>,
constant: Bitvector
) -> Option<DataDomain<IntervalDomain>>
pub fn evaluate_constant( &self, runtime_memory_image: &RuntimeMemoryImage, block_first_def_set: &HashSet<(Tid, Tid)>, constant: Bitvector ) -> Option<DataDomain<IntervalDomain>>
Evaluates the constant used as input of a Def Term. It checks whether it is a constant address pointing to global read only memory. If so, a pointer is added to the register map.
sourcepub fn handle_assign_and_load(
&mut self,
output: &Variable,
input: &Expression,
runtime_memory_image: &RuntimeMemoryImage,
block_first_def_set: &HashSet<(Tid, Tid)>,
is_assign: bool
)
pub fn handle_assign_and_load( &mut self, output: &Variable, input: &Expression, runtime_memory_image: &RuntimeMemoryImage, block_first_def_set: &HashSet<(Tid, Tid)>, is_assign: bool )
Handles assign and load Def Terms.
sourcepub fn check_if_output_is_string_pointer_and_add_targets(
&mut self,
pi_state: &PointerInferenceState,
output: &Variable,
runtime_memory_image: &RuntimeMemoryImage,
block_first_def_set: &HashSet<(Tid, Tid)>
) -> bool
pub fn check_if_output_is_string_pointer_and_add_targets( &mut self, pi_state: &PointerInferenceState, output: &Variable, runtime_memory_image: &RuntimeMemoryImage, block_first_def_set: &HashSet<(Tid, Tid)> ) -> bool
Checks whether the given pointer points to a string and adds missing targets to the string maps as Top values.
sourcepub fn add_global_pointer_if_input_is_string_constant(
&mut self,
runtime_memory_image: &RuntimeMemoryImage,
block_first_def_set: &HashSet<(Tid, Tid)>,
output: &Variable,
input: &Expression
) -> bool
pub fn add_global_pointer_if_input_is_string_constant( &mut self, runtime_memory_image: &RuntimeMemoryImage, block_first_def_set: &HashSet<(Tid, Tid)>, output: &Variable, input: &Expression ) -> bool
If the input is a string constant, add the global pointer to the variable map.
sourcepub fn add_relative_targets_to_string_maps(
&mut self,
pi_state: &PointerInferenceState,
pointer: &DataDomain<IntervalDomain>
)
pub fn add_relative_targets_to_string_maps( &mut self, pi_state: &PointerInferenceState, pointer: &DataDomain<IntervalDomain> )
Adds all relative targets of the given DataDomain to the string maps if they are not already tracked.
sourcepub fn pointer_added_to_variable_maps(
&mut self,
pi_state: &PointerInferenceState,
output: &Variable,
loaded_pointer: DataDomain<IntervalDomain>
) -> bool
pub fn pointer_added_to_variable_maps( &mut self, pi_state: &PointerInferenceState, output: &Variable, loaded_pointer: DataDomain<IntervalDomain> ) -> bool
Adds a pointer to the variable pointer maps if its targets were fully or partially tracked. Returns true if it was added.
sourcepub fn pointer_added_to_stack_maps(
&mut self,
pi_state: &PointerInferenceState,
target_address: &Expression,
potential_string_pointer: DataDomain<IntervalDomain>
) -> bool
pub fn pointer_added_to_stack_maps( &mut self, pi_state: &PointerInferenceState, target_address: &Expression, potential_string_pointer: DataDomain<IntervalDomain> ) -> bool
Adds a pointer to the stack pointer maps if its targets were fully or partially tracked.
sourcepub fn pointer_targets_partially_tracked(
&mut self,
pi_state: &PointerInferenceState,
pointer: &DataDomain<IntervalDomain>
) -> bool
pub fn pointer_targets_partially_tracked( &mut self, pi_state: &PointerInferenceState, pointer: &DataDomain<IntervalDomain> ) -> bool
If only some targets of a pointer point to tracked strings, add top values for the other targets. It is assumed that all targets point to the same data type.
sourcepub fn add_top_domain_values_for_additional_pointer_targets(
&mut self,
new_stack_entries: Vec<i64>,
new_heap_entries: Vec<AbstractIdentifier>
)
pub fn add_top_domain_values_for_additional_pointer_targets( &mut self, new_stack_entries: Vec<i64>, new_heap_entries: Vec<AbstractIdentifier> )
Adds Top values to stack and heap maps for additional pointer targets.
sourcepub fn pointer_is_in_pointer_maps(
&self,
pointer: &DataDomain<IntervalDomain>
) -> bool
pub fn pointer_is_in_pointer_maps( &self, pointer: &DataDomain<IntervalDomain> ) -> bool
Checks whether a given pointer is contained in one of the pointer maps.
sourcepub fn handle_store(
&mut self,
target_address: &Expression,
value: &Expression,
runtime_memory_image: &RuntimeMemoryImage,
block_first_def_set: &HashSet<(Tid, Tid)>
)
pub fn handle_store( &mut self, target_address: &Expression, value: &Expression, runtime_memory_image: &RuntimeMemoryImage, block_first_def_set: &HashSet<(Tid, Tid)> )
Handles store Def Terms.
sourcepub fn add_pointer_to_stack_map(
&mut self,
target: &Expression,
string_pointer: DataDomain<IntervalDomain>
)
pub fn add_pointer_to_stack_map( &mut self, target: &Expression, string_pointer: DataDomain<IntervalDomain> )
If a string pointer is to be stored on the stack, add it to the stack map.
sourcepub fn remove_non_callee_saved_pointer_entries_for_external_symbol(
&mut self,
project: &Project,
extern_symbol: &ExternSymbol
)
pub fn remove_non_callee_saved_pointer_entries_for_external_symbol( &mut self, project: &Project, extern_symbol: &ExternSymbol )
Removes all non callee saved register entries from the variable to pointer map.
sourcepub fn is_stack_pointer(
pi_state: &PointerInferenceState,
target: &AbstractIdentifier
) -> bool
pub fn is_stack_pointer( pi_state: &PointerInferenceState, target: &AbstractIdentifier ) -> bool
Checks whether a target refers to the Stack.
Trait Implementations§
source§impl<T: AbstractDomain + DomainInsertion + HasTop + Eq + From<String>> AbstractDomain for State<T>
impl<T: AbstractDomain + DomainInsertion + HasTop + Eq + From<String>> AbstractDomain for State<T>
source§impl<T: Clone + AbstractDomain + DomainInsertion + HasTop + Eq + From<String>> Clone for State<T>
impl<T: Clone + AbstractDomain + DomainInsertion + HasTop + Eq + From<String>> Clone for State<T>
source§impl<T: Debug + AbstractDomain + DomainInsertion + HasTop + Eq + From<String>> Debug for State<T>
impl<T: Debug + AbstractDomain + DomainInsertion + HasTop + Eq + From<String>> Debug for State<T>
source§impl<'de, T> Deserialize<'de> for State<T>
impl<'de, T> Deserialize<'de> for State<T>
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl<T: PartialEq + AbstractDomain + DomainInsertion + HasTop + Eq + From<String>> PartialEq for State<T>
impl<T: PartialEq + AbstractDomain + DomainInsertion + HasTop + Eq + From<String>> PartialEq for State<T>
impl<T: Eq + AbstractDomain + DomainInsertion + HasTop + Eq + From<String>> Eq for State<T>
impl<T: AbstractDomain + DomainInsertion + HasTop + Eq + From<String>> StructuralEq for State<T>
impl<T: AbstractDomain + DomainInsertion + HasTop + Eq + From<String>> StructuralPartialEq for State<T>
Auto Trait Implementations§
impl<T> RefUnwindSafe for State<T>where
T: RefUnwindSafe,
impl<T> Send for State<T>where
T: Send,
impl<T> Sync for State<T>where
T: Sync,
impl<T> Unpin for State<T>where
T: Unpin,
impl<T> UnwindSafe for State<T>where
T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.