pub enum Ceiling {
Unbounded,
Scopes(BTreeSet<String>),
}Expand description
The host’s ceiling for one script: the most it will let that script’s runs touch.
Variants§
Unbounded
The host imposes nothing beyond what the script declared and its publisher held.
Scopes(BTreeSet<String>)
Exactly these scopes. A grant ending in * admits every scope under that prefix
(urn:cap:net:*); a deny-shaped scope (is_deny_scope) is an exclusion every run
of the script carries.
Implementations§
Source§impl Ceiling
impl Ceiling
Sourcepub fn unbounded() -> Ceiling
pub fn unbounded() -> Ceiling
No ceiling: Ceiling::Unbounded.
Sourcepub fn nothing() -> Ceiling
pub fn nothing() -> Ceiling
The empty ceiling: the script may touch nothing, not even its language, so it cannot run. The answer for a script the host has no file for, when the host fails closed.
Sourcepub fn parse(text: &str) -> Result<Ceiling>
pub fn parse(text: &str) -> Result<Ceiling>
Parse the text of a ceiling file (<config home>/script-authority/{name}): one
urn:cap: scope per line, # to the end of a line is a comment, blank lines are
ignored. A lone * line means Ceiling::Unbounded.
use ikigai_script::authority::Ceiling;
let ceiling = Ceiling::parse(
"# the nightly report\nurn:cap:lisp\nurn:cap:net:* # any host\n\
urn:cap:net:-internal.example\n",
)
.unwrap();
assert!(ceiling.allows("urn:cap:lisp"));
assert!(ceiling.allows("urn:cap:net:example.com"));
assert!(!ceiling.allows("urn:cap:mail:send"));
assert_eq!(ceiling.exclusions(), vec!["urn:cap:net:-internal.example".to_string()]);
assert_eq!(Ceiling::parse("*\n").unwrap(), Ceiling::Unbounded);
assert!(Ceiling::parse("lisp\n").is_err()); // not a capability scopeSourcepub fn allows(&self, scope: &str) -> bool
pub fn allows(&self, scope: &str) -> bool
Whether the ceiling admits the grant scope: held exactly, or under a held
prefix* family. An exclusion is never admitted as a grant.
Sourcepub fn exclusions(&self) -> Vec<String>
pub fn exclusions(&self) -> Vec<String>
The exclusions the ceiling carries, which every run of the script carries too.