mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 14:10:49 -05:00
Under IAM enforcement a request is checked against the resources it acts on. ResourceArnBuilder builds their ARNs by hand for 17 namespaces; every other request was checked on *, so a grant scoped to a resource was refused and a deny scoped to one never applied. AWS's Service Reference lists the resource types each action acts on and each type's ARN formats, but not which request member names a resource; botocore's models give the members. A new generator, tools/aws/regen_iam_request_resources.py, joins the two into src/main/resources/aws/iam-request-resources.json: for each operation, the action it is checked as, that action's resource types and the resources its request names, by a member holding a resource's ARN or by members filling the variables of a type's format, matched by name. A variable nothing fills is left open, as a service mints a new resource's id; a type nothing names is not checked, as an action lists the optional resources its requests may use; and types named only through the same members are alternatives, of which the one named in full is kept. Corrections give a v2 CreateLoadBalancer the load balancer of its Type, application when it gives none (a Type outside application, network and gateway is now refused, as AWS refuses it, rather than read as an application load balancer the table does not name), and read StartExecution's and StartSyncExecution's stateMachineArn up to a #, as Floci runs the machine before Step Functions Local's test case. A state machine's version or alias, stateMachine:<name>:<qualifier>, is checked on the state machine's ARN, as Step Functions authorizes it, so an execution started through one is the state machine's too. RequestResources reads them from a JSON or CBOR body or a Query form, for the namespaces the table reads, and ResourceArnBuilder uses them where it has no branch. They are read for the operation the request is dispatched as, which IamEnforcementFilter resolves and checks the action of (the Query action, the JSON target or the Smithy RPC v2 path's operation), never for an X-Amz-Target or Action the request names again, and as the handlers read them: a list only from a list, a number or a null as its text. A member whose botocore shape is an account id gives the account of the types named by variables: ECR's registryId selects the registry its handler acts in, and a JSON null is no registry, the caller's, as ECR reads it. ECR's BatchGetRepositoryScanningConfiguration, whose AWS request has no registryId, no longer reads one: it acts in the caller's registry, where IAM checks it. An ARN value counts when it matches the format of a type the action acts on; one naming another account or Region is checked as given and as each resource of that name a handler may act on instead, in its account or the caller's and its Region or the request's (ECR's tag handlers keep the ARN's account in the request's Region). A request naming none, or whose action acts on no resource type, stays on *, as AWS checks it. A create's tagging action is checked on the same resources, except where the create makes a resource under a parent its action acts on: CreateListener acts on a load balancer and CreateRule on a listener, and their tags are checked on the new listener or rule, built from the parent's ARN with the type word replaced and its own id open. The table gives these from the formats: a child type's is its parent's with one id appended. So the AWS Load Balancer Controller's policy, which allows AddTags at creation only on target groups and application and network load balancers, and on listeners and rules, now holds. The first namespaces read are Elastic Load Balancing, ECR, Step Functions and Cognito user pools (298 operations); the 99 others Floci serves are listed as not read yet, with their reason, and RequestResourceNamespacesIntegrationTest fails for a served namespace in none of the lists. make iam-request-resources-check, part of aws-data-check, re-derives every operation from the pinned botocore; make iam-request-resources-verify, part of iam-data-verify, checks the actions, types and formats against AWS, and the IAM data drift workflow also runs on a change to the table or its generator. Not in this change: the 99 other namespaces, Query lists other than Name.member.N, identifiers inside structures (SetRulePriorities, CreateStateMachineAlias' routing configuration) and EventBridge.