mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(ec2): reject prefix list names AWS reserves for its own lists (#2274)
* fix(ec2): reject prefix list names AWS reserves for its own lists CreateManagedPrefixList accepted names beginning com.amazonaws., com.amazon. or com.aws., which AWS refuses with InvalidParameterValue, so a customer list could shadow a seeded gateway-endpoint one. The trailing dot is part of each prefix. Checked against a live account: com.amazonaws-probe and comamazonaws.probe are both accepted there, so matching without the dot would refuse names AWS allows. Closes #2273 * fix(ec2): apply the reserved-name rule to a prefix list rename too ModifyManagedPrefixList persisted any nonblank name, so a list could be renamed to com.amazonaws.us-east-1.s3 and returned alongside the seeded AWS-managed list of that name. AWS applies the same rule to a rename, verified against a live account, and leaves the existing name in place when it rejects one. Create and rename now share the check. --------- Co-authored-by: Michal Schreiber <michal.schreiber@benefitsystems.pl>
This commit is contained in:
1 parent
62ff490619
commit
2d003b52f2
3 files changed
+69
No files matched your search
@@ -729,6 +729,51 @@ class Ec2ServiceTest {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verified against a live AWS account: the three dotted prefixes are rejected, and the
|
||||
* trailing dot matters — {@code com.amazonaws-probe} and {@code comamazonaws.probe} are both
|
||||
* accepted there, so a dotless prefix match would refuse names AWS allows.
|
||||
*/
|
||||
@Test
|
||||
void createManagedPrefixListRejectsNamesReservedByAws() {
|
||||
Ec2Service service = prefixListService();
|
||||
|
||||
for (String reserved : new String[] {"com.amazonaws.probe", "com.amazon.probe", "com.aws.probe"}) {
|
||||
AwsException error = assertThrows(AwsException.class, () -> service.createManagedPrefixList(
|
||||
"us-east-1", reserved, "IPv4", 5, List.of(), List.of()), "expected rejection for " + reserved);
|
||||
assertEquals("InvalidParameterValue", error.getErrorCode());
|
||||
}
|
||||
|
||||
// Names that only look reserved are still allowed.
|
||||
for (String allowed : new String[] {"com.amazonaws-probe", "comamazonaws.probe", "corp"}) {
|
||||
assertEquals(allowed, service.createManagedPrefixList(
|
||||
"us-east-1", allowed, "IPv4", 5, List.of(), List.of()).getPrefixListName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verified against a live AWS account: the rename path applies the same rule, and rejecting it
|
||||
* leaves the existing name in place. A lookalike is still allowed.
|
||||
*/
|
||||
@Test
|
||||
void renamingToAReservedNameIsRejected() {
|
||||
Ec2Service service = prefixListService();
|
||||
ManagedPrefixList list = service.createManagedPrefixList("us-east-1", "corp", "IPv4", 5,
|
||||
List.of(), List.of());
|
||||
|
||||
AwsException error = assertThrows(AwsException.class, () -> service.modifyManagedPrefixList(
|
||||
"us-east-1", list.getPrefixListId(), null, "com.amazonaws.us-east-1.s3", null,
|
||||
List.of(), List.of()));
|
||||
assertEquals("InvalidParameterValue", error.getErrorCode());
|
||||
assertEquals("corp", service.describeManagedPrefixLists("us-east-1",
|
||||
List.of(list.getPrefixListId()), Map.of()).getFirst().getPrefixListName());
|
||||
|
||||
service.modifyManagedPrefixList("us-east-1", list.getPrefixListId(), null,
|
||||
"com.amazonaws-renamed", null, List.of(), List.of());
|
||||
assertEquals("com.amazonaws-renamed", service.describeManagedPrefixLists("us-east-1",
|
||||
List.of(list.getPrefixListId()), Map.of()).getFirst().getPrefixListName());
|
||||
}
|
||||
|
||||
@Test
|
||||
void describeManagedPrefixListsFiltersByName() {
|
||||
Ec2Service service = prefixListService();
|
||||
|
||||
Reference in new issue
Block a user