Validate the full Windows Update plan through its fixed script revision
This commit is contained in:
@@ -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)));
|
||||
|
||||
Reference in New Issue
Block a user