Add fresh device trust, installer recovery and scoped patch runtime
This commit is contained in:
@@ -83,6 +83,8 @@ pub struct Settings {
|
||||
deserialize_with = "rmm_domain::jobs::deserialize_script_profiles"
|
||||
)]
|
||||
pub allowed_script_profiles: Option<Vec<rmm_domain::jobs::PrivilegedScriptProfile>>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub windows_update_max_runtime_seconds: Option<u32>,
|
||||
}
|
||||
fn strict_recipe_hashes<'de, D: serde::Deserializer<'de>>(
|
||||
d: D,
|
||||
@@ -113,7 +115,7 @@ impl Settings {
|
||||
&& job
|
||||
.action
|
||||
.valid_job_limits(job.max_runtime_seconds, job.max_output_bytes)
|
||||
&& job.max_runtime_seconds <= self.max_runtime_seconds
|
||||
&& job.max_runtime_seconds <= job.action.windows_system_runtime_limit(self.max_runtime_seconds, self.windows_update_max_runtime_seconds)
|
||||
&& self.allowed_script_profiles.as_deref()
|
||||
== Some(&[rmm_domain::jobs::PrivilegedScriptProfile::FullMaintenanceV1])
|
||||
}
|
||||
@@ -144,6 +146,7 @@ impl Settings {
|
||||
|v| v == [rmm_domain::jobs::PrivilegedScriptProfile::FullMaintenanceV1]
|
||||
)
|
||||
&& (self.schema_version == 4 || !self.allow_reboot)
|
||||
&& 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)
|
||||
&& self.allowed_services.len() <= 16,
|
||||
"SYSTEM_POLICY_PROFILE"
|
||||
@@ -1167,8 +1170,8 @@ impl SystemHelper {
|
||||
&& ((job.max_runtime_seconds <= self.settings.max_runtime_seconds
|
||||
&& (matches!(&job.action,Action::SetServiceState{unit,state} if matches!(state.as_str(),"running"|"stopped")&&self.settings.allowed_services.iter().any(|r|r.name==*unit))
|
||||
|| self.settings.permits_msi(&job)
|
||||
|| self.settings.permits_script(&job)
|
||||
|| self.settings.permits_reboot(&job)))
|
||||
|| self.settings.permits_script(&job)
|
||||
|| crate::update_admission::permits_denial(
|
||||
&self.settings.binding,
|
||||
&job
|
||||
@@ -1974,6 +1977,7 @@ mod tests {
|
||||
allow_reboot: false,
|
||||
allowed_msi_recipe_sha256: None,
|
||||
allowed_script_profiles: None,
|
||||
windows_update_max_runtime_seconds: None,
|
||||
};
|
||||
let legacy = serde_json::to_value(&settings).unwrap();
|
||||
assert!(legacy.get("allowed_msi_recipe_sha256").is_none());
|
||||
@@ -2013,6 +2017,19 @@ mod tests {
|
||||
assert!(!settings.permits_script(&script));
|
||||
settings.schema_version = 3;
|
||||
assert!(settings.permits_script(&script));
|
||||
let generic_script = script.action.clone();
|
||||
script.max_runtime_seconds = 3600;
|
||||
settings.windows_update_max_runtime_seconds = Some(3600);
|
||||
assert!(!settings.permits_script(&script));
|
||||
if let Action::RunScript { script_utf8, windows_execution_profile, .. } = &mut script.action {
|
||||
*script_utf8 = rmm_domain::jobs::WINDOWS_UPDATE_SCRIPT_UTF8.into();
|
||||
*windows_execution_profile = Some(rmm_domain::jobs::WindowsExecutionProfile::PowerShell51RemoteSigned);
|
||||
}
|
||||
assert!(settings.permits_script(&script));
|
||||
settings.windows_update_max_runtime_seconds = None;
|
||||
assert!(!settings.permits_script(&script));
|
||||
script.action = generic_script;
|
||||
script.max_runtime_seconds = 30;
|
||||
script.execution_identity = "root".into();
|
||||
assert!(!settings.permits_script(&script));
|
||||
let mut null = legacy;
|
||||
|
||||
Reference in New Issue
Block a user