mirror of
https://github.com/floci-io/floci.git
synced 2026-12-03 02:07:58 -05:00
* refactor(cloudformation): read property types from the vendored resource schemas Follow-up asked on #5958: the types EventsCfnProvisioner checked a rule target's members against were written by hand from describe-type, and LambdaCfnProvisioner named the JSON type of each property it reads. They now come from src/main/resources/aws/cfn-property-types.json, which tools/aws/regen_cfn_property_types.py generates from the resource schemas AWS publishes for us-east-1, in the request shapes' layout so RequestShapeModel reads it: a structure, list, map or scalar per shape, and "json" for what a schema leaves free. The schemas come from AWS's live archive rather than a pinned package. cfn-lint ships copies, but widens some types: a Lambda environment variable's value takes any JSON type there and a string in the published schema, where CloudFormation refuses an object or a list with "Property [AB] expected type: String, found: JSONObject" (measured). The archive keeps no older copy, so the generator follows the IAM data's split: --check is offline and structural and runs on every pull request, --verify compares a fresh generation with the vendored file and runs in cfn-schema-drift.yml, weekly and on changes to the file or its generator. CfnPropertyTypes.Reader walks the vendored shapes instead of type trees, maps included: a map's values are read as its value shape, and a mismatch names the key, as CloudFormation does ("Property [h] expected type: String, found: JSONObject", measured). Every member of a rule target is now read against its schema type, not only the four #5958 typed, and Lambda reads the properties it already typed through the same reader, nested members included (VpcConfig.SubnetIds, EphemeralStorage. Size, ImageConfig.Command, TracingConfig.Mode, Environment.Variables). The messages for the newly checked members were measured on CloudFormation (eu-west-1) and are in the tests. * fix(cloudformation): keep a literal list's blank entries where the template put them Review of #5988: the reader read every list of strings through the engine's resolveStringList, which drops blank entries, so a rule target's HttpParameters.PathParameterValues ["", "b"] became ["b"] and moved "b" into the first wildcard. CloudFormation passes a literal list on as written (measured: SecurityGroups ["", "sg-..."] reaches the target as both). A literal list is now read through the engine's new resolveLiteralList, which keeps blanks and still expands a list-valued intrinsic in place; a list an intrinsic yields keeps the engine's reading. Lambda's literal lists, read through the same reader, keep their blanks too, for Lambda to judge as on AWS. resolveLiteralList delegates to the private resolveListElements rather than opening it: tests that mock the engine and call resolveStringList's real code would otherwise get the mock's empty list from it, as IamUserCfnProvisionerTest did. * refactor(cloudformation): read a launch configuration's MetadataOptions by its schema shape Review of #5988: #5964, merged after this branch opened, read AWS::AutoScaling::LaunchConfiguration's MetadataOptions through the type trees this PR removes. The generator now vendors that resource type too, and AutoScalingGroupCfnProvisioner reads the block by the shape its published schema declares (HttpTokens and HttpEndpoint strings, HttpPutResponseHopLimit an integer, the same types #5964 wrote by hand), so its tests pass unchanged. The hop limit's type is an anchor of the generator's offline check.
131 lines
5.3 KiB
YAML
131 lines
5.3 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
|
|
|
|
# And for the CloudFormation property types, which come from AWS's live resource schema
|
|
# archive: shape here, the online comparison in cfn-schema-drift.yml.
|
|
- name: Check the vendored CloudFormation property types are well-formed
|
|
run: make cfn-property-types-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
|
|
|