Add reviewed Windows scope completion and idle certificate renewal; deploy completion API
Rust development slice / linux (push) Failing after 7s
Rust development slice / linux (push) Failing after 7s
This commit is contained in:
@@ -4,11 +4,22 @@ import { renderToStaticMarkup } from 'react-dom/server';
|
||||
import { PlanInput, record, RecordValue, Session, validateInput } from './api';
|
||||
import { sha256, validateSensitiveInput, verifyPlanIntegrity } from './safety';
|
||||
import { verifyScriptPlan } from './script-console';
|
||||
import { agentUpdateApprovalBlockers, agentUpdatePlanJobs, verifyAgentUpdatePlan, uploadAgentUpdateArtifact } from './agent-updates';
|
||||
import { agentUpdateApprovalBlockers, agentUpdatePlanJobs, verifyAgentUpdatePlan, uploadAgentUpdateArtifact, validateAgentUpdateAction } from './agent-updates';
|
||||
vi.mock('react-dom/client', () => ({ createRoot: () => ({ render: vi.fn() }) }));
|
||||
// Actual rmm-domain serde/codec output; synthetic signatures are NOT update trust.
|
||||
const golden = JSON.parse(readFileSync(new URL('../../tests/agent_update/codec-golden.json', import.meta.url), 'utf8')) as Record<string, RecordValue>;
|
||||
const fixture = (name = 'linux_full') => structuredClone(golden[name]!) as RecordValue;
|
||||
it('retains the exact optional Windows clock transition before approval and rejects null or changed shape', () => {
|
||||
const action = record(record(record((record(fixture('windows_pair').payload).jobs as unknown[])[0]).payload).action);
|
||||
const transition = record(record(action.update).peer_pin_transition);
|
||||
transition.time_profile = { schema_version: 1, old_time_profile_sha256: '21'.repeat(32), new_time_profile_sha256: '22'.repeat(32), agent_qualification_sha256: '23'.repeat(32), helper_qualification_sha256: '24'.repeat(32) };
|
||||
const projected = validateAgentUpdateAction(action, 'system');
|
||||
expect(record(record(projected.update).peer_pin_transition).time_profile).toEqual(transition.time_profile);
|
||||
for (const value of [null, {}, { ...record(transition.time_profile), ready: true }, { ...record(transition.time_profile), schema_version: 2 }, { ...record(transition.time_profile), new_time_profile_sha256: '21'.repeat(32) }]) {
|
||||
const changed = structuredClone(action); record(record(changed.update).peer_pin_transition).time_profile = value;
|
||||
expect(() => validateAgentUpdateAction(changed, 'system')).toThrow();
|
||||
}
|
||||
});
|
||||
async function rehashed(change: (raw: RecordValue) => void): Promise<RecordValue> {
|
||||
const p = fixture(), raw = record(p.payload); change(raw);
|
||||
const bytes = new TextEncoder().encode(JSON.stringify(raw)); p.plan_payload_bytes = Array.from(bytes); p.plan_hash = await sha256(bytes);
|
||||
|
||||
@@ -72,9 +72,16 @@ export function validateAgentUpdateAction(value: unknown, identity: unknown): Re
|
||||
if (full.old_helper_sha256 !== predecessor.helper_sha256 || full.new_helper_sha256 !== record((release.manifest.artifacts as unknown[])[1]).sha256 || full.old_config_sha256 === full.new_config_sha256 || full.old_pin_sha256 === full.new_pin_sha256) throw new Error('Agentupdate: Fullpin-Codepaarbindung fehlt');
|
||||
transition = { profile: p.profile, general_pin_sha256: digest(p.general_pin_sha256), full };
|
||||
} else if (p.profile === 'windows_code_pair_v1') {
|
||||
exact(p, ['profile', 'old_settings_sha256', 'new_settings_sha256', 'old_pin_sha256', 'new_pin_sha256']); if (linux) throw new Error('Agentupdate: Windows-Pinprofil auf Linux');
|
||||
const hasTime = Object.prototype.hasOwnProperty.call(p, 'time_profile');
|
||||
exact(p, ['profile', 'old_settings_sha256', 'new_settings_sha256', 'old_pin_sha256', 'new_pin_sha256', ...(hasTime ? ['time_profile'] : [])]); if (linux) throw new Error('Agentupdate: Windows-Pinprofil auf Linux');
|
||||
transition = { profile: p.profile, old_settings_sha256: digest(p.old_settings_sha256), new_settings_sha256: digest(p.new_settings_sha256), old_pin_sha256: digest(p.old_pin_sha256), new_pin_sha256: digest(p.new_pin_sha256) };
|
||||
if (transition.old_settings_sha256 === transition.new_settings_sha256 || transition.old_pin_sha256 === transition.new_pin_sha256) throw new Error('Agentupdate: unveränderte Windows-Pinübergabe');
|
||||
if (hasTime) {
|
||||
const t = record(p.time_profile); exact(t, ['schema_version', 'old_time_profile_sha256', 'new_time_profile_sha256', 'agent_qualification_sha256', 'helper_qualification_sha256']);
|
||||
if (t.schema_version !== 1) throw new Error('Agentupdate: unbekanntes Windows-Zeitprofilschema');
|
||||
transition.time_profile = { schema_version: 1, old_time_profile_sha256: digest(t.old_time_profile_sha256), new_time_profile_sha256: digest(t.new_time_profile_sha256), agent_qualification_sha256: digest(t.agent_qualification_sha256), helper_qualification_sha256: digest(t.helper_qualification_sha256) };
|
||||
if (t.old_time_profile_sha256 === t.new_time_profile_sha256) throw new Error('Agentupdate: unverändertes Windows-Zeitprofil');
|
||||
}
|
||||
} else throw new Error('Agentupdate: unbekannter Peerpinübergang');
|
||||
return { action: 'update_agent', update: { schema_version: 1, profile: 'fixed_code_pair_v1', release_envelope: release.envelope, release_envelope_sha256: digest(u.release_envelope_sha256), manifest_sha256: digest(u.manifest_sha256), predecessor, updater, peer_pin_transition: transition, recovery: 'restore_exact_predecessor_once', health_profile: 'mtls_inventory_sync_v1', health_timeout_seconds: 180, no_reboot: true } };
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
import { expect, it } from 'vitest';
|
||||
import { canonicalJson } from './api';
|
||||
import { sha256 } from './safety';
|
||||
import { completionReview } from './echo-completion-review';
|
||||
|
||||
it('prüft Abschlussbindung und verweigert Bereitschaft oder eine als echt behauptete Freigabe', async () => {
|
||||
const witness = { scope: { tenant_id: '11111111-1111-4111-8111-111111111111', asset_id: 'a176520e-8a91-4e93-a78b-8e7620f430e0',
|
||||
agent_id: '63ea15b2-0643-403d-b5b4-cba1288dbea3', execution_identity: 'agent_service',
|
||||
script_sha256: await sha256(new TextEncoder().encode("Write-Output 'Zeitprofil-Test'\r\n")) },
|
||||
probe_receipt_sha256: '1'.repeat(64), probe_signature_sha256: '2'.repeat(64), grant_payload_sha256: '3'.repeat(64),
|
||||
grant_signature_sha256: '4'.repeat(64), outcome_sha256: '5'.repeat(64) };
|
||||
const digest = await sha256(new TextEncoder().encode(canonicalJson(witness)));
|
||||
const receipt = { domain: 'rmm.dev.windows-echo-completion.v1', schema_version: 1, witness, witness_sha256: digest,
|
||||
confirmed_by: 'simulated-testprincipal-a', approval_origin: 'dev_test_browser_simulation', testsimulation: true,
|
||||
ready: false, helper_ready: false, unlock: false };
|
||||
expect((await completionReview({ witness, witness_sha256: digest, receipt })).witness_sha256).toBe(digest);
|
||||
for (const changed of [{ ...receipt, ready: true }, { ...receipt, helper_ready: true }, { ...receipt, unlock: true },
|
||||
{ ...receipt, testsimulation: false }, { ...receipt, confirmed_by: 'Administrator' },
|
||||
{ ...receipt, witness: { ...witness, grant_payload_sha256: '0'.repeat(64) } }]) {
|
||||
await expect(completionReview({ witness, witness_sha256: digest, receipt: changed })).rejects.toThrow();
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,61 @@
|
||||
import React, { useState } from 'react';
|
||||
import { canonicalJson, pretty, record, RecordValue, request, Session, tenantPath } from './api';
|
||||
import { allowed, sha256 } from './safety';
|
||||
|
||||
const tenant = '11111111-1111-4111-8111-111111111111';
|
||||
const asset = 'a176520e-8a91-4e93-a78b-8e7620f430e0';
|
||||
const agent = '63ea15b2-0643-403d-b5b4-cba1288dbea3';
|
||||
interface Review { witness: RecordValue; witness_sha256: string; receipt: RecordValue | null }
|
||||
export async function completionReview(value: unknown): Promise<Review> {
|
||||
const r = record(value), w = record(r.witness), s = record(w.scope);
|
||||
if (s.tenant_id !== tenant || s.asset_id !== asset || s.agent_id !== agent || s.execution_identity !== 'agent_service' ||
|
||||
s.script_sha256 !== await sha256(new TextEncoder().encode("Write-Output 'Zeitprofil-Test'\r\n")) ||
|
||||
typeof r.witness_sha256 !== 'string' || await sha256(new TextEncoder().encode(canonicalJson(w))) !== r.witness_sha256 ||
|
||||
!['probe_receipt_sha256', 'probe_signature_sha256', 'grant_payload_sha256', 'grant_signature_sha256', 'outcome_sha256'].every(k => typeof w[k] === 'string' && /^[a-f0-9]{64}$/.test(w[k] as string)) ||
|
||||
!(r.receipt === null || (typeof r.receipt === 'object' && !Array.isArray(r.receipt)))) {
|
||||
throw new Error('Der Abschlussbeleg ist ungültig.');
|
||||
}
|
||||
if (r.receipt !== null) {
|
||||
const receipt = record(r.receipt);
|
||||
if (receipt.domain !== 'rmm.dev.windows-echo-completion.v1' || receipt.schema_version !== 1 || receipt.testsimulation !== true ||
|
||||
receipt.approval_origin !== 'dev_test_browser_simulation' || receipt.confirmed_by !== 'simulated-testprincipal-a' ||
|
||||
receipt.ready !== false || receipt.helper_ready !== false || receipt.unlock !== false ||
|
||||
receipt.witness_sha256 !== r.witness_sha256 || canonicalJson(receipt.witness) !== canonicalJson(w)) {
|
||||
throw new Error('Die Quittung passt nicht zum geprüften Abschluss.');
|
||||
}
|
||||
}
|
||||
return r as unknown as Review;
|
||||
}
|
||||
export function EchoCompletionReview({ auth }: { auth: Session }) {
|
||||
const [review, setReview] = useState<Review | null>(null), [checked, setChecked] = useState(false);
|
||||
const [busy, setBusy] = useState(false), [error, setError] = useState('');
|
||||
const eligible = auth.principal.simulated && auth.principal.id === 'simulated-testprincipal-a' && !!auth.csrf_token && allowed(auth, 'plans:approve');
|
||||
const path = tenantPath(tenant, '/windows-echo-completion');
|
||||
async function load() {
|
||||
setBusy(true); setError(''); setChecked(false); setReview(null);
|
||||
try { setReview(await completionReview(await request(path))); }
|
||||
catch (e) { setError(String(e)); } finally { setBusy(false); }
|
||||
}
|
||||
async function confirm() {
|
||||
if (!eligible || !checked || !review || busy) return;
|
||||
setBusy(true); setError(''); setChecked(false);
|
||||
try { setReview(await completionReview(await request(path + '/confirm', { csrf: auth.csrf_token,
|
||||
body: { reviewed: true, witness_sha256: review.witness_sha256 } }))); }
|
||||
catch (e) { setReview(null); setError(String(e)); } finally { setBusy(false); }
|
||||
}
|
||||
return <section aria-label="Abschluss des festen PowerShell-Testbetriebs">
|
||||
<h3>Abschluss des festen PowerShell-Testbetriebs</h3>
|
||||
<p>Nach dem nachgewiesenen einzelnen Test kann die zusätzliche Beschränkung auf diesen Auftrag beendet werden. Identität, alte Begrenzung, Quittungen und Journale bleiben erhalten. Jeder weitere Auftrag braucht weiterhin einen eigenen unveränderlichen Plan und seine WebUI-Genehmigung; dieser Schritt erteilt keine Jobfreigabe oder Ausführungsbereitschaft.</p>
|
||||
<button disabled={busy} onClick={load}>Erfolgreichen PowerShell-Test und Originalbelege prüfen</button>
|
||||
{error && <p role="alert">{error}</p>}
|
||||
{review && <>
|
||||
<pre aria-label="Geprüfter Abschlussbeleg">{pretty(review)}</pre>
|
||||
{!review.receipt && eligible && <>
|
||||
<label><input type="checkbox" checked={checked} disabled={busy} onChange={e => setChecked(e.target.checked)}/>
|
||||
Ich habe den erfolgreichen Test und die erhaltenen Originalbelege geprüft. Ich beende ausschließlich die zusätzliche Begrenzung auf diesen Testauftrag.</label>
|
||||
<button disabled={busy || !checked} onClick={confirm}>SIMULIERT: Zusätzliche Testbegrenzung beenden</button>
|
||||
</>}
|
||||
{review.receipt && eligible && <a href={path + '/receipt'} download="windows-echo-completion.json">Signierte Abschlussquittung herunterladen</a>}
|
||||
</>}
|
||||
</section>;
|
||||
}
|
||||
+2
-1
@@ -7,6 +7,7 @@ import { AdminControl, Catalog, TenantControls } from './management';
|
||||
import { allowed, availableActions, parseStrictJson, powerShellApprovalBlockers, powerShellPlanJobs, rootWarning, systemWarning, systemPlanJobs, validateSensitiveInput, verifyPlanIntegrity, queryLogsApprovalBlockers, queryLogsPlanJobs, windowsMsiApprovalBlockers, windowsMsiPlanJobs, verifyWindowsMsiManifest, fullMaintenanceWarning } from './safety';
|
||||
import { RecoveryReview, recoveryAsset, recoveryTenant } from './recovery-review';
|
||||
import { EchoProbeReview } from './echo-probe-review';
|
||||
import { EchoCompletionReview } from './echo-completion-review';
|
||||
import { Login } from './login';
|
||||
import { ConsoleOutput, outputText } from './console-output';
|
||||
import { scriptApprovalBlockers, scriptPlanJobs, verifyScriptPlan } from './script-console';
|
||||
@@ -102,7 +103,7 @@ function Devices({ tenantId, auth, selected, setSelected }: { tenantId: string;
|
||||
<p>Fester Auswahlsnapshot ({selected.length}): {selected.join(', ') || 'keine Ziele'}</p>
|
||||
{asset && <article><h3>Inventardetail {asset}</h3><ErrorBox error={detail.error}/>{detail.data && <><CatalogCheckNotice device={detail.data}/><JsonView value={detail.data} label="Inventar, Capabilities, Metriken, Dienste, Software, Updates, Logs und Quellen (soweit geliefert)"/></>}<AdminControl auth={auth} path={tenantPath(tenantId, `/devices/${encodeURIComponent(asset)}/revocation`)} permission="devices:revoke" title="Geräteidentität widerrufen" warning="ACHTUNG: Widerruf unterbricht die Geräteverwaltung und sperrt neue Starts. Kein Entfernen aus einer Liste, kein Rollback. Wiederaufnahme erfordert einen gesonderten sicheren Enrollment-/Recoveryprozess." done={detail.reload}/></article>}
|
||||
{tenantId === recoveryTenant && asset === recoveryAsset && allowed(auth, 'inventory:read') &&
|
||||
<><EchoProbeReview key={auth.principal.id + '-probe'} auth={auth}/><RecoveryReview key={auth.principal.id} auth={auth}/></>}
|
||||
<><EchoProbeReview key={auth.principal.id + '-probe'} auth={auth}/><EchoCompletionReview key={auth.principal.id + '-completion'} auth={auth}/><RecoveryReview key={auth.principal.id} auth={auth}/></>}
|
||||
</section>;
|
||||
}
|
||||
const initialParameters: Record<Action, RecordValue> = {
|
||||
|
||||
Reference in New Issue
Block a user