-
Notifications
You must be signed in to change notification settings - Fork 296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure all resources are returned for relation check when caveats are specified #2027
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, see comment
// found, as we need to ensure that all caveats are used for building the final expression. | ||
resultsSetting := crc.resultsSetting | ||
if hasCaveats { | ||
resultsSetting = v1.DispatchCheckRequest_REQUIRE_ALL_RESULTS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understanding check:
The issue is that we were short-circuiting when we found a single relation which matched the check but whose caveat was false and calling it false.
This fix says that when we have a caveat, we must find all relations that match the check so that we can evaluate the caveats on all of them and then OR
them together so that we can decide whether the overall check was true.
The more efficient fix would be to continue evaluating relationships that match the check until we find one that also matches the caveat or we exhaust the set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I'm reading slack and realizing that my "more efficient fix" isn't how it would work for the caching reasons described.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. We cannot just eval here because we build the full caveat expression and then evaluate outside of the dispatcher.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
0e4c99e
to
20855de
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be nice if there were a helper that could assert that two cel expressions are equivalent, instead of providing two options in the test
Fixes #2026