feat(process): add explicitly granted process API
This commit is contained in:
1 parent
9922bfae98
commit
3ef18fb496
17 files changed
+433
-15
No files matched your search
@@ -26,6 +26,8 @@ pub struct SandboxSettings {
|
||||
pub allow_net: Vec<String>,
|
||||
/// Environment variable grants (ADR-0043).
|
||||
pub allow_env: Vec<String>,
|
||||
/// Process program grants (ADR-0044).
|
||||
pub allow_process: Vec<String>,
|
||||
/// Foreign execution grant.
|
||||
pub allow_foreign: bool,
|
||||
/// Plugin grants.
|
||||
@@ -77,6 +79,7 @@ impl SandboxSettings {
|
||||
|| !self.allow_net.is_empty()
|
||||
|| !self.allow_write.is_empty()
|
||||
|| !self.allow_env.is_empty()
|
||||
|| !self.allow_process.is_empty()
|
||||
|| !self.allow_plugin.is_empty()
|
||||
|| !self.plugins.is_empty()
|
||||
|| self.trust_native_plugin
|
||||
@@ -85,9 +88,9 @@ impl SandboxSettings {
|
||||
if requested {
|
||||
return Err(
|
||||
"strict mode currently supports pure Marqdo and native Math only; \
|
||||
--allow-read/--allow-write/--allow-env/--allow-foreign/--allow-plugin/\
|
||||
--plugin/--trust-native-plugin/--kernel/--trace-file are rejected. Use \
|
||||
--mode project for those capabilities."
|
||||
--allow-read/--allow-write/--allow-env/--allow-process/--allow-foreign/\
|
||||
--allow-plugin/--plugin/--trust-native-plugin/--kernel/--trace-file are
|
||||
rejected. Use --mode project for those capabilities."
|
||||
.to_string(),
|
||||
);
|
||||
}
|
||||
@@ -103,6 +106,7 @@ impl SandboxSettings {
|
||||
|| !self.allow_net.is_empty()
|
||||
|| !self.allow_write.is_empty()
|
||||
|| !self.allow_env.is_empty()
|
||||
|| !self.allow_process.is_empty()
|
||||
|| self.allow_foreign
|
||||
|| !self.allow_plugin.is_empty()
|
||||
{
|
||||
@@ -126,6 +130,9 @@ impl SandboxSettings {
|
||||
for name in &self.allow_env {
|
||||
capabilities = capabilities.allow_env(name.clone());
|
||||
}
|
||||
for program in &self.allow_process {
|
||||
capabilities = capabilities.allow_process(program.clone());
|
||||
}
|
||||
if self.allow_foreign {
|
||||
capabilities = capabilities.allow_foreign();
|
||||
}
|
||||
|
||||
@@ -95,6 +95,9 @@ struct SandboxArgs {
|
||||
/// Grant read access to an environment variable (repeatable, ADR-0043).
|
||||
#[arg(long = "allow-env", value_name = "NAME")]
|
||||
allow_env: Vec<String>,
|
||||
/// Grant execution of an exact program path (repeatable, ADR-0044).
|
||||
#[arg(long = "allow-process", value_name = "PROGRAM")]
|
||||
allow_process: Vec<String>,
|
||||
/// Grant explicit foreign kernel execution.
|
||||
#[arg(long = "allow-foreign")]
|
||||
allow_foreign: bool,
|
||||
@@ -147,6 +150,7 @@ impl SandboxArgs {
|
||||
allow_net: self.allow_net.clone(),
|
||||
allow_write: self.allow_write.clone(),
|
||||
allow_env: self.allow_env.clone(),
|
||||
allow_process: self.allow_process.clone(),
|
||||
allow_foreign: self.allow_foreign,
|
||||
allow_plugin: self.allow_plugin.clone(),
|
||||
fuel: self.fuel,
|
||||
|
||||
Reference in new issue
Block a user