Skip to content

Commit

Permalink
update(cloudtrail): Update ct.resources handling
Browse files Browse the repository at this point in the history
Generalize our array length check. Use strings.TrimSuffix in order to
avoid a potential string under-read.

Signed-off-by: Gerald Combs <[email protected]>
  • Loading branch information
geraldcombs committed Jun 9, 2024
1 parent ef2a608 commit 82feae2
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions plugins/cloudtrail/pkg/cloudtrail/extract.go
Original file line number Diff line number Diff line change
Expand Up @@ -532,16 +532,14 @@ func getfieldStr(jdata *fastjson.Value, field string) (bool, string) {
case "ct.resources":
var resources string = ""
rlist := jdata.GetArray("resources")
if rlist == nil {
if len(rlist) == 0 {
return false, ""
}
for _, resource := range rlist {
resources += string(resource.MarshalTo(nil))
resources += ","
}
if resources[len(resources)-1] == ',' {
resources = resources[0 : len(resources)-1]
}
resources = strings.TrimSuffix(resources, ",")
if resources == "" {
return false, ""
}
Expand Down

0 comments on commit 82feae2

Please sign in to comment.