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

[Cases] Integrating file service and registering file kinds #152031

Merged
merged 29 commits into from
Mar 2, 2023
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
81b27ad
Adding file service into cases
jonathan-buttner Feb 23, 2023
8cabedd
Merge branch 'main' of github.com:elastic/kibana into cases-files-be
jonathan-buttner Feb 23, 2023
b2f75f3
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Feb 23, 2023
a6c62bf
Typing owner info
jonathan-buttner Feb 23, 2023
869474a
Adding more mime types
jonathan-buttner Feb 23, 2023
770253e
Adding initial tests
jonathan-buttner Feb 23, 2023
03e450b
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Feb 23, 2023
3314aa9
Moving to integration directory and adding more
jonathan-buttner Feb 24, 2023
75e71d5
Merge branch 'cases-files-be' of github.com:jonathan-buttner/kibana i…
jonathan-buttner Feb 24, 2023
50f806a
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Feb 24, 2023
73d55bc
Adding delete test
jonathan-buttner Feb 27, 2023
4e6b026
Merge branch 'cases-files-be' of github.com:jonathan-buttner/kibana i…
jonathan-buttner Feb 27, 2023
a8e0344
Merge branch 'main' of github.com:elastic/kibana into cases-files-be
jonathan-buttner Feb 27, 2023
6d36d1a
Adding image file size limit
jonathan-buttner Feb 27, 2023
4163a04
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Feb 27, 2023
6407130
Removing duplicate mime types
jonathan-buttner Feb 27, 2023
8316e85
Merge branch 'cases-files-be' of github.com:jonathan-buttner/kibana i…
jonathan-buttner Feb 27, 2023
c4e09a5
Merge branch 'main' into cases-files-be
jonathan-buttner Feb 27, 2023
89c50f7
Merge branch 'main' into cases-files-be
jonathan-buttner Feb 27, 2023
71e8482
Merge branch 'main' into cases-files-be
jonathan-buttner Feb 27, 2023
b9cb6a5
Merge branch 'main' into cases-files-be
jonathan-buttner Feb 27, 2023
218b2ac
Addressing feedback
jonathan-buttner Feb 28, 2023
69aab41
Merge branch 'cases-files-be' of github.com:jonathan-buttner/kibana i…
jonathan-buttner Feb 28, 2023
fb62610
Making files plugin required for observability
jonathan-buttner Feb 28, 2023
9828325
Merge branch 'main' into cases-files-be
jonathan-buttner Feb 28, 2023
d4dcc78
Merge branch 'main' into cases-files-be
jonathan-buttner Feb 28, 2023
5bd1018
Merge branch 'main' of github.com:elastic/kibana into cases-files-be
jonathan-buttner Mar 1, 2023
e8d2639
Addressing feedback
jonathan-buttner Mar 1, 2023
506d718
Fixing tests
jonathan-buttner Mar 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions x-pack/plugins/cases/common/constants/application.ts
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;
14 changes: 14 additions & 0 deletions x-pack/plugins/cases/common/constants/files.ts
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}`;
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,15 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { CASE_VIEW_PAGE_TABS } from './types';
import type { CasesFeaturesAllRequired } from './ui/types';

export const DEFAULT_DATE_FORMAT = 'dateFormat' as const;
export const DEFAULT_DATE_FORMAT_TZ = 'dateFormat:tz' as const;

/**
* Application
*/
import type { CasesFeaturesAllRequired } from '../ui/types';

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;
export * from './owners';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split this file up to move the file service constants to their own place and moved various other constants to avoid circular references.

export * from './files';
export * from './application';

/**
* 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;
export const DEFAULT_DATE_FORMAT = 'dateFormat' as const;
export const DEFAULT_DATE_FORMAT_TZ = 'dateFormat:tz' as const;

/**
* Saved objects
Expand Down Expand Up @@ -111,37 +92,6 @@ export const CONNECTORS_URL = `${ACTION_URL}/connectors` as const;
*/
export const MAX_ALERTS_PER_CASE = 1000 as const;

/**
* 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 OWNER_INFO = {
[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;

/**
* Searching
*/
Expand Down Expand Up @@ -186,6 +136,20 @@ export const UPDATE_CASES_CAPABILITY = 'update_cases' as const;
export const DELETE_CASES_CAPABILITY = 'delete_cases' as const;
export const PUSH_CASES_CAPABILITY = 'push_cases' as const;

/**
* Cases API Tags
*/

/**
* This tag registered for the cases suggest user profiles API
*/
export const SUGGEST_USER_PROFILES_API_TAG = 'casesSuggestUserProfiles';

/**
* This tag is registered for the security bulk get API
*/
export const BULK_GET_USER_PROFILES_API_TAG = 'bulkGetUserProfiles';

/**
* User profiles
*/
Expand Down
110 changes: 110 additions & 0 deletions x-pack/plugins/cases/common/constants/mime_types.ts
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',
];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, extensive!!


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);
50 changes: 50 additions & 0 deletions x-pack/plugins/cases/common/constants/owners.ts
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;
17 changes: 17 additions & 0 deletions x-pack/plugins/cases/common/constants/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* 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',
Update = 'Update',
Delete = 'Delete',
}

export type Owner = typeof OWNERS[number];
1 change: 1 addition & 0 deletions x-pack/plugins/cases/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,4 @@ export { StatusAll } from './ui/types';

export { getCreateConnectorUrl, getAllConnectorsUrl } from './utils/connectors_api';
export { createUICapabilities } from './utils/capabilities';
export { getApiTags } from './utils/api_tags';

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading