Repository navigation
feat(iam): the account authorization snapshot, and MaxItems refused rather than coerced (#848, #868) - #874
Merged
Conversation
…ather than coerced (#848, #868) GetAccountAuthorizationDetails is the one operation that reports all four IAM entity shapes in one response, so it is the only place AttachmentCount, PermissionsBoundaryUsageCount and RoleLastUsed can be seen beside the single-entity operations that also report them. #847, #815 and #816 were all defects of exactly that kind — a derived value diverging between two operations — and nothing in the tree put the two derivations side by side. The action was already authorizable, so only a handler was needed. Three decisions are recorded rather than implied. An instance profile's embedded role is re-read from state instead of rendered from the profile's frozen copy, because STS writes RoleLastUsed onto the role record and AWS's own sample renders that member inside InstanceProfileList. MaxItems counts across the four lists combined over one ordered composite key space, which AWS does not document either way, and with 52 bundled policies against a default of 100 truncation is on the default path rather than an edge case. The detail shapes drop members their single-entity siblings carry — RoleDetail has no Description or MaxSessionDuration, UserDetail no PasswordLastUsed — while the Role nested inside an instance profile does carry them, because those are two different shapes. The issue's fourth acceptance criterion is reversed with its citation: the operation page claims every policy document is RFC 3986 URL-encoded, while its own sample response renders all of them as plain JSON, and only PolicyVersion.Document's own type page repeats the mandate. Substrate follows the per-shape pages, so PolicyVersionList[].Document is percent-encoded and matches GetPolicyVersion byte for byte while AssumeRolePolicyDocument and the inline documents stay plain JSON and match GetRole and GetRolePolicy — two conventions in one response, which is what AWS's model has. An unknown Filter value is refused with ValidationError naming the value and the five accepted ones. A store read that fails reaches the caller as a 500, because this operation's answer is the account and a swallowed error reads as "the entity is gone"; a record that does not decode is skipped, because it never will decode and failing the whole operation would let one bad key hide an account's authorization for good. MaxItems outside 1-1000 was silently rewritten to 100 by the shared paginator, so a caller who asked for 1001 got 100 — a page size no part of the request named, the release's theme applied to a request parameter. It is now refused before any work at all seventeen handlers, nineteen operations, that decode the parameter, with the presence rule read from the decoded form parameters so an explicit MaxItems=0 is below the minimum rather than absent. The code is ValidationError/400 there and stays InvalidInput/400 at SimulatePrincipalPolicy and SimulateCustomPolicy, which publish that code in their own Errors sections; that split is AWS's. Those two now apply the same bounds and the same presence rule, where an explicit zero had been taken as absent at the one place already validating. ListInstanceProfiles is a stale row in #868's inventory rather than a site this fix reaches: it decodes no request parameters at all, so there is no value to range-check. Corrected on that issue and filed as #873. Closes #848 Closes #868
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
Why
GetAccountAuthorizationDetailsis the only operation that reports all four IAM entity shapes — user, group, role and managed policy — in one response, with their inline and attached policies. That makes it the only placeAttachmentCount,PermissionsBoundaryUsageCountandRoleLastUsedcan be observed beside the single-entity operations that also report them. #847, #815 and #816 were all defects of exactly that kind: a derived value diverging between two operations that report the same shape, with nothing in the tree putting the two derivations side by side. Until now the operation answeredInvalidActionwhile already being authorizable —authzref/iam.jsonandauthz_reference_gen.goboth carryiam:GetAccountAuthorizationDetailswith an empty resource list — so only a handler was needed.The second half is the same release theme aimed at a request parameter.
paginateIAMKeysrewrote anyMaxItemsoutside 1–1000 to 100, so a caller who asked for 1001 items got 100 and a caller who asked for 0 got 100 — a page size no part of the request named, while AWS refuses both with a 400.What changed
GetAccountAuthorizationDetails(#848) — new fileemulator/iam_account_authorization_details.go, followingiam_list_policies.go's convention, plus one dispatch arm. Three decisions are recorded in the file's preamble, indocs/services.mdand in the CHANGELOG rather than left implied:IAMInstanceProfile.Roles. That field is a frozen copy written atAddRoleToInstanceProfile; STS writesRoleLastUsedonto the role record and never reaches it, and AWS's own sample renders<RoleLastUsed>insideInstanceProfileList. Rendering from the snapshot reportsnilthere for essentially every role.TestIAMAccountAuthorizationDetails_RoleLastUsedInsideInstanceProfilewas verified to fail — with the exact "does not contain" diff — when the refresh loop is deleted.MaxItemscounts across the four lists combined, over one ordered composite key space (user/<name>,policy/<arn>, …) so aMarkeris unambiguous. AWS documents neither reading. With 52 bundled managed policies against a default of 100, truncation is on the default path, not an edge case.RoleDetailhas noDescriptionand noMaxSessionDuration;UserDetailhas noPasswordLastUsed. TheRolenested inside an instance profile does carry both, becauseInstanceProfile.Rolesis an array ofRole, notRoleDetail— two different shapes, asserted as two different member sets.#848's fourth acceptance criterion is reversed, with the citation. The issue asks for every policy document to be URL-encoded. The operation page claims exactly that, and its own sample response renders every document as plain JSON; only
PolicyVersion.Document's own type page repeats the RFC-3986 mandate, andPolicyDetail.PolicyDocumentandRoleDetail's carry no such sentence. Substrate follows the per-shape pages:PolicyVersionList[].Documentis percent-encoded viaiamEscapeRFC3986and matchesGetPolicyVersionbyte for byte, whileAssumeRolePolicyDocumentand the inline documents stay plain JSON and matchGetRole/GetRolePolicy. Encoding everything would have been a breaking wire change to five shipped operations. Two conventions in one response is what AWS's model has, andTestIAMAccountAuthorizationDetails_PolicyDocumentEncodingsasserts both in one body.An unknown
Filtervalue is refused withValidationErrornaming the value and the five accepted ones. A store read that fails reaches the caller as a 500 — this operation's answer is the account, so a swallowed error reads as "the entity is gone" — while a record that does not decode is skipped, because it never will decode and failing the whole operation would let one bad key hide an account's authorization for good. Nine armed store-failure arms and one corrupt-record case cover the split.An out-of-range
MaxItemsis refused (#868) — newemulator/iam_max_items.go. Validated before any work at all seventeen handlers, nineteen operations, that decode the parameter. The presence rule is read from the decoded form parameters, because a decodedintcannot distinguish an explicitMaxItems=0(below the minimum) from an absent one (the documented default of 100). The coercion inpaginateIAMKeysremains the defaulting path for an absent value; it is no longer reachable by a value the caller sent.The code is
ValidationError/400 at those nineteen and staysInvalidInput/400 atSimulatePrincipalPolicyandSimulateCustomPolicy— that split is AWS's, not substrate's: the simulate pair publishInvalidInputin their own Errors sections, while the nineteen publish onlyNoSuchEntityandServiceFailureand so can only draw fromCommonErrors, which does not list it. Those two now apply the same bounds and the same presence rule, closing a below-minimum hole at the one place that was already validating: an explicitMaxItems=0had been taken as absent and served a page its nineteen siblings now refuse. Only the code differs across all twenty-one operations.Corrected on the record. #868's inventory row for
ListInstanceProfilesis stale (a line number that drifted). That operation decodes no request parameters at all — it ignoresMaxItems,MarkerandPathPrefixand hardcodesIsTruncated=false— so there is no decoded value for this guard to range-check. That is the accepted-and-ignored class rather than the silently-coerced one, and closing it means implementing pagination the operation has never had. Corrected in a comment on #868 and filed as #873.Verification
The nine-command gate, all green:
gofmt -l . && go build ./... && go vet ./...— cleangolangci-lint run ./...— 0 issuesmake test— exit 0GOTOOLCHAIN=go1.26.6 make test— exit 0GOTOOLCHAIN=go1.26.6 make coverage— 83.9% emulator / 83.3% total, holding the 83.9%/83.2% baselinemake docs-reference docs-reference-check docs-versions authz-reference-check— exit 0npm --prefix docs run build— exit 0go vet -C test/e2e ./... && go test -C test/e2e ./...— exit 0Every assertion in
emulator/iam_account_authorization_details_test.gois on raw XML, not a decoded struct: a struct cannot distinguish an absent member from an empty one, which is howiam_shape_members_test.gomissed the boundary defect #807 fixed. Every entity is created through the API over the wire — noputTest*helper, per #765's rule that a helper writing state directly cannot prove a value is readable through the owning service's own call.Compatibility
GetAccountAuthorizationDetailsexists where it previously answeredInvalidAction.MaxItemsoutside 1–1000 is refused at nineteen IAM operations that previously coerced it to 100, and an explicitMaxItems=0is now refused at the two simulate operations that previously treated it as absent. A caller relying on the coercion was relying on a page size it did not ask for.Closes #848
Closes #868