Repository navigation
feat(authz): vendor AWS's per-operation authorization data, generated and drift-checked - #797
Merged
Merged
Conversation
… and drift-checked Adds the table #762 and #770 are decided against, with no behaviour change of its own. Both issues turn on a per-action question — which resource types does this action support, and what shape is a resource ARN of that type — that AWS answers in the Service Authorization Reference, whose HTML renders its tables in JavaScript and so cannot be read by a fetch. docs/services.md already records that dead end for both ELB pages, which is why some ELB parameters are still authorized against "*". AWS publishes the same data as JSON at https://servicereference.us-east-1.amazonaws.com/v1/{service}/{service}.json, where an action's Resources list names the types it supports and an action with no Resources list supports none. That last fact is the whole of #762, published per action rather than argued about. Pruned snapshots of ec2 (v1.4, 824 actions, 114 resource types) and iam (v1.4, 190 actions, 15 types) are committed under emulator/authzref, and cmd/gen-authz-reference turns them into emulator/authz_reference_gen.go. Vendored rather than fetched at generate time so that generation, the drift check and the whole test suite stay offline: no CI job and no test may depend on network access. Refreshing is a deliberate human step (make authz-reference-fetch) and the diff it produces is the review. make authz-reference-check regenerates in memory and diffs, offline, and runs on the existing docs-reference CI job, mirroring cmd/gen-service-reference — a refreshed snapshot committed without regenerating would otherwise leave the table disagreeing with its own source. The reader returns both the resource types and whether AWS publishes the action at all, because those are different facts: an action AWS scopes to "*" and an action substrate names but AWS does not publish must stay distinguishable, even though both answers point at "*". A resource narrower than the one AWS would use is a grant substrate would be inventing, and inventing a grant is worse than inventing a refusal. Deviation from the plan, stated: the generated file is 1887 lines rather than pruned below the ~1500 the plan allowed for. The alternative was dropping the ARN-format rows, which are precisely what makes the table #770's citation, and the only two rows genuinely unreadable on one line (ec2:CreateTags and ec2:DeleteTags, over a hundred types each) are already written one type per line. A test sweeps every resource-ID prefix ec2TaggableResource recognizes and asserts AWS publishes the resource type substrate names for it. The forthcoming #762 gate compares those names by string, so a type substrate spells differently from AWS — natgateway is unhyphenated where every sibling is hyphenated — would silently never match and quietly widen every operation naming it to "*". Towards #762 and #770.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
download's parse, prune and refusal branches were untested, which left the generator at 49.6% and the new lines short on patch coverage. An httptest server covers them without a test that reaches the internet — the constraint the vendored-snapshot design exists to satisfy — and pins that AWS's per-action ConditionKeys are dropped by pruning, since substrate reads its condition keys from the API reference and a second differently-shaped copy would be a source to keep in sync for no gain. Generator coverage 49.6% -> 61.8%. Only -fetch's own loop over the fixed endpoint is left untested; it is the one part that cannot run offline.
This was referenced Sep 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the data both #762 and #770 will be decided against. No behaviour change: no
production code reads the new table yet, which is what makes it reviewable in isolation.
The problem this solves first
Both issues turn on a per-action question — which resource types does this action support,
and what shape is a resource ARN of that type? AWS answers it in the Service Authorization
Reference, whose HTML renders its tables in JavaScript and so cannot be read by a fetch.
docs/services.mdalready records that dead end for both ELB pages, and it is why some ELBparameters are still authorized against
*. Hand-transcribing 824 EC2 actions was thealternative, and a hand-written list is an assertion about AWS with no source behind it.
AWS publishes the same data as JSON:
An action's
Resourceslist names the resource types it supports, and an action with noResourceslist supports none — that last fact is the whole of #762, published per action.What lands
emulator/authzref/{ec2,iam}.json— pruned snapshots (ec2 v1.4: 824 actions, 114resource types; iam v1.4: 190 actions, 15 types), keeping only
Name,Version,Actions[].Name,Actions[].Resources[].Name,Resources[].Name,Resources[].ARNFormats.A directory with no
.gofiles, so no new package.cmd/gen-authz-reference— generatesemulator/authz_reference_gen.gofrom them.-checkregenerates in memory and diffs, offline.-fetchre-downloads, and is the onlynetwork path in the tool.
emulator/authz_reference.go— the hand-written reader. Nothing else may touch thegenerated maps, so the meaning of an absent key stays in one place.
Makefile:authz-reference,authz-reference-check,authz-reference-fetch(the lastdocumented as network-dependent and never run by CI).
make authz-reference-checkas a step on the existingdocs-referencejob, not a newjob.
Two decisions worth review
The reader returns two values, not one. An action AWS scopes to
*and an action substratenames but AWS does not publish are different facts and must stay distinguishable — even though
both answers point at
*. A resource narrower than the one AWS would use is a grant substratewould be inventing, and inventing a grant is worse than inventing a refusal: the caller's
test passes here and their deployment fails there.
Deviation from the plan, stated rather than quietly taken. The plan said to prune EC2's
action rows if the generated file exceeded ~1500 lines. It is 1887. Pruning would have dropped
the ARN-format rows, which are precisely what makes the table #770's citation, and the only two
rows genuinely unreadable on one line —
ec2:CreateTagsandec2:DeleteTags, over a hundredresource types each — are already written one type per line by the generator.
Why vendored rather than fetched
Generation, the drift check and the whole test suite stay offline: no CI job and no test may
depend on network access. Refreshing is a deliberate human step and the diff it produces is
the review. The drift check exists because a refreshed snapshot committed without regenerating
would leave the table disagreeing with its own source — which is exactly how the #762 gate
would silently widen behaviour.
Verification
Total coverage moves 83.0% → 82.9%: the new generator package sits at 49.6%, because
-fetchand
main's flag handling are deliberately untested — the first is the network path, and a testthat exercised it would violate the constraint this design exists to satisfy.
prune,writeEntry,renderandload's four refusals are covered directly.One unrelated flake surfaced under
-race -cover:TestConfigChannel_PutIsIdempotentAndASecondNameIsRefusedfailed once withread: connection reset by peeragainst its ownhttptestserver, then passed on re-run. Ittouches nothing in this PR; filing separately, since a flake is exactly the signal substrate
exists to eliminate.
Towards #762 and #770.