Implement bounded Windows Event Log jobs and verify contracts on cloud Linux
Rust development slice / linux (push) Failing after 7s
Rust development slice / linux (push) Failing after 7s
This commit is contained in:
@@ -33,8 +33,8 @@ impl Binding {
|
||||
);
|
||||
ensure!(
|
||||
j.action.validate()
|
||||
&& (1..=3600).contains(&j.max_runtime_seconds)
|
||||
&& (1..=262144).contains(&j.max_output_bytes)
|
||||
&& j.action
|
||||
.valid_job_limits(j.max_runtime_seconds, j.max_output_bytes)
|
||||
&& j.not_before < j.start_before,
|
||||
"INVALID_JOB"
|
||||
);
|
||||
|
||||
@@ -201,6 +201,39 @@ fn exact_permit_bytes_time_and_all_identity_hash_bindings_are_required() {
|
||||
request.permit_bytes = encode(&permit).unwrap();
|
||||
request.signature = key.sign(&request.permit_bytes).to_bytes().to_vec();
|
||||
binding.verify(&request, now).unwrap();
|
||||
// The exact fixed Event Log source/window/limits are original signed bytes.
|
||||
job.action = Action::QueryLogs {
|
||||
unit: rmm_domain::jobs::WINDOWS_EVENT_LOG_FIXTURE_SOURCE.into(),
|
||||
since: now - chrono::Duration::hours(1),
|
||||
until: now,
|
||||
max_lines: 1000,
|
||||
};
|
||||
request.job_bytes = encode(&job).unwrap();
|
||||
permit.action = job.action.name().into();
|
||||
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();
|
||||
let mut wrong_source = job.clone();
|
||||
if let Action::QueryLogs { unit, .. } = &mut wrong_source.action {
|
||||
*unit = "Security".into();
|
||||
}
|
||||
let mut changed = request.clone();
|
||||
changed.job_bytes = encode(&wrong_source).unwrap();
|
||||
assert!(binding.verify(&changed, now).is_err());
|
||||
for (runtime, bytes) in [(9, 4096), (121, 4096), (10, 1023), (10, 65537)] {
|
||||
let mut changed_job = job.clone();
|
||||
changed_job.max_runtime_seconds = runtime;
|
||||
changed_job.max_output_bytes = bytes;
|
||||
let mut changed_permit = permit.clone();
|
||||
changed_permit.max_runtime_seconds = runtime;
|
||||
let mut changed = request.clone();
|
||||
changed.job_bytes = encode(&changed_job).unwrap();
|
||||
changed_permit.job_payload_hash = hash(&changed.job_bytes);
|
||||
changed.permit_bytes = encode(&changed_permit).unwrap();
|
||||
changed.signature = key.sign(&changed.permit_bytes).to_bytes().to_vec();
|
||||
assert!(binding.verify(&changed, now).is_err());
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
|
||||
Reference in New Issue
Block a user