Repository navigation
fix(cfn,wafv2,config): an identifier that distinguishes, a request that is checked, and two fields nothing wrote - #860
Merged
Conversation
…at is checked, and two fields nothing wrote
Four fixes, one shape: substrate reported a value that could not tell two
resources apart, accepted a request it then invented the answers for, or
carried a field no writer ever touched.
An AWS::ApiGateway::Method's physical ID was its HTTP verb, so two methods
with the same verb on different resources of one API were indistinguishable —
and because a PhysicalResourceId lookup scans every stack in the account, so
was every GET method everywhere. The type joins cfnGeneratedNameTypes, giving
the {stack}-{logical}-{suffix} shape AWS's own Ref example for the type has.
It is the one entry there whose bound comes from that example rather than a
service limit, because API Gateway's REST API publishes no method identifier
at all — which is also why the two acceptance criteria asking the plugin to
mint one are reversed with that citation. Deploy and delete now resolve the
verb through one shared helper reading the declared properties; the deleter
had been using the physical ID as the verb, so changing the ID without it
would have left every method behind with DeleteStack reporting success.
CreateIPSet defaulted three of its four documented-required members, so a
request AWS rejects created an IP set whose scope and address family the
caller never chose. An omitted member now answers ValidationError/400 (WAFv2's
CommonErrors) and an invalid value WAFInvalidParameterException/400 (the
operation's own Errors section), which settles the issue's open question from
AWS's pages rather than by choice. "Addresses": [] still succeeds: AWS lists
it valid while marking [""] INVALID, so absent and empty stay distinct and the
nil-to-empty normalisation had to go rather than sit beside the check.
Every arn:aws:wafv2 now comes from one builder. v0.114.0 fixed the
CloudFormation path to derive the scope segment and left the plugin hardcoding
"regional", so one logical web ACL reported two different ARNs depending on
which path created it. Which literal a CLOUDFRONT scope renders is substrate's
reading — four sources are named in wafv2ARN's doc comment, and the only
substituted example AWS publishes is a REGIONAL ACL.
ConfigurationRecorder.Tags and ConfigRule.Tags were declared json:"-" and
never assigned or read anywhere. Config's tags live in a side-car record and
work; giving either field a real tag would have emitted a member AWS's shapes
do not have and created a second spelling of one resource's tags. Their
accurate doc comments move to where the behaviour lives.
Two statements justifying why the stored PhysicalID is left alone were
checkable and neither held; both are corrected in cfn_intrinsics.go and in
v0.114.0's CHANGELOG entry.
Closes #755
Closes #836
Closes #843
Closes #858
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 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.
Group D of v0.115.0. Four fixes with one shape: substrate reported an identifier that could not tell two resources apart, accepted a request it then invented the answers for, or carried a field no writer ever touched.
Closes #755
Closes #836
Closes #843
Closes #858
Also corrects two false statements about CloudFormation's stored
PhysicalID— part of #837, which stays open.AWS::ApiGateway::Method's physical ID (#843)Every method in a stack was identified by its HTTP verb. Two methods with the same verb on different resources of one API were indistinguishable in
DescribeStackResources, and because aPhysicalResourceId-only request scans every stack in the account,describe-stack-resources --physical-resource-id GETreturned everyGETmethod in every stack.!Refresolved to the verb too.The type joins
cfnGeneratedNameTypes, so the physical ID is{stack}-{logical}-{suffix}— the shape AWS's Template Reference publishes for this type'sRef, "the method ID, such asmysta-metho-01234b567890example" — derived from account, Region, stack name and logical ID, so a redeploy reports the same value.Two of the issue's acceptance criteria are reversed with a citation rather than implemented. They ask the API Gateway plugin to mint and return a method ID; AWS's REST API publishes none.
API_Methodcarries the eleven configuration fields and noid, andAPI_PutMethodreturns none. Implementing them would have invented a member AWS does not have. The plugin already keys methods by (account, Region, API, resource, verb), so there was never a service-state collision — the defect was purely in what CloudFormation reported.It is also the one entry in that table whose bound comes from an example rather than a service limit, since the type has no name property and nothing is ever sent to a service for validation. 31 and lowercase are read off AWS's published example, which is the only evidence there is, and the table's comment says so.
Stack deletion was load-bearing on the old value. The deleter built the method's DELETE path using the physical ID as the verb, so generating an ID without changing the deleter would have left every method behind — with
DeleteStackreporting no error, because a DELETE of/methods/{stack}-{logical}-{suffix}is a well-formed request for a method that does not exist. Deploy and delete now resolve the verb through one shared helper reading the declared properties, which is where the deleter already got the method's two parent IDs.The verb is deliberately not recorded in
Metadata. That is a genericFn::GetAttchannel — any metadata key resolves under its own name — andAWS::ApiGateway::Methodhas noFn::GetAttsection, so recording it there would publish an attribute AWS does not have. That is the defect this release fixes in IAM's permissions boundary; repeating it to fix an identifier would be a poor trade.CreateIPSetrefuses an incomplete request (#755)All four of
Addresses,IPAddressVersion,NameandScopeare documentedRequired: Yes, and substrate silently defaulted three of them. A request AWS rejects created an IP set whose scope and address family the caller never chose, then reported them back as though it had asked.The issue's open question was which error code; AWS's own pages answer it in two parts:
ValidationError/400, from WAFv2's Common Error Types ("Check that all required parameters are included and that values are valid");WAFInvalidParameterException/400, whichCreateIPSet's own Errors section lists.IPAddressVersion∈IPV4|IPV6;Scope∈CLOUDFRONT|REGIONAL;Namematches^[\w\-]+$within 128 characters; each address is a CIDR range other than/0."Addresses": []still succeeds. AWS lists it among the operation's valid example specifications while marking"Addresses": [""]INVALID, so absent and empty are distinct and thenil-to-[]normalisation had to go rather than sit beside the refusal. The generated Go SDK independently draws the same line — its validator keys onv.Addresses == nil.Two things are recorded rather than enforced: AWS does not say an
IPV4set refuses an IPv6 CIDR, so the version and the addresses are checked independently; andWAFInvalidParameterException's three modelled members (Field,Parameter,Reason) have no published enumeration of the valuesFieldandReasontake, so they are folded into the message rather than emitted with invented values.AWSErrorhas no channel for them today either.An existing test case asserting "an omitted version still defaults to IPV4" is deleted: it pinned the defect.
One builder for every WAFv2 ARN (#858)
v0.114.0 fixed CloudFormation's web-ACL ARN to derive its scope segment from
Scopeand left the plugin hardcodingregionalat both create paths — the only otherarn:aws:wafv2literals in non-test code. So the same logical web ACL reported two different ARNs depending on which path created it, and aCLOUDFRONTresource created through the API reported a scope it does not have. An IP-set ARN is whatIPSetReferenceStatementtakes and a web-ACL ARN is whatAssociateWebACLtakes, so that is an identifier another operation is expected to accept.All three sites go through
wafv2ARN— two implementations of an ARN are two answers, which is how this diverged.Which literal a
CLOUDFRONTscope renders is unverified and documented as substrate's reading. Four sources: the Service Authorization Reference page returns an empty body; the machine-readable Service Reference gives only${Scope};API_AssociateWebACLlists the eight protectable-resource ARN formats but no web-ACL ARN; and the only substituted example AWS publishes anywhere is a REGIONAL ACL renderingregional. What the fix guarantees is that the three paths agree.Two dead
Tagsfields on Config's shapes (#836)ConfigurationRecorder.TagsandConfigRule.Tagswere declaredjson:"-"and were never assigned or read anywhere in the tree, tests included.#836 is re-scoped, with the finding posted on the issue first. It was filed on the premise that the fields' presence meant creation-time tags were never persisted. They are: Config keeps every resource's tags in a side-car record keyed by ARN, and nine paths go through it, including creation-time tags for both
PutConfigurationRecorderandPutConfigRule, which read the request's top-levelTagsmember where the API model puts it. Three existing tests already assert what the issue's criteria asked for.Giving either field a real JSON tag — the issue's first criterion — would have introduced a defect: AWS's
ConfigurationRecorderandConfigRuleshapes have noTagsmember, anddescribeConfigurationRecordersserialises the record straight to the wire, so it would emit a member AWS never emits and create a second spelling of one resource's tags with only the side-car read. Their accurate doc comments move tocfgsvcSaveTagsandcfgsvcTagsKey.This is a breaking change for a Go consumer constructing either struct with a
Tagsfield, which nothing in substrate did.Two corrected statements (part of #837)
cfn_intrinsics.goand v0.114.0's #827 CHANGELOG entry both claimed the stored physical ID is "what a redeploy recognizes an existing resource by" and that everyaws:cloudformation:*state key is built from it. Neither held:deployedResourcematches on logical ID with no physical-ID fallback; recognition isclearUnchangedRedeploys, whose own doc comment gives the reason the physical ID cannot be the key — a refused create returns none at all.cfnResolveStampTargetentirely:cfnStampELBResourcefinds the record by ARN.Both are corrected in place, and the correction is also recorded under
## [Unreleased]so the false statement does not survive in a released section while the reversal is only in a diff. The real reasons to leavePhysicalIDalone —DescribeStackResources, the deletion path, drift detection, and the stamp for the types that do use it — are stronger than the two that were written down. #837 stays open.Tests
Every new test was proved non-vacuous by reverting exactly the behaviour it exists for, one at a time:
dr.PhysicalIDas the verbTestCFNMethodID_TheStackStillDeletes(200 afterDeleteStack, not 404)AWS::ApiGateway::Methodtable entryTwoMethodsWithOneVerbReportDistinctPhysicalIDs,TwoStacksReportDifferentMethodIDscreateIPSet's three defaultswafv2ARN's derived segment back to"regional"TheScopeSegmentFollowsTheScope/CLOUDFRONT,TheAPIAndCloudFormationAgree,TestJourney_WAFv2CloudFrontARNNamesItsScopeemulator/cfn_apigateway_method_id_test.go— two methods with one verb report distinct physical IDs;Refround-trips; an update does not move an ID; two stacks report different IDs; the stack deletes (proved by reading each method back through the plugin, since a cleanDeleteStackcannot distinguish "deleted" from "asked to delete something else"); and the created method is still addressed by its verb while the generated ID is not.emulator/wafv2_createipset_validation_test.go— the four omitted members, thirteen invalid values,"Addresses": []accepted and reading back empty, a valid request keeping what it asked for, and the ARN scope segment from both creation paths on one deployer.test/e2e/journey_wafv2_required_members_test.go— the wire tier, which proves three things the plugin tier cannot: that the refusal decodes as WAFv2's typedWAFInvalidParameterException(the #738 failure mode, where a consumer'serrors.Asbranch never runs); that"Addresses": []crosses the wire as an empty list rather than an absent member; and that aCLOUDFRONTARN names its scope. The omitted-member case is a hand-built POST because the generated SDK refuses such a request client-side — which is why no Go consumer ever reached the defaulting, and why every tier that used a client shipped it green.Verification
The nine-command gate, all clean:
Coverage does not regress against the 83.8% emulator / 83.2% total baseline.
Compatibility
AWS::ApiGateway::Method'sPhysicalResourceIdandRefchange value, from the HTTP verb to a generated method ID. A consumer assertingRefequalsGETbreaks; one looking up a method by--physical-resource-id GETstops matching every method in the account.CreateIPSetstarts refusing requests it used to accept. A caller relying on theREGIONAL/IPV4defaults, or on an absentAddressesbecoming[], now gets a 400.CLOUDFRONTweb ACL or IP set created through the WAFv2 API reports acloudfrontscope segment where it previously reportedregional.ConfigurationRecorderandConfigRulelose aTagsfield. Go-source-level only; no wire change, since the field wasjson:"-".