Skip to content

[Security Solution] UI trusted applications RBAC#145593

Merged
gergoabraham merged 6 commits intoelastic:mainfrom
gergoabraham:feature/olm-4913-ui-trusted-applications-rbac
Nov 23, 2022
Merged

[Security Solution] UI trusted applications RBAC#145593
gergoabraham merged 6 commits intoelastic:mainfrom
gergoabraham:feature/olm-4913-ui-trusted-applications-rbac

Conversation

@gergoabraham
Copy link
Contributor

@gergoabraham gergoabraham commented Nov 17, 2022

Summary

RBAC UI features for Trusted Applications. To test, enable endpointRbacEnabled feature-flag, create a non-superuser user with Security: ALL privilege and (All | Read | None) sub-privilege for Trusted Applications.
image

The modification should:

  • hide Trusted Apps from Manage navigation items if privilege is NONE, (note: it is still displayed for non-superusers, if the feature flag is disabled)
  • disable add/edit/delete for Trusted Applications if privilege is READ.

⚠️ Note

This PR focuses on Read and None. The sub-privilege All does not work perfectly at the moment, because of unauthorised API calls. A follow-up PR will fix this, after this PR is merged: #145361

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.6.0 labels Nov 17, 2022
@gergoabraham gergoabraham self-assigned this Nov 17, 2022
@gergoabraham gergoabraham force-pushed the feature/olm-4913-ui-trusted-applications-rbac branch from 3cc4cc5 to bf8c768 Compare November 18, 2022 09:34
@gergoabraham gergoabraham force-pushed the feature/olm-4913-ui-trusted-applications-rbac branch from bf8c768 to c20c08e Compare November 21, 2022 08:19
@gergoabraham gergoabraham marked this pull request as ready for review November 21, 2022 14:05
@gergoabraham gergoabraham requested a review from a team as a code owner November 21, 2022 14:05
@elasticmachine
Copy link
Contributor

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

Copy link
Member

@ashokaditya ashokaditya left a comment

Choose a reason for hiding this comment

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

Mostly nits, but it's good to 🚢

linksToExclude.push(SecurityPageName.hostIsolationExceptions);
}

if (endpointRbacEnabled && !canReadTrustedApplications) {
Copy link
Member

Choose a reason for hiding this comment

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

endpointRbacEnabled is redundant here, as canReadTrustedApplications is already calculated with isEndpointRbacEnabled which is true if either FF (endpointRbacEnabled, endpointRbacV1Enabled) is true.

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 slight difference in the operation with and without the feature flag:

  • if RBAC is enabled, we should hide the Trusted Apps from nav,
  • if disabled, Trusted Apps should be visible to non-superusers, too, but they are shown the Privileges Required screen when clicking on it.

So this condition here is to ensure that the operation stays exactly the same if the feature flag is disabled.

Copy link
Contributor

Choose a reason for hiding this comment

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

@gergoabraham ,
I agree with @ashokaditya here. The fact that the TA menu items appear before, even if the user did not have permission to it, was actually not the desired behaviour and is something we been meaning to correct for a while.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@paul-tavares
Oh, I see, didn't know that it was a not desired behaviour. I'll clean it up in a next RBAC UI PR then. 👍 Another benefit is that there will be less to clean up when removing the feature flag.

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's here: 8ecd2ba

Comment on lines +43 to +44
mockedEndpointPrivileges = { canWriteTrustedApplications: true };
mockUserPrivileges.mockReturnValue({ endpointPrivileges: mockedEndpointPrivileges });
Copy link
Member

Choose a reason for hiding this comment

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

Consider resetting mockUserPrivileges after each test

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nice catch, thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines +35 to +39
const getLinksWithout = (...excludedLinks: SecurityPageName[]) => ({
...links,
links: links.links?.filter((link) => !excludedLinks.includes(link.id)),
});

Copy link
Member

Choose a reason for hiding this comment

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

nice 🚀

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 suggestion but other than that, this is good to go!

let getPlugins: (roles: string[]) => StartPlugins;
let fakeHttpServices: jest.Mocked<HttpSetup>;

const getLinksWithout = (...excludedLinks: SecurityPageName[]) => ({
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be worth using the without function from lodash?

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 wasn't familiar with without so thanks for the suggestion! However, it looks like that without uses equality comparison on objects, so I don't think it's possible to filter out objects based on their attributes, link.id here.

@kibana-ci
Copy link

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] Security Solution Tests #1 / Cases Creates a new case with timeline and opens the timeline

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 9.7MB 9.7MB +196.0B
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 59 65 +6
osquery 109 115 +6
securitySolution 443 449 +6
total +20

Total ESLint disabled count

id before after diff
enterpriseSearch 20 22 +2
fleet 68 74 +6
osquery 110 117 +7
securitySolution 520 526 +6
total +21

History

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

cc @gergoabraham

@gergoabraham gergoabraham merged commit 4c6a915 into elastic:main Nov 23, 2022
@gergoabraham gergoabraham deleted the feature/olm-4913-ui-trusted-applications-rbac branch November 23, 2022 12:50
gergoabraham added a commit that referenced this pull request Dec 1, 2022
## Summary

Similarly to #145593, this PR
handles the _None_ and _Read_ privileges for the Event Filters
sub-feature. The _All_ privilege should not need any UI modification,
but will need API modification.
<img width="554" alt="image"
src="https://user-images.githubusercontent.com/39014407/203514418-b016a47b-819c-4057-a86e-d7b4a3d8e5c5.png">

The modification should:
- hide Event Filters from Manage navigation items if privilege is NONE,
~(note: it is still displayed for non-superusers, if the feature flag is
disabled)~ update: it is hidden for non-superusers if the feature flag
is disabled
- disable add/edit/delete for Event Filters if privilege is READ.



#### Checked:
- the Event Filters form still works from the "Hosts > Events" side of
the app ✅
<img width="1354" alt="image"
src="https://user-images.githubusercontent.com/39014407/204316619-85121106-9d28-4165-9675-522890e39dfe.png">
<img width="1323" alt="image"
src="https://user-images.githubusercontent.com/39014407/204326904-6917c8fe-a364-4a40-8bdc-e8240115fa1d.png">



### Checklist

Delete any items that are not applicable to this PR.

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
gergoabraham added a commit that referenced this pull request Dec 11, 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.
<img width="541" alt="image"
src="https://user-images.githubusercontent.com/39014407/204349035-ca234eae-66ec-4018-bc04-8deaebdd8a0b.png">


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:
<img width="773" alt="image"
src="https://user-images.githubusercontent.com/39014407/205944360-fed60b11-7a88-42d5-93cd-307c7b34891b.png">

With `Policies:None` privilege, hovering on the last item:
<img width="778" alt="image"
src="https://user-images.githubusercontent.com/39014407/205944198-7dccfa37-177f-4eb7-a773-09eaeaa4b1fe.png">




### Checklist

Delete any items that are not applicable to this PR.

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
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.

6 participants