-
Notifications
You must be signed in to change notification settings - Fork 8.2k
/
links.ts
305 lines (289 loc) · 9.83 KB
/
links.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import type { CoreStart } from '@kbn/core/public';
import { i18n } from '@kbn/i18n';
import { hasKibanaPrivilege } from '../../common/endpoint/service/authz/authz';
import { checkArtifactHasData } from './services/exceptions_list/check_artifact_has_data';
import {
calculateEndpointAuthz,
getEndpointAuthzInitialState,
calculatePermissionsFromCapabilities,
} from '../../common/endpoint/service/authz';
import {
BLOCKLIST_PATH,
ENDPOINTS_PATH,
EVENT_FILTERS_PATH,
EXCEPTIONS_PATH,
HOST_ISOLATION_EXCEPTIONS_PATH,
MANAGE_PATH,
POLICIES_PATH,
RESPONSE_ACTIONS_HISTORY_PATH,
RULES_CREATE_PATH,
RULES_PATH,
SecurityPageName,
SERVER_APP_ID,
TRUSTED_APPS_PATH,
} from '../../common/constants';
import {
BLOCKLIST,
CREATE_NEW_RULE,
ENDPOINTS,
EVENT_FILTERS,
EXCEPTIONS,
HOST_ISOLATION_EXCEPTIONS,
LIST_DETAILS,
MANAGE,
POLICIES,
RESPONSE_ACTIONS_HISTORY,
RULES,
TRUSTED_APPLICATIONS,
} from '../app/translations';
import { licenseService } from '../common/hooks/use_license';
import type { LinkItem } from '../common/links/types';
import type { StartPlugins } from '../types';
import {
manageCategories as cloudSecurityPostureCategories,
manageLinks as cloudSecurityPostureLinks,
} from '../cloud_security_posture/links';
import { IconActionHistory } from './icons/action_history';
import { IconBlocklist } from './icons/blocklist';
import { IconEndpoints } from './icons/endpoints';
import { IconEndpointPolicies } from './icons/endpoint_policies';
import { IconEventFilters } from './icons/event_filters';
import { IconExceptionLists } from './icons/exception_lists';
import { IconHostIsolation } from './icons/host_isolation';
import { IconSiemRules } from './icons/siem_rules';
import { IconTrustedApplications } from './icons/trusted_applications';
import { HostIsolationExceptionsApiClient } from './pages/host_isolation_exceptions/host_isolation_exceptions_api_client';
import { ExperimentalFeaturesService } from '../common/experimental_features_service';
import { KibanaServices } from '../common/lib/kibana';
const categories = [
{
label: i18n.translate('xpack.securitySolution.appLinks.category.siem', {
defaultMessage: 'SIEM',
}),
linkIds: [SecurityPageName.rules, SecurityPageName.exceptions],
},
{
label: i18n.translate('xpack.securitySolution.appLinks.category.endpoints', {
defaultMessage: 'ENDPOINTS',
}),
linkIds: [
SecurityPageName.endpoints,
SecurityPageName.policies,
SecurityPageName.trustedApps,
SecurityPageName.eventFilters,
SecurityPageName.hostIsolationExceptions,
SecurityPageName.blocklist,
SecurityPageName.responseActionsHistory,
],
},
...cloudSecurityPostureCategories,
];
export const links: LinkItem = {
id: SecurityPageName.administration,
title: MANAGE,
path: MANAGE_PATH,
skipUrlState: true,
hideTimeline: true,
globalNavPosition: 8,
capabilities: [`${SERVER_APP_ID}.show`],
globalSearchKeywords: [
i18n.translate('xpack.securitySolution.appLinks.manage', {
defaultMessage: 'Manage',
}),
],
categories,
links: [
{
id: SecurityPageName.rules,
title: RULES,
description: i18n.translate('xpack.securitySolution.appLinks.rulesDescription', {
defaultMessage:
"Create and manage rules to check for suspicious source events, and create alerts when a rule's conditions are met.",
}),
landingIcon: IconSiemRules,
path: RULES_PATH,
globalSearchKeywords: [
i18n.translate('xpack.securitySolution.appLinks.rules', {
defaultMessage: 'Rules',
}),
],
links: [
{
id: SecurityPageName.rulesCreate,
title: CREATE_NEW_RULE,
path: RULES_CREATE_PATH,
skipUrlState: true,
hideTimeline: true,
},
],
},
{
id: SecurityPageName.exceptions,
title: EXCEPTIONS,
description: i18n.translate('xpack.securitySolution.appLinks.exceptionsDescription', {
defaultMessage: 'Create and manage exceptions to prevent the creation of unwanted alerts.',
}),
landingIcon: IconExceptionLists,
path: EXCEPTIONS_PATH,
skipUrlState: true,
hideTimeline: true,
globalSearchKeywords: [
i18n.translate('xpack.securitySolution.appLinks.exceptions', {
defaultMessage: 'Exception lists',
}),
],
links: [
{
id: SecurityPageName.exceptionListDetails,
title: LIST_DETAILS,
path: '',
skipUrlState: true,
},
],
},
{
id: SecurityPageName.endpoints,
description: i18n.translate('xpack.securitySolution.appLinks.endpointsDescription', {
defaultMessage: 'Hosts running Elastic Defend.',
}),
landingIcon: IconEndpoints,
title: ENDPOINTS,
path: ENDPOINTS_PATH,
skipUrlState: true,
hideTimeline: true,
},
{
id: SecurityPageName.policies,
title: POLICIES,
description: i18n.translate('xpack.securitySolution.appLinks.policiesDescription', {
defaultMessage:
'Use policies to customize endpoint and cloud workload protections and other configurations.',
}),
landingIcon: IconEndpointPolicies,
path: POLICIES_PATH,
skipUrlState: true,
hideTimeline: true,
experimentalKey: 'policyListEnabled',
},
{
id: SecurityPageName.trustedApps,
title: TRUSTED_APPLICATIONS,
description: i18n.translate(
'xpack.securitySolution.appLinks.trustedApplicationsDescription',
{
defaultMessage:
'Improve performance or alleviate conflicts with other applications running on your hosts.',
}
),
landingIcon: IconTrustedApplications,
path: TRUSTED_APPS_PATH,
skipUrlState: true,
hideTimeline: true,
},
{
id: SecurityPageName.eventFilters,
title: EVENT_FILTERS,
description: i18n.translate('xpack.securitySolution.appLinks.eventFiltersDescription', {
defaultMessage: 'Exclude high volume or unwanted events being written into Elasticsearch.',
}),
landingIcon: IconEventFilters,
path: EVENT_FILTERS_PATH,
skipUrlState: true,
hideTimeline: true,
},
{
id: SecurityPageName.hostIsolationExceptions,
title: HOST_ISOLATION_EXCEPTIONS,
description: i18n.translate('xpack.securitySolution.appLinks.hostIsolationDescription', {
defaultMessage: 'Allow isolated hosts to communicate with specific IPs.',
}),
landingIcon: IconHostIsolation,
path: HOST_ISOLATION_EXCEPTIONS_PATH,
skipUrlState: true,
hideTimeline: true,
},
{
id: SecurityPageName.blocklist,
title: BLOCKLIST,
description: i18n.translate('xpack.securitySolution.appLinks.blocklistDescription', {
defaultMessage: 'Exclude unwanted applications from running on your hosts.',
}),
landingIcon: IconBlocklist,
path: BLOCKLIST_PATH,
skipUrlState: true,
hideTimeline: true,
},
{
id: SecurityPageName.responseActionsHistory,
title: RESPONSE_ACTIONS_HISTORY,
description: i18n.translate('xpack.securitySolution.appLinks.actionHistoryDescription', {
defaultMessage: 'View the history of response actions performed on hosts.',
}),
landingIcon: IconActionHistory,
path: RESPONSE_ACTIONS_HISTORY_PATH,
skipUrlState: true,
hideTimeline: true,
},
cloudSecurityPostureLinks,
],
};
const excludeLinks = (linkIds: SecurityPageName[]) => ({
...links,
links: links.links?.filter((link) => !linkIds.includes(link.id)),
});
export const getManagementFilteredLinks = async (
core: CoreStart,
plugins: StartPlugins
): Promise<LinkItem> => {
const fleetAuthz = plugins.fleet?.authz;
const { endpointRbacEnabled, endpointRbacV1Enabled } = ExperimentalFeaturesService.get();
const isEndpointRbacEnabled = endpointRbacEnabled || endpointRbacV1Enabled;
const endpointPermissions = calculatePermissionsFromCapabilities(core.application.capabilities);
const linksToExclude: SecurityPageName[] = [];
const currentUser = await plugins.security.authc.getCurrentUser();
const isPlatinumPlus = licenseService.isPlatinumPlus();
let hasHostIsolationExceptions: boolean = isPlatinumPlus;
// If not Platinum+ license and user has read permissions to security solution
// then check if Host Isolation Exceptions exist.
// *** IT IS IMPORTANT *** that this HTTP call only be made if the user has access to the
// Lists plugin, else non-security solution users, especially when license is not Platinum,
// may see failed HTTP requests in the browser console. This is the reason that
// `hasKibanaPrivilege()` is used below.
if (
!isPlatinumPlus &&
fleetAuthz &&
hasKibanaPrivilege(
fleetAuthz,
isEndpointRbacEnabled,
currentUser.roles.includes('superuser'),
'readHostIsolationExceptions'
)
) {
hasHostIsolationExceptions = await checkArtifactHasData(
HostIsolationExceptionsApiClient.getInstance(KibanaServices.get().http)
);
}
const { canReadActionsLogManagement, canReadHostIsolationExceptions } = fleetAuthz
? calculateEndpointAuthz(
licenseService,
fleetAuthz,
currentUser.roles,
isEndpointRbacEnabled,
endpointPermissions,
hasHostIsolationExceptions
)
: getEndpointAuthzInitialState();
if (!canReadActionsLogManagement) {
linksToExclude.push(SecurityPageName.responseActionsHistory);
}
if (!canReadHostIsolationExceptions) {
linksToExclude.push(SecurityPageName.hostIsolationExceptions);
}
return excludeLinks(linksToExclude);
};