Skip to content
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

[CA-1065] Update queries for nested roles #481

Merged
merged 5 commits into from
Nov 13, 2020

Conversation

marctalbott
Copy link
Contributor

@marctalbott marctalbott commented Nov 12, 2020

Ticket: CA-1065
update queries that list roles to check for any nested roles as well


PR checklist

  • I've followed the instructions if I've made any changes to the API, especially if they're breaking changes
  • I've updated the RC_XXX release ticket with any manual steps required to release this change
  • I've updated the FISMA documentation if I've made any security-related changes, including auth, encryption, or auditing

left join ${PolicyRoleTable as policyRole} on ${userResourcePolicy.policyId} = ${policyRole.resourcePolicyId} and ${userResourcePolicy.inherited} = ${policyRole.descendantsOnly}
left join ${ResourceRoleTable as resourceRole} on ${policyRole.resourceRoleId} = ${resourceRole.id} and ${userResourcePolicy.baseResourceTypeId} = ${resourceRole.resourceTypeId}
left join ${PolicyRoleTable as policyRole} on ${userResourcePolicy.policyId} = ${policyRole.resourcePolicyId}
left join ${FlattenedRoleMaterializedView as flattenedRole} on ${policyRole.resourceRoleId} = ${flattenedRole.baseRoleId} and ((${userResourcePolicy.inherited} and (${policyRole.descendantsOnly} or ${flattenedRole.descendantsOnly})) or not (${userResourcePolicy.inherited} or ${policyRole.descendantsOnly} or ${flattenedRole.descendantsOnly}))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really care for this long logic statement, but I believe it is right. Would love to shorten/simplify it if anyone has any ideas

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

first, I might try putting everything after on ${policyRole.resourceRoleId} = ${flattenedRole.baseRoleId} in the where clause

second, how about
${userResourcePolicy.inherited} = ${policyRole.descendantsOnly} or ${userResourcePolicy.inherited} = ${flattenedRole.descendantsOnly}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well I tried this and it did not quite work so I am missing something

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to draw out a truth table because I kept making minor changes that would fix one test and break another.
Screen Shot 2020-11-13 at 9 24 56 AM

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't move everything into the where clause because it's just on a left join here and the where clause is too selective, but I did move it into a where clause for listUserResourceActions and listUserResourceRoles

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it be useful to leave a comment about this ^? (maybe even including the truth table!)

Copy link
Contributor Author

@marctalbott marctalbott Nov 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's a good call, I think it would be helpful. I'm pulling this check out into a separate query fragment and adding a comment

@dvoet
Copy link
Collaborator

dvoet commented Nov 13, 2020

also enable the pet test that I disabled please

@marctalbott marctalbott removed the request for review from gpolumbo-broad November 13, 2020 18:17
@marctalbott
Copy link
Contributor Author

can jenkins retest if it hasn't finished failing yet?

Copy link
Contributor

@andy7i andy7i left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 LGTM - thanks for adding the nice bit of documentation.
I didn't get too deep into reviewing the unit tests

@marctalbott marctalbott merged commit 55186b4 into develop Nov 13, 2020
@marctalbott marctalbott deleted the mtalbott-flattened-role-queries branch November 13, 2020 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants