Plan OPNsense POSIX root scripts with explicit device policy, profile and approval
This commit is contained in:
@@ -441,7 +441,7 @@ pub(crate) async fn plan_resolved(
|
||||
let row = &rows[0];
|
||||
let caps = capabilities(row.get("capabilities"))?;
|
||||
let action = target_action(&input, &caps)?;
|
||||
if caps.iter().any(|s| s=="opnsense.base/1") &&
|
||||
if input.execution_identity=="agent_service" && caps.iter().any(|s| s=="opnsense.base/1") &&
|
||||
(input.max_runtime_seconds != 10 || input.max_output_bytes != 1024) {
|
||||
return Err(fail("UNSUPPORTED_CAPABILITY"));
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@ use uuid::Uuid;
|
||||
struct Policy {
|
||||
schema_version: u8,
|
||||
linux: Vec<RootScope>,
|
||||
#[serde(default)]
|
||||
opnsense: Vec<RootScope>,
|
||||
windows: Vec<SystemScope>,
|
||||
#[serde(default)]
|
||||
release_anchors: Vec<ReleaseAnchor>,
|
||||
@@ -123,6 +125,8 @@ impl Policy {
|
||||
return false;
|
||||
}
|
||||
let permits_subject = |subject: &str| match job.execution_identity.as_str() {
|
||||
"root" if caps.iter().any(|c| c=="opnsense.base/1") => self.opnsense.iter()
|
||||
.any(|scope| scope.permits(subject,job,caps,None)),
|
||||
"root" => self
|
||||
.linux
|
||||
.iter()
|
||||
@@ -206,7 +210,7 @@ pub(crate) async fn permits(
|
||||
.map_err(|_| invalid())?;
|
||||
let policy: Policy = serde_json::from_slice(&bytes).map_err(|_| invalid())?;
|
||||
if policy.schema_version != 1
|
||||
|| policy.linux.len() + policy.windows.len() > 64
|
||||
|| policy.linux.len() + policy.windows.len() + policy.opnsense.len() > 64
|
||||
|| policy.release_anchors.len() > 64
|
||||
|| policy
|
||||
.release_anchors
|
||||
|
||||
@@ -380,6 +380,9 @@ pub async fn authorize(
|
||||
if crate::managed_scripts::permits(tx, principal, job, &caps).await? {
|
||||
return Ok(());
|
||||
}
|
||||
if caps.iter().any(|c| c=="opnsense.base/1") {
|
||||
return Err(Error(StatusCode::FORBIDDEN,"SCRIPT_HELPER_SCOPE_DENIED"));
|
||||
}
|
||||
let policy = load()?;
|
||||
let global_log_units = if matches!(job.action, Action::QueryLogs { .. }) {
|
||||
parse_log_units(std::env::var("RMM_ROOT_LOG_UNITS").ok().as_deref())?
|
||||
|
||||
Reference in New Issue
Block a user