diff --git a/crates/paralegal-policy/src/context.rs b/crates/paralegal-policy/src/context.rs index d207c2caf5..feebdc08b2 100644 --- a/crates/paralegal-policy/src/context.rs +++ b/crates/paralegal-policy/src/context.rs @@ -1,8 +1,8 @@ use std::{io::Write, process::exit, sync::Arc}; use paralegal_spdg::{ - Annotation, CallSite, CallSiteOrDataSink, Ctrl, DataSink, DataSource, DefKind, HashMap, - HashSet, Identifier, MarkerAnnotation, MarkerRefinement, ProgramDescription, + Annotation, CallSiteOrDataSink, Ctrl, DataSink, DataSource, DefKind, HashMap, HashSet, + Identifier, MarkerAnnotation, MarkerRefinement, ProgramDescription, }; pub use paralegal_spdg::rustc_portable::DefId; @@ -241,19 +241,6 @@ impl Context { }) } - /// Returns an iterator over all the call sites marked with `marker` out of the provided `dsts`. - pub fn marked_callsites<'a>( - &'a self, - dsts: impl IntoIterator + 'a, - marker: Marker, - ) -> impl Iterator + 'a { - self.marked_sinks(dsts, marker) - .filter_map(|sink| match sink { - DataSink::Argument { function, .. } => Some(function), - _ => None, - }) - } - /// Returns an iterator over the data sources within controller `c` that have type `t`. pub fn srcs_with_type<'a>( &self, diff --git a/props/lemmy/src/main.rs b/props/lemmy/src/main.rs index 19b37a988b..47011f98aa 100644 --- a/props/lemmy/src/main.rs +++ b/props/lemmy/src/main.rs @@ -6,7 +6,7 @@ use std::sync::Arc; use paralegal_policy::{ assert_error, - paralegal_spdg::{CallSite, Ctrl, DataSource, Identifier}, + paralegal_spdg::{CallSite, Ctrl, DataSink, DataSource, Identifier}, Marker, PolicyContext, }; @@ -22,7 +22,11 @@ impl CommunityProp { fn flow_to_auth(&self, c: &Ctrl, sink: &CallSite, marker: Marker) -> bool { let auth_callsites = self .cx - .marked_callsites(c.data_flow.0.values().flatten(), marker) + .marked_sinks(c.data_flow.0.values().flatten(), marker) + .filter_map(|sink| match sink { + DataSink::Argument { function, .. } => Some(function), + _ => None, + }) .collect::>(); let mut influence_sink = c.ctrl_flow.0.iter().filter_map(|(src, dsts)| match src { @@ -40,7 +44,14 @@ impl CommunityProp { for c in self.cx.desc().controllers.values() { for dsts in c.data_flow.0.values() { - for write_sink in self.cx.marked_callsites(dsts, db_community_write) { + for write_sink in + self.cx + .marked_sinks(dsts, db_community_write) + .filter_map(|sink| match sink { + DataSink::Argument { function, .. } => Some(function), + _ => None, + }) + { let ok = self.flow_to_auth(c, write_sink, community_delete_check) && self.flow_to_auth(c, write_sink, community_ban_check); assert_error!(self.cx, !ok, "Found a failure!");