Integrate strict Windows MSI manifests tenant catalog and SYSTEM package policy
Rust development slice / linux (push) Failing after 7s
Rust development slice / linux (push) Failing after 7s
This commit is contained in:
@@ -48,6 +48,17 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
/// Missing preserves Linux codecs; explicit null/nonobject is never a manifest.
|
||||
pub fn deserialize_windows_msi_manifest<'de, D>(
|
||||
deserializer: D,
|
||||
) -> Result<Option<Box<crate::windows_execution::ResolvedWindowsMsi>>, D::Error>
|
||||
where
|
||||
D: serde::Deserializer<'de>,
|
||||
{
|
||||
crate::windows_execution::ResolvedWindowsMsi::deserialize(deserializer)
|
||||
.map(|m| Some(Box::new(m)))
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, schemars::JsonSchema)]
|
||||
#[serde(tag = "action", rename_all = "snake_case", deny_unknown_fields)]
|
||||
pub enum Action {
|
||||
@@ -88,6 +99,13 @@ pub enum Action {
|
||||
recipe_id: Option<String>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
apt_manifest: Option<crate::apt_transaction::AptExecutionManifest>,
|
||||
#[serde(
|
||||
default,
|
||||
deserialize_with = "deserialize_windows_msi_manifest",
|
||||
skip_serializing_if = "Option::is_none"
|
||||
)]
|
||||
#[schemars(with = "crate::windows_execution::ResolvedWindowsMsi")]
|
||||
windows_msi_manifest: Option<Box<crate::windows_execution::ResolvedWindowsMsi>>,
|
||||
},
|
||||
ApplyUpdates {
|
||||
provider: String,
|
||||
@@ -185,6 +203,28 @@ impl Action {
|
||||
installation_context,
|
||||
recipe_id,
|
||||
apt_manifest,
|
||||
windows_msi_manifest: Some(m),
|
||||
} => {
|
||||
m.validate()
|
||||
&& provider == "msi"
|
||||
&& package == crate::windows_execution::MSI_PACKAGE_ID
|
||||
&& version == &m.recipe.postcondition.product_version
|
||||
&& architecture == "x64"
|
||||
&& installation_context == "machine"
|
||||
&& recipe_version == &m.recipe.recipe_version
|
||||
&& recipe_id.as_ref() == Some(&m.recipe.recipe_id)
|
||||
&& apt_manifest.is_none()
|
||||
}
|
||||
Self::EnsurePackage {
|
||||
provider,
|
||||
package,
|
||||
version,
|
||||
architecture,
|
||||
recipe_version,
|
||||
installation_context,
|
||||
recipe_id,
|
||||
apt_manifest,
|
||||
windows_msi_manifest: None,
|
||||
} => {
|
||||
provider == "apt"
|
||||
&& unit(package)
|
||||
@@ -243,6 +283,20 @@ impl Action {
|
||||
}
|
||||
}
|
||||
}
|
||||
pub fn windows_msi(&self) -> Option<&crate::windows_execution::ResolvedWindowsMsi> {
|
||||
match self {
|
||||
Self::EnsurePackage {
|
||||
windows_msi_manifest: Some(m),
|
||||
..
|
||||
} => Some(m.as_ref()),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
pub fn valid_helper_denial_shape(&self, identity: &str) -> bool {
|
||||
(matches!(self,Self::SetServiceState{state,..} if matches!(state.as_str(),"running"|"stopped"))
|
||||
&& self.validate())
|
||||
|| (identity == "system" && self.windows_msi().is_some() && self.validate())
|
||||
}
|
||||
pub fn is_windows_event_log_fixture(&self) -> bool {
|
||||
matches!(self, Self::QueryLogs { unit, .. } if unit == WINDOWS_EVENT_LOG_FIXTURE_SOURCE)
|
||||
}
|
||||
@@ -250,6 +304,9 @@ impl Action {
|
||||
/// its inner Event Log calls retain their own cooperative <=5s deadline.
|
||||
pub fn valid_job_limits(&self, runtime_seconds: u32, output_bytes: u32) -> bool {
|
||||
(1..=3600).contains(&runtime_seconds)
|
||||
&& (self.windows_msi().is_none()
|
||||
|| ((10..=120).contains(&runtime_seconds)
|
||||
&& (1024..=65536).contains(&output_bytes)))
|
||||
&& (1..=262144).contains(&output_bytes)
|
||||
&& (!self.is_windows_event_log_fixture()
|
||||
|| ((10..=120).contains(&runtime_seconds)
|
||||
@@ -268,7 +325,7 @@ impl Action {
|
||||
}
|
||||
/// Shared plan/revalidation/start gate. Passive Windows never implies job support.
|
||||
pub fn available_for(&self, identity: &str, capabilities: &[String]) -> bool {
|
||||
if identity == "system" && !matches!(self, Self::SetServiceState { .. }) {
|
||||
if identity == "system" && !self.valid_helper_denial_shape(identity) {
|
||||
return false;
|
||||
}
|
||||
let has = |cap: &str| capabilities.iter().any(|c| c == cap);
|
||||
@@ -304,6 +361,17 @@ impl Action {
|
||||
&& !(has("linux.base/1") && has("windows.base/1"))
|
||||
&& (scope != "windows.base" || has("rmm.sync.v1"))
|
||||
}
|
||||
Self::EnsurePackage { .. } if self.windows_msi().is_some() || has("windows.base/1") => {
|
||||
self.windows_msi().is_some()
|
||||
&& self.validate()
|
||||
&& identity == "system"
|
||||
&& has("windows.base/1")
|
||||
&& !has("linux.base/1")
|
||||
&& has("rmm.sync.v1")
|
||||
&& has("helper.system.v1")
|
||||
&& has("system:ensure_package")
|
||||
&& has(crate::windows_execution::MSI_CAPABILITY)
|
||||
}
|
||||
Self::QueryLogs { unit, .. }
|
||||
if unit == WINDOWS_EVENT_LOG_FIXTURE_SOURCE || has("windows.base/1") =>
|
||||
{
|
||||
@@ -349,6 +417,7 @@ impl Action {
|
||||
installation_context,
|
||||
recipe_id: None,
|
||||
apt_manifest: None,
|
||||
windows_msi_manifest: None,
|
||||
} => {
|
||||
provider == "apt"
|
||||
&& !package.is_empty()
|
||||
|
||||
Reference in New Issue
Block a user