mirror of
https://github.com/Yamato-Security/WELA.git
synced 2025-12-06 01:02:48 +01:00
fix: optimize rule counting logic in WELA.ps1 for improved performance
This commit is contained in:
4
WELA.ps1
4
WELA.ps1
@@ -61,7 +61,7 @@ class WELA {
|
||||
[void] CountByLevel() {
|
||||
$this.RulesCount = @{}
|
||||
foreach ($level in [WELA]::Levels) {
|
||||
$this.RulesCount[$level] = ($this.Rules | Where-Object { $_.level -eq $level }).Count
|
||||
$this.RulesCount[$level] = @($this.Rules | Where-Object { $_.level -eq $level }).Count
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ class WELA {
|
||||
$color = if ($this.CurrentSetting -eq "Enabled" -or $this.CurrentSetting -contains "Success" -or $this.CurrentSetting -contains "Failure") { "Green" } else { "Red" }
|
||||
$ruleCounts = ""
|
||||
$logEnabled = $this.CurrentSetting
|
||||
$allZero = $this.RulesCount.Values | Where-Object { $_ -ne 0 } | Measure-Object | Select-Object -ExpandProperty Count
|
||||
$allZero = ($this.RulesCount.Values | Where-Object { $_ -ne 0 }).Count
|
||||
if ($allZero -eq 0) {
|
||||
$ruleCounts = "(no rules)"
|
||||
$color = "DarkYellow"
|
||||
|
||||
Reference in New Issue
Block a user