mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
fix(ses): check PutEmailIdentityDkimSigningAttributes against the SES v2 shapes (#7084)
A SigningAttributes member that is not a JSON object answered a Floci-only BadRequestException. The operation now runs the shared SES v2 shape check first, so a member of the wrong JSON type is a SerializationException with AWS's deserializer message, ahead of the origin check and the identity lookup, as AWS answers it. A missing identity now answers AWS's "The specified email identity, <id>, does not exist."
This commit is contained in:
1 parent
5e9df931e3
commit
f40d784f66
7 files changed
+49
-30
No files matched your search
@@ -36,7 +36,6 @@ import static io.github.hectorvent.floci.services.ses.SesV2Json.parseTagsArray;
|
||||
import static io.github.hectorvent.floci.services.ses.SesV2Json.putTimestamp;
|
||||
import static io.github.hectorvent.floci.services.ses.SesV2Json.readOptionBody;
|
||||
import static io.github.hectorvent.floci.services.ses.SesV2Json.remapV1Exception;
|
||||
import static io.github.hectorvent.floci.services.ses.SesV2Json.requireObjectOrAbsent;
|
||||
import static io.github.hectorvent.floci.services.ses.SesV2Json.stringMapMemberOrAbsent;
|
||||
import static io.github.hectorvent.floci.services.ses.SesV2Json.stringMemberOrAbsent;
|
||||
|
||||
@@ -315,12 +314,13 @@ public class SesIdentityController {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
try {
|
||||
JsonNode request = readOptionBody(objectMapper, body);
|
||||
SesV2RequestShapes.check("PutEmailIdentityDkimSigningAttributes", request);
|
||||
String origin = request.path("SigningAttributesOrigin").asText(null);
|
||||
if (!"AWS_SES".equals(origin) && !"EXTERNAL".equals(origin)) {
|
||||
throw new AwsException("BadRequestException",
|
||||
"SigningAttributesOrigin must be AWS_SES or EXTERNAL.", 400);
|
||||
}
|
||||
JsonNode attrs = requireObjectOrAbsent(request, "SigningAttributes");
|
||||
JsonNode attrs = request.path("SigningAttributes");
|
||||
String selector = attrs.path("DomainSigningSelector").asText(null);
|
||||
String nextKeyLength = attrs.path("NextSigningKeyLength").asText(null);
|
||||
if (nextKeyLength != null
|
||||
|
||||
@@ -631,7 +631,7 @@ public class SesIdentityService implements SesTaggable {
|
||||
}
|
||||
Identity identity = identityStore.get(identityKey(region, identityValue))
|
||||
.orElseThrow(() -> new AwsException("NotFoundException",
|
||||
"Email identity " + identityValue + " does not exist.", 404));
|
||||
"The specified email identity, " + identityValue + ", does not exist.", 404));
|
||||
if ("EXTERNAL".equals(origin)) {
|
||||
identity.setDkimSigningAttributesOrigin("EXTERNAL");
|
||||
// Clear the Easy DKIM tokens and reset the status: Floci can't verify a BYODKIM selector,
|
||||
|
||||
@@ -67,15 +67,6 @@ final class SesV2Json {
|
||||
throw new AwsException(SERIALIZATION_EXCEPTION, null, 400);
|
||||
}
|
||||
|
||||
static JsonNode requireObjectOrAbsent(JsonNode parent, String fieldName) {
|
||||
JsonNode child = parent.path(fieldName);
|
||||
if (!child.isMissingNode() && !child.isNull() && !child.isObject()) {
|
||||
throw new AwsException("BadRequestException",
|
||||
fieldName + " must be a JSON object.", 400);
|
||||
}
|
||||
return child;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a JSON {@code Tags} array node into a list of tag records. Returns {@code null}
|
||||
* when the node is missing or null so callers can decide whether that is an error
|
||||
|
||||
@@ -12,11 +12,13 @@ import java.util.Set;
|
||||
* {@code aws/sesv2-request-shapes.json}, generated from botocore's SES v2 model by
|
||||
* {@code tools/aws/regen_sesv2_shapes.py}, and are walked by {@link RequestShapeCheck}.
|
||||
*
|
||||
* <p>An operation calls this when its body nests a structure in a structure or holds a list of
|
||||
* structures, where member-by-member checks drift apart. A flat body, a {@code Tags}-only body and
|
||||
* a list operation's map {@code Filter} keep the {@link SesV2Json} member helpers, except in the
|
||||
* reputation entity operations, which were added after this check and call it although their
|
||||
* bodies are flat.
|
||||
* <p>An operation calls this when a structure member of its body holds another structure, or the
|
||||
* body holds a list of structures, where member-by-member checks drift apart. A flat body, a
|
||||
* {@code Tags}-only body and a list operation's map {@code Filter} keep the {@link SesV2Json}
|
||||
* member helpers, except in the reputation entity operations, {@code GetEmailAddressInsights} and
|
||||
* {@code ListRecommendations}, which were added after this check, and
|
||||
* {@code PutEmailIdentityDkimSigningAttributes}, whose hand-written object check this replaced.
|
||||
* Those call it although their bodies are flat.
|
||||
*
|
||||
* <p>AWS reads the body in order and reports the first bad member, without naming it. A map
|
||||
* container answers like a structure, except that a scalar for it is "Expected map or null". Only
|
||||
|
||||
Reference in new issue
Block a user