Files
floci/.github/workflows/partition-literals.yml
T
Priamo Germosen eba058266b fix(iam): authorize an operation as the action AWS checks for it (#5604)
Under enforcement a request naming its operation, in a Query Action or an
X-Amz-Target header, was authorized as <namespace>:<Operation>, the operation's
own name. AWS authorizes some operations as an action of another name: SQS
SendMessageBatch, DeleteMessageBatch and ChangeMessageVisibilityBatch as
sqs:SendMessage, sqs:DeleteMessage and sqs:ChangeMessageVisibility, and SNS
PublishBatch as sns:Publish. None of the batch names is an IAM action, so a policy
AWS honours for a batch call was denied, and a policy naming the batch operation
granted something AWS does not check.

AWS publishes the mapping in the Operations of each Service Reference file.
tools/aws/regen_iam_authorized_actions.py vendors the operations authorized by
exactly one action of their own namespace under another name, 235 over 33
namespaces, into src/main/resources/aws/iam-authorized-actions.json. Everything else
keeps its own name. The generator leaves out operations that list:
- several actions, whose extras apply only when tags or a role are passed;
- no action, which is missing data;
- an action of another namespace;
- another action while one of the operation's own name exists;
- a tagging action alone;
- the same action for several SDK clients, which AWS can authorize differently,
  as S3 and S3 Control's GetPublicAccessBlock;
or whose name is listed again with another answer. A record of the wrong shape
fails the run instead of being skipped.
make iam-authorized-actions-check gates the file's shape on pull requests that touch it, and
iam-authorized-actions-verify, run by the IAM Data Drift workflow, checks every
entry against AWS.

IamAuthorizedActions reads the file through the new core.common
VendoredResources, rather than adding one more copy of the read-or-fail block a
dozen catalogs carry, and the Query and X-Amz-Target paths ask it for the action.
DynamoDB TransactGetItems, which AWS authorizes as dynamodb:GetItem, keeps its own
name: the transaction check recognizes the call by it and checks every Get as
dynamodb:GetItem on its own table, with its own dynamodb:LeadingKeys. Renamed, the
call would skip that check and be authorized as one GetItem whose body has no
top-level Key, which a ForAllValues condition accepts, so a fine-grained policy
would grant every key.

The check for operations AWS serves without credentials reads the Query action
directly, rather than through resolve with a placeholder scope, now that resolve
returns the authorized action. A Query request naming no action is not one of them.

An SDK compatibility test covers SendMessageBatch and PublishBatch, granted by
the single-item action and refused under the batch name, with enforcement on.
2026-10-13 22:29:06 -05:00

126 lines
5.0 KiB
YAML

name: Partition Literals
# Keeps the commercial-partition assumption from growing back while floci moves to
# serving every AWS partition. tools/partition/partition_literals.py inventories the
# hardcoded arn:aws: prefixes, amazonaws.com hosts, hosted-zone ids and hand-rolled
# partition regexes in src/main/java against the checked-in per-file baseline: a
# literal in a new file fails, growth in an existing file fails, and a drop fails until
# the baseline is regenerated so the remaining count stays exact. The second job checks
# that the vendored AWS data (src/main/resources/aws/*.json) still matches what tools/aws/
# produces from the pinned botocore release, and that the IAM managed-policy catalog keeps its
# generated shape (its iam-dataset source lives only in local/aws, so CI checks shape, not
# drift). Python-only, so both are fast and independent of the Java build job.
on:
pull_request:
paths:
- 'src/main/java/**'
- 'src/main/resources/aws/**'
- 'tools/partition/**'
- 'tools/aws/**'
- 'tools/slr/**'
- 'src/main/resources/iam/service-linked-roles.tsv'
- 'src/main/resources/iam/managed-policy-documents.json'
- 'src/main/resources/iam/managed-policies.yaml'
- 'src/main/resources/iam/managed-policy-versions.json'
- 'Makefile'
- '.github/workflows/partition-literals.yml'
push:
branches:
- main
paths:
- 'src/main/java/**'
- 'src/main/resources/aws/**'
- 'tools/partition/**'
- 'tools/aws/**'
- 'tools/slr/**'
- 'src/main/resources/iam/service-linked-roles.tsv'
- 'src/main/resources/iam/managed-policy-documents.json'
- 'src/main/resources/iam/managed-policies.yaml'
- 'src/main/resources/iam/managed-policy-versions.json'
- 'Makefile'
- '.github/workflows/partition-literals.yml'
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
# Cancel a superseded run only on pull requests; a run on main is left to finish (see ci.yml).
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
partition-literals:
name: Partition literals match baseline
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"
- name: Install tooling deps
run: pip install -r tools/partition/requirements.txt
- name: Run partition tooling tests
run: make partition-test
- name: Check partition literals against the baseline
run: make partition-check
- name: Print the remaining-literal audit
if: always()
run: make partition-audit
aws-data:
name: Vendored AWS data in sync
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"
- name: Install the pinned botocore
run: pip install -r tools/aws/requirements.txt
- name: Run generator tests
run: make aws-data-test
- name: Check partitions.json against a fresh generation
run: make aws-data-check
# Offline and hermetic, so it is safe on a job this broadly triggered. The online check
# that needs AWS lives in iam-data-drift.yml, which only runs when the vendored file
# or its generator changes, so an outage cannot fail an unrelated Java pull request.
- name: Check the vendored IAM namespace list is well-formed
run: make iam-namespaces-check
# Same split for the IAM action resource map: shape here, the online check against AWS in
# iam-data-drift.yml. A malformed or hand-edited map would authorize IAM requests
# against the wrong resource, which is why its shape is gated on every pull request.
- name: Check the vendored IAM action resource map is well-formed
run: make iam-action-resources-check
# And for the map of operations AWS authorizes under another action's name: a malformed
# entry would authorize a request as an action AWS does not check for it.
- name: Check the vendored map of operations to their IAM actions is well-formed
run: make iam-authorized-actions-check
# Also offline: the service-linked role table is checked against the vendored managed
# policy documents in the repository, never against AWS. The half that comes from a
# recorded create cannot be re-derived without the snapshot, which is why every row in
# the table carries the source it rests on.
- name: Run the service-linked role generator tests
run: make slr-test
- name: Check the service-linked role table against the vendored policy documents
run: make slr-check