Bind approved Windows PowerShell process policy and prove Linux-first contracts
Rust development slice / linux (push) Failing after 6s
Rust development slice / linux (push) Failing after 6s
This commit is contained in:
@@ -1,9 +1,27 @@
|
||||
import { expect, it, vi } from 'vitest';
|
||||
import { renderToStaticMarkup } from 'react-dom/server';
|
||||
import { sha256, verifyPlanIntegrity } from './safety';
|
||||
|
||||
// Import the actual renderer without mounting the application's network effects.
|
||||
vi.mock('react-dom/client', () => ({ createRoot: () => ({ render: vi.fn() }) }));
|
||||
|
||||
it('shows the verified PowerShell process profile before approval without issuing requests', async () => {
|
||||
const fetch = vi.fn(); vi.stubGlobal('fetch', fetch); vi.stubGlobal('document', { getElementById: () => ({}) });
|
||||
try {
|
||||
const { PowerShellPlanNotice } = await import('./main');
|
||||
const payload = { jobs: [{ payload: { asset_id: 'fixed-windows', execution_identity: 'agent_service', action: { action: 'run_script', interpreter: 'powershell', script_utf8: 'Write-Output 1\r\n', arguments: [], expected_stdout: '1\r\n', windows_execution_profile: 'powershell_51_remote_signed' } } }] };
|
||||
const raw = new TextEncoder().encode(JSON.stringify(payload)), plan = { plan_payload_bytes: Array.from(raw), plan_hash: await sha256(raw), plan_payload: payload };
|
||||
expect(renderToStaticMarkup(<PowerShellPlanNotice plan={plan}/>)).toContain('role="alert"');
|
||||
await verifyPlanIntegrity(plan);
|
||||
const html = renderToStaticMarkup(<PowerShellPlanNotice plan={plan}/>);
|
||||
for (const expected of ['fixed-windows', 'Windows PowerShell5.1', 'RemoteSigned', 'nur Jobprozess', 'angeforderte Option']) expect(html).toContain(expected);
|
||||
expect(html).not.toMatch(/<(button|input|form)\b/);
|
||||
plan.plan_payload_bytes[0] = 0;
|
||||
expect(renderToStaticMarkup(<PowerShellPlanNotice plan={plan}/>)).toContain('role="alert"');
|
||||
expect(fetch).not.toHaveBeenCalled();
|
||||
} finally { vi.unstubAllGlobals(); }
|
||||
});
|
||||
|
||||
it('renders hostile log content only as text, without executable nodes, approval controls or requests', async () => {
|
||||
const fetch = vi.fn();
|
||||
vi.stubGlobal('fetch', fetch);
|
||||
|
||||
Reference in New Issue
Block a user