Repository navigation
fix(pricing,authz): classify pricing's error protocol, and assert over the registry (#653) - #667
Merged
Merged
Conversation
…r the registry (#653) AuthController.CheckAccess derives a denial code from the service's wire protocol and calls accessDeniedCodeFor(service, "") with no Content-Type, so a service absent from serviceErrorProtocols cannot be rescued by the Content-Type sniff and takes errorProtocolFor's final errProtoQueryXML default. pricing was absent, so the generic gate refused a caller with the bare XML AccessDenied while the plugin's own gate reported AccessDeniedException — two codes for one outcome on one service, which is #595's complaint restated. pricing is classified as JSON RPC, per its model's "protocol": "json", jsonVersion 1.1 and targetPrefix AWSPriceListService. Its own AccessDeniedException shape corroborates the spelling; it is declared on GetPriceListFileUrl and ListPriceLists but not on GetProducts, the operation the report names, so for GetProducts the protocol rule alone decides it. The property test guarding the mapping iterated serviceErrorProtocols itself, so a service missing from the map had no entry to iterate and was invisible — the same blind spot config sat in until #580. The new assertion is driven from the plugin registry instead: every plugin RegisterDefaultPlugins registers must have an entry, and one that lands without it fails with a message naming it. Closes #653
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
4 tasks
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.
Closes #653.
The gap
AuthController.CheckAccessderives its denial code from the service's wire protocol (#595) by readingserviceErrorProtocols. It callsaccessDeniedCodeFor(req.Service, "")with no Content-Type, so a service absent from that map cannot be rescued byerrorProtocolFor's Content-Type sniff either — it takes the finalerrProtoQueryXMLdefault and is refused with the bare XMLAccessDenied.pricingwas absent. Its plugin already reportsAccessDeniedExceptionfor the refusals it raises itself (pricing_plugin.go:46), so substrate emitted two codes for one outcome on one service — the driftTestAccessDenied_IAMPluginAgreesWithTheGenericGateexists to prevent, one level down.Why no test saw it
TestAccessDeniedCode_MatchesTheServiceErrorProtocolasserts the protocol→code property over every registered service — by iteratingserviceErrorProtocolsitself. A service missing from the map has no entry to iterate, so it is invisible to the test that exists to cover it.configsat in exactly that blind spot until #580;pricingwas next.The new
TestAccessDenied_EveryRegisteredPluginHasAnErrorProtocoldrives the assertion from the plugin registry: it builds a real registry viaRegisterDefaultPluginsand asserts everyregistry.Names()entry has a mapping. A plugin that lands without one now fails with a message naming it and saying what to add.Provenance
pricingis classified from its botocore model:"protocol": "json",jsonVersion 1.1,targetPrefix AWSPriceListService. Its ownAccessDeniedExceptionshape ("exception": true, "General authentication failure.") corroborates the suffixed spelling — but note it is declared onGetPriceListFileUrlandListPriceListsand not onGetProducts, the operation the issue reports. So forGetProductsneither spelling is modeled and the protocol rule from #595 alone decides it; the shape confirms rather than supplies it.Verification
Both new tests and the new table row were confirmed to fail with the map entry removed:
gofmt,go build,go vet,golangci-lint run(0 issues),make test(race) all green.Compatibility
A
pricingauthorization denial changes code fromAccessDeniedtoAccessDeniedException. A fixture matching the old string must be updated — it was never a code the Price List SDK could parse.