mirror of
https://github.com/Yamato-Security/WELA.git
synced 2026-10-08 07:15:25 +02:00
Preserve positional bindings and propagate native fixture failures
This commit is contained in:
1 parent
adaf3f9681
commit
4ab4c275a5
3 files changed
+10
-6
No files matched your search
@@ -77,9 +77,6 @@
|
||||
[string]$RuleEvidencePath,
|
||||
[string]$RuleCorpusPath,
|
||||
[string]$RuleManifestPath,
|
||||
[ValidateSet('Audit','Plan','Configure')][string]$PowerShellLoggingAction = 'Audit',
|
||||
[ValidateSet('ScriptBlock','Module')][string[]]$PowerShellLoggingControl,
|
||||
[string[]]$PowerShellLoggingModuleName,
|
||||
[ValidateSet('Audit', 'Plan', 'Configure')][string]$TranscriptionAction = 'Audit',
|
||||
[string]$TranscriptDirectory,
|
||||
[ValidateSet('Audit','Plan','Configure')][string]$LdapAction = 'Audit',
|
||||
@@ -231,7 +228,10 @@
|
||||
[ValidateRange(1,1024)][int]$MeasurementMaximumEvents = 256,
|
||||
[string]$MeasurementOutputPath,
|
||||
[switch]$MeasurementExportEvtx,
|
||||
[switch]$Help
|
||||
[switch]$Help,
|
||||
[ValidateSet('Audit','Plan','Configure')][string]$PowerShellLoggingAction = 'Audit',
|
||||
[ValidateSet('ScriptBlock','Module')][string[]]$PowerShellLoggingControl,
|
||||
[string[]]$PowerShellLoggingModuleName
|
||||
)
|
||||
|
||||
$WELAVersion = "2.2.0"
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
$ErrorActionPreference='Stop';$repo=Split-Path $PSScriptRoot -Parent;$engine=(Get-Process -Id $PID).Path;$count=0
|
||||
$parameterAst=[Management.Automation.Language.Parser]::ParseFile((Join-Path $repo 'WELA.ps1'),[ref]$null,[ref]$null).ParamBlock.Parameters
|
||||
$names=@($parameterAst|ForEach-Object {$_.Name.VariablePath.UserPath});$helpIndex=[array]::IndexOf($names,'Help')
|
||||
foreach($name in @('PowerShellLoggingAction','PowerShellLoggingControl','PowerShellLoggingModuleName')){if([array]::IndexOf($names,$name) -le $helpIndex){throw 'New logging parameters must follow existing Help to preserve legacy positional binding.'};$count++}
|
||||
$cases=@(
|
||||
@{Args=@('powershell-logging','-Help');Code=0;Pattern='Windows PowerShell 5.1'},
|
||||
@{Args=@('configure','-PowerShellLoggingAction','Configure');Code=1;Pattern='require powershell-logging'},
|
||||
|
||||
@@ -37,8 +37,9 @@ param([string]$Repository,[string]$Request)
|
||||
$ErrorActionPreference='Stop'
|
||||
$data=Get-Content -LiteralPath $Request -Raw|ConvertFrom-Json;$options=@{}
|
||||
foreach($property in $data.PSObject.Properties){$options[$property.Name]=$property.Value}
|
||||
$global:LASTEXITCODE=0
|
||||
& (Join-Path $Repository 'WELA.ps1') @options
|
||||
exit 0
|
||||
exit $LASTEXITCODE
|
||||
'@ | Set-Content -LiteralPath $wrapper -Encoding UTF8
|
||||
function Public([string]$Label,[hashtable]$Parameters,[int]$ExpectedExit=0){
|
||||
$Parameters.Cmd='powershell-logging';$Parameters.ResultsPath=Join-Path $root ($Label+'.json');$request=Join-Path $root ($Label+'-request.json');$Parameters|ConvertTo-Json -Depth 8|Set-Content -LiteralPath $request -Encoding UTF8
|
||||
@@ -134,7 +135,7 @@ finally{
|
||||
try{RemoveCreatedKeys $original.Machine}catch{$cleanupErrors+=$_.ToString()}
|
||||
try{$after=Get-WelaPsLoggingSnapshot;Save 'cleanup-after.json' $after;if((ConvertTo-WelaPsLoggingKey $after) -cne (ConvertTo-WelaPsLoggingKey $original)){$cleanupErrors+='Full policy/host/source/channel snapshot did not restore exactly.'};if($masks -and (Masks) -cne $masks){$cleanupErrors+='Audit masks changed.'}}catch{$cleanupErrors+=$_.ToString()}
|
||||
}
|
||||
Save 'cleanup.json' @{Status=$(if($cleanupErrors.Count){'Failed'}else{'Restored'});Errors=$cleanupErrors;OriginalCaptured=[bool]$original;MutationStarted=$mutationStarted;All59MasksUnchanged=($masks -and (Masks) -ceq $masks)}
|
||||
Save 'cleanup.json' @{Status=$(if($cleanupErrors.Count){'Failed'}elseif($mutationStarted){'Restored'}else{'NotMutated'});Errors=$cleanupErrors;OriginalCaptured=[bool]$original;MutationStarted=$mutationStarted;All59MasksUnchanged=($masks -and (Masks) -ceq $masks)}
|
||||
$artifacts=@(Get-ChildItem -LiteralPath $root -File -Recurse|ForEach-Object{[pscustomobject]@{Path=$_.FullName.Substring($root.Length+1);Sha256=(Get-FileHash $_.FullName -Algorithm SHA256).Hash.ToLowerInvariant()}})
|
||||
Save 'manifest.json' @{Kind='WelaPowerShellLoggingNativeFixture';Head=$env:GITHUB_SHA;Engine=$PSVersionTable.PSVersion.ToString();Assertions=$script:count;Failure=$failure;CleanupErrors=$cleanupErrors;ReadyRuleCredit=0;Artifacts=$artifacts}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user