use kernel::{AxCode, AxError, Effect, TaintSet, TaintSource};
pub(super) fn entered(effect: &Effect, taint: &TaintSet) -> Result<TaintSet, AxError> {
let label = match effect {
Effect::Connector { label } => format!("mcp:{}", label.as_str()),
Effect::Egress => "web".to_owned(),
Effect::AttachUserBrowser { .. } => "web:browser".to_owned(),
Effect::Read | Effect::Write { .. } | Effect::Spawn | Effect::Govern | Effect::Spend => {
return Ok(taint.clone());
}
};
TaintSource::new(label)
.map(|source| taint.union(&TaintSet::of(source)))
.ok_or_else(|| {
AxError::failure(
AxCode::ConfigInvalid,
"mark the taint of outside content",
"the taint source label is empty",
)
.with_recovery("give the connector a non-empty server label")
})
}