Add the fixed PowerShell probe review to the local development WebUI
Rust development slice / linux (push) Failing after 7s

This commit is contained in:
2026-11-15 23:43:54 +01:00
parent cc2bc67a5e
commit ab9725157f
4 changed files with 111 additions and 1 deletions
+14
View File
@@ -536,3 +536,17 @@ Native Apply und erster genehmigter PowerShell-Job sind deshalb weiterhin
nicht abgenommen. Nach Bestätigung sind der Gast-Apply, der korrigierte
Agentcode mit neuer Profilbindung, frische Zeit-/Syncbelege und der eigene
MCP-/WebUI-Skriptplan die nächsten Schritte.
### Fester PowerShell-Test ohne OIDC, Version 1.25
Der Betreiber verlangt die selbst bediente Testgenehmigung im lokalen
Entwicklungslogin. Die zusätzliche WebUI bindet dafür den regulär gespeicherten
PowerShell-Antrag an genau einen Testscope mit Plan-, Job- und Versuch-ID,
Payload-/Skripthash, LocalService, 60 Sekunden und 65536 Ausgabebytes.
Die Review-Ansicht prüft den kanonischen Scopehash sowie den unveränderten
historischen Witness. Ihre Bestätigung ist sichtbar simuliert. Die
anschließende eigentliche Jobplangenehmigung bleibt ein separater WebUI-Schritt.
Der gezielte UI-Test verwarf geänderten Interpreterinhalt, SYSTEM-Identität,
geänderte Limits und fremde Ziel-/Antragsbindung auch bei neu berechnetem
Scopehash. Typecheck und Webbuild bestanden lokal. Der neue Testpfad ist zu
diesem Zeitpunkt noch nicht veröffentlicht oder nativ ausgeführt.
+26
View File
@@ -0,0 +1,26 @@
import { readFileSync } from 'node:fs';
import { expect, it } from 'vitest';
import { canonicalJson } from './api';
import { sha256 } from './safety';
import { echoReview } from './echo-probe-review';
it('bindet die simulierte Echoabnahme an den einzelnen gespeicherten Auftrag und die Originalbelege', async () => {
const witness = JSON.parse(readFileSync(new URL('../../crates/domain/src/windows_sync_history_case.json', import.meta.url), 'utf8'));
const operation = '06e55f7a-0263-4def-b7c3-7d28b1202a51';
const scope = { tenant_id: witness.tenant_id, asset_id: witness.asset_id, agent_id: witness.agent_id,
operation_id: operation, plan_id: 'ee49a5a7-5b1a-4bb7-a08f-91169b6994ef',
job_id: '81a299d0-e4a7-4ddb-97bb-dd9f435cab58', attempt_id: 'bd5c1c80-c0be-446b-857e-7a2e07dc4920',
execution_identity: 'agent_service', max_runtime_seconds: 60, max_output_bytes: 65536,
plan_hash: '1'.repeat(64), job_payload_hash: '2'.repeat(64),
script_sha256: await sha256(new TextEncoder().encode("Write-Output 'Zeitprofil-Test'\r\n")) };
const make = async (s: typeof scope) => ({ scope: s,
scope_sha256: await sha256(new TextEncoder().encode(canonicalJson(s))), witness,
witness_sha256: await sha256(new TextEncoder().encode(canonicalJson(witness))),
receipt_id: null, valid_until: null });
expect((await echoReview(await make(scope), operation)).scope.job_id).toBe(scope.job_id);
for (const changed of [ { ...scope, execution_identity: 'system' }, { ...scope, script_sha256: '0'.repeat(64) },
{ ...scope, max_runtime_seconds: 61 }, { ...scope, max_output_bytes: 65537 },
{ ...scope, operation_id: scope.plan_id }, { ...scope, asset_id: scope.plan_id } ]) {
await expect(echoReview(await make(changed), operation)).rejects.toThrow();
}
});
+69
View File
@@ -0,0 +1,69 @@
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';
const uuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
interface Review { scope: RecordValue; scope_sha256: string; witness_sha256: string; witness: RecordValue; receipt_id: string | null; valid_until: string | null }
export async function echoReview(value: unknown, operation: string): Promise<Review> {
const r = record(value), s = record(r.scope), w = record(r.witness);
if (s.operation_id !== operation || s.tenant_id !== tenant || s.asset_id !== asset || s.agent_id !== agent ||
s.execution_identity !== 'agent_service' || s.max_runtime_seconds !== 60 || s.max_output_bytes !== 65536 ||
s.script_sha256 !== await sha256(new TextEncoder().encode("Write-Output 'Zeitprofil-Test'\r\n")) ||
await sha256(new TextEncoder().encode(canonicalJson(s))) !== r.scope_sha256 ||
r.witness_sha256 !== 'f29b5afadaf2debab9610282725c2493cb7405784640a4616e1998c304309cab' ||
await sha256(new TextEncoder().encode(canonicalJson(w))) !== r.witness_sha256 ||
!['plan_id', 'job_id', 'attempt_id'].every(k => typeof s[k] === 'string' && uuid.test(s[k] as string)) ||
!['plan_hash', 'job_payload_hash'].every(k => typeof s[k] === 'string' && /^[a-f0-9]{64}$/.test(s[k] as string)) ||
!(r.receipt_id === null || (typeof r.receipt_id === 'string' && uuid.test(r.receipt_id))) ||
!(r.valid_until === null || (typeof r.valid_until === 'string' && Number.isFinite(Date.parse(r.valid_until))))) {
throw new Error('Der gespeicherte Beleg passt nicht zum festen PowerShell-Test.');
}
return r as unknown as Review;
}
export function EchoProbeReview({ auth }: { auth: Session }) {
const [operation, setOperation] = useState(''), [review, setReview] = useState<Review | null>(null);
const [checked, setChecked] = useState(false), [busy, setBusy] = useState(false), [error, setError] = useState('');
const eligible = auth.principal.simulated && auth.principal.id === 'simulated-testprincipal-a' &&
auth.tenants.some(t => t.tenant_id === tenant) && !!auth.csrf_token && allowed(auth, 'plans:approve');
const path = tenantPath(tenant, '/windows-echo-probe/' + encodeURIComponent(operation));
async function load() {
if (busy || !uuid.test(operation)) return;
setBusy(true); setError(''); setChecked(false); setReview(null);
try { setReview(await echoReview(await request(path), operation)); }
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 echoReview(await request(path + '/confirm', { csrf: auth.csrf_token,
body: { reviewed: true, scope_sha256: review.scope_sha256, witness_sha256: review.witness_sha256 } }), operation));
} catch (e) { setReview(null); setError(String(e)); } finally { setBusy(false); }
}
return <section aria-label="Fester PowerShell-Testbetrieb">
<h3>Fester PowerShell-Testbetrieb</h3>
<p>Dieser Entwicklungsnachweis bindet genau einen unprivilegierten PowerShell-Auftrag. Die spätere Plangenehmigung erfolgt separat.</p>
<label>Antrags-ID des festen PowerShell-Tests<input value={operation} disabled={busy} onChange={e => {
setOperation(e.target.value); setReview(null); setChecked(false);
}}/></label>
<button disabled={busy || !uuid.test(operation)} onClick={load}>Gespeicherten Testauftrag prüfen</button>
{error && <p role="alert">{error}</p>}
{review && <>
<p>PowerShell 5.1 · LocalService · RemoteSigned für den Jobprozess · 60 Sekunden · 65536 Ausgabebytes</p>
<pre>{"Write-Output 'Zeitprofil-Test'\r\n"}</pre>
<pre aria-label="Fester Testscope und historische Belege">{pretty(review)}</pre>
{!review.receipt_id && eligible && <>
<label><input type="checkbox" checked={checked} disabled={busy} onChange={e => setChecked(e.target.checked)}/>
Ich habe den einzelnen Testauftrag und die dauerhafte Begrenzung auf dessen gespeicherte Bytes geprüft.</label>
<button disabled={busy || !checked} onClick={confirm}>SIMULIERT: Ausschließlich diesen PowerShell-Testbetrieb bestätigen</button>
</>}
{review.receipt_id && eligible && <a href={path + '/receipt'} download="windows-echo-probe.json">Signierte Testquittung herunterladen</a>}
{!eligible && <p>Diese Entwicklungsfunktion verlangt die ausdrücklich simulierte Browsersitzung mit Planfreigaberecht.</p>}
</>}
</section>;
}
+2 -1
View File
@@ -6,6 +6,7 @@ import './style.css';
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 { Login } from './login';
import { ConsoleOutput, outputText } from './console-output';
import { scriptApprovalBlockers, scriptPlanJobs, verifyScriptPlan } from './script-console';
@@ -101,7 +102,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') &&
<RecoveryReview key={auth.principal.id} auth={auth}/>}
<><EchoProbeReview key={auth.principal.id + '-probe'} auth={auth}/><RecoveryReview key={auth.principal.id} auth={auth}/></>}
</section>;
}
const initialParameters: Record<Action, RecordValue> = {