Bind approved Windows PowerShell process policy and prove Linux-first contracts
Rust development slice / linux (push) Failing after 6s
Rust development slice / linux (push) Failing after 6s
This commit is contained in:
@@ -40,6 +40,7 @@ fn fixture() -> (Binding, Request, ExecutionPermitPayload, DateTime<Utc>) {
|
||||
script_utf8: "printf 'Hello\\n'\n".into(),
|
||||
arguments: vec![],
|
||||
expected_stdout: Some("Hello\n".into()),
|
||||
windows_execution_profile: None,
|
||||
},
|
||||
execution_identity: "agent_service".into(),
|
||||
not_before: now - Duration::minutes(1),
|
||||
@@ -170,6 +171,36 @@ fn exact_permit_bytes_time_and_all_identity_hash_bindings_are_required() {
|
||||
let mut changed = request;
|
||||
changed.signature.truncate(63);
|
||||
assert!(binding.verify(&changed, now).is_err());
|
||||
// Changing only the process policy is a payload mutation, even with the
|
||||
// same script/attempt and a still valid original signature.
|
||||
let (_, mut request, mut permit, _) = fixture();
|
||||
let mut job: JobPayload = serde_json::from_slice(&request.job_bytes).unwrap();
|
||||
job.action = Action::RunScript {
|
||||
interpreter: "powershell".into(),
|
||||
script_utf8: "Write-Output 'Hello'\r\n".into(),
|
||||
arguments: vec![],
|
||||
expected_stdout: Some("Hello\r\n".into()),
|
||||
windows_execution_profile: None,
|
||||
};
|
||||
request.job_bytes = encode(&job).unwrap();
|
||||
permit.job_payload_hash = hash(&request.job_bytes);
|
||||
request.permit_bytes = encode(&permit).unwrap();
|
||||
request.signature = key.sign(&request.permit_bytes).to_bytes().to_vec();
|
||||
binding.verify(&request, now).unwrap();
|
||||
if let Action::RunScript {
|
||||
windows_execution_profile,
|
||||
..
|
||||
} = &mut job.action
|
||||
{
|
||||
*windows_execution_profile =
|
||||
Some(rmm_domain::jobs::WindowsExecutionProfile::PowerShell51RemoteSigned);
|
||||
}
|
||||
request.job_bytes = encode(&job).unwrap();
|
||||
assert!(binding.verify(&request, now).is_err());
|
||||
permit.job_payload_hash = hash(&request.job_bytes);
|
||||
request.permit_bytes = encode(&permit).unwrap();
|
||||
request.signature = key.sign(&request.permit_bytes).to_bytes().to_vec();
|
||||
binding.verify(&request, now).unwrap();
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
|
||||
Reference in New Issue
Block a user