Skip to content

Serialize application privileges in PutRoleRequest #31712

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

Merged
merged 4 commits into from
Jul 3, 2018

Conversation

tvernum
Copy link
Contributor

@tvernum tvernum commented Jul 2, 2018

The serialization methods for PutRoleRequest did not handle the
applicationPrivileges array.
Fixes this and added tests

The serialization methods for `PutRoleRequest` did not handle the
applicationPrivileges array.
Fixes this and added tests
@tvernum tvernum added >bug review :Security/Authorization Roles, Privileges, DLS/FLS, RBAC/ABAC labels Jul 2, 2018
@tvernum tvernum requested a review from albertzaharovits July 2, 2018 02:53
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-security

out.writeStringArray(runAs);
refreshPolicy.writeTo(out);
out.writeMap(metadata);

Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: extra line

final PutRoleRequest copy = new PutRoleRequest();
copy.readFrom(out.bytes().streamInput());

assertThat(copy.roleDescriptor(), equalTo(original.roleDescriptor()));
Copy link
Contributor

Choose a reason for hiding this comment

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

I see that RoleDescriptor.ApplicationPrivilege#equals

does not check for application name to be equal.
This looks to me as an oversight?

request.cluster(randomSubsetOf(Arrays.asList("monitor", "manage", "all", "manage_security", "manage_ml", "monitor_watcher"))
.toArray(Strings.EMPTY_ARRAY));

for (int i = randomIntBetween(1, 4); i > 0; i--) {
Copy link
Contributor

Choose a reason for hiding this comment

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

randomIntBetween(0, 4), would be more alike to a true request?


final Supplier<String> stringWithInitialLowercase = ()
-> randomAlphaOfLength(1).toLowerCase(Locale.ROOT) + randomAlphaOfLengthBetween(3, 12);
final ApplicationResourcePrivileges[] applicationPrivileges = new ApplicationResourcePrivileges[randomIntBetween(1, 5)];
Copy link
Contributor

Choose a reason for hiding this comment

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

same heere, randomIntBetween(0, 5) would be more life-like

Copy link
Contributor

@albertzaharovits albertzaharovits left a comment

Choose a reason for hiding this comment

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

One question and 3 nits, OTT LGTM

@tvernum tvernum merged commit 95948c7 into elastic:security-app-privs Jul 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Security/Authorization Roles, Privileges, DLS/FLS, RBAC/ABAC
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants