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

[Security Solution][Endpoint][Response Actions] Add license check to actions log management RBAC #142482

Conversation

ashokaditya
Copy link
Member

@ashokaditya ashokaditya commented Oct 3, 2022

Summary

Allows access to the response actions history page for platinum licenses and up.

iteration of /pull/142470 for >v8.6

Checklist

@ashokaditya ashokaditya self-assigned this Oct 3, 2022
@ashokaditya ashokaditya added release_note:skip Skip the PR/issue when compiling release notes Team:Defend Workflows “EDR Workflows” sub-team of Security Solution OLM Sprint v8.6.0 labels Oct 3, 2022
@ashokaditya ashokaditya marked this pull request as ready for review October 3, 2022 15:08
@ashokaditya ashokaditya requested review from a team as code owners October 3, 2022 15:08
@ashokaditya ashokaditya requested a review from dasansol92 October 3, 2022 15:08
@elasticmachine
Copy link
Contributor

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

@ashokaditya ashokaditya requested a review from kevinlog October 3, 2022 15:09
SecurityPageName.responseActionsHistory
);

if (!canAccessResponseActionsHistoryNavLink) {
Copy link
Contributor

Choose a reason for hiding this comment

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

redirecting silently is not the best UX here. If the user does not have access to it, they should see a "not found" or "permission denied" type of message.

Should we instead change the Management page's index file to NOT register the route instead? Which would result in the user getting a 404 instead:

<Switch>
<Route path={MANAGEMENT_ROUTING_ENDPOINTS_PATH} component={EndpointTelemetry} />
<Route path={MANAGEMENT_ROUTING_POLICIES_PATH} component={PolicyTelemetry} />
<Route path={MANAGEMENT_ROUTING_TRUSTED_APPS_PATH} component={TrustedAppTelemetry} />
<Route path={MANAGEMENT_ROUTING_EVENT_FILTERS_PATH} component={EventFilterTelemetry} />
<Route
path={MANAGEMENT_ROUTING_HOST_ISOLATION_EXCEPTIONS_PATH}
component={HostIsolationExceptionsTelemetry}
/>
<Route path={MANAGEMENT_ROUTING_BLOCKLIST_PATH} component={BlocklistContainer} />
<Route
path={MANAGEMENT_ROUTING_RESPONSE_ACTIONS_HISTORY_PATH}
component={ResponseActionsTelemetry}
/>
<Route path={MANAGEMENT_PATH} exact>
<Redirect to={getEndpointListPath({ name: 'endpointList' })} />
</Route>
<Route path="*" component={NotFoundPage} />
</Switch>

Copy link
Member Author

@ashokaditya ashokaditya Oct 3, 2022

Choose a reason for hiding this comment

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

I like that idea as well. A 404 page is better. What do you think @kevinlog

Although, HIE page also silently redirects. Maybe change that too?

Copy link
Member Author

@ashokaditya ashokaditya Oct 3, 2022

Choose a reason for hiding this comment

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

I like that idea as well. A 404 page is better. What do you think @kevinlog

Although, HIE page also silently redirects. Maybe change that too?

Copy link
Member Author

Choose a reason for hiding this comment

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

* Checks if the current user should be able to see the response actions history
* menu item based on their current privileges
*/
export function useCanSeeResponseActionsHistoryMenu(): boolean {
Copy link
Contributor

Choose a reason for hiding this comment

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

(Optional) Seems like this hook is really only used once. should you just access:

useUserPrivileges().endpointPrivileges.canReadActionsLogManagement?

Copy link
Member Author

Choose a reason for hiding this comment

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

* menu item based on their current privileges
*/
export function useCanSeeResponseActionsHistoryMenu(): boolean {
const privileges = useEndpointPrivileges();
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 useUserPrivileges().endpointPrivileges instead?
The endpoint hook is really meant to be used internally by useUserPrivileges() hook

Copy link
Member Author

Choose a reason for hiding this comment

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

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.

Approving, but left a minor comment (optional)

@@ -117,6 +122,23 @@ describe('useSecuritySolutionNavigation', () => {
).toBeUndefined();
});

it('should omit response actions history if hook reports false', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

being that the useUserPrivileges is being mocked via jest.mock(), should you add a afterEach() that resets the mock back to its default?

Copy link
Member Author

Choose a reason for hiding this comment

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

oh yes. Missed that. Will add it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@YulNaumenko YulNaumenko left a comment

Choose a reason for hiding this comment

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

LGTM!

@ashokaditya ashokaditya enabled auto-merge (squash) October 4, 2022 07:46
@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #32 / analytics instrumented events from the browser Loaded Dashboard full loaded dashboard should emit the "Loaded Dashboard" event when done loading complex dashboard

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 6.6MB 6.6MB +238.0B

History

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

cc @ashokaditya

@ashokaditya ashokaditya merged commit 87dc1fa into elastic:main Oct 4, 2022
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Oct 4, 2022
@ashokaditya ashokaditya deleted the task/olm-rbac-license-based-access-response-actions-history branch October 4, 2022 12:36
WafaaNasr pushed a commit to WafaaNasr/kibana that referenced this pull request Oct 11, 2022
…actions log management RBAC (elastic#142482)

* Add license check to actions log management RBAC

fixes elastic/security-team/issues/5118
refs elastic/pull/142470

* useUSerPrivileges instead

review changes (@paul-tavares)

* Don't register route if no access

review changes (@paul-tavares)

* reset mocked privilege

review changes (@paul-tavares)
WafaaNasr pushed a commit to WafaaNasr/kibana that referenced this pull request Oct 14, 2022
…actions log management RBAC (elastic#142482)

* Add license check to actions log management RBAC

fixes elastic/security-team/issues/5118
refs elastic/pull/142470

* useUSerPrivileges instead

review changes (@paul-tavares)

* Don't register route if no access

review changes (@paul-tavares)

* reset mocked privilege

review changes (@paul-tavares)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting OLM Sprint release_note:skip Skip the PR/issue when compiling release notes Team:Defend Workflows “EDR Workflows” sub-team of Security Solution v8.6.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants