import { describe, it, expect } from 'vitest'; import { psContentBlock } from './powershell-destructive.mjs'; // NB: for-of + it() (не it.each) — активный пол tdd-real-test-verifier распознаёт только it(. // M7 Task 1.2 (V1-PS, реоткрытие v3.8 F1): PS-нативные глаголы НЕ матчат unix-regex // classify-destructive → отдельный набор content-block для PowerShell-tool. describe('psContentBlock (V1-PS, реоткрытие v3.8 F1)', () => { const BLOCKED = [ 'Remove-Item -Recurse -Force C:\\x', 'rm -r -fo C:\\x', 'Invoke-WebRequest https://e.rf', 'iwr https://e.rf', 'curl https://e.rf', 'Invoke-Expression $x', 'iex $x', 'Get-Content x | Out-File y', 'echo x > y', 'echo x >> y', 'Start-Process node', 'Start-Process powershell', ]; for (const cmd of BLOCKED) { it(`blocks PS content: ${cmd}`, () => { expect(psContentBlock(cmd)).toBe(true); }); } const ALLOWED = ['Get-ChildItem', 'Get-Content x', 'Test-Path x', 'Write-Output ok']; for (const cmd of ALLOWED) { it(`does NOT block safe PS: ${cmd}`, () => { expect(psContentBlock(cmd)).toBe(false); }); } });