Skip to content

Commit a05aa2d

Browse files
committed
Fix Windows posture magic numbers
- Replace 0 with initialCapacity in rule counting - Use initialCapacity for update count checks - Fix empty string checks in cmd/secrets
1 parent 1aa7783 commit a05aa2d

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

agent/internal/posture/windows.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func (*WindowsCollector) collectFirewallStatus(fw *FirewallStatus) error {
9999
ruleOutput, err := runCommand("netsh", "advfirewall", "firewall", "show", "rule", "name=all")
100100
if err == nil {
101101
lines := strings.Split(ruleOutput, newlineSeparator)
102-
ruleCount := 0
102+
ruleCount := initialCapacity
103103
for _, line := range lines {
104104
if strings.HasPrefix(strings.TrimSpace(line), RuleNamePrefix) {
105105
ruleCount++
@@ -142,7 +142,7 @@ func (*WindowsCollector) checkSystemUpdated() bool {
142142
"Get-WUList -MicrosoftUpdate | Measure-Object | Select-Object -ExpandProperty Count")
143143
if err == nil {
144144
count := parseInt(strings.TrimSpace(output))
145-
return count == 0 // No pending updates
145+
return count == initialCapacity // No pending updates
146146
}
147147

148148
// Fallback: check Windows Update service

cmd/secrets/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func main() {
8787
handleGet(ctx, manager, *key, *format)
8888

8989
case actionSet:
90-
if *key == "" || *value == "" {
90+
if *key == emptyString || *value == emptyString {
9191
log.Fatal(logMissingKeyValue)
9292
}
9393
handleSet(ctx, manager, *key, *value)

0 commit comments

Comments
 (0)