Files
floci/.github/workflows/iam-data-drift.yml
T
Priamo Germosen 1276a8857f fix(iam): check iam:PassRole from a table generated from the Service Reference (#6422)
Under IAM enforcement a request that names a role is checked for
iam:PassRole only where PassedRoles has a case for its operation, so most
of the operations AWS's Service Reference lists with iam:PassRole went
through without it: a caller allowed to create a CodeBuild project, a
Firehose stream, a Glue job or an SSM association could hand it any role
in the account. Adding a case per operation took one pull request per few
services.

The Service Reference names, for each operation, the services its role
goes to, but not the request member that names it; botocore's models give
the members. tools/aws/regen_iam_passed_roles.py joins the two into
src/main/resources/aws/iam-passed-roles.json: every operation listing
iam:PassRole in the namespaces Floci serves over JSON, Query and Smithy
RPC v2 CBOR, and in the REST services whose routes are authorized as
operations, each either read from the table, read by hand in PassedRoles,
or not read with a reason. Generation fails on an operation in none of
the three.

A member names a role when its name ends in Role, RoleArn or RoleName (a
plural, or one followed by Update or Override) and it holds a string or a
list or map of them, not an enum. A member whose documentation says it
takes a role by name is checked on the ARN IAM holds the role under. A
role the Service Reference passes to no named service, as it does
Cognito's, is checked with no iam:PassedToService. The generator records
its corrections with their reasons: members that pass no role (the roles
a Budgets action attaches a policy to, a CodePipeline action's role,
which the pipeline's role assumes, SSM target accounts' execution roles,
the roles a Glue job's generated nodes assume with STS, Firehose's
Snowflake role), members the rule does not see (a Cognito user pool's SMS
caller roles, a Glue connection's ROLE_ARN property and a view's definer,
Service Catalog's AssumeRole and LAUNCH_ROLE keys), and which service a
member's role goes to where the reference names several.

PassedRoles reads a table member from a JSON or CBOR body, or from Query
form parameters in either list form. Its own cases now return null for an
operation they do not read, and the table covers the rest. New cases read
SNS's role attributes (a topic's delivery status roles, a platform
application's, a Firehose subscription's and the SMS one, as the SNS
handlers read the map; an attribute with no value names none), a
CloudWatch Logs subscription filter policy's RoleArn, a Service Catalog
launch constraint's role, by the type Service Catalog holds for the
constraint on an update and in any case, since Floci keeps the type as
given, and an SWF decision's Lambda role from the attributes its type
names.

Not read: requests that name no role, roles that are a runbook's
parameter, operations whose roles go to several services without the
reference saying which member goes where (EMR RunJobFlow, EKS
UpdateClusterConfig, CloudWatch Logs CreateImportTask, SageMaker
CreateTrainingSession), XML bodies (S3 PutBucketReplication), EC2's
RequestSpotFleet, and REST services whose routes no rule maps yet.

make iam-passed-roles-check, part of aws-data-check, re-derives every
member from the pinned botocore; make iam-passed-roles-verify, part of
iam-data-verify, checks every operation against AWS; the IAM data drift
workflow now also runs on a change to the table or its generator.
PassedRoleNamespacesIntegrationTest fails for a namespace Floci serves
that the table neither reads nor names as not read yet.
2026-10-24 08:38:14 -05:00

77 lines
3.7 KiB
YAML

name: IAM Data Drift
# Checks the four 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, and the
# table of the operations that pass a role and the services they pass it to. 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'
- '.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