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] Update session viewer Policy permissions to use Policy specific check #160448

Merged
merged 3 commits into from Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -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,
});
});

Expand Down
Expand Up @@ -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) => ({
Expand Down Expand Up @@ -309,7 +309,7 @@ export const useSessionView = ({
loadAlertDetails: openEventDetailsPanel,
isFullScreen: fullScreen,
height: heightMinusSearchBar,
canAccessEndpointManagement,
canReadPolicyManagement,
})
: null;
}, [
Expand All @@ -318,7 +318,7 @@ export const useSessionView = ({
sessionView,
openEventDetailsPanel,
fullScreen,
canAccessEndpointManagement,
canReadPolicyManagement,
]);

return {
Expand Down
Expand Up @@ -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) {
Expand Down Expand Up @@ -435,7 +435,7 @@ export const SessionView = ({
isFullscreen={isFullScreen}
onJumpToEvent={onJumpToEvent}
autoSeekToEntityId={currentJumpToOutputEntityId}
canAccessEndpointManagement={canAccessEndpointManagement}
canReadPolicyManagement={canReadPolicyManagement}
/>
</div>
);
Expand Down
Expand Up @@ -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));
Expand Down
Expand Up @@ -41,7 +41,7 @@ export interface TTYPlayerDeps {
isFullscreen: boolean;
onJumpToEvent(event: ProcessEvent): void;
autoSeekToEntityId?: string;
canAccessEndpointManagement?: boolean;
canReadPolicyManagement?: boolean;
}

export const TTYPlayer = ({
Expand All @@ -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>({});
Expand All @@ -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({
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/session_view/public/types.ts
Expand Up @@ -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 {
Expand Down