pub struct State { /* private fields */ }
Expand description
The state object of the taint analysis representing all known tainted memory and register values at a certain location within the program.
Implementations§
source§impl State
impl State
sourcepub fn new_return(
taint_source: &ExternSymbol,
vsa_result: &impl VsaResult<ValueDomain = PiData>,
return_node: NodeIndex
) -> Self
pub fn new_return( taint_source: &ExternSymbol, vsa_result: &impl VsaResult<ValueDomain = PiData>, return_node: NodeIndex ) -> Self
Returns a state where only return values of the extern call are tainted.
sourcepub fn eval(&self, expression: &Expression) -> Taint
pub fn eval(&self, expression: &Expression) -> Taint
Evaluate whether the result of the given expression is tainted in the current state.
sourcepub fn load_taint_from_memory(&self, address: &PiData, size: ByteSize) -> Taint
pub fn load_taint_from_memory(&self, address: &PiData, size: ByteSize) -> Taint
Returns the taint of the value at the given address (with the given size).
If the address may point to more than one location, then the taint state of all possible locations is merged. Only exact locations are considered, all other locations are treated as untainted.
sourcepub fn save_taint_to_memory(&mut self, address: &PiData, taint: Taint)
pub fn save_taint_to_memory(&mut self, address: &PiData, taint: Taint)
Mark the value at the given address with the given taint.
If the address may point to more than one object, we merge the taint into all objects for which the corresponding offset is exact. Since we merge, this will never remove any taint.
If the pointee object and offset are exactly known, we write the
taint
to the object at the given offset. This may remove taint.
In all other cases we do nothing.
sourcepub fn remove_all_memory_taints(&mut self)
pub fn remove_all_memory_taints(&mut self)
Remove all knowledge about taints contained in memory objects.
sourcepub fn set_register_taint(&mut self, register: &Variable, taint: Taint)
pub fn set_register_taint(&mut self, register: &Variable, taint: Taint)
Set the taint of a register.
sourcepub fn get_register_taint(&self, register: &Variable) -> Taint
pub fn get_register_taint(&self, register: &Variable) -> Taint
Returns the taint state of the given register.
sourcepub fn check_mem_id_for_taint(&self, id: &AbstractIdentifier) -> bool
pub fn check_mem_id_for_taint(&self, id: &AbstractIdentifier) -> bool
Returns true if the memory object with the given ID contains a tainted value.
sourcepub fn check_if_address_points_to_taint(&self, address: PiData) -> bool
pub fn check_if_address_points_to_taint(&self, address: PiData) -> bool
Check if the given address points to tainted memory.
Returns true iff the value at any of the exact memory locations that the pointer may point to is tainted.
sourcepub fn check_generic_function_params_for_taint<const POINTER_TAINT: bool>(
&self,
vsa_result: &impl VsaResult<ValueDomain = PiData>,
call_tid: &Tid,
project: &Project,
calling_convention_hint: &Option<String>
) -> bool
pub fn check_generic_function_params_for_taint<const POINTER_TAINT: bool>( &self, vsa_result: &impl VsaResult<ValueDomain = PiData>, call_tid: &Tid, project: &Project, calling_convention_hint: &Option<String> ) -> bool
Check if a generic function call may contain tainted values in its arguments.
If POINTER_TAINT
is selected, pointers to tainted memory are
considered to be tainted.
Since we don’t know the actual parameters of the call, we approximate the parameters with all parameter registers of the calling convention of the function or of the standard calling convention of the project.
In case no standard calling convention is found. We assume everything may be parameters or referenced by parameters, i.e., we assume the parameters of the call are tainted iff there is taint in the state.
sourcepub fn check_return_values_for_taint<const POINTER_TAINT: bool>(
&self,
vsa_result: &impl VsaResult<ValueDomain = PiData>,
return_tid: &Tid,
project: &Project,
calling_convention_hint: &Option<String>
) -> bool
pub fn check_return_values_for_taint<const POINTER_TAINT: bool>( &self, vsa_result: &impl VsaResult<ValueDomain = PiData>, return_tid: &Tid, project: &Project, calling_convention_hint: &Option<String> ) -> bool
Check if the return registers may contain tainted values.
If POINTER_TAINT
is selected, pointers to tainted memory are
considered to be tainted.
Since we don’t know the actual return registers, we approximate them by all return registers of the calling convention of the function or of the standard calling convention of the project.
If no standard calling convention is found, we assume that everything may be a return value or referenced by return values.
sourcepub fn remove_non_callee_saved_taint(
&mut self,
calling_conv: &CallingConvention
)
pub fn remove_non_callee_saved_taint( &mut self, calling_conv: &CallingConvention )
Remove the taint from all registers not contained in the callee-saved register list of the given calling convention.
sourcepub fn check_extern_parameters_for_taint<const POINTER_TAINT: bool>(
&self,
vsa_result: &impl VsaResult<ValueDomain = PiData>,
extern_symbol: &ExternSymbol,
call_tid: &Tid
) -> bool
pub fn check_extern_parameters_for_taint<const POINTER_TAINT: bool>( &self, vsa_result: &impl VsaResult<ValueDomain = PiData>, extern_symbol: &ExternSymbol, call_tid: &Tid ) -> bool
Check parameters of a call to an extern symbol for taint.
If POINTER_TAINT
is selected, we also return true if a pointer to
tainted memory is passed as an argument.
sourcepub fn has_register_taint(&self) -> bool
pub fn has_register_taint(&self) -> bool
Check whether there are any tainted registers in the state.
sourcepub fn has_memory_taint(&self) -> bool
pub fn has_memory_taint(&self) -> bool
Check whether there is any tainted memory in the state.
sourcepub fn merge_with_renaming(
&mut self,
other: &Self,
renaming_map: Option<&BTreeMap<AbstractIdentifier, PiData>>
)
pub fn merge_with_renaming( &mut self, other: &Self, renaming_map: Option<&BTreeMap<AbstractIdentifier, PiData>> )
Merges the given other
state into this state with renaming of abstract
identifiers.
The set of valid abstract identfiers (aIDs) is local to a given function. When merging states across function boundaries it is necessary to map aIDs into the set of valid aIDs in the target context before performing the merging.
This function assumes that the target context is the one of self
and
that renaming_map
specifies how valid aIDs in the context of other
correspond to the aIDs of this context.
sourcepub fn into_mem_reg_taint(
self
) -> (DomainMap<Variable, Taint, UnionMergeStrategy>, DomainMap<AbstractIdentifier, MemRegion<Taint>, MemoryTaintMergeStrategy>)
pub fn into_mem_reg_taint( self ) -> (DomainMap<Variable, Taint, UnionMergeStrategy>, DomainMap<AbstractIdentifier, MemRegion<Taint>, MemoryTaintMergeStrategy>)
Deconstructs a State
into its register and memory taint maps.
sourcepub fn from_mem_reg_taint(
register_taint: DomainMap<Variable, Taint, UnionMergeStrategy>,
memory_taint: DomainMap<AbstractIdentifier, MemRegion<Taint>, MemoryTaintMergeStrategy>
) -> Self
pub fn from_mem_reg_taint( register_taint: DomainMap<Variable, Taint, UnionMergeStrategy>, memory_taint: DomainMap<AbstractIdentifier, MemRegion<Taint>, MemoryTaintMergeStrategy> ) -> Self
Constructs a State
from register and memory taint maps.
Trait Implementations§
source§impl AbstractDomain for State
impl AbstractDomain for State
source§impl<'de> Deserialize<'de> for State
impl<'de> Deserialize<'de> for State
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 ToJsonCompact for State
impl ToJsonCompact for State
source§fn to_json_compact(&self) -> Value
fn to_json_compact(&self) -> Value
self
that is
suitable for debugging purposes. Read moresource§fn print_compact_json(&self)
fn print_compact_json(&self)
Self
for debugging purposes.impl Eq for State
impl StructuralEq for State
Auto Trait Implementations§
impl RefUnwindSafe for State
impl Send for State
impl Sync for State
impl Unpin for State
impl UnwindSafe for State
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.