mirror of
https://github.com/floci-io/floci.git
synced 2026-11-30 08:55:17 -05:00
fix(wafv2): reject logging for nonexistent web ACLs (#6203)
* fix(wafv2): reject logging for nonexistent web ACLs * fix(wafv2): preserve legacy web ACL ARN lookups * fix(wafv2): drop legacy web ACL fallback
This commit is contained in:
1 parent
da66550c70
commit
52b7cbe75f
2 files changed
+52
-12
No files matched your search
@@ -274,11 +274,8 @@ public class WafV2Service {
|
||||
// ──────────────────────────── Association ────────────────────────────
|
||||
|
||||
public void associateWebAcl(String webAclArn, String resourceArn) {
|
||||
boolean known = webAclStore.scan(k -> true).stream()
|
||||
.anyMatch(a -> a.getArn().equals(webAclArn));
|
||||
if (!known) {
|
||||
throw new AwsException("WAFNonexistentItemException",
|
||||
"AWS WAF couldn't perform the operation because your resource doesn't exist.", 400);
|
||||
if (scanArn(webAclStore, webAclArn) == null) {
|
||||
throw nonexistentItem();
|
||||
}
|
||||
associationStore.put(resourceArn, webAclArn);
|
||||
}
|
||||
@@ -310,6 +307,9 @@ public class WafV2Service {
|
||||
// ──────────────────────────── Logging ────────────────────────────
|
||||
|
||||
public String putLoggingConfiguration(String resourceArn, String loggingConfigJson) {
|
||||
if (scanArn(webAclStore, resourceArn) == null) {
|
||||
throw nonexistentItem();
|
||||
}
|
||||
loggingStore.put(resourceArn, loggingConfigJson);
|
||||
return loggingConfigJson;
|
||||
}
|
||||
@@ -438,16 +438,18 @@ public class WafV2Service {
|
||||
if (name == null || name.isBlank()) {
|
||||
throw new AwsException("WAFInvalidParameterException", "Name is required.", 400);
|
||||
}
|
||||
V resource = store.get(key(scope, id)).orElseThrow(() -> new AwsException(
|
||||
"WAFNonexistentItemException",
|
||||
"AWS WAF couldn't perform the operation because your resource doesn't exist.", 400));
|
||||
V resource = store.get(key(scope, id)).orElseThrow(WafV2Service::nonexistentItem);
|
||||
if (!name.equals(nameOf(resource))) {
|
||||
throw new AwsException("WAFNonexistentItemException",
|
||||
"AWS WAF couldn't perform the operation because your resource doesn't exist.", 400);
|
||||
throw nonexistentItem();
|
||||
}
|
||||
return resource;
|
||||
}
|
||||
|
||||
private static AwsException nonexistentItem() {
|
||||
return new AwsException("WAFNonexistentItemException",
|
||||
"AWS WAF couldn't perform the operation because your resource doesn't exist.", 400);
|
||||
}
|
||||
|
||||
private <V> V findByName(StorageBackend<String, V> store, String scope, String name) {
|
||||
return store.scan(k -> true).stream()
|
||||
.filter(v -> scope.equals(scopeOf(v)) && name.equals(nameOf(v)))
|
||||
|
||||
Reference in new issue
Block a user