Add fresh device trust, installer recovery and scoped patch runtime

This commit is contained in:
2026-11-17 16:08:53 +01:00
parent 60f8f21f54
commit 81fcd9c8f8
24 changed files with 543 additions and 45 deletions
+20
View File
@@ -51,6 +51,26 @@ it('shows the immutable library revision and rejects a different catalog script
await expect(verifyScriptPlan(await stored('f'.repeat(64)))).rejects.toThrow('Bibliotheksversion');
});
it('accepts one hour only for the exact Windows Update revision', async () => {
const source = readFileSync(new URL('../../crates/domain/src/windows_update.ps1', import.meta.url), 'utf8');
async function windowPlan(script: string, fixed: boolean, seconds: number) {
const original = plan('windows_system_full');
const parsed = record(JSON.parse(new TextDecoder().decode(new Uint8Array(original.plan_payload_bytes as number[]))));
const job = (parsed.jobs as RecordValue[])[0]!, payload = record(job.payload), action = record(payload.action);
action.script_utf8 = script; action.arguments = []; action.expected_stdout = null; payload.max_runtime_seconds = seconds;
job.script_sha256 = await sha256(new TextEncoder().encode(script));
job.job_payload_hash = await sha256(new TextEncoder().encode(JSON.stringify(payload)));
if (fixed) parsed.script_revision = { revision_id: parsed.plan_id, name: 'Windows-Updates installieren', version: 1, script_sha256: job.script_sha256 };
const raw = new TextEncoder().encode(JSON.stringify(parsed));
return { plan_hash: await sha256(raw), plan_payload_bytes: Array.from(raw) };
}
const valid = await windowPlan(source, true, 3600);
await verifyScriptPlan(valid); expect(scriptPlanJobs(valid)[0]?.runtimeSeconds).toBe(3600);
for (const bad of [await windowPlan(source+'\n',true,3600), await windowPlan(source,false,3600), await windowPlan(source,true,3601)]) {
await expect(verifyScriptPlan(bad)).rejects.toThrow();
}
});
it('rejects view, byte and fixed identity/budget/profile tampering before and after display', async () => {
for (const alias of ['payload', 'plan_payload', 'jobs', 'resolved_targets']) {
const p = plan('linux_root_full'); await verifyScriptPlan(p); p[alias] = [];