MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / grant_capabilities

Function grant_capabilities

libatomic/src/daemon/sandbox_grants.rs:239–255  ·  view source on GitHub ↗

A requested capability list as a grant's set: nonempty, and every entry delegable.

(requested: &[String])

Source from the content-addressed store, hash-verified

237/// A requested capability list as a grant's set: nonempty, and every entry
238/// delegable.
239pub fn grant_capabilities(requested: &[String]) -> Result<BTreeSet<String>, GrantError> {
240 if requested.is_empty() {
241 return Err(GrantError::InvalidCapabilities(
242 "name the capabilities the sandbox needs".to_string(),
243 ));
244 }
245 let mut out = BTreeSet::new();
246 for capability in requested {
247 if !DELEGABLE_CAPABILITIES.contains(&capability.as_str()) {
248 return Err(GrantError::InvalidCapabilities(format!(
249 "'{capability}' cannot be delegated to a sandbox"
250 )));
251 }
252 out.insert(capability.clone());
253 }
254 Ok(out)
255}
256
257/// Where sandbox grants live. The handlers only ever reach grants through
258/// this trait; a host that persists grants (its own database) implements it

Callers 1

open_sandboxMethod · 0.85

Calls 5

is_emptyMethod · 0.45
containsMethod · 0.45
as_strMethod · 0.45
insertMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected