Freeze minimal SYSTEM nonstart 221 closure and reproducible Windows source
Rust development slice / linux (push) Failing after 6s
Rust development slice / linux (push) Failing after 6s
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
//! Offline, deny-only typed transition from the existing 30s script policy to
|
||||
//! passive new pair pins. No files, IPC, services, sync, jobs or approvals.
|
||||
#[cfg(all(windows, feature = "system-helper"))]
|
||||
fn main() -> anyhow::Result<()> {
|
||||
use anyhow::{Result, ensure};
|
||||
use rmm_agent_windows::helper_system::Settings;
|
||||
use rmm_domain::jobs::{PrivilegedScriptProfile, hash};
|
||||
use serde::Deserialize;
|
||||
use std::io::{Read, Write};
|
||||
#[derive(Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
struct Input {
|
||||
schema_version: u32,
|
||||
current_settings: Vec<u8>,
|
||||
current_settings_sha256: String,
|
||||
new_agent_sha256: String,
|
||||
new_helper_sha256: String,
|
||||
}
|
||||
fn render(input: Input) -> Result<serde_json::Value> {
|
||||
ensure!(
|
||||
input.schema_version == 1
|
||||
&& !input.current_settings.is_empty()
|
||||
&& input.current_settings.len() <= 32768
|
||||
&& hash(&input.current_settings) == input.current_settings_sha256
|
||||
&& rmm_domain::agent_update::digest(&input.new_agent_sha256)
|
||||
&& rmm_domain::agent_update::digest(&input.new_helper_sha256),
|
||||
"SCRIPT_PAIR_PREPARE_INPUT"
|
||||
);
|
||||
let mut settings: Settings = serde_json::from_slice(&input.current_settings)?;
|
||||
settings.validate()?;
|
||||
ensure!(
|
||||
settings.schema_version == 3
|
||||
&& settings.enable_effects
|
||||
&& settings.max_runtime_seconds == 30
|
||||
&& !settings.allow_reboot
|
||||
&& settings.allowed_services.is_empty()
|
||||
&& settings.allowed_msi_recipe_sha256.is_none()
|
||||
&& settings.allowed_script_profiles.as_deref()
|
||||
== Some(&[PrivilegedScriptProfile::FullMaintenanceV1])
|
||||
&& settings.agent.binary_sha256 != input.new_agent_sha256
|
||||
&& settings.helper.binary_sha256 != input.new_helper_sha256,
|
||||
"SCRIPT_PAIR_EXACT_ORIGINAL_30S_SCOPE_REQUIRED"
|
||||
);
|
||||
settings.agent.binary_sha256 = input.new_agent_sha256;
|
||||
settings.helper.binary_sha256 = input.new_helper_sha256;
|
||||
settings.enable_effects = false;
|
||||
settings.allowed_script_profiles = None;
|
||||
settings.validate()?;
|
||||
let settings_bytes = serde_json::to_vec(&settings)?;
|
||||
let pin = settings.pin()?;
|
||||
let pin_bytes = serde_json::to_vec(&pin)?;
|
||||
ensure!(
|
||||
pin.policy_sha256 == hash(&settings_bytes),
|
||||
"SCRIPT_PAIR_CANONICAL_POLICY"
|
||||
);
|
||||
Ok(
|
||||
serde_json::json!({"schema_version":1,"source":"actual_rust_settings_codec",
|
||||
"prepared_only":true,"target_mutations":false,"target_job_executed":false,
|
||||
"effects_enabled":false,"settings_bytes":settings_bytes,"settings_sha256":hash(&settings_bytes),
|
||||
"pin_bytes":pin_bytes,"pin_sha256":hash(&pin_bytes),"policy_sha256":pin.policy_sha256,
|
||||
"helper_settings_source_sha256":hash(include_bytes!("../src/helper_system.rs")),
|
||||
"peer_codec_source_sha256":hash(include_bytes!("../src/helper_ipc.rs"))}),
|
||||
)
|
||||
}
|
||||
let mut input = Vec::new();
|
||||
std::io::stdin()
|
||||
.take(128 * 1024 + 1)
|
||||
.read_to_end(&mut input)?;
|
||||
ensure!(input.len() <= 128 * 1024, "SCRIPT_PAIR_PREPARE_FRAME_LIMIT");
|
||||
let output = render(serde_json::from_slice(&input)?)?;
|
||||
std::io::stdout().write_all(&serde_json::to_vec(&output)?)?;
|
||||
std::io::stdout().write_all(b"\n")?;
|
||||
Ok(())
|
||||
}
|
||||
#[cfg(not(all(windows, feature = "system-helper")))]
|
||||
fn main() {
|
||||
eprintln!("Windows/system-helper typed renderer only; no operation executed");
|
||||
std::process::exit(2);
|
||||
}
|
||||
Reference in New Issue
Block a user