mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 22:11:36 -05:00
fix: parse S3 EventBridge notification XML (#3350)
This commit is contained in:
1 parent
9f36a8729f
commit
ad9a88cf7e
2 files changed
+131
-1
No files matched your search
@@ -1779,7 +1779,7 @@ public class S3Controller {
|
||||
new LambdaNotification(parsed.id, parsed.arn, parsed.events, parsed.filterRules));
|
||||
}
|
||||
|
||||
config.setEventBridgeEnabled(xml.contains("<EventBridgeConfiguration"));
|
||||
config.setEventBridgeEnabled(parseEventBridgeConfiguration(xml));
|
||||
|
||||
s3Service.putBucketNotificationConfiguration(bucket, config);
|
||||
return Response.ok().build();
|
||||
@@ -1788,6 +1788,20 @@ public class S3Controller {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean parseEventBridgeConfiguration(String xml) {
|
||||
if (!"NotificationConfiguration".equals(XmlParser.rootElementName(xml))) {
|
||||
throw new AwsException("MalformedXML", "The XML you provided was not well-formed.", 400);
|
||||
}
|
||||
List<String> children = XmlParser.childElementNames(xml, "NotificationConfiguration");
|
||||
long eventBridgeConfigurations = children.stream()
|
||||
.filter("EventBridgeConfiguration"::equals)
|
||||
.count();
|
||||
if (eventBridgeConfigurations > 1) {
|
||||
throw new AwsException("MalformedXML", "The XML you provided was not well-formed.", 400);
|
||||
}
|
||||
return eventBridgeConfigurations == 1;
|
||||
}
|
||||
|
||||
private record ParsedNotificationGroup(String id, String arn, List<String> events,
|
||||
List<FilterRule> filterRules) {}
|
||||
|
||||
|
||||
Reference in new issue
Block a user