Skip to content

Commit 97ae651

Browse files
committed
update(plugins/cloudtrail): support pre-ControlTower organization trails
Some pre-ControlTower organization Cloutrail trails are missing the OrgId in the AWSLogs S3 path. Making the OrgId optional gives them the option to use S3AccountList. Signed-off-by: Uli Heilmeier <uh@heilmeier.eu>
1 parent 947abb0 commit 97ae651

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

plugins/cloudtrail/pkg/cloudtrail/cloudtrail.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const (
4848
PluginName = "cloudtrail"
4949
PluginDescription = "reads cloudtrail JSON data saved to file in the directory specified in the settings"
5050
PluginContact = "github.com/falcosecurity/plugins/"
51-
PluginVersion = "0.12.4"
51+
PluginVersion = "0.12.5"
5252
PluginEventSource = "aws_cloudtrail"
5353
)
5454

plugins/cloudtrail/pkg/cloudtrail/source.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -271,15 +271,17 @@ func (oCtx *PluginInstance) openS3(input string) error {
271271
// bucket_name/prefix_name/AWSLogs/Account ID/CloudTrail/region/YYYY/MM/DD/AccountID_CloudTrail_RegionName_YYYYMMDDTHHmmZ_UniqueString.json.gz
272272
// for organization trails the format is
273273
// bucket_name/prefix_name/AWSLogs/O-ID/Account ID/CloudTrail/Region/YYYY/MM/DD/AccountID_CloudTrail_RegionName_YYYYMMDDTHHmmZ_UniqueString.json.gz
274+
// for pre ControlTower organization trails the format is
275+
// bucket_name/prefix_name/AWSLogs/Account ID/CloudTrail/Region/YYYY/MM/DD/AccountID_CloudTrail_RegionName_YYYYMMDDTHHmmZ_UniqueString.json.gz
274276
// Reduce the number of pages we have to process using "StartAfter" parameters
275277
// here, then trim individual filepaths below.
276278

277279
intervalPrefix := prefix
278280

279281
// For durations, carve out a special case for "Copy S3 URI" in the AWS console, which gives you
280282
// bucket_name/prefix_name/AWSLogs/<Account ID>/ or bucket_name/prefix_name/AWSLogs/<Org-ID>/<Account ID>/
281-
awsLogsRE := regexp.MustCompile(`AWSLogs/(?:o-[a-z0-9]{10,32}/)?\d{12}/?$`)
282-
awsLogsOrgRE := regexp.MustCompile(`AWSLogs/o-[a-z0-9]{10,32}/?$`)
283+
awsLogsRE := regexp.MustCompile(`/AWSLogs/(?:o-[a-z0-9]{10,32}/)?\d{12}/?$`)
284+
awsLogsOrgRE := regexp.MustCompile(`/AWSLogs(?:/o-[a-z0-9]{10,32})?/?$`)
283285
if awsLogsRE.MatchString(prefix) {
284286
if (! strings.HasSuffix(intervalPrefix, "/")) {
285287
intervalPrefix += "/"

0 commit comments

Comments
 (0)