mirror of
https://github.com/floci-io/floci.git
synced 2026-11-25 14:57:54 -05:00
* fix(cloudformation): check S3 ownership rules against the resource schema #5712 made AWS::S3::Bucket apply OwnershipControls, with the provisioner answering a wrong type and a rule without ObjectOwnership, and S3 answering two rules, no rule and an unknown mode with MalformedXML. Two constraints of AWS's published resource schema were still missing. A key the schema does not define was dropped unread: next to a valid rule the stack reached CREATE_COMPLETE, and a misspelt ObjectOwnership was reported as missing. A rule listed twice was refused by S3 for the rule count, not by the schema for the repeat. Both now fail the resource before the bucket is created or changed, in the provisioner's "Model validation failed (#/OwnershipControls...)" form: "extraneous key [<key>] is not permitted" on OwnershipControls and on each rule, and "array items are not unique" on Rules, compared once intrinsic functions are resolved. Every other case keeps #5712's answer: two different rules, no rule and an unknown mode still get MalformedXML, and a rule without ObjectOwnership still reports the missing key. Its type checks get tests for the shapes it did not cover. docs/services/cloudformation.md gains an S3 ownership controls section. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * fix(cloudformation): check each ownership rule before the repeat The uniqueness check ran before each rule's own checks, so a repeated rule that is malformed by itself, such as {"Rules": [{}, {}]} or two string rules, was refused as "array items are not unique" rather than for its own fault, which is the answer #5712 gives the same rule alone. The repeat is now checked once every rule passes on its own, still before S3's rule count. Tests now pin the order and the key each level allows: an extra key beside a Rules of the wrong type, ObjectOwnership on OwnershipControls, Rules on a rule, and a repeat that is not adjacent. The update test checks the error it gets. The previous commit's "Every other case keeps #5712's answer" holds from this commit on. Where the schema and S3 disagree, a missing Rules key and a mode outside the enum still get S3's MalformedXML. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * docs(cloudformation): correct the S3 ownership controls section Say which key each level allows, that S3 rather than the resource schema requires ObjectOwnership, and that a repeated rule is checked once every rule passes its own checks. Name the two cases, a missing Rules and a mode outside the enum, where Floci keeps S3's answer and the schema would refuse the template itself. Describe the reason a stack reports rather than error codes it never shows, and flatten the nested list, which Python-Markdown renders as siblings at a two-space indent. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * test(cloudformation): pin the repeat check after every ownership rule A repeat ahead of a malformed rule, as in [A, A, {}], must still fail for the third rule's missing ObjectOwnership, as a single malformed rule does. Without this row, checking each rule against the earlier ones inside the rule loop passed every test. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * docs(cloudformation): say S3 ownership rules are checked in turn The section said that what the resource schema refuses is reported first. The provisioner checks each rule in turn, so a rule without ObjectOwnership, which only S3 requires, is reported ahead of a schema fault in a later rule. Give the order the checks run in, and say that CloudFormation's reason can differ for such a rule, since the schema accepts it. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> --------- Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>