mirror of
https://github.com/Yamato-Security/WELA.git
synced 2025-12-06 17:22:50 +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() {
|
[void] CountByLevel() {
|
||||||
$this.RulesCount = @{}
|
$this.RulesCount = @{}
|
||||||
foreach ($level in [WELA]::Levels) {
|
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" }
|
$color = if ($this.CurrentSetting -eq "Enabled" -or $this.CurrentSetting -contains "Success" -or $this.CurrentSetting -contains "Failure") { "Green" } else { "Red" }
|
||||||
$ruleCounts = ""
|
$ruleCounts = ""
|
||||||
$logEnabled = $this.CurrentSetting
|
$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) {
|
if ($allZero -eq 0) {
|
||||||
$ruleCounts = "(no rules)"
|
$ruleCounts = "(no rules)"
|
||||||
$color = "DarkYellow"
|
$color = "DarkYellow"
|
||||||
|
|||||||
Reference in New Issue
Block a user