Plan an exact service-account OPNsense kernel probe through normal approval
This commit is contained in:
@@ -480,7 +480,16 @@ impl Action {
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
/// Shared plan/revalidation/start gate. Passive Windows never implies job support.
|
||||
/// The first FreeBSD profile is one exact POSIX script. It does not make
|
||||
/// an appliance eligible for the Linux library, arbitrary scripts or root.
|
||||
pub fn opnsense_kernel_probe(&self) -> bool {
|
||||
matches!(self, Self::RunScript { interpreter, script_utf8, arguments,
|
||||
expected_stdout: Some(expected), windows_execution_profile: None, privileged_script_profile: None }
|
||||
if interpreter == "posix_sh" && script_utf8 == "uname -s\n"
|
||||
&& arguments.is_empty() && expected == "FreeBSD\n")
|
||||
}
|
||||
|
||||
/// Shared plan/revalidation/start gate. Passive inventory never implies job support.
|
||||
pub fn available_for(&self, identity: &str, capabilities: &[String]) -> bool {
|
||||
if !self.valid_execution_identity(identity)
|
||||
|| (identity == "system"
|
||||
@@ -490,6 +499,11 @@ impl Action {
|
||||
return false;
|
||||
}
|
||||
let has = |cap: &str| capabilities.iter().any(|c| c == cap);
|
||||
if has("opnsense.base/1") {
|
||||
return identity == "agent_service" && has("run_script") && has("rmm.sync.v1")
|
||||
&& has("opnsense.uname/1") && !has("windows.base/1") && !has("linux.base/1")
|
||||
&& self.opnsense_kernel_probe();
|
||||
}
|
||||
if !has(self.name())
|
||||
|| (self.full_maintenance()
|
||||
&& !((has(FULL_MAINTENANCE_CAPABILITY)
|
||||
@@ -828,6 +842,22 @@ impl JobState {
|
||||
mod tests {
|
||||
use super::*;
|
||||
#[test]
|
||||
fn appliance_kernel_probe_rejects_unbound_or_changed_profiles() {
|
||||
let caps: Vec<String> = ["run_script","opnsense.base/1","rmm.sync.v1","opnsense.uname/1"].map(String::from).into();
|
||||
let mut a = Action::RunScript { interpreter:"posix_sh".into(),script_utf8:"uname -s\n".into(),
|
||||
arguments:vec![],expected_stdout:Some("FreeBSD\n".into()),windows_execution_profile:None,privileged_script_profile:None };
|
||||
assert!(a.available_for("agent_service",&caps));
|
||||
for excluded in &caps {
|
||||
let fewer = caps.iter().filter(|v| *v!=excluded).cloned().collect::<Vec<_>>();
|
||||
assert!(!a.available_for("agent_service",&fewer));
|
||||
}
|
||||
assert!(!a.available_for("root",&caps));
|
||||
let mut mixed = caps.clone(); mixed.push("linux.base/1".into());
|
||||
assert!(!a.available_for("agent_service",&mixed));
|
||||
if let Action::RunScript { script_utf8,.. } = &mut a { script_utf8.push(' '); }
|
||||
assert!(!a.available_for("agent_service",&caps));
|
||||
}
|
||||
#[test]
|
||||
fn windows_update_final_report_and_policy_are_exact() {
|
||||
assert_eq!(
|
||||
windows_update_reboot_report(
|
||||
|
||||
Reference in New Issue
Block a user