Watch
0
0
Fork
You've already forked hyperhive
0

squid blocks a runtime deny list from the controller in every egress mode, ahead of the allow list

This commit is contained in:
atlas 2026-11-04 22:00:42 +01:00 • committed by mara
commit dd5fde848f

View file

@ -122,6 +122,12 @@ pub fn spawn(
shutdown.clone(),
));
// The swarm's egress deny list, on the same connection.
tokio::spawn(crate::workers::squid_deny::follow(
client.clone(),
shutdown.clone(),
));
// The permissions the swarm grants, and the import of the meta repo's.
tokio::spawn(crate::workers::swarm_permissions::follow(
client.clone(),
@ -375,15 +381,24 @@ struct Snapshot {
#[serde(flatten)]
readiness: crate::warnings::Readiness,
capabilities: &'static [&'static str],
/// The deny-list revision this hive rendered into squid's include
/// (`swarm_wire::hive_status::EGRESS_DENY_APPLIED`); absent until a pass has.
#[serde(skip_serializing_if = "Option::is_none")]
egress_deny_applied: Option<u64>,
}
fn snapshot() -> Snapshot {
snapshot_with(crate::workers::squid_deny::applied())
}
fn snapshot_with(egress_deny_applied: Option<u64>) -> Snapshot {
Snapshot {
readiness: crate::warnings::readiness(),
capabilities: &[
swarm_wire::hive_status::TOLERANT_PERMISSIONS,
swarm_wire::hive_status::NO_CONFIG_CHECKOUT,
],
egress_deny_applied,
}
}
@ -404,7 +419,7 @@ async fn publish(client: &async_nats::Client, hive: &str) -> Result<()> {
#[cfg(test)]
mod snapshot_tests {
use super::snapshot;
use super::{snapshot, snapshot_with};
/// The controller reads the capability out of the published bytes with
/// the wire type, and the readiness keeps its own top-level fields.
@ -421,4 +436,22 @@ mod snapshot_tests {
);
assert!(value.get("status").is_some() && value.get("warnings").is_some());
}
/// Before a pass has rendered the list the field is absent, as on a hive that
/// predates it; after, the controller reads the revision with the wire type.
#[test]
fn the_snapshot_carries_the_applied_deny_revision_once_there_is_one() {
let fresh = serde_json::to_value(snapshot_with(None)).unwrap();
assert!(
fresh
.get(swarm_wire::hive_status::EGRESS_DENY_APPLIED)
.is_none()
);
assert_eq!(swarm_wire::hive_status::egress_deny_applied(&fresh), None);
let rendered = serde_json::to_value(snapshot_with(Some(4))).unwrap();
assert_eq!(
swarm_wire::hive_status::egress_deny_applied(&rendered),
Some(4)
);
}
}