From e60fa02ed33c8953a685758a864a85831e37a238 Mon Sep 17 00:00:00 2001 From: Gerald Combs Date: Wed, 3 May 2023 10:04:46 -0700 Subject: [PATCH] update(plugins/cloudtrail): Fix a time comparison Time.Compare was added in go 1.20. Signed-off-by: Gerald Combs --- plugins/cloudtrail/pkg/cloudtrail/source.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/cloudtrail/pkg/cloudtrail/source.go b/plugins/cloudtrail/pkg/cloudtrail/source.go index 8e7e2ffb..829b8b41 100644 --- a/plugins/cloudtrail/pkg/cloudtrail/source.go +++ b/plugins/cloudtrail/pkg/cloudtrail/source.go @@ -187,9 +187,6 @@ func (oCtx *PluginInstance) openS3(input string) error { return fmt.Errorf(PluginName + " invalid interval: \"%s\": %s", oCtx.config.S3Interval, err.Error()) } - if !endTime.IsZero() && endTime.Compare(startTime) > 0 { - return fmt.Errorf(PluginName + " start time %s must be less than end time %s", startTime.Format(RFC3339Simple), endTime.Format(RFC3339Simple)) - } // CloudTrail logs have the format // bucket_name/prefix_name/AWSLogs/Account ID/CloudTrail/region/YYYY/MM/DD/AccountID_CloudTrail_RegionName_YYYYMMDDTHHmmZ_UniqueString.json.gz @@ -235,6 +232,9 @@ func (oCtx *PluginInstance) openS3(input string) error { startTS = startTime.Format("20060102T0304") if !endTime.IsZero() { endTS = endTime.Format("20060102T0304") + if endTS < startTS { + return fmt.Errorf(PluginName + " start time %s must be less than end time %s", startTime.Format(RFC3339Simple), endTime.Format(RFC3339Simple)) + } } } else { // No region prefixes found, just use what we were given.