mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
* feat(cloudtrail): in-process CloudTrail with S3 data event emission
New service supporting CreateTrail / DescribeTrails / DeleteTrail /
UpdateTrail / PutEventSelectors / GetEventSelectors / StartLogging /
StopLogging / GetTrailStatus.
S3 ops (PutObject / GetObject / HeadObject / DeleteObject / ListObjects
/ GetObjectAcl) emit CloudTrail data events through a per-trail buffer.
The CloudTrailLogWriter scheduler flushes pending records as gzipped
JSON envelopes into the destination bucket at AWS-shaped key paths
(AWSLogs/<account>/CloudTrail/<region>/yyyy/MM/dd/<file>.json.gz) on
a configurable cadence (default 60s).
IAM-enforcement denials emit matching AccessDenied records by hooking
IamEnforcementFilter. IamActionRegistry now distinguishes
s3:GetObjectAcl / PutObjectAcl / {Get|Put|Delete}ObjectTagging from
their base ops via ?acl / ?tagging query parameters so the right
event names land in the trail.
Seeded AWSCloudTrail_FullAccess / _ReadOnlyAccess managed policies.
* fix(cloudtrail): return LatestDeliveryTime in GetTrailStatus after StartLogging
The sdk-test-java compatibility test asserts latestDeliveryTime() is
non-null immediately after startLogging. Seed it with the startLoggingTime
so the field is always present once logging has been started.
* fix(cloudtrail): emit SnsTopicARN alongside SnsTopicName in CreateTrail/UpdateTrail responses
Accept both SnsTopicARN and SnsTopicName on input (SnsTopicARN takes
precedence). Emit both fields on output so clients reading the current
field name (SnsTopicARN) get a non-null value.
* fix(cloudtrail): wildcard S3 ARN matching, trail name validation, LookupEvents
- matchesS3DataResourceArn: handle bare "arn:aws:s3", "arn:aws:s3:::*", and
"arn:aws:s3:::*/*" wildcard forms so trails configured via the AWS Console
"capture everything" selector actually record events (previously fell through
silently). Unit tests added to CloudTrailSelectorMatchingTest.
- createTrail: enforce AWS trail name rules (3–128 chars, start/end with letter
or digit, only letters/numbers/./_/-). Integration tests in new
CloudTrailNameValidationTest.
- CloudTrailJsonHandler: add LookupEvents stub returning an empty Events array,
matching upstream's addition in #1603.
* fix(cloudtrail): log empty catches, key selectors/logging by trail home region
- CloudTrailLogWriter.stop(): log at WARN instead of silently swallowing the
final-flush exception (AGENTS.md: never leave a catch block empty).
- CloudTrailService.putEventSelectors / getEventSelectors / startLogging /
stopLogging / getTrailStatus: use trail.homeRegion() as the storage key
instead of the request region. Previously a cross-region call (e.g. accessing
a trail by ARN from a different-region endpoint) stored selectors and logging
state in the wrong region's map, so trailsMatching() found an empty selector
list and logging never fired.
- S3Controller.emitCloudTrailEvent / IamEnforcementFilter.emitS3DenialIfApplicable:
replace empty inner catch blocks with LOG.tracev() so unexpected failures
during request-context extraction surface at trace level.
* fix(iam): distinguish bucket-level vs object-level ?acl / ?tagging IAM actions
resolveS3SubResourceAction was always mapping ?acl and ?tagging to object-level
actions (s3:PutObjectAcl, s3:GetObjectAcl, etc.) regardless of path depth.
A PUT /{bucket}?acl request requires s3:PutBucketAcl, not s3:PutObjectAcl —
callers with the correct bucket-level permission were incorrectly denied.
Fix: inspect the URL path after stripping the leading slash. When there is no
slash (or the path ends with one), the target is a bucket; otherwise it is an
object. Applies to all six variants: GetBucketAcl, PutBucketAcl,
GetBucketTagging, PutBucketTagging, DeleteBucketTagging (and their object
counterparts).
* fix(cloudtrail): re-queue records on flush failure instead of dropping them
drainPendingRecords atomically dequeues all records before the S3 write.
If serializeAndGzip or s3Service.putObject threw, those records were gone —
permanently lost before the re-throw reached flushAll.
Fix: wrap the serialize+write block in a try-catch that calls requeueRecords
before rethrowing. Records are added back to the tail of the queue and will be
retried on the next flush cycle. The new CloudTrailService.requeueRecords helper
also makes the re-queue path unit-testable independently of flushTrail.
* fix(s3): emit GetObjectAcl error record under correct event name
getObjectAcl was called inside the outer GET-object try block. On any
AwsException (NoSuchKey, AccessDenied, etc.) the catch at the bottom fired
and emitted a GetObject error record. CloudTrail consumers auditing ACL
errors would see the wrong event name.
Wrap the acl branch in its own try-catch that emits GetObjectAcl on both
success and failure paths, mirroring the pattern used by the other hooked ops.
* ci: retrigger
* fix(test): pass CloudTrailService and CurrentVertxRequest to IamEnforcementFilter constructor
* fix(cloudtrail): persist trail state via StorageFactory instead of volatile in-memory maps
* fix(cloudtrail): address review feedback on region, name lookup, and ACL detection
- S3Controller: use request region (from credential scope) instead of
getDefaultRegion() for CloudTrail event emission, matching the IAM
denial hook behaviour so allowed and denied calls land in the same trail.
- CloudTrailService.findTrail: name lookup now uses regionKey(region, name)
directly; ARNs still do a cross-region scan. Prevents two same-name
single-region trails from resolving ambiguously by map iteration order.
- TrailKey: add eventRegion field so multi-region trail events are written
to the correct S3 delivery path (CloudTrail/<eventRegion>/) rather than
always the trail home region. drainPendingRecords/requeueRecords now take
a TrailKey to carry all three dimensions.
- IamActionRegistry: fix isBucketLevel — trailing slash is a valid S3 key
character, so /bucket/folder/?acl is an object ACL request. Replaced the
endsWith("/") check with an index-based test. Add IamActionRegistryTest
cases for the folder/ regression.
* docs(cloudtrail): sync action table order with make docs-sync