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']);