Skip to content

fix(plugins/cloudtrail): apply s3Interval to logs at the bucket root - #1610

Open
RaphaelFakhri wants to merge 1 commit into
falcosecurity:mainfrom
RaphaelFakhri:fix/cloudtrail-s3-interval-bucket-root
Open

RaphaelFakhri wants to merge 1 commit into
falcosecurity:mainfrom
RaphaelFakhri:fix/cloudtrail-s3-interval-bucket-root

Conversation

@RaphaelFakhri

Copy link
Copy Markdown

What type of PR is this?

/kind bug

Any specific area of the project related to this PR?

/area plugins

What this PR does / why we need it:

The S3 prefix comes from the open params without the bucket name, so a trail that writes to the bucket root (the CloudTrail default) gives a prefix that starts with AWSLogs/. Since #650, awsLogsRE and awsLogsOrgRE require a leading / before AWSLogs, so these prefixes no longer match. The plugin then skips the region lookup, lists the whole prefix, and silently ignores s3Interval and s3AccountList.

This PR matches AWSLogs either at the start of the prefix or after a /. Prefixes such as fooAWSLogs/ still do not match.

A new test, TestOpenS3Interval, runs openS3 against a fake S3 endpoint with a fixed s3Interval. It covers account, organization (with and without s3AccountList) and pre-ControlTower trails at the bucket root, plus a trail below a key prefix. Without the fix, the four bucket-root cases fail because every log file is returned.

Which issue(s) this PR fixes:

Fixes #1609

Special notes for your reviewer:

go vet with Go 1.27 already reports non-constant format strings in cloudtrail.go and source.go on main, so the tests were run with go test -vet=off ./.... The new test file has no vet findings.

The S3 prefix is taken from the open params without the bucket name, so
a trail that writes to the bucket root gives a prefix that starts with
`AWSLogs/`. Since the AWSLogs patterns started to require a leading
slash, such prefixes no longer match. The plugin then skips the region
lookup, lists the whole prefix, and silently ignores s3Interval and
s3AccountList.

Match `AWSLogs` either at the start of the prefix or after a slash.

Signed-off-by: Raphael Fakhri <153192858+RaphaelFakhri@users.noreply.github.com>
@poiana poiana added the kind/bug Something isn't working label Nov 5, 2026
@poiana

poiana commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: RaphaelFakhri
Once this PR has been reviewed and has the lgtm label, please assign jasondellaluce for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@poiana

poiana commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Welcome @RaphaelFakhri! It looks like this is your first PR to falcosecurity/plugins 🎉

@poiana poiana added the size/L label Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[cloudtrail] s3Interval and s3AccountList are ignored when CloudTrail logs are at the bucket root

2 participants