Add reviewed Windows scope completion and idle certificate renewal; deploy completion API
Rust development slice / linux (push) Failing after 7s

This commit is contained in:
2026-11-16 10:25:25 +01:00
parent ebcad08731
commit bb4ffe518d
43 changed files with 5146 additions and 50 deletions
@@ -65,6 +65,7 @@ fn fixture(platform: Platform, full: bool) -> serde_json::Value {
new_settings_sha256: "12".repeat(32),
old_pin_sha256: "13".repeat(32),
new_pin_sha256: "14".repeat(32),
time_profile: None,
},
};
let update = ResolvedAgentUpdate {
+78
View File
@@ -211,6 +211,15 @@ pub struct LinuxFullTransition {
pub effective_signing_key_id: String,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, schemars::JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct WindowsTimeProfileTransition {
pub schema_version: u32,
pub old_time_profile_sha256: String,
pub new_time_profile_sha256: String,
pub agent_qualification_sha256: String,
pub helper_qualification_sha256: String,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, schemars::JsonSchema)]
#[serde(tag = "profile", rename_all = "snake_case", deny_unknown_fields)]
pub enum PeerPinTransition {
UnchangedGeneralPinV1 {
@@ -225,8 +234,40 @@ pub enum PeerPinTransition {
new_settings_sha256: String,
old_pin_sha256: String,
new_pin_sha256: String,
#[serde(
default,
skip_serializing_if = "Option::is_none",
deserialize_with = "strict_windows_time_profile"
)]
time_profile: Option<WindowsTimeProfileTransition>,
},
}
fn strict_windows_time_profile<'de, D: serde::Deserializer<'de>>(
d: D,
) -> Result<Option<WindowsTimeProfileTransition>, D::Error> {
WindowsTimeProfileTransition::deserialize(d).map(Some)
}
#[cfg(test)]
mod windows_time_transition_tests {
use super::*;
#[test]
fn optional_windows_clock_binding_is_additive_and_null_is_never_missing() {
let old = serde_json::json!({"profile":"windows_code_pair_v1","old_settings_sha256":"11".repeat(32),
"new_settings_sha256":"22".repeat(32),"old_pin_sha256":"33".repeat(32),"new_pin_sha256":"44".repeat(32)});
let decoded: PeerPinTransition = serde_json::from_value(old.clone()).unwrap();
assert_eq!(serde_json::to_value(decoded).unwrap(), old);
let mut invalid = old.clone();
invalid["time_profile"] = serde_json::Value::Null;
assert!(serde_json::from_value::<PeerPinTransition>(invalid).is_err());
let mut current = old;
current["time_profile"] = serde_json::json!({"schema_version":1,
"old_time_profile_sha256":"55".repeat(32),"new_time_profile_sha256":"66".repeat(32),
"agent_qualification_sha256":"77".repeat(32),"helper_qualification_sha256":"88".repeat(32)});
let decoded: PeerPinTransition = serde_json::from_value(current.clone()).unwrap();
assert_eq!(serde_json::to_value(decoded).unwrap(), current);
}
}
impl PeerPinTransition {
fn validate(&self, platform: Platform, predecessor: &Predecessor, target_helper: &str) -> bool {
match self {
@@ -261,6 +302,7 @@ impl PeerPinTransition {
new_settings_sha256,
old_pin_sha256,
new_pin_sha256,
time_profile,
} => {
platform == Platform::WindowsX64
&& [
@@ -273,6 +315,18 @@ impl PeerPinTransition {
.all(|h| digest(h))
&& old_settings_sha256 != new_settings_sha256
&& old_pin_sha256 != new_pin_sha256
&& time_profile.as_ref().is_none_or(|t| {
t.schema_version == 1
&& [
&t.old_time_profile_sha256,
&t.new_time_profile_sha256,
&t.agent_qualification_sha256,
&t.helper_qualification_sha256,
]
.iter()
.all(|h| digest(h))
&& t.old_time_profile_sha256 != t.new_time_profile_sha256
})
}
}
}
@@ -751,6 +805,7 @@ pub fn handoff_matches_job(
new_settings_sha256,
old_pin_sha256,
new_pin_sha256,
time_profile: None,
},
PinTransition::WindowsCodePairV1,
) => {
@@ -762,6 +817,29 @@ pub fn handoff_matches_job(
&& f.new_sha256 == *new_settings_sha256
})
}
(
PeerPinTransition::WindowsCodePairV1 {
old_settings_sha256,
new_settings_sha256,
old_pin_sha256,
new_pin_sha256,
time_profile: Some(time),
},
PinTransition::WindowsCodePairClockV1,
) => {
h.predecessor.pin_sha256 == *old_pin_sha256
&& h.target.pin_sha256 == *new_pin_sha256
&& h.files.get(2).is_some_and(|f| {
f.role == FileRole::WindowsSettings
&& f.old_sha256 == *old_settings_sha256
&& f.new_sha256 == *new_settings_sha256
})
&& h.files.get(4).is_some_and(|f| {
f.role == FileRole::WindowsTimeProfile
&& f.old_sha256 == time.old_time_profile_sha256
&& f.new_sha256 == time.new_time_profile_sha256
})
}
_ => false,
}
}
+1
View File
@@ -7,6 +7,7 @@ pub mod inventory_document;
pub mod jobs;
pub mod reconciliation;
pub mod windows_echo_probe;
pub mod windows_echo_completion;
pub mod windows_execution;
pub mod windows_sync_history;
@@ -0,0 +1,100 @@
//! Retirement of an additional development-only scope after its exact probe.
//! This administrative receipt is neither a job approval nor a readiness lease.
use crate::{checkpoint_repair::inventory_sha256, windows_echo_probe::ProbeScope};
use chrono::{DateTime, Duration, Utc};
use serde::{Deserialize, Serialize};
use serde_json::{Value, json};
use uuid::Uuid;
pub const DOMAIN: &str = "rmm.dev.windows-echo-completion.v1";
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
pub struct Witness {
pub scope: ProbeScope,
pub probe_receipt_id: Uuid,
pub probe_receipt_sha256: String,
pub probe_signature_sha256: String,
pub grant_id: Uuid,
pub grant_payload_sha256: String,
pub grant_signature_sha256: String,
pub outcome_sha256: String,
pub boot_id: Uuid,
}
impl Witness {
pub fn digest(&self) -> Option<String> {
inventory_sha256(&serde_json::to_value(self).ok()?).ok()
}
pub fn valid(&self) -> bool {
!self.probe_receipt_id.is_nil()
&& !self.grant_id.is_nil()
&& !self.boot_id.is_nil()
&& [
&self.probe_receipt_sha256,
&self.probe_signature_sha256,
&self.grant_payload_sha256,
&self.grant_signature_sha256,
&self.outcome_sha256,
]
.iter()
.all(|h| {
h.len() == 64
&& h.bytes()
.all(|c| c.is_ascii_digit() || (b'a'..=b'f').contains(&c))
})
}
}
/// Both server result and retained native Outcome use this one comparison.
pub fn successful_outcome(v: &Value) -> bool {
v["state"] == "succeeded"
&& v["exit_code"] == 0
&& v["stdout"] == json!(crate::windows_echo_probe::OUTPUT.as_bytes())
&& v["stderr"] == json!([])
&& v["output_truncated"] == false
&& v["reboot_required"] == false
&& v["error_code"] == ""
&& v["evidence"]["postconditions_passed"] == true
&& v["evidence"]["execution_sid"] == "S-1-5-19"
&& v["evidence"]["execution_policy_scope"] == "process"
&& v["evidence"]["execution_policy_requested"] == "RemoteSigned"
&& v["evidence"]["script_sha256"]
== crate::jobs::hash(crate::windows_echo_probe::SCRIPT.as_bytes())
}
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct Receipt {
pub domain: String,
pub schema_version: u32,
pub receipt_id: Uuid,
pub witness: Witness,
pub witness_sha256: String,
pub key_id: String,
pub issued_at: DateTime<Utc>,
pub valid_until: DateTime<Utc>,
pub confirmed_by: String,
pub approval_origin: String,
pub testsimulation: bool,
pub ready: bool,
pub helper_ready: bool,
pub unlock: bool,
}
impl Receipt {
pub fn valid(&self, now: DateTime<Utc>) -> bool {
self.domain == DOMAIN
&& self.schema_version == 1
&& !self.receipt_id.is_nil()
&& self.witness.valid()
&& self.witness.digest().as_deref() == Some(self.witness_sha256.as_str())
&& self.confirmed_by == crate::windows_echo_probe::TEST_PRINCIPAL
&& self.approval_origin == "dev_test_browser_simulation"
&& self.testsimulation
&& !self.ready
&& !self.helper_ready
&& !self.unlock
&& self.issued_at <= now
&& now < self.valid_until
&& self.valid_until - self.issued_at <= Duration::minutes(10)
}
}