Skip to content

Commit c9ad0ec

Browse files
authored
[Serverless][SecuritySolution] Remove role based checks on nav tree for v1 footer (elastic#240276)
## Summary - Removes role based checks on the nav tree for v1 navigation that was used to launchpad footer and links. There is another role based check within [app_links.ts](https://github.com/elastic/kibana/blob/be1d887be62eb765a01db7523fd2f85ad035b116/x-pack/solutions/security/plugins/security_solution/public/app/links/app_links.ts#L54) that is invoked at the plugin registration level to filter out value report links for all other pre-defined roles ( except for SOC Manager, Admin and EASE SOC Manager) We should clean the above in a follow up PR as described in elastic#236069 (comment) - Adds/updates `id`s to launchpad v2 nav items (value report, siem readiness, get started) related elastic#234377 ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [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 - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [ ] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) - [ ] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels. ### Identify risks Does this PR introduce any risks? For example, consider risks like hard to test bugs, performance regression, potential of data loss. Describe the risk, its severity, and mitigation for each identified risk. Invite stakeholders and evaluate how to proceed before merging. - [ ] [See some risk examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) - [ ] ...
1 parent 48c27b4 commit c9ad0ec

9 files changed

Lines changed: 37 additions & 342 deletions

File tree

x-pack/solutions/security/packages/navigation/src/i18n_strings.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@ export const i18nStrings = {
3737
'This functionality is experimental and not supported. It may change or be removed at any time.',
3838
}),
3939
},
40-
launchpad: {
41-
title: i18n.translate('securitySolutionPackages.navLinks.launchpad', {
42-
defaultMessage: 'Security launchpad',
43-
}),
44-
},
4540
assets: {
4641
title: i18n.translate('securitySolutionPackages.navLinks.assets', {
4742
defaultMessage: 'Assets',

x-pack/solutions/security/packages/navigation/src/link_groups.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ export const SecurityLinkGroup: Record<SecurityGroupName, SecurityLinkGroupDefin
2020
[SecurityGroupName.assets]: { title: i18nStrings.assets.title },
2121
[SecurityGroupName.entityAnalytics]: { title: i18nStrings.entityAnalytics.title },
2222
[SecurityGroupName.machineLearning]: { title: i18nStrings.ml.title },
23-
[SecurityGroupName.launchpad]: { title: i18nStrings.launchpad.title },
23+
[SecurityGroupName.launchpad]: { title: i18nStrings.launchPad.title },
2424
});

x-pack/solutions/security/packages/navigation/src/navigation_tree/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
* 2.0.
66
*/
77

8-
import { createLaunchpadNavigationTree } from './security_launchpad_navigation_tree';
98
import { createDashboardsNavigationTree } from './dashboards_navigation_tree';
109
import { createRulesNavigationTree } from './rules_navigation_tree';
1110
import { createCasesNavigationTree } from './cases_navigation_tree';
@@ -22,7 +21,6 @@ export const defaultNavigationTree = {
2221
cases: createCasesNavigationTree,
2322
investigations: createInvestigationsNavigationTree,
2423
explore: createExploreNavigationTree,
25-
launchpad: createLaunchpadNavigationTree,
2624
assets: createAssetsNavigationTree,
2725
entityAnalytics: createEntityAnalyticsNavigationTree,
2826
ml: createMachineLearningNavigationTree,

x-pack/solutions/security/packages/navigation/src/navigation_tree/security_launchpad_navigation_tree.test.ts

Lines changed: 0 additions & 136 deletions
This file was deleted.

x-pack/solutions/security/packages/navigation/src/navigation_tree/security_launchpad_navigation_tree.ts

Lines changed: 0 additions & 66 deletions
This file was deleted.

x-pack/solutions/security/plugins/security_solution_serverless/public/navigation/navigation.test.ts

Lines changed: 0 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import { mockServices } from '../common/services/__mocks__/services.mock';
1010
import { registerSolutionNavigation } from './navigation';
1111
import { createNavigationTree } from './navigation_tree';
1212
import { createAiNavigationTree } from './ai_navigation/ai_navigation_tree';
13-
import { SecurityPageName, SecurityGroupName } from '@kbn/security-solution-navigation';
14-
import type { NavigationTreeDefinition } from '@kbn/core-chrome-browser';
1513

1614
jest.mock('./navigation_tree');
1715
jest.mock('./ai_navigation/ai_navigation_tree');
@@ -74,112 +72,3 @@ describe('Security Side Nav', () => {
7472
});
7573
});
7674
});
77-
78-
describe('Navigation Tree Role-Based Access', () => {
79-
const services = mockServices;
80-
const mockGetCurrentUser = jest.fn();
81-
82-
beforeEach(() => {
83-
jest.clearAllMocks();
84-
// Set up the mock for getCurrentUser
85-
services.security.authc.getCurrentUser = mockGetCurrentUser;
86-
});
87-
88-
const findLaunchpadNode = (navigationTree: NavigationTreeDefinition) => {
89-
const footer = navigationTree.footer?.[0];
90-
if (footer && 'children' in footer) {
91-
return footer.children.find(
92-
(child) => 'id' in child && child.id === SecurityPageName.landing
93-
);
94-
}
95-
return undefined;
96-
};
97-
98-
const findAiValueNode = (navigationTree: NavigationTreeDefinition) => {
99-
const footer = navigationTree.footer?.[0];
100-
if (footer && 'children' in footer) {
101-
const launchpadGroup = footer.children?.find(
102-
(child) => 'id' in child && child.id === SecurityGroupName.launchpad
103-
);
104-
if (launchpadGroup && launchpadGroup.children) {
105-
return launchpadGroup.children[0]?.children?.find(
106-
(child) => 'id' in child && child.id === SecurityPageName.aiValue
107-
);
108-
}
109-
}
110-
return undefined;
111-
};
112-
113-
const createNavigationTreeWithUser = async (user: { roles?: string[] } | null) => {
114-
if (user === null) {
115-
mockGetCurrentUser.mockResolvedValue(null);
116-
} else {
117-
mockGetCurrentUser.mockResolvedValue(user);
118-
}
119-
const actualCreateNavigationTree = jest.requireActual('./navigation_tree').createNavigationTree;
120-
return actualCreateNavigationTree(services);
121-
};
122-
123-
const createNavigationTreeWithError = async (error: Error) => {
124-
mockGetCurrentUser.mockRejectedValue(error);
125-
const actualCreateNavigationTree = jest.requireActual('./navigation_tree').createNavigationTree;
126-
return actualCreateNavigationTree(services);
127-
};
128-
129-
const expectAiValueAccess = (navigationTree: NavigationTreeDefinition) => {
130-
const launchpadNode = findLaunchpadNode(navigationTree);
131-
const aiValueNode = findAiValueNode(navigationTree);
132-
133-
expect(launchpadNode).toBeUndefined(); // Should not be a direct item
134-
expect(aiValueNode).toBeDefined(); // Should be in the launchpad group
135-
expect(aiValueNode?.id).toBe(SecurityPageName.aiValue);
136-
};
137-
138-
const expectNoAiValueAccess = (navigationTree: NavigationTreeDefinition) => {
139-
const launchpadNode = findLaunchpadNode(navigationTree);
140-
const aiValueNode = findAiValueNode(navigationTree);
141-
142-
expect(launchpadNode).toBeDefined(); // Should be a direct item
143-
expect(launchpadNode?.id).toBe(SecurityPageName.landing);
144-
expect(aiValueNode).toBeUndefined(); // Should not be in the launchpad group
145-
};
146-
147-
it('grants AI value access to admin role', async () => {
148-
const navigationTree = await createNavigationTreeWithUser({ roles: ['admin', 'viewer'] });
149-
expectAiValueAccess(navigationTree);
150-
});
151-
152-
it('grants AI value access to soc_manager role', async () => {
153-
const navigationTree = await createNavigationTreeWithUser({
154-
roles: ['soc_manager', 'analyst'],
155-
});
156-
expectAiValueAccess(navigationTree);
157-
});
158-
159-
it('denies AI value access to other roles', async () => {
160-
const navigationTree = await createNavigationTreeWithUser({
161-
roles: ['viewer', 'analyst', 'editor'],
162-
});
163-
expectNoAiValueAccess(navigationTree);
164-
});
165-
166-
it('denies AI value access when user has no roles', async () => {
167-
const navigationTree = await createNavigationTreeWithUser({ roles: [] });
168-
expectNoAiValueAccess(navigationTree);
169-
});
170-
171-
it('denies AI value access when getCurrentUser fails', async () => {
172-
const navigationTree = await createNavigationTreeWithError(new Error('Authentication failed'));
173-
expectNoAiValueAccess(navigationTree);
174-
});
175-
176-
it('denies AI value access when getCurrentUser returns null', async () => {
177-
const navigationTree = await createNavigationTreeWithUser(null);
178-
expectNoAiValueAccess(navigationTree);
179-
});
180-
181-
it('denies AI value access when user object has no roles property', async () => {
182-
const navigationTree = await createNavigationTreeWithUser({});
183-
expectNoAiValueAccess(navigationTree);
184-
});
185-
});

0 commit comments

Comments
 (0)