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 authored and poiana committed Jun 17, 2024
1 parent b31ad61 commit fbd9f48
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion plugins/cloudtrail/pkg/cloudtrail/cloudtrail.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const (
PluginName = "cloudtrail"
PluginDescription = "reads cloudtrail JSON data saved to file in the directory specified in the settings"
PluginContact = "github.com/falcosecurity/plugins/"
PluginVersion = "0.12.2"
PluginVersion = "0.12.3"
PluginEventSource = "aws_cloudtrail"
)

Expand Down
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 rlist == nil || 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 fbd9f48

Please sign in to comment.