From 68b49c2c4bb7fa925aa48c43f0562434a24fb352 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 12 Mar 2024 23:12:58 +0000 Subject: [PATCH] added more mime types for yaml file (#909) Signed-off-by: Amardeepsingh Siglani (cherry picked from commit 3812afd19a3724e4b9bcd2d30b344a77bb31d153) Signed-off-by: github-actions[bot] --- public/pages/Rules/containers/ImportRule/ImportRule.tsx | 3 ++- public/pages/Rules/utils/constants.ts | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/public/pages/Rules/containers/ImportRule/ImportRule.tsx b/public/pages/Rules/containers/ImportRule/ImportRule.tsx index b8bc76a0b..f666916b1 100644 --- a/public/pages/Rules/containers/ImportRule/ImportRule.tsx +++ b/public/pages/Rules/containers/ImportRule/ImportRule.tsx @@ -16,6 +16,7 @@ import { NotificationsStart } from 'opensearch-dashboards/public'; import { CoreServicesContext } from '../../../../components/core_services'; import { setBreadCrumb, validateRule } from '../../utils/helpers'; import { DataStore } from '../../../../store/DataStore'; +import { yamlMediaTypes } from '../../utils/constants'; export interface ImportRuleProps { services: BrowserServices; @@ -29,7 +30,7 @@ export const ImportRule: React.FC = ({ history, services, notif const onChange = useCallback((files: any) => { setFileError(''); - if (files[0]?.type === 'application/x-yaml') { + if (yamlMediaTypes.has(files[0]?.type)) { let reader = new FileReader(); reader.readAsText(files[0]); reader.onload = function () { diff --git a/public/pages/Rules/utils/constants.ts b/public/pages/Rules/utils/constants.ts index a3780d277..7640d3759 100644 --- a/public/pages/Rules/utils/constants.ts +++ b/public/pages/Rules/utils/constants.ts @@ -50,3 +50,5 @@ export const ruleSeverity: { export const ruleSource: string[] = ['Sigma', 'Custom']; export const ruleStatus: string[] = ['experimental', 'test', 'stable']; + +export const yamlMediaTypes = new Set(['application/x-yaml', 'text/yaml', 'text/x-yaml']);