-
Notifications
You must be signed in to change notification settings - Fork 298
fix: clear role members when set to trust role #3087
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
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: takumats <[email protected]>
Summary of ChangesHello @TakuyaMatsu, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical bug in the SolutionTemplate functionality where roles configured with a Trust relationship were not correctly clearing their roleMembers. The change ensures that when a SolutionTemplate is used to define or update a role with a Trust attribute, any explicit or existing roleMembers are removed, aligning the role's configuration with the intended trust-based access model. This prevents unintended access and maintains the integrity of role definitions. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request fixes an issue where applying a solution template could result in a role having both a trust relationship and members, which is an invalid state. The changes correctly clear role members when a trust is set via a template, and ignore members defined in a template if a trust is also present. The fix is implemented in DBService.java and is well-covered by two new test cases that validate both scenarios. The changes look correct and improve the consistency of role management through templates. I've added a minor suggestion to improve test isolation in the new test cases.
servers/zms/src/test/java/com/yahoo/athenz/zms/DBServiceTest.java
Outdated
Show resolved
Hide resolved
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Signed-off-by: Tak <[email protected]>
|
I'm not sure if I follow this PR fix. It is completely invalid to specify a role with both trust and members. If you do that through the API, you should get back 400 request error. Now, as an admin, you're forcing an incorrect state through solution template. So the server must not apply that template since it's invalid if it would have come through API. As an admin, it's your responsibility to generate the valid template (this is why it's an admin operation and users are not allowed to create template). The correct fix for this problem would be that the server must validate the solution template and not just assume that admin did the right thing and reject the template during startup and require the admin to fix the template to make it valid |
|
Thank you for the feedback. I agree admins should ship valid templates. This change is meant as a guardrail to prevent human mistakes from creating a bad state. What I’m seeing right nowIf I apply a SolutionTemplate that sets trust to a role that already has members (and the template doesn’t set roleMembers), the merged role ends up with both. getRole looks fine, but /sys/modified_domains shows both fields, e.g.: That breaks the “trust XOR members” rule and confuses anything reading modified_domains. Plan
|
|
@TakuyaMatsu your PR just masks invalid state and allows it to continue on so we shouldn't promote that.
In both case the correct operation is to reject the invalid state. Otherwise, the merge may not be what the user wants and as such it should not be allowed |
Right now we only validate JSON format at startup. Should I add logic here to stop startup if the template changes both trust and roleMembers? athenz/servers/zms/src/main/java/com/yahoo/athenz/zms/ZMSImpl.java Lines 1293 to 1317 in fa063a2
My understanding is that SolutionTemplate is merge-oriented. In practice, when applying a template to an existing role, fields like members are merged rather than hard-replaced. If we reject applying a template that sets trust to a role that already has members, we’d be introducing an implicit rule—“you can’t set trust via SolutionTemplate on roles with existing members.” I’d prefer to avoid that. |
The server should check the role when modifying and it's not the same type as the template role that it's trying to apply, it should reject the operation. |
|
@havetisyan |
Description
When creating or editing a Role with the Trust field set via SolutionTemplate, a role is created that has both Trust and role members. We confirmed the problem mainly in the following two patterns:
This change fixes the issue so that it does not occur in the patterns described above.
Contribution Checklist:
Attach Screenshots (Optional)