From 1fb255acb6bd3d236fa4c10222234c0b464bb1cf Mon Sep 17 00:00:00 2001 From: Yash Mehrotra Date: Fri, 6 Sep 2024 18:19:57 +0530 Subject: [PATCH] fix: handle nil interface for aws conversion --- scrapers/aws/aws.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scrapers/aws/aws.go b/scrapers/aws/aws.go index 15b631d7..efc42b2c 100644 --- a/scrapers/aws/aws.go +++ b/scrapers/aws/aws.go @@ -1972,7 +1972,11 @@ func parseAssumeRolePolicyDoc(ctx *AWSContext, encodedDoc string) (map[string]an c := gabs.Wrap(policyDocObj) for _, stmt := range c.S("Statement").Children() { // If Principal.Service is a list, sort that for cleaner change diff - if svcs, ok := lo.FromAnySlice[string](stmt.Search("Principal", "Service").Data().([]any)); ok { + svcsObj := stmt.Search("Principal", "Service").Data() + if svcsObj == nil { + continue + } + if svcs, ok := lo.FromAnySlice[string](svcsObj.([]any)); ok { slices.Sort(svcs) if _, err := stmt.Set(svcs, "Principal", "Service"); err != nil { ctx.Errorf("error setting services object[%v] in Principal.Services: %v", svcs, err)