Qualify Windows IPC client runtime and prepare bounded native providers
Rust development slice / linux (push) Failing after 7s

This commit is contained in:
2026-11-14 03:53:48 +01:00
parent 2bf0183e68
commit 9d6a6f0eb6
24 changed files with 3880 additions and 30 deletions
+159
View File
@@ -0,0 +1,159 @@
//! Unexported Windows MSI fixture contract. No legacy Linux codec is changed.
//! This version supports first installation or independently proven exact noop;
//! an upgrade requires a separate reviewed recipe with explicit predecessor
//! products/UpgradeCode semantics. No implicit REINSTALL flags are inferred.
use serde::{Deserialize, Serialize};
use sha2::{Digest, Sha256};
use uuid::Uuid;
pub const MSI_RECIPE_ID: &str = "rmm-windows-msi-fixture-install-1.0";
pub const MSI_PRODUCT_CODE: &str = "{3F070B4B-9C08-4D65-BD41-13D81B884AEC}";
pub const MSI_UPGRADE_CODE: &str = "{C9BF1FB8-E31D-4BD7-BA0D-AB46539BBBAA}";
pub const MSI_VERSION: &str = "1.0.0";
pub const MSI_PAYLOAD: &str = r"C:\Program Files\RustDiscoveryFixtures\msi-payload.txt";
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum Architecture {
X64,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum InstallContext {
Machine,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum MsiCommandProfile {
FixtureQuietNoRebootV1,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct MsiArtifact {
pub artifact_id: Uuid,
pub sha256: String,
pub bytes: u64,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct MsiPostcondition {
pub product_code: String,
pub product_version: String,
pub payload_path: String,
pub payload_sha256: String,
pub payload_bytes: u64,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct WindowsMsiRecipe {
pub schema_version: u32,
pub recipe_id: String,
pub recipe_version: String,
pub platform: String,
pub upgrade_code: String,
pub architecture: Architecture,
pub context: InstallContext,
pub command_profile: MsiCommandProfile,
pub artifact: MsiArtifact,
pub postcondition: MsiPostcondition,
pub no_reboot: bool,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct ResolvedWindowsMsi {
pub recipe: WindowsMsiRecipe,
/// SHA256 of exactly serde_json::to_vec(recipe), not a self-reference.
pub recipe_sha256: String,
}
pub fn digest(value: &str) -> bool {
value.len() == 64
&& value
.bytes()
.all(|b| b.is_ascii_digit() || (b'a'..=b'f').contains(&b))
}
impl WindowsMsiRecipe {
pub fn validate(&self) -> bool {
self.schema_version == 1
&& self.recipe_id == MSI_RECIPE_ID
&& self.recipe_version == "1"
&& self.platform == "windows"
&& self.upgrade_code == MSI_UPGRADE_CODE
&& self.no_reboot
&& !self.artifact.artifact_id.is_nil()
&& digest(&self.artifact.sha256)
&& (1..=262144).contains(&self.artifact.bytes)
&& self.postcondition.product_code == MSI_PRODUCT_CODE
&& self.postcondition.product_version == MSI_VERSION
&& self.postcondition.payload_path == MSI_PAYLOAD
&& digest(&self.postcondition.payload_sha256)
&& (1..=65536).contains(&self.postcondition.payload_bytes)
}
pub fn sha256(&self) -> Result<String, serde_json::Error> {
Ok(format!("{:x}", Sha256::digest(serde_json::to_vec(self)?)))
}
}
impl ResolvedWindowsMsi {
pub fn validate(&self) -> bool {
self.recipe.validate()
&& digest(&self.recipe_sha256)
&& self
.recipe
.sha256()
.is_ok_and(|sha| sha == self.recipe_sha256)
}
}
#[cfg(test)]
mod tests {
use super::*;
fn recipe() -> WindowsMsiRecipe {
WindowsMsiRecipe {
schema_version: 1,
recipe_id: MSI_RECIPE_ID.into(),
recipe_version: "1".into(),
platform: "windows".into(),
upgrade_code: MSI_UPGRADE_CODE.into(),
architecture: Architecture::X64,
context: InstallContext::Machine,
command_profile: MsiCommandProfile::FixtureQuietNoRebootV1,
artifact: MsiArtifact {
artifact_id: Uuid::new_v4(),
sha256: "ab".repeat(32),
bytes: 1234,
},
postcondition: MsiPostcondition {
product_code: MSI_PRODUCT_CODE.into(),
product_version: MSI_VERSION.into(),
payload_path: MSI_PAYLOAD.into(),
payload_sha256: "cd".repeat(32),
payload_bytes: 20,
},
no_reboot: true,
}
}
#[test]
fn immutable_fixture_recipe_rejects_reboot_url_transform_and_implicit_upgrade() {
let recipe = recipe();
let bound = ResolvedWindowsMsi {
recipe_sha256: recipe.sha256().unwrap(),
recipe: recipe.clone(),
};
assert!(bound.validate());
let mut changed = bound.clone();
changed.recipe.artifact.bytes += 1;
assert!(!changed.validate());
for case in 0..6 {
let mut r = recipe.clone();
match case {
0 => r.no_reboot = false,
1 => r.postcondition.product_code = Uuid::new_v4().to_string(),
2 => r.postcondition.product_version = "1.1.0".into(),
3 => r.postcondition.payload_path = r"\\server\share\payload".into(),
4 => r.artifact.bytes = 262145,
_ => r.platform = "linux".into(),
};
assert!(!r.validate());
}
let mut value = serde_json::to_value(recipe).unwrap();
value["transforms"] = serde_json::json!(["unapproved.mst"]);
assert!(serde_json::from_value::<WindowsMsiRecipe>(value).is_err());
}
}