91af38ca11
Task 1.2 Фазы 1 М7. Новый модуль tools/powershell-destructive.mjs — psContentBlock для PowerShell-tool (PS-нативные глаголы Remove-Item/-Recurse/iwr/iex/Start-Process/ Out-File/redirect НЕ матчат unix-regex classify-destructive). Реоткрытие v3.8 F1: PowerShell-tool был полностью вне scope content-floor. 16 GREEN.
28 lines
1.2 KiB
JavaScript
28 lines
1.2 KiB
JavaScript
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);
|
|
});
|
|
}
|
|
});
|