Validate the full Windows Update plan through its fixed script revision

This commit is contained in:
2026-11-17 17:40:42 +01:00
parent 4f69312bef
commit c94c3939f1
4 changed files with 47 additions and 31 deletions
+5 -2
View File
@@ -1,5 +1,5 @@
import { canonicalJson, record, RecordValue, text, windowsScriptProfile, privilegedScriptProfile, fullMaintenanceScriptProfile, validateScriptIdentityProfile } from './api';
import { bytes, hashPattern, parseStrictJson, sha256 } from './safety';
import { bytes, hashPattern, parseStrictJson, sha256 } from './plan-bytes';
export const windowsUpdateScriptHash = '0fa5f513a06b6cf902a3f9ac1989987642c181eedd6c305b3912771bd10f2ebf';
export interface ScriptPlanJob {
@@ -56,7 +56,10 @@ function validateViews(plan: RecordValue, parsed: RecordValue, jobs: RecordValue
* This is an approval display check, never a grant of execution rights. */
export async function verifyScriptPlan(plan: RecordValue): Promise<void> {
const before = snapshot(plan), old = verified.get(plan);
if (old && old.snapshot !== before) throw new Error('Skriptplan wurde nach Anzeige verändert');
if (old) {
if (old.snapshot !== before) throw new Error('Skriptplan wurde nach Anzeige verändert');
return;
}
const raw = bytes(plan.plan_payload_bytes);
if (await sha256(raw) !== digest(plan.plan_hash)) throw new Error('Skript-Planhash widerspricht gespeicherten Bytes');
const parsed = record(parseStrictJson(new TextDecoder('utf-8', { fatal: true }).decode(raw)));