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
+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>;
}