-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Cases] Integrating file service and registering file kinds (#152031)
This PR registers three file kinds for cases. One for each instance of cases (stack, observability, and security). Each solution needs separate http tags for the routes that are generated by the file service to implement RBAC. I refactored the logic to remove some duplication across the three plugins since we're essentially registering the same http tags with slightly different names. This PR shouldn't affect any of the current functionality. Notable changes: - I split up the constants.ts file, really the only change is adding the file kinds logic to generate the http tags the rest is copy/paste - Refactored the logic to generate the `api` http tags for each plugin - Registered the three file kinds Issues: #151780 #151933 --------- Co-authored-by: kibanamachine <[email protected]>
- Loading branch information
1 parent
54b2a4a
commit 7d81cf2
Showing
29 changed files
with
1,115 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* 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 { CASE_VIEW_PAGE_TABS } from '../types'; | ||
|
||
/** | ||
* Application | ||
*/ | ||
|
||
export const APP_ID = 'cases' as const; | ||
export const FEATURE_ID = 'generalCases' as const; | ||
export const APP_OWNER = 'cases' as const; | ||
export const APP_PATH = '/app/management/insightsAndAlerting/cases' as const; | ||
export const CASES_CREATE_PATH = '/create' as const; | ||
export const CASES_CONFIGURE_PATH = '/configure' as const; | ||
export const CASE_VIEW_PATH = '/:detailName' as const; | ||
export const CASE_VIEW_COMMENT_PATH = `${CASE_VIEW_PATH}/:commentId` as const; | ||
export const CASE_VIEW_ALERT_TABLE_PATH = | ||
`${CASE_VIEW_PATH}/?tabId=${CASE_VIEW_PAGE_TABS.ALERTS}` as const; | ||
export const CASE_VIEW_TAB_PATH = `${CASE_VIEW_PATH}/?tabId=:tabId` as const; | ||
|
||
/** | ||
* The main Cases application is in the stack management under the | ||
* Alerts and Insights section. To do that, Cases registers to the management | ||
* application. This constant holds the application ID of the management plugin | ||
*/ | ||
export const STACK_APP_ID = 'management' as const; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* 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 { HttpApiTagOperation, Owner } from './types'; | ||
|
||
export const MAX_FILE_SIZE = 100 * 1024 * 1024; // 100 MiB | ||
|
||
export const constructFilesHttpOperationTag = (owner: Owner, operation: HttpApiTagOperation) => { | ||
return `${owner}FilesCases${operation}`; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
/** | ||
* These were retrieved from https://www.iana.org/assignments/media-types/media-types.xhtml#image | ||
*/ | ||
const imageMimeTypes = [ | ||
'image/aces', | ||
'image/apng', | ||
'image/avci', | ||
'image/avcs', | ||
'image/avif', | ||
'image/bmp', | ||
'image/cgm', | ||
'image/dicom-rle', | ||
'image/dpx', | ||
'image/emf', | ||
'image/example', | ||
'image/fits', | ||
'image/g3fax', | ||
'image/heic', | ||
'image/heic-sequence', | ||
'image/heif', | ||
'image/heif-sequence', | ||
'image/hej2k', | ||
'image/hsj2', | ||
'image/jls', | ||
'image/jp2', | ||
'image/jpeg', | ||
'image/jph', | ||
'image/jphc', | ||
'image/jpm', | ||
'image/jpx', | ||
'image/jxr', | ||
'image/jxrA', | ||
'image/jxrS', | ||
'image/jxs', | ||
'image/jxsc', | ||
'image/jxsi', | ||
'image/jxss', | ||
'image/ktx', | ||
'image/ktx2', | ||
'image/naplps', | ||
'image/png', | ||
'image/prs.btif', | ||
'image/prs.pti', | ||
'image/pwg-raster', | ||
'image/svg+xml', | ||
'image/t38', | ||
'image/tiff', | ||
'image/tiff-fx', | ||
'image/vnd.adobe.photoshop', | ||
'image/vnd.airzip.accelerator.azv', | ||
'image/vnd.cns.inf2', | ||
'image/vnd.dece.graphic', | ||
'image/vnd.djvu', | ||
'image/vnd.dwg', | ||
'image/vnd.dxf', | ||
'image/vnd.dvb.subtitle', | ||
'image/vnd.fastbidsheet', | ||
'image/vnd.fpx', | ||
'image/vnd.fst', | ||
'image/vnd.fujixerox.edmics-mmr', | ||
'image/vnd.fujixerox.edmics-rlc', | ||
'image/vnd.globalgraphics.pgb', | ||
'image/vnd.microsoft.icon', | ||
'image/vnd.mix', | ||
'image/vnd.ms-modi', | ||
'image/vnd.mozilla.apng', | ||
'image/vnd.net-fpx', | ||
'image/vnd.pco.b16', | ||
'image/vnd.radiance', | ||
'image/vnd.sealed.png', | ||
'image/vnd.sealedmedia.softseal.gif', | ||
'image/vnd.sealedmedia.softseal.jpg', | ||
'image/vnd.svf', | ||
'image/vnd.tencent.tap', | ||
'image/vnd.valve.source.texture', | ||
'image/vnd.wap.wbmp', | ||
'image/vnd.xiff', | ||
'image/vnd.zbrush.pcx', | ||
'image/webp', | ||
'image/wmf', | ||
]; | ||
|
||
const textMimeTypes = ['text/plain', 'text/csv', 'text/json', 'application/json']; | ||
|
||
const compressionMimeTypes = [ | ||
'application/zip', | ||
'application/gzip', | ||
'application/x-bzip', | ||
'application/x-bzip2', | ||
'application/x-7z-compressed', | ||
'application/x-tar', | ||
]; | ||
|
||
const pdfMimeTypes = ['application/pdf']; | ||
|
||
export const ALLOWED_MIME_TYPES = [ | ||
...imageMimeTypes, | ||
...textMimeTypes, | ||
...compressionMimeTypes, | ||
...pdfMimeTypes, | ||
]; | ||
|
||
export const IMAGE_MIME_TYPES = new Set(imageMimeTypes); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* 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 { APP_ID } from './application'; | ||
import type { Owner } from './types'; | ||
|
||
/** | ||
* Owner | ||
*/ | ||
export const SECURITY_SOLUTION_OWNER = 'securitySolution' as const; | ||
export const OBSERVABILITY_OWNER = 'observability' as const; | ||
export const GENERAL_CASES_OWNER = APP_ID; | ||
|
||
export const OWNERS = [SECURITY_SOLUTION_OWNER, OBSERVABILITY_OWNER, GENERAL_CASES_OWNER] as const; | ||
|
||
interface RouteInfo { | ||
id: Owner; | ||
appId: string; | ||
label: string; | ||
iconType: string; | ||
appRoute: string; | ||
} | ||
|
||
export const OWNER_INFO: Record<Owner, RouteInfo> = { | ||
[SECURITY_SOLUTION_OWNER]: { | ||
id: SECURITY_SOLUTION_OWNER, | ||
appId: 'securitySolutionUI', | ||
label: 'Security', | ||
iconType: 'logoSecurity', | ||
appRoute: '/app/security', | ||
}, | ||
[OBSERVABILITY_OWNER]: { | ||
id: OBSERVABILITY_OWNER, | ||
appId: 'observability-overview', | ||
label: 'Observability', | ||
iconType: 'logoObservability', | ||
appRoute: '/app/observability', | ||
}, | ||
[GENERAL_CASES_OWNER]: { | ||
id: GENERAL_CASES_OWNER, | ||
appId: 'management', | ||
label: 'Stack', | ||
iconType: 'casesApp', | ||
appRoute: '/app/management/insightsAndAlerting', | ||
}, | ||
} as const; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* 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 { OWNERS } from './owners'; | ||
|
||
export enum HttpApiTagOperation { | ||
Read = 'Read', | ||
Create = 'Create', | ||
Delete = 'Delete', | ||
} | ||
|
||
export type Owner = typeof OWNERS[number]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
x-pack/plugins/cases/common/utils/__snapshots__/api_tags.test.ts.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.