mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -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
+42
@@ -1236,6 +1236,48 @@ class SesConfigurationSetV2IntegrationTest {
|
||||
.body("DeliveryOptions.SendingPoolName", equalTo("v2-cs-pool-ref"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(62)
|
||||
void createConfigurationSet_nonStringTagKey_returnsSerializationException() {
|
||||
// AWS restJson1 rejects a non-string tag member with SerializationException rather than
|
||||
// coercing it (probe-confirmed: a numeric Key returns "NUMBER_VALUE can not be converted to a
|
||||
// String"). Floci matches the type/status; its error body uses __type (project-wide).
|
||||
given().contentType("application/json").header("Authorization", AUTH_HEADER)
|
||||
.body("{\"ConfigurationSetName\": \"v2-cs-nonstr-key\", \"Tags\": [{\"Key\": 123, \"Value\": \"v\"}]}")
|
||||
.when().post("/v2/email/configuration-sets")
|
||||
.then().statusCode(400).body("__type", equalTo("SerializationException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(63)
|
||||
void createConfigurationSet_nonStringTagValue_returnsSerializationException() {
|
||||
// A boolean value and an object value are both non-string members and rejected the same way.
|
||||
given().contentType("application/json").header("Authorization", AUTH_HEADER)
|
||||
.body("{\"ConfigurationSetName\": \"v2-cs-nonstr-val\", \"Tags\": [{\"Key\": \"k\", \"Value\": true}]}")
|
||||
.when().post("/v2/email/configuration-sets")
|
||||
.then().statusCode(400).body("__type", equalTo("SerializationException"));
|
||||
|
||||
given().contentType("application/json").header("Authorization", AUTH_HEADER)
|
||||
.body("{\"ConfigurationSetName\": \"v2-cs-nonstr-obj\", \"Tags\": [{\"Key\": \"k\", \"Value\": {\"x\": 1}}]}")
|
||||
.when().post("/v2/email/configuration-sets")
|
||||
.then().statusCode(400).body("__type", equalTo("SerializationException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(64)
|
||||
void createConfigurationSet_nonObjectTagElement_returnsSerializationException() {
|
||||
// A tag list element that is not an object (scalar, array, or null) is a wire deserialization
|
||||
// error. AWS returns SerializationException for scalar/array elements and a 500 InternalFailure
|
||||
// for a null element (a server-side bug); Floci normalizes all of them to 400
|
||||
// SerializationException. Probe-confirmed against real AWS.
|
||||
for (String badElement : new String[] {"true", "123", "\"k\"", "[\"k\",\"v\"]", "null"}) {
|
||||
given().contentType("application/json").header("Authorization", AUTH_HEADER)
|
||||
.body("{\"ConfigurationSetName\": \"v2-cs-bad-el\", \"Tags\": [" + badElement + "]}")
|
||||
.when().post("/v2/email/configuration-sets")
|
||||
.then().statusCode(400).body("__type", equalTo("SerializationException"));
|
||||
}
|
||||
}
|
||||
|
||||
private static void putConfigSet(String name) {
|
||||
given().contentType("application/json").header("Authorization", AUTH_HEADER)
|
||||
.body("{\"ConfigurationSetName\": \"" + name + "\"}")
|
||||
|
||||
Reference in new issue
Block a user