mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
fix(cloudfront): reject a function runtime that CloudFront does not support (#5445)
Closes #5425
This commit is contained in:
1 parent
d6f93abb18
commit
8deac0a424
3 files changed
+90
No files matched your search
@@ -62,6 +62,7 @@ public class CloudFrontService implements ServerCertificateReferenceProvider {
|
||||
Set.of("s3", "mediastore", "mediapackagev2", "lambda");
|
||||
private static final Set<String> OAC_SIGNING_BEHAVIORS =
|
||||
Set.of("always", "never", "no-override");
|
||||
private static final Set<String> FUNCTION_RUNTIMES = Set.of("cloudfront-js-1.0", "cloudfront-js-2.0");
|
||||
private static final int MAX_ORIGIN_CUSTOM_HEADERS = 30;
|
||||
private static final int MAX_CUSTOM_HEADER_NAME_LENGTH = 256;
|
||||
private static final int MAX_CUSTOM_HEADER_VALUE_LENGTH = 1_783;
|
||||
@@ -1293,6 +1294,7 @@ public class CloudFrontService implements ServerCertificateReferenceProvider {
|
||||
// ── CloudFront Functions ──────────────────────────────────────────────────
|
||||
|
||||
public synchronized CloudFrontFunction createFunction(CloudFrontFunction fn) {
|
||||
validateFunctionRuntime(fn.getRuntime());
|
||||
// The bare name holds the DEVELOPMENT stage, and the LIVE stage of releases before
|
||||
// stage-aware keys.
|
||||
if (functionStore.get(fn.getName()).isPresent()
|
||||
@@ -1324,6 +1326,7 @@ public class CloudFrontService implements ServerCertificateReferenceProvider {
|
||||
|
||||
public synchronized CloudFrontFunction updateFunction(String name, String ifMatch,
|
||||
CloudFrontFunction updated) {
|
||||
validateFunctionRuntime(updated.getRuntime());
|
||||
CloudFrontFunction existing = describeFunction(name, null);
|
||||
if (!existing.getEtag().equals(ifMatch)) {
|
||||
throw new AwsException("InvalidIfMatchVersion",
|
||||
@@ -1396,6 +1399,13 @@ public class CloudFrontService implements ServerCertificateReferenceProvider {
|
||||
return effectiveStage;
|
||||
}
|
||||
|
||||
private static void validateFunctionRuntime(String runtime) {
|
||||
if (runtime != null && !FUNCTION_RUNTIMES.contains(runtime)) {
|
||||
throw new AwsException("InvalidArgument",
|
||||
"The parameter Runtime must be cloudfront-js-1.0 or cloudfront-js-2.0.", 400);
|
||||
}
|
||||
}
|
||||
|
||||
private static AwsException invalidFunctionStage(String stage) {
|
||||
return new AwsException("InvalidArgument",
|
||||
"The parameter Stage must be DEVELOPMENT or LIVE: " + stage, 400);
|
||||
|
||||
Reference in new issue
Block a user