Skip to content

Commit

Permalink
Try patch to make sure we don't loop on caller-checked implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidThien committed Feb 6, 2024
1 parent f1d814d commit ec02b28
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/audit_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,19 @@ impl EffectTree {
_ => None,
}
}

pub fn get_effect_infos(&self) -> HashSet<EffectInfo> {
match self {
EffectTree::Leaf(e, _) => vec![e.clone()].into_iter().collect::<HashSet<_>>(),
EffectTree::Branch(e, next) => {
let mut res = next.iter().map(|x| {
x.get_effect_infos()
}).flatten().collect::<HashSet<_>>();
res.insert(e.clone());
res
}
}
}
}

#[derive(Clone, Debug, Copy)]
Expand Down
11 changes: 10 additions & 1 deletion src/auditing/audit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,11 +357,20 @@ fn update_audit_annotation(
return Ok(AuditStatus::ContinueAudit);
}

// flatten the effect tree to look for duplicates so we don't loop
let prev_effects = effect_tree.get_effect_infos();

// Add all call locations as parents of this effect
let new_check_locs = scan_res
.get_callers(&curr_effect.caller_path)?
.into_iter()
.map(|e| EffectTree::Leaf(e, SafetyAnnotation::Skipped))
.filter_map(|e| {
if !prev_effects.contains(&e) {
Some(EffectTree::Leaf(e, SafetyAnnotation::Skipped))
} else {
None
}
})
.collect::<Vec<_>>();

if new_check_locs.is_empty() {
Expand Down

0 comments on commit ec02b28

Please sign in to comment.