mirror of
https://github.com/Yamato-Security/WELA.git
synced 2026-09-30 03:27:15 +02:00
* Add explicit native SMB runtime audit activation * Select explicit PowerShell workflow shells and link PR changelog * Clear expected refusal child exit codes after assertions * Retain native SMB command provenance in capability diagnostics * Bind SMB command guards to observed native CDXML module identities
22 lines
1.3 KiB
PowerShell
22 lines
1.3 KiB
PowerShell
$ErrorActionPreference='Stop'
|
|
$repo=Split-Path $PSScriptRoot -Parent
|
|
$engine=(Get-Process -Id $PID).Path
|
|
$script:checks=0
|
|
function Check-Cli {
|
|
param([string[]]$Arguments,[bool]$Success,[string]$Match)
|
|
$old=$ErrorActionPreference;$ErrorActionPreference='Continue'
|
|
try{$output=(& $engine -NoProfile -File (Join-Path $repo 'WELA.ps1') @Arguments 2>&1 | Out-String);$code=$LASTEXITCODE}finally{$ErrorActionPreference=$old}
|
|
if(($Success -and $code -ne 0) -or (-not $Success -and $code -eq 0) -or $output -notmatch $Match){throw "CLI guard failed: $($Arguments -join ' '), exit $code : $output"}
|
|
$script:checks++
|
|
}
|
|
Check-Cli @('smb-runtime','-Help') $true 'smb-runtime'
|
|
Check-Cli @('smb-runtime','-Profile','test','-Help') $false 'dedicated options'
|
|
Check-Cli @('help','-SmbRuntimeAction','Activate') $false 'SmbRuntime options require'
|
|
Check-Cli @('smb-runtime','-SmbAction','Configure','-Help') $false 'dedicated options'
|
|
Check-Cli @('smb-runtime','-DryRun') $false 'DryRun is supported only'
|
|
Check-Cli @('smb-runtime','-SmbRuntimeAction','Activate','-DryRun','-Help') $true 'smb-runtime'
|
|
Check-Cli @('smb-runtime','-BackupPath','unused','-Help') $false 'dedicated options'
|
|
Write-Host "PASS: $script:checks public SMB runtime CLI guards"
|
|
# Expected child failures are assertions, not the enclosing Actions step result.
|
|
$global:LASTEXITCODE=0
|