Add fresh device trust, installer recovery and scoped patch runtime
This commit is contained in:
@@ -45,6 +45,8 @@ struct SystemScope {
|
||||
deserialize_with = "rmm_domain::jobs::deserialize_script_profiles"
|
||||
)]
|
||||
allowed_script_profiles: Option<Vec<rmm_domain::jobs::PrivilegedScriptProfile>>,
|
||||
#[serde(default)]
|
||||
windows_update_max_runtime_seconds: Option<u32>,
|
||||
#[serde(default, deserialize_with = "strict_optional_reboot")]
|
||||
allow_reboot: Option<bool>,
|
||||
}
|
||||
@@ -122,6 +124,10 @@ impl SystemScope {
|
||||
.allowed_script_profiles
|
||||
.as_deref()
|
||||
.is_none_or(|v| v == [rmm_domain::jobs::PrivilegedScriptProfile::FullMaintenanceV1])
|
||||
&& rmm_domain::jobs::valid_windows_update_limit(
|
||||
self.windows_update_max_runtime_seconds,
|
||||
self.allowed_script_profiles.as_deref(),
|
||||
)
|
||||
&& (1..=120).contains(&self.max_runtime_seconds)
|
||||
}
|
||||
fn permits(
|
||||
@@ -154,7 +160,13 @@ impl SystemScope {
|
||||
"helper.binary.sha256:{}",
|
||||
self.helper_binary_sha256
|
||||
))
|
||||
&& (1..=self.max_runtime_seconds).contains(&job.max_runtime_seconds)
|
||||
&& (1..=job.action.windows_system_runtime_limit(
|
||||
self.max_runtime_seconds,
|
||||
self.windows_update_max_runtime_seconds,
|
||||
))
|
||||
.contains(&job.max_runtime_seconds)
|
||||
&& (job.max_runtime_seconds <= 120
|
||||
|| has(rmm_domain::jobs::WINDOWS_UPDATE_LONG_CAPABILITY))
|
||||
&& (1..=65536).contains(&job.max_output_bytes)
|
||||
&& match &job.action {
|
||||
Action::Reboot { .. } => {
|
||||
@@ -556,6 +568,32 @@ mod tests {
|
||||
policy.schema_version = 3;
|
||||
assert!(policy.permits("selected", &job, &caps, Utc::now()));
|
||||
assert!(!policy.permits("foreign", &job, &caps, Utc::now()));
|
||||
let general = job.action.clone();
|
||||
job.action = Action::RunScript {
|
||||
interpreter: "powershell".into(),
|
||||
script_utf8: rmm_domain::jobs::WINDOWS_UPDATE_SCRIPT_UTF8.into(),
|
||||
arguments: vec![],
|
||||
expected_stdout: None,
|
||||
windows_execution_profile: Some(
|
||||
rmm_domain::jobs::WindowsExecutionProfile::PowerShell51RemoteSigned,
|
||||
),
|
||||
privileged_script_profile: Some(
|
||||
rmm_domain::jobs::PrivilegedScriptProfile::FullMaintenanceV1,
|
||||
),
|
||||
};
|
||||
caps.push("script.powershell.process_remote_signed/1".into());
|
||||
job.max_runtime_seconds = 3600;
|
||||
assert!(!policy.permits("selected", &job, &caps, Utc::now()));
|
||||
policy.scopes[0].windows_update_max_runtime_seconds = Some(3600);
|
||||
assert!(!policy.permits("selected", &job, &caps, Utc::now()));
|
||||
caps.push(rmm_domain::jobs::WINDOWS_UPDATE_LONG_CAPABILITY.into());
|
||||
assert!(policy.permits("selected", &job, &caps, Utc::now()));
|
||||
policy.scopes[0].windows_update_max_runtime_seconds = Some(1800);
|
||||
assert!(!policy.permits("selected", &job, &caps, Utc::now()));
|
||||
policy.scopes[0].windows_update_max_runtime_seconds = Some(3600);
|
||||
job.action = general;
|
||||
assert!(!policy.permits("selected", &job, &caps, Utc::now()));
|
||||
job.max_runtime_seconds = 30;
|
||||
caps.retain(|c| c != rmm_domain::jobs::FULL_MAINTENANCE_CAPABILITY);
|
||||
assert!(!policy.permits("selected", &job, &caps, Utc::now()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user