mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 06:00:46 -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.
85 lines
4.2 KiB
YAML
85 lines
4.2 KiB
YAML
name: IAM Data Drift
|
|
|
|
# Checks the six vendored files that come from AWS's live service reference rather than from a
|
|
# pinned dependency: the IAM service namespace list, the map of which resource each IAM action is
|
|
# authorized against, the map of operations AWS authorizes as an action of another name, the
|
|
# table of the operations that pass a role and the services they pass it to, the table of the
|
|
# tagging actions operations that tag what they create need, and the table of the resources each
|
|
# operation's request names. That
|
|
# needs the live service reference index, so unlike every other check here it can
|
|
# fail without anything in the repository having changed: an AWS outage, or a namespace AWS has
|
|
# retired. It therefore runs on its own, never as part of a job that ordinary changes trigger.
|
|
#
|
|
# Two triggers, for two different failures:
|
|
#
|
|
# - On a pull request that touches a vendored file or its generator, which is where a
|
|
# hand-typed or mistyped entry would enter the repository. A pull request that does not touch
|
|
# them cannot introduce one, so it does not run and cannot be failed by an outage.
|
|
# - Weekly, because the files also go stale without anyone touching them: AWS ships services
|
|
# and actions, and occasionally retires them. Tying the only upstream check to pull request
|
|
# activity would mean a quiet month is a month with no drift detection at all.
|
|
#
|
|
# An entry AWS has *added* since the last sync is reported without failing: a new namespace makes
|
|
# the service-last-accessed report incomplete rather than wrong, and a new action or resource type
|
|
# leaves that action evaluated against `*`, which is where it was before any of this existed. The
|
|
# fix for a real failure is to run the matching sync target and commit the result.
|
|
#
|
|
# The offline shape check is hermetic and runs per pull request inside the "Vendored AWS data in
|
|
# sync" job in partition-literals.yml instead.
|
|
|
|
on:
|
|
pull_request:
|
|
paths:
|
|
- 'src/main/resources/aws/iam-service-namespaces.json'
|
|
- 'src/main/resources/aws/iam-action-resources.json'
|
|
- 'tools/aws/regen_service_namespaces.py'
|
|
- 'tools/aws/test_regen_service_namespaces.py'
|
|
- 'tools/aws/regen_iam_action_resources.py'
|
|
- 'tools/aws/test_regen_iam_action_resources.py'
|
|
- 'src/main/resources/aws/iam-authorized-actions.json'
|
|
- 'tools/aws/regen_iam_authorized_actions.py'
|
|
- 'tools/aws/test_regen_iam_authorized_actions.py'
|
|
- 'src/main/resources/aws/iam-passed-roles.json'
|
|
- 'tools/aws/regen_iam_passed_roles.py'
|
|
- 'tools/aws/test_regen_iam_passed_roles.py'
|
|
- 'src/main/resources/aws/iam-tag-on-create.json'
|
|
- 'tools/aws/regen_iam_tag_on_create.py'
|
|
- 'tools/aws/test_regen_iam_tag_on_create.py'
|
|
- 'src/main/resources/aws/iam-request-resources.json'
|
|
- 'tools/aws/regen_iam_request_resources.py'
|
|
- 'tools/aws/test_regen_iam_request_resources.py'
|
|
- '.github/workflows/iam-data-drift.yml'
|
|
schedule:
|
|
# Mondays at 06:00 UTC, before the working week rather than during it.
|
|
- cron: '0 6 * * 1'
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
# One job, and one step that runs both verifies. They are kept in a single Makefile target rather
|
|
# than two steps because sequential steps stop at the first failure: while the namespace list was
|
|
# stale, the action resource check never ran at all, so the half that was still fine went
|
|
# unreported. The target runs both regardless and fails afterwards, naming which file drifted.
|
|
jobs:
|
|
iam-data-drift:
|
|
name: Vendored IAM data still matches upstream
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 5
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
|
|
with:
|
|
python-version: "3.x"
|
|
|
|
# No dependency install: the generators are deliberately stdlib-only, and this job runs no
|
|
# tests. The pinned botocore the sibling workflow needs is for the partition generator.
|
|
- name: Check every vendored IAM file still matches upstream
|
|
run: make iam-data-verify
|