/* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 */ import { EuiBadge, EuiCodeBlock, EuiFlexGroup, EuiFlexItem, EuiFormLabel, EuiFormRow, EuiLink, EuiModalBody, EuiSpacer, EuiText, EuiButtonGroup, } from '@elastic/eui'; import { DEFAULT_EMPTY_DATA } from '../../../../utils/constants'; import React, { useState } from 'react'; import { RuleContentYamlViewer } from './RuleContentYamlViewer'; import { RuleItemInfoBase } from '../../../../../types'; export interface RuleContentViewerProps { rule: RuleItemInfoBase; } const editorTypes = [ { id: 'visual', label: 'Visual', }, { id: 'yaml', label: 'YAML', }, ]; export const RuleContentViewer: React.FC = ({ rule: { prePackaged, _source: ruleData, _id: ruleId }, }) => { if (!ruleData.id) { ruleData.id = ruleId; } const [selectedEditorType, setSelectedEditorType] = useState('visual'); const onEditorTypeChange = (optionId: string) => { setSelectedEditorType(optionId); }; return ( onEditorTypeChange(id)} /> {selectedEditorType === 'visual' && ( <> Rule Name {ruleData.title} Log Type {ruleData.category} Description {ruleData.description || DEFAULT_EMPTY_DATA} Last Updated {ruleData.last_update_time} Author {ruleData.author} Source {prePackaged ? 'Sigma' : 'Custom'} {prePackaged ? ( License Detection Rule License (DLR) ) : null} Rule level {ruleData.level} Tags {ruleData.tags.length > 0 ? ( {ruleData.tags.map((tag: any, i: number) => ( {tag.value} ))} ) : (
{DEFAULT_EMPTY_DATA}
)} References {ruleData.references.length > 0 ? ( ruleData.references.map((reference: any, i: number) => (
{reference.value}
)) ) : (
{DEFAULT_EMPTY_DATA}
)} False positive cases
{ruleData.false_positives.length > 0 ? ( ruleData.false_positives.map((falsepositive: any, i: number) => (
{falsepositive.value}
)) ) : (
{DEFAULT_EMPTY_DATA}
)}
Rule Status
{ruleData.status}
{ruleData.detection} )} {selectedEditorType === 'yaml' && ( )}
); };