fix(partition): hold escaped host regexes to the DNS suffix gate (#5232)

The partition literal gate's dns-suffix pattern matched amazonaws.com but
not a Java regex that escapes its dots (amazonaws\\.com), so hand-written
host patterns escaped it. With the dots allowed to be escaped, the gate
found two on main:

- ECR's pull-through cache recognised an ecr upstream only on the
  commercial and China suffixes, while Floci's own registry recognises an
  ECR image URI in every partition. The upstream host pattern is now
  built from AwsPartitions.dnsSuffixRegex() the same way.
- The console sign-in host pattern in SigninService has no published
  non-commercial form, so it carries a partition-literal escape like the
  console literals beside it.
This commit is contained in:
Hector Ventura authored and GitHub committed 2026-10-06 22:49:23 -04:00
1 parent a0a2a5f0d6
commit 1b61945f28
5 files changed
+40 -3

No files matched your search

@@ -227,6 +227,29 @@ class EcrServiceTest {
"missing/cache", null, null, null, REGION)).getErrorCode());
}
/**
* An ECR upstream is recognised in every partition, as Floci's own registry recognises an ECR
* image URI: the host pattern once accepted only the commercial and China suffixes.
*/
@Test
void pullThroughCacheRule_acceptsAnEcrUpstreamInEveryPartition() {
String[] hosts = {
"123456789012.dkr.ecr.us-east-1.amazonaws.com",
"123456789012.dkr.ecr.cn-north-1.amazonaws.com.cn",
"123456789012.dkr.ecr.us-gov-west-1.amazonaws.com",
"123456789012.dkr.ecr.us-iso-east-1.c2s.ic.gov",
"123456789012.dkr.ecr.eusc-de-east-1.amazonaws.eu",
};
for (int i = 0; i < hosts.length; i++) {
PullThroughCacheRule rule = service.createPullThroughCacheRule("ecr-up-" + i, hosts[i], null,
null, null, null, null, REGION);
assertEquals("ecr", rule.getUpstreamRegistry(), hosts[i]);
}
assertEquals("UnsupportedUpstreamRegistryException", assertThrows(AwsException.class,
() -> service.createPullThroughCacheRule("ecr-up-bad", "123456789012.dkr.ecr.us-east-1.example.com",
null, null, null, null, null, REGION)).getErrorCode());
}
@Test
void pullThroughCacheRule_rejectsInvalidInputs() {
assertEquals("InvalidParameterException", assertThrows(AwsException.class,