Record verified passive time samples for each Windows service role
Rust development slice / linux (push) Failing after 7s
Rust development slice / linux (push) Failing after 7s
This commit is contained in:
@@ -785,8 +785,38 @@ pub(crate) fn msi_test_job() -> JobPayload {
|
||||
}
|
||||
}
|
||||
fn write_current_probe(state: &Path, value: &serde_json::Value) -> Result<()> {
|
||||
write_report(state, PROBE_FILE, ".helper-probe.pending", value)
|
||||
}
|
||||
|
||||
/// A historical observation by the agent. The helper lane calls this only after
|
||||
/// the authenticated peer has acknowledged its own signature verification.
|
||||
pub fn record_verified_time(
|
||||
state: &Path,
|
||||
request: &rmm_time_attestation::Request,
|
||||
response_sha256: &str,
|
||||
observed_at: chrono::DateTime<chrono::Utc>,
|
||||
) -> Result<()> {
|
||||
use sha2::{Digest, Sha256};
|
||||
let (filename, pending) = match request.context.role {
|
||||
rmm_time_attestation::Role::Agent => ("agent-time-sample.json", ".agent-time.pending"),
|
||||
rmm_time_attestation::Role::SystemHelper => {
|
||||
("helper-time-sample.json", ".helper-time.pending")
|
||||
}
|
||||
};
|
||||
let value = json!({
|
||||
"schema_version": 1, "agent_pid": std::process::id(), "observed_at": observed_at,
|
||||
"role": request.context.role, "windows_boot_id": request.context.windows_boot_id,
|
||||
"connection_generation": request.context.connection_generation,
|
||||
"verifier_incarnation": request.context.verifier_incarnation,
|
||||
"request_sha256": format!("{:x}", Sha256::digest(serde_json::to_vec(request)?)),
|
||||
"response_sha256": response_sha256
|
||||
});
|
||||
write_report(state, filename, pending, &value)
|
||||
}
|
||||
|
||||
fn write_report(state: &Path, name: &str, pending: &str, value: &serde_json::Value) -> Result<()> {
|
||||
native::private_path(state, true)?;
|
||||
let path = state.join(PROBE_FILE);
|
||||
let path = state.join(name);
|
||||
if path.try_exists()? {
|
||||
native::private_path(&path, false)?;
|
||||
}
|
||||
@@ -794,7 +824,7 @@ fn write_current_probe(state: &Path, value: &serde_json::Value) -> Result<()> {
|
||||
ensure!(bytes.len() <= 8192, "HELPER_PROBE_REPORT_LIMIT");
|
||||
// One fixed create-only staging file bounds even interrupted-report state.
|
||||
// A leftover from a killed process is refused; it is never overwritten.
|
||||
let temporary = state.join(".helper-probe.pending");
|
||||
let temporary = state.join(pending);
|
||||
let mut file = std::fs::OpenOptions::new()
|
||||
.write(true)
|
||||
.create_new(true)
|
||||
|
||||
Reference in New Issue
Block a user