mirror of
https://github.com/floci-io/floci.git
synced 2026-11-30 00:45:17 -05:00
* fix(iam): evaluate SSM GetParametersByPath and GetParameters against the requested parameters GetParametersByPath is now checked against the parameter ARN of its Path, and GetParameters against each entry in Names, instead of parameter/*. A root Path keeps the parameter/* fallback. * test(ssm): cover path and per-name IAM checks on parameter reads * fix(iam): read each SSM operation's own resource field and drop read selectors GetParametersByPath is evaluated against Path only, GetParameters and DeleteParameters against Names only, and other actions against Name only, so a field the handler ignores can no longer stand in for the one it acts on. GetParameter and GetParameters names lose their :version or :label selector, in name and ARN form, before the parameter ARN is built, so a grant on the base parameter covers them. * test(ssm): cover per-operation IAM fields, read selectors and batch deletion GetParametersByPath with a denied Path and an allowed extraneous Names entry is refused; a grant on a parameter allows reading its versions and labels by name and ARN; DeleteParameters needs a grant on every name and deletes nothing when one is refused. * fix(iam): check SSM Names as the handler reads them and the root path as parameter/ Names is iterated the way SsmJsonHandler iterates it, so an object-shaped Names is checked against each of its values instead of parameter/*. A name that looks like an ARN but does not parse loses its selector like any other name, matching how SsmService reads it. GetParametersByPath on the root path is checked against parameter/, the empty parameter name AWS authorizes it against; a missing or empty Path keeps the parameter/* fallback. * test(ssm): prove path and batch-delete checks with a Deny under a parameter/* Allow Both tests now allow the action on parameter/* and deny it on the protected path or parameter, so they fail where the request is checked against parameter/* and pass only when it is checked against the Path or every entry in Names. * fix(iam): treat an SSM request without an operation as a Name request Set.of rejects a null lookup, so the Names and selector-read checks now test for a missing operation first; such a request falls to the Name branch as it did before. * fix(iam): check GetParametersByPath without a Path against the root path SsmJsonHandler reads Path with asText and SsmService lists a blank path from the root, so a missing, empty or non-text Path is now checked against parameter/, the same resource as Path="/", instead of parameter/*. A Deny on parameter/ could otherwise be sidestepped by leaving Path out. A null Path or, for the parameter operations whose handler reads Name with asText, a null Name is checked against parameter/null, the parameter the handler acts on. The builder's Javadoc is split into shorter sentences and wrapped to 120 columns. * test(ssm): prove a Deny holds against read selectors and the root path A Deny on a parameter refuses GetParameter on its version, its label and its ARN with a label, and a Deny on parameter/ refuses GetParametersByPath on Path="/" and with no Path at all, each under a parameter/* Allow. * fix(ssm): reject a PutParameter name outside the parameter name syntax * test(ssm): cover PutParameter rejecting colon and space names * fix(iam): check SSM names with the whitespace their handler keeps * test(ssm): cover untrimmed Name and Names in IAM checks * test(ssm): prove a Deny holds against GetParameters selectors * fix(ssm): strip surrounding spaces from a PutParameter name as AWS does * fix(iam): check a PutParameter against the name it stores, spaces stripped * test(ssm): cover PutParameter stripping surrounding spaces from a name * test(iam): cover a PutParameter Name checked with its spaces stripped * fix(ssm): read a parameter//name ARN as //name, not /name * test(ssm): prove a parameter//name ARN cannot read a denied /name * fix(iam): check GetParametersByPath on its path without a trailing slash * test(iam): prove a Deny on a path holds when GetParametersByPath adds a trailing slash * fix(iam): check an empty SSM name on parameter/, not parameter/* * test(iam): cover an empty SSM Name and Names entry checked on parameter/ * fix(cloudformation): record an SSM parameter under the name PutParameter stores * test(cloudformation): cover an SSM parameter Name with surrounding spaces * fix(iam): check SSM tagging against the parameter its ResourceId names * test(iam): cover SSM tagging checked against ResourceId, not an injected Name * fix(cloudformation): update an SSM parameter in place when its prior id differs only by surrounding spaces * test(cloudformation): cover updating a parameter recorded with surrounding spaces * fix(ssm): resolve a tagging ResourceId ARN only in the request's partition, region and account AddTagsToResource, ListTagsForResource and RemoveTagsFromResource now resolve an ARN ResourceId the way parameter reads do: only an ssm parameter/ ARN in the request's partition, region and account names a stored parameter. An ARN for another region or account, or a parameter ARN without the slash after parameter, is looked up as a literal name and reported as InvalidResourceId. IAM evaluates tagging against the ResourceId ARN as sent, so before this a foreign-region ARN could pass a Deny on the local parameter's ARN and still tag the local parameter. * test(iam): cover SSM tagging by a foreign-region ARN leaving a denied parameter untagged * fix(cloudformation): replace an SSM parameter whose prior id has surrounding spaces A stack created before parameter names were stripped stored its parameter under the spaced name, so updating it in place under the stripped name read a parameter that does not exist and failed with ParameterNotFound. The update is a replacement again, as for any changed physical id: it creates the stripped name and deletes the spaced parameter when the update commits. * refactor(iam): shorten the SSM resource ARN builder's Javadoc * fix(ssm): resolve a legacy parameter<name> ARN in tagging calls Before parameter ARNs matched AWS, Floci gave a top-level parameter the form parameter<name>, and the ARN normalization promised those ARNs still resolve. Tagging now reads its ResourceId through the request-scoped read path, which rejected them. A parameter<name> ARN of the request's partition, region and account is now read as parameter/<name> before the lookup; one from any other partition, region or account is still rejected. * fix(iam): check a legacy parameter<name> tagging ARN as parameter/<name> The tagging handler reads a parameter<name> ResourceId ARN of the request's partition, region and account as parameter/<name>. IAM now evaluates the same ARN, so a Deny on parameter/<name> holds against the legacy form and IAM and the handler agree on the parameter. A legacy ARN of another partition, region or account is evaluated as given, and the handler rejects it. * fix(ssm): trim only spaces from a PutParameter name AWS removes leading and trailing spaces from a PutParameter name, not other whitespace. PutParameter, the AWS::SSM::Parameter provisioner and the IAM check on PutParameter used String.strip(), which also dropped tabs, newlines and non-breaking spaces, so such a name was stored under a different name instead of failing validation. All three now share SsmService.withoutSurroundingSpaces, which removes only the space character, so IAM still checks the name the handler stores. UnlabelParameterVersion keeps its existing strip() on both sides. * fix(cloudformation): roll back an SSM parameter without PutParameter's name checks A failed stack update restores the parameter through PutParameter under the name its snapshot recorded. PutParameter now trims spaces and rejects colons and interior spaces, so restoring a parameter stored before those checks either failed, leaving the rollback half done, or wrote a different, trimmed name. SsmService.restoreParameter overwrites the parameter under its exact stored name with the rest of PutParameter's validation, and the rollback uses it. * docs(ssm): describe parameter name checks, tagging ARNs and IAM resources Document that PutParameter trims only spaces and rejects names outside the parameter name syntax, that tagging accepts parameter ARNs of the request's partition, region and account (the legacy parameter<name> form included), and which request field each action's IAM check reads. * fix(iam): check a GetParametersByPath path ending in // as the path searched GetParametersByPath searches under a Path that already ends in a slash unchanged, so /app// lists /app//<name>. Dropping one slash checked it against parameter/app/, which a Deny on parameter/app// never matched. Only a single trailing slash is dropped now. Signed-off-by: Tyler Webb <tyler.webb@verkada.com> * fix(iam): read a legacy SSM tagging ARN in the request's partition The tagging handlers decide whether a legacy parameter<name> ARN is the request's own using the request's partition, which for a Region no partition publishes is the deployment's. The IAM check used the commercial partition there, so in a non-aws deployment it checked the literal parameter<name> ARN while the handler tagged parameter/<name>, and a Deny on parameter/<name> did not apply. SSM requests now carry the request's partition into the check, as Route 53's do. Signed-off-by: Tyler Webb <tyler.webb@verkada.com> * test(cloudformation): fail an SSM rollback restore through restoreParameter The rollback restore now writes through SsmService.restoreParameter rather than putParameter, so the integration test's simulated restore failure has to stub that method for the rollback to fail as the tests expect. Signed-off-by: Tyler Webb <tyler.webb@verkada.com> * refactor(iam): leave SSM request resources to the existing builder Move the SSM IAM resource changes out of this branch so it carries only the SSM service fixes. The resource-per-operation work moves onto the IAM request-resource generator separately. withLegacyParameterSlash goes back to private now that only SsmService reads it. Signed-off-by: Tyler Webb <tyler.webb@verkada.com> * test(ssm): cover a parameter//name ARN reading nothing under one slash Signed-off-by: Tyler Webb <tyler.webb@verkada.com> * docs(ssm): drop the IAM resource description and note the double-slash ARN Signed-off-by: Tyler Webb <tyler.webb@verkada.com> --------- Signed-off-by: Tyler Webb <tyler.webb@verkada.com>