mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
fix(lambda): quote the model's FunctionName pattern in the validation error (#5487)
The ValidationException for a bad function name quoted a region pattern without the (eusc-)? and -iso([a-z]?) branches the Lambda model's FunctionName pattern has. The text is only quoted, never enforced, so no name is accepted or refused differently. Signed-off-by: Hector Ventura <hectorvent@gmail.com>
This commit is contained in:
1 parent
03a0dfefdd
commit
32cb4b7b8b
2 files changed
+12
-1
No files matched your search
@@ -22,7 +22,9 @@ public final class LambdaArnUtils {
|
||||
private static final Pattern NAME_PATTERN = Pattern.compile("[a-zA-Z0-9-_]+");
|
||||
private static final int MAX_NAME_LENGTH = 64;
|
||||
private static final int MAX_TOTAL_LENGTH = 140;
|
||||
private static final String NAME_REGEX = "(arn:(aws[a-zA-Z-]*)?:lambda:)?([a-z]{2}(-gov)?-[a-z]+-\\d{1}:)?"
|
||||
/** The model's {@code FunctionName} pattern, quoted in the ValidationException a bad name gets. */
|
||||
private static final String NAME_REGEX = "(arn:(aws[a-zA-Z-]*)?:lambda:)?"
|
||||
+ "((eusc-)?[a-z]{2}((-gov)|(-iso([a-z]?)))?-[a-z]+-\\d{1}:)?"
|
||||
+ "(\\d{12}:)?(function:)?([a-zA-Z0-9-_]+)(:(\\$LATEST|[a-zA-Z0-9-_]+))?";
|
||||
private static final Pattern ACCOUNT_PATTERN = Pattern.compile("\\d{12}");
|
||||
private static final Pattern QUALIFIER_PATTERN = Pattern.compile("\\$LATEST|[a-zA-Z0-9-_]+");
|
||||
|
||||
@@ -85,6 +85,15 @@ class LambdaArnUtilsTest {
|
||||
assertEquals(maxLen, ref.name());
|
||||
}
|
||||
|
||||
@Test
|
||||
void aBadNameQuotesTheModelsFunctionNamePattern() {
|
||||
AwsException ex = assertThrows(AwsException.class, () -> LambdaArnUtils.resolve("bad.name"));
|
||||
|
||||
assertEquals("ValidationException", ex.getErrorCode());
|
||||
assertTrue(ex.getMessage().contains("((eusc-)?[a-z]{2}((-gov)|(-iso([a-z]?)))?-[a-z]+-\\d{1}:)?"),
|
||||
ex.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void resolveAccepts140CharPartialArn() {
|
||||
String name = "a".repeat(118);
|
||||
|
||||
Reference in new issue
Block a user