Skip to content

[Security Solution] UI Blocklist RBAC#146455

Merged
gergoabraham merged 13 commits intoelastic:mainfrom
gergoabraham:feat/olm-4918-ui-blocklist-ui-rbac
Dec 11, 2022
Merged

[Security Solution] UI Blocklist RBAC#146455
gergoabraham merged 13 commits intoelastic:mainfrom
gergoabraham:feat/olm-4918-ui-blocklist-ui-rbac

Conversation

@gergoabraham
Copy link
Contributor

@gergoabraham gergoabraham commented Nov 28, 2022

Summary

Similarly to #145593 and #146111, this PR handles the None and Read privileges for the Blocklist sub-feature. The All privilege should not need any UI modification, but will need API modification.
image

The modification should:

  • hide Blocklist from Manage navigation items if privilege is NONE,
  • disable add/edit/delete for Blocklist if privilege is READ.
  • disable opening Policies from Blocklist (and any other ArtifactListPage) by disabling the links in the 'Applied for N policies' context menu

For testing the last part:

  • add Read privilege for Blocklist (or any other artifact using ArtifactListPage), and None to Policies
  • for now, it has to be tested with Fleet:All and Integrations:Read privileges

With Policies:Read privilege, hovering on the last item:
image

With Policies:None privilege, hovering on the last item:
image

Checklist

Delete any items that are not applicable to this PR.

@gergoabraham gergoabraham added release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting Team:Defend Workflows “EDR Workflows” sub-team of Security Solution v8.7.0 labels Nov 28, 2022
@gergoabraham gergoabraham self-assigned this Nov 28, 2022
@gergoabraham gergoabraham force-pushed the feat/olm-4918-ui-blocklist-ui-rbac branch from 1abd7a3 to 479cd6b Compare December 1, 2022 12:48
@gergoabraham gergoabraham marked this pull request as ready for review December 1, 2022 13:06
@gergoabraham gergoabraham requested a review from a team as a code owner December 1, 2022 13:06
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-onboarding-and-lifecycle-mgt (Team:Onboarding and Lifecycle Mgt)

Copy link
Contributor

@dasansol92 dasansol92 left a comment

Choose a reason for hiding this comment

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

LGTM! Left minor suggestions on test cases but other than that, it looks great!

expect(filteredLinks).toEqual(getLinksWithout(SecurityPageName.eventFilters));
});

it('should hide Blocklist for user without privilege', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add a test case for the case it has right privileges and Blocklist is shown?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is a test case for showing all links, I believe that should be enough. What was missing is the correct name, so I renamed it: 00e8553

});
});

describe('READ privilege', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add a NONE privileges case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This page is never displayed with NONE privilege - instead the NoPrivileges page is displayed, so I think there is no need for that test case.

Copy link
Contributor

@paul-tavares paul-tavares left a comment

Choose a reason for hiding this comment

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

Left some feedback. Let me know your thoughts on my suggestion for the policy names in the card's popover

{children}
</EuiButtonEmpty>
}
disabled={!canReadPolicies}
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think its a good idea to display this with a disabled Button. When the user is not allowed to Read policies, then we should just display the policy name using regular text (<EuiText />). It looks strange (to me) for those entries to be displayed grey'ed out in the UI.

Thoughts?

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 agree, so with some more effort, here is a new version: babbcf2

(I've added screenshots to the description)

history.push(BLOCKLIST_PATH);
});

mockedEndpointPrivileges = { canWriteBlocklist: true };
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you use getEndpointAuthzInitialStateMock() here to instead of setting this to a partial object? it will be easier to maintain in the future, especially if we start to check other RBAC properties for whatever reason - they will be already set.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, thanks!
b53c545

`;

const StyledEuiText = styled(EuiText)`
padding: 10px 12px;
Copy link
Contributor

Choose a reason for hiding this comment

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

can you use Eui Style props here instead of hard coding it?

Should be able to use one of the "size" props in the theme - https://gist.github.com/paul-tavares/303d718ac7f514d6ee681a3851407a7e#file-eui_theme_style_props-js-L576-L579

(FYI: that's my own gist that I keep as a reference to what's available in the theme)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks a lot for this suggestion! Unfortunately, I forgot about using theme constants, so I'm glad it came up.

1057e99

});

it('should hide Event Filters for user without privilege', async () => {
it('should hide Blocklist for user without privilege', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you change this test from Event filters to Blocklist?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It must be some merge/diff magic. 🤷

Originally I had should show and should hide tests for Trusted Apps, but then figured that there's only need for one should show all test, and individual should hide tests for all artefacts. So I renamed the should show Trusted Apps test and moved it up in this commit: 00e8553

Then got some merge conflicts and stuff, so here we are, with a messed up diff, where should show Trusted Apps became should hide Event filters, and should hide Event filters became should hide Blocklists. So I think all should be fine, every test is here.

Copy link
Contributor

@paul-tavares paul-tavares left a comment

Choose a reason for hiding this comment

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

👍

@gergoabraham gergoabraham enabled auto-merge (squash) December 8, 2022 17:10
@gergoabraham
Copy link
Contributor Author

@elasticmachine merge upstream

@gergoabraham
Copy link
Contributor Author

@elasticmachine merge upstream

@kibana-ci
Copy link

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
securitySolution 10.1MB 10.1MB +1.7KB
Unknown metric groups

ESLint disabled in files

id before after diff
osquery 1 2 +1

ESLint disabled line counts

id before after diff
enterpriseSearch 19 21 +2
fleet 60 66 +6
osquery 109 115 +6
securitySolution 445 451 +6
total +20

Total ESLint disabled count

id before after diff
enterpriseSearch 20 22 +2
fleet 69 75 +6
osquery 110 117 +7
securitySolution 521 527 +6
total +21

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @gergoabraham

@gergoabraham gergoabraham merged commit b214406 into elastic:main Dec 11, 2022
@gergoabraham gergoabraham deleted the feat/olm-4918-ui-blocklist-ui-rbac branch December 12, 2022 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:Defend Workflows “EDR Workflows” sub-team of Security Solution v8.7.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants