mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Security Solution] Update session viewer Policy permissions to use Policy specific check (#160448)
## Summary This PR updates the session viewer code to use the `canReadPolicyManagement ` permission as opposed to `canAccessEndpointManagement`. This is because `canAccessEndpointManagement` requires super user permissions while `canReadPolicyManagement` which is a more specific permission. ### Checklist - [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: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
0aea720fb6
commit
6a9e8d422c
6 changed files with 12 additions and 16 deletions
|
@ -158,7 +158,7 @@ describe('useSessionView with active timeline and a session id and graph event i
|
|||
height: 1000,
|
||||
sessionEntityId: 'test',
|
||||
loadAlertDetails: mockOpenDetailFn,
|
||||
canAccessEndpointManagement: false,
|
||||
canReadPolicyManagement: false,
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -264,7 +264,7 @@ export const useSessionView = ({
|
|||
}, [scopeId]);
|
||||
const { globalFullScreen } = useGlobalFullScreen();
|
||||
const { timelineFullScreen } = useTimelineFullScreen();
|
||||
const { canAccessEndpointManagement } = useUserPrivileges().endpointPrivileges;
|
||||
const { canReadPolicyManagement } = useUserPrivileges().endpointPrivileges;
|
||||
|
||||
const defaults = isTimelineScope(scopeId) ? timelineDefaults : tableDefaults;
|
||||
const { sessionViewConfig, activeTab } = useDeepEqualSelector((state) => ({
|
||||
|
@ -309,7 +309,7 @@ export const useSessionView = ({
|
|||
loadAlertDetails: openEventDetailsPanel,
|
||||
isFullScreen: fullScreen,
|
||||
height: heightMinusSearchBar,
|
||||
canAccessEndpointManagement,
|
||||
canReadPolicyManagement,
|
||||
})
|
||||
: null;
|
||||
}, [
|
||||
|
@ -318,7 +318,7 @@ export const useSessionView = ({
|
|||
sessionView,
|
||||
openEventDetailsPanel,
|
||||
fullScreen,
|
||||
canAccessEndpointManagement,
|
||||
canReadPolicyManagement,
|
||||
]);
|
||||
|
||||
return {
|
||||
|
|
|
@ -51,7 +51,7 @@ export const SessionView = ({
|
|||
jumpToCursor,
|
||||
investigatedAlertId,
|
||||
loadAlertDetails,
|
||||
canAccessEndpointManagement,
|
||||
canReadPolicyManagement,
|
||||
}: SessionViewDeps) => {
|
||||
// don't engage jumpTo if jumping to session leader.
|
||||
if (jumpToEntityId === sessionEntityId) {
|
||||
|
@ -435,7 +435,7 @@ export const SessionView = ({
|
|||
isFullscreen={isFullScreen}
|
||||
onJumpToEvent={onJumpToEvent}
|
||||
autoSeekToEntityId={currentJumpToOutputEntityId}
|
||||
canAccessEndpointManagement={canAccessEndpointManagement}
|
||||
canReadPolicyManagement={canReadPolicyManagement}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -107,9 +107,7 @@ describe('TTYPlayer component', () => {
|
|||
});
|
||||
|
||||
it('renders a message warning when max_bytes exceeded with link to policies page', async () => {
|
||||
renderResult = mockedContext.render(
|
||||
<TTYPlayer {...props} canAccessEndpointManagement={true} />
|
||||
);
|
||||
renderResult = mockedContext.render(<TTYPlayer {...props} canReadPolicyManagement={true} />);
|
||||
|
||||
await waitForApiCall();
|
||||
await new Promise((r) => setTimeout(r, 10));
|
||||
|
|
|
@ -41,7 +41,7 @@ export interface TTYPlayerDeps {
|
|||
isFullscreen: boolean;
|
||||
onJumpToEvent(event: ProcessEvent): void;
|
||||
autoSeekToEntityId?: string;
|
||||
canAccessEndpointManagement?: boolean;
|
||||
canReadPolicyManagement?: boolean;
|
||||
}
|
||||
|
||||
export const TTYPlayer = ({
|
||||
|
@ -53,7 +53,7 @@ export const TTYPlayer = ({
|
|||
isFullscreen,
|
||||
onJumpToEvent,
|
||||
autoSeekToEntityId,
|
||||
canAccessEndpointManagement,
|
||||
canReadPolicyManagement,
|
||||
}: TTYPlayerDeps) => {
|
||||
const ref = useRef<HTMLDivElement>(null);
|
||||
const { ref: scrollRef, height: containerHeight = 1 } = useResizeObserver<HTMLDivElement>({});
|
||||
|
@ -71,10 +71,8 @@ export const TTYPlayer = ({
|
|||
const { getUrlForApp } = useKibana<CoreStart>().services.application;
|
||||
const policiesUrl = useMemo(
|
||||
() =>
|
||||
canAccessEndpointManagement
|
||||
? getUrlForApp(SECURITY_APP_ID, { path: POLICIES_PAGE_PATH })
|
||||
: '',
|
||||
[canAccessEndpointManagement, getUrlForApp]
|
||||
canReadPolicyManagement ? getUrlForApp(SECURITY_APP_ID, { path: POLICIES_PAGE_PATH }) : '',
|
||||
[canReadPolicyManagement, getUrlForApp]
|
||||
);
|
||||
|
||||
const { search, currentLine, seekToLine } = useXtermPlayer({
|
||||
|
|
|
@ -34,7 +34,7 @@ export interface SessionViewDeps {
|
|||
// Callback used when alert flyout panel is closed
|
||||
handleOnAlertDetailsClosed: () => void
|
||||
) => void;
|
||||
canAccessEndpointManagement?: boolean;
|
||||
canReadPolicyManagement?: boolean;
|
||||
}
|
||||
|
||||
export interface EuiTabProps {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue