fix: handle unrelated exists in authorizer ref replacement #2556
+154
−7
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.
Prior to this commit, replace_refs in the policy authorizer did not handle a case for unrelated exists expressions (no :path or :at_path).
Notes
Path handling in
replace_refsWhen recursively calling
replace_refson an unrelated exists, I ignored the path for the new stack entry, passing an empty list:The reasoning is that since this is a "new" level of the expression, starting at
resource, we do not care about the current path in the stack.The second test
"filter_input with nested unrelated exists respects field level authorization"attempts to cover this case, though messing with different values for path at this point all seemed to work anyways?All to say I'm not too sure about this, and would suggest closer review.
Default read action
We use the default read action here, since there is no existing way to pass in a custom action for an unrelated exists. This is in line with existing behavior at some other places like here and here
Stack Trace
An example of the stack trace produced by attempting to filter in this way prior to this commit:
Contributor checklist
Leave anything that you believe does not apply unchecked.