Skip to content

Commit 553e190

Browse files
committed
fix: guard against empty firewall policy results to prevent panic
If the FortiOS API returns an empty array (no VDOMs or permission error), accessing ps4[0] panics with index out of range. Signed-off-by: Aprazors <Aprazors@gmail.com>
1 parent b3a54c2 commit 553e190

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

pkg/probe/firewall_policy.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ func probeFirewallPolicies(c fortigatehttpclient.FortiHTTP, _ *TargetMetadata) (
8080
return nil, false
8181
}
8282

83+
if len(ps4) == 0 {
84+
log.Printf("Error: no firewall policy results returned")
85+
return nil, false
86+
}
87+
8388
combined := false
8489
major, minor, ok := fortiversion.ParseVersion(ps4[0].Version)
8590
if !ok {

0 commit comments

Comments
 (0)