refactor(iam): drop the empty HAND_BUILT list and the reader's hand-built check (#9272)

With IAM read from the generated tables, no namespace is built by hand and
HAND_BUILT is empty. Remove it from the request-resources generator (the
tuple, the file's handBuilt key, and the clauses reading a hand-built
namespace's operations only where MEASURED gives them) and from the reader
(RequestResources.builtByHand, the parsed table's handBuilt set, and the
clauses of readsNamespace and IamActionRegistry.checkedAsAws that asked it).

Every operation's resources are unchanged: the generator's offline check
regenerates the same file, without the empty key.
This commit is contained in:
Priamo Germosen authored and GitHub committed 2026-11-23 11:03:51 -04:00
1 parent da661523ae
commit 4897db0bad
9 files changed
+57 -89

No files matched your search

@@ -231,14 +231,10 @@ class RequestResourceMembersTest {
void theTableReadsItsNamespacesAndGivesEachTypeItNamesAnArnFormat() {
RequestResourceMembers.Table table = RequestResourceMembers.table();
assertTrue(table.namespaces().containsAll(List.of("cognito-idp", "ecr", "elasticloadbalancing", "states")));
assertTrue(table.namespaces().contains("lambda"));
assertFalse(table.handBuilt().contains("lambda"));
assertFalse(table.handBuilt().contains("logs"));
assertEquals(Set.of(), table.namespaces().stream().filter(table.handBuilt()::contains)
.collect(Collectors.toSet()));
assertTrue(table.namespaces().containsAll(List.of("lambda", "logs", "iam")));
assertEquals(Set.of(), table.operations().keySet().stream()
.filter(operation -> table.handBuilt().contains(operation.substring(0, operation.indexOf(':'))))
.collect(Collectors.toSet()), "nothing is read in a hand-built namespace");
.filter(operation -> !table.namespaces().contains(operation.substring(0, operation.indexOf(':'))))
.collect(Collectors.toSet()), "every operation read is one of a namespace read whole");
assertTrue(table.namespaces().stream().noneMatch(table.notCovered()::contains));
assertTrue(table.operations().containsKey("rds:CreateDBParameterGroup"));
assertTrue(table.operations().containsKey("rds:CreateDBProxy"));
@@ -15,7 +15,6 @@ import java.io.InputStream;
import java.net.URI;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -122,19 +121,16 @@ class IamRestRouteCoverageTest {
/**
* Every operation of a scope the vendored routes do not leave to the rules alone resolves to its action when
* Floci can check it as AWS does: its resources built by hand for its namespace or read by the vendored request
* resources, or none, AWS authorizing its action on no resource type. Any other operation stays unmapped,
* unchecked rather than checked on {@code *}, until the resources in its path are read. An operation the
* authorized actions list as authorized by method is the action its route's method names, and an alternative
* route a shared controller also serves it on is checked as the operation, by that route's own method.
* Floci can check it as AWS does: its resources read by the vendored request resources, or none, AWS authorizing
* its action on no resource type. Any other operation stays unmapped, unchecked rather than checked on {@code *},
* until the resources in its path are read. An operation the authorized actions list as authorized by method is
* the action its route's method names, and an alternative route a shared controller also serves it on is checked
* as the operation, by that route's own method.
*/
@TestFactory
Stream<DynamicTest> everyOperationOfARoutedScopeResolvesToItsActionWhenFlociCanCheckIt() throws IOException {
JsonNode document = load("/aws/rest-routes.json");
JsonNode models = document.path("models");
JsonNode requestResources = load("/aws/iam-request-resources.json");
Set<String> handBuilt = new HashSet<>();
requestResources.path("handBuilt").forEach(namespace -> handBuilt.add(namespace.asText()));
List<DynamicTest> tests = new ArrayList<>();
for (String model : routedModels(document)) {
String scope = models.path(model).path("credentialScope").asText();
@@ -155,8 +151,7 @@ class IamRestRouteCoverageTest {
ContainerRequestContext request = route.request();
String action = IamAuthorizedActions.actionFor(scope, operation.getKey(), route.method(),
model, request.getUriInfo().getQueryParameters());
String expected = handBuilt.contains(scope) || read
|| IamAuthorizedActions.actsOnNoResourceType(action) ? action : null;
String expected = read || IamAuthorizedActions.actsOnNoResourceType(action) ? action : null;
assertEquals(expected, registry.resolveRoute(scope, request), route.toString());
}));
}