feat(random): add explicitly granted OS entropy API
This commit is contained in:
1 parent
6338fa10e9
commit
ee0c6cc80a
20 files changed
+309
-15
No files matched your search
@@ -23,6 +23,8 @@ pub struct SandboxSettings {
|
||||
pub allow_env: Vec<String>,
|
||||
/// Process program grants (ADR-0044).
|
||||
pub allow_process: Vec<String>,
|
||||
/// OS entropy grant (ADR-0046).
|
||||
pub allow_random: bool,
|
||||
/// Foreign execution grant.
|
||||
pub allow_foreign: bool,
|
||||
/// Plugin grants.
|
||||
@@ -75,6 +77,7 @@ impl SandboxSettings {
|
||||
|| !self.allow_write.is_empty()
|
||||
|| !self.allow_env.is_empty()
|
||||
|| !self.allow_process.is_empty()
|
||||
|| self.allow_random
|
||||
|| !self.allow_plugin.is_empty()
|
||||
|| !self.plugins.is_empty()
|
||||
|| self.trust_native_plugin
|
||||
@@ -83,8 +86,8 @@ impl SandboxSettings {
|
||||
if requested {
|
||||
return Err(
|
||||
"strict mode currently supports pure Marqdo and native Math only; \
|
||||
--allow-read/--allow-write/--allow-env/--allow-process/--allow-foreign/\
|
||||
--allow-plugin/--plugin/--trust-native-plugin/--kernel/--trace-file are
|
||||
--allow-read/--allow-write/--allow-env/--allow-process/--allow-random/\
|
||||
--allow-foreign/--allow-plugin/--plugin/--trust-native-plugin/--kernel/--trace-file are
|
||||
rejected. Use --mode project for those capabilities."
|
||||
.to_string(),
|
||||
);
|
||||
@@ -102,6 +105,7 @@ impl SandboxSettings {
|
||||
|| !self.allow_write.is_empty()
|
||||
|| !self.allow_env.is_empty()
|
||||
|| !self.allow_process.is_empty()
|
||||
|| self.allow_random
|
||||
|| self.allow_foreign
|
||||
|| !self.allow_plugin.is_empty()
|
||||
{
|
||||
@@ -128,6 +132,9 @@ impl SandboxSettings {
|
||||
for program in &self.allow_process {
|
||||
capabilities = capabilities.allow_process(program.clone());
|
||||
}
|
||||
if self.allow_random {
|
||||
capabilities = capabilities.allow_random();
|
||||
}
|
||||
if self.allow_foreign {
|
||||
capabilities = capabilities.allow_foreign();
|
||||
}
|
||||
|
||||
@@ -98,6 +98,9 @@ struct SandboxArgs {
|
||||
/// Grant execution of an exact program path (repeatable, ADR-0044).
|
||||
#[arg(long = "allow-process", value_name = "PROGRAM")]
|
||||
allow_process: Vec<String>,
|
||||
/// Grant OS entropy reads (ADR-0046).
|
||||
#[arg(long = "allow-random")]
|
||||
allow_random: bool,
|
||||
/// Grant explicit foreign kernel execution.
|
||||
#[arg(long = "allow-foreign")]
|
||||
allow_foreign: bool,
|
||||
@@ -151,6 +154,7 @@ impl SandboxArgs {
|
||||
allow_write: self.allow_write.clone(),
|
||||
allow_env: self.allow_env.clone(),
|
||||
allow_process: self.allow_process.clone(),
|
||||
allow_random: self.allow_random,
|
||||
allow_foreign: self.allow_foreign,
|
||||
allow_plugin: self.allow_plugin.clone(),
|
||||
fuel: self.fuel,
|
||||
|
||||
Reference in new issue
Block a user