mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
fix(ses): reject non-string tag members with SerializationException (#2512)
* fix(ses): reject non-string tag members with SerializationException SesController.parseTagsArray coerced tag Key/Value via asText(null), so a non-string member (number, boolean, object, array) was silently turned into a string (123 -> "123") and accepted, across all five SES tag entry points that share the method (CreateEmailIdentity, CreateConfigurationSet, CreateEmailTemplate, CreateContactList, TagResource). AWS's restJson1 deserializer rejects a non-string tag member with SerializationException / 400 (probe-confirmed). parseTagsArray now rejects a present-but-non-string Key/Value the same way, leaving missing/null members to the downstream service validation. * fix(ses): reject non-object tag list elements with SerializationException parseTagsArray validated Key/Value types but not that each Tags element is a JSON object, so a scalar/array/null element fell through to service-layer validation. Reject a non-object element with SerializationException, matching AWS's restJson1 deserializer (AWS returns 500 for a null element, a server-side bug, normalized to the same 400).
This commit is contained in:
1 parent
29f6e7ac6b
commit
60dd795703
3 files changed
+63
-4
No files matched your search
@@ -2453,13 +2453,30 @@ public class SesController {
|
||||
}
|
||||
List<Tag> out = new ArrayList<>();
|
||||
for (JsonNode t : tagsNode) {
|
||||
out.add(new Tag(
|
||||
t.path("Key").asText(null),
|
||||
t.path("Value").asText(null)));
|
||||
// Each element must be a JSON object. A scalar/array/null element is a wire deserialization
|
||||
// error (AWS returns SerializationException for a scalar/array element; it returns a 500
|
||||
// InternalFailure for a null element, a server-side bug we normalize to the same 400).
|
||||
if (!t.isObject()) {
|
||||
throw new AwsException("SerializationException", null, 400);
|
||||
}
|
||||
JsonNode key = t.path("Key");
|
||||
JsonNode value = t.path("Value");
|
||||
// A present-but-non-string Key/Value (number, boolean, object, array) is a wire
|
||||
// deserialization error, not a coercible value: AWS restJson1 rejects it with
|
||||
// SerializationException rather than turning 123 into "123". A missing/null member is left
|
||||
// to the downstream service validation, matching AWS.
|
||||
if (nonStringMember(key) || nonStringMember(value)) {
|
||||
throw new AwsException("SerializationException", null, 400);
|
||||
}
|
||||
out.add(new Tag(key.asText(null), value.asText(null)));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
private static boolean nonStringMember(JsonNode node) {
|
||||
return !node.isMissingNode() && !node.isNull() && !node.isTextual();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a {@code SuppressedReasons} JSON array into a list, validating
|
||||
* structure only; reason values are validated by the service layer.
|
||||
|
||||
Reference in new issue
Block a user