From b041c09cd4d069f338c56820897cb27376d0c3fc Mon Sep 17 00:00:00 2001 From: Daichi Sakaue Date: Wed, 11 Dec 2024 13:54:12 +0900 Subject: [PATCH] Fix SEGV Signed-off-by: Daichi Sakaue --- cmd/npv/app/list.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cmd/npv/app/list.go b/cmd/npv/app/list.go index adb8b78..75b77eb 100644 --- a/cmd/npv/app/list.go +++ b/cmd/npv/app/list.go @@ -2,6 +2,7 @@ package app import ( "context" + "errors" "fmt" "io" "sort" @@ -102,6 +103,15 @@ func runList(ctx context.Context, w io.Writer, name string) error { if err != nil { return fmt.Errorf("failed to get endpoint information: %w", err) } + if response.Payload == nil || + response.Payload.Status == nil || + response.Payload.Status.Policy == nil || + response.Payload.Status.Policy.Realized == nil || + response.Payload.Status.Policy.Realized.L4 == nil || + response.Payload.Status.Policy.Realized.L4.Ingress == nil || + response.Payload.Status.Policy.Realized.L4.Egress == nil { + return errors.New("api response is insufficient") + } // The same rule appears multiple times in the response, so we need to dedup it policySet := make(map[derivedFromEntry]struct{})