From 81638035490a8e02ca5f255a2237622592b191ee Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Wed, 13 Mar 2024 13:22:33 +0530 Subject: [PATCH] added more mime types for yaml file (#909) (#916) (cherry picked from commit 3812afd19a3724e4b9bcd2d30b344a77bb31d153) Signed-off-by: Amardeepsingh Siglani Signed-off-by: github-actions[bot] Co-authored-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 f389e721e..0e86b6d2c 100644 --- a/public/pages/Rules/utils/constants.ts +++ b/public/pages/Rules/utils/constants.ts @@ -34,3 +34,5 @@ export const ruleSeverity: { name: string; value: string; priority: string; colo 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']);