squid blocks a runtime deny list from the controller in every egress mode, ahead of the allow list
This commit is contained in:
parent
99ab0ae77f
commit
dd5fde848f
1 changed files with 1814 additions and 24 deletions
|
|
@ -613,6 +613,9 @@ impl Policy {
|
|||
// The egress allow-list (`swarm_wire::egress_allow`): one key, read with
|
||||
// one direct get, so exactly that subject and no other key of the bucket.
|
||||
subjects.push(swarm_wire::egress_allow::direct_get_subject());
|
||||
// The deny list is a second key of that bucket, read the same way; the
|
||||
// allow-list grant does not cover it, since it names one key.
|
||||
subjects.push(swarm_wire::egress_allow::deny_direct_get_subject());
|
||||
// The archetype an agent was created from
|
||||
// (`swarm_queue_client::agent_archetype`), read the same way and every
|
||||
// key for the same reason.
|
||||
|
|
@ -984,6 +987,48 @@ mod tests {
|
|||
}
|
||||
}
|
||||
|
||||
/// A hive reads the deny list with its own grant, not the allow-list's, and
|
||||
/// can change none of it. An agent's token reaches neither key, so nothing an
|
||||
/// agent holds can write the list a hive enforces.
|
||||
#[test]
|
||||
fn a_hive_reads_the_deny_list_and_no_agent_reaches_it() {
|
||||
use swarm_wire::egress_allow::{
|
||||
STREAM, deny_direct_get_subject, deny_key_subject, direct_get_subject, key_subject,
|
||||
};
|
||||
|
||||
let p = policy()
|
||||
.permissions("hive-alpha")
|
||||
.expect("a hive is admitted");
|
||||
let may = |subject: &str| p.publish.iter().any(|g| covers(g, subject));
|
||||
assert!(may(&deny_direct_get_subject()), "cannot read the deny list");
|
||||
for forbidden in [
|
||||
deny_key_subject(),
|
||||
format!("$JS.API.STREAM.PURGE.{STREAM}"),
|
||||
format!("$JS.API.STREAM.MSG.DELETE.{STREAM}"),
|
||||
] {
|
||||
assert!(!may(&forbidden), "hive alpha may publish {forbidden}");
|
||||
}
|
||||
|
||||
let agent = policy()
|
||||
.with_agent_token_subjects(vec!["$SWARM.term.{agent}".to_owned()])
|
||||
.expect("a per-agent template is valid")
|
||||
.agent_token_permissions("atlas")
|
||||
.expect("configured");
|
||||
let agent_may = |subject: &str| agent.publish.iter().any(|g| covers(g, subject));
|
||||
for reached in [
|
||||
deny_key_subject(),
|
||||
deny_direct_get_subject(),
|
||||
key_subject(),
|
||||
direct_get_subject(),
|
||||
] {
|
||||
assert!(!agent_may(&reached), "an agent may publish {reached}");
|
||||
}
|
||||
// Control: the lookup finds a subject the agent is granted.
|
||||
assert!(agent_may(
|
||||
&swarm_queue_client::operator_profiles::direct_get_subject()
|
||||
));
|
||||
}
|
||||
|
||||
/// A hive reads any agent's archetype and can change none of them, and the
|
||||
/// grant reaches no other bucket.
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Reference in a new issue