-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* rewrote rules pages Signed-off-by: Amardeepsingh Siglani <[email protected]> * removed unwanted changed Signed-off-by: Amardeepsingh Siglani <[email protected]> Signed-off-by: Amardeepsingh Siglani <[email protected]>
- Loading branch information
Showing
48 changed files
with
1,371 additions
and
2,271 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { EuiConfirmModal } from '@elastic/eui'; | ||
import React from 'react'; | ||
|
||
export interface DeleteRuleModalProps { | ||
title: string; | ||
onCancel: () => void; | ||
onConfirm: () => void; | ||
} | ||
|
||
export const DeleteRuleModal: React.FC<DeleteRuleModalProps> = ({ title, onCancel, onConfirm }) => { | ||
return ( | ||
<EuiConfirmModal | ||
title={`Delete ${title}?`} | ||
onCancel={onCancel} | ||
onConfirm={onConfirm} | ||
cancelButtonText="Cancel" | ||
confirmButtonText="Delete" | ||
buttonColor="danger" | ||
defaultFocusedButton="confirm" | ||
> | ||
<p>Delete the rule permanently? This action cannot be undone.</p> | ||
</EuiConfirmModal> | ||
); | ||
}; |
148 changes: 148 additions & 0 deletions
148
public/pages/Rules/components/RuleContentViewer/RuleContentViewer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { | ||
EuiBadge, | ||
EuiCodeBlock, | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
EuiFormLabel, | ||
EuiFormRow, | ||
EuiLink, | ||
EuiModalBody, | ||
EuiSpacer, | ||
EuiText, | ||
} from '@elastic/eui'; | ||
import { DEFAULT_EMPTY_DATA } from '../../../../utils/constants'; | ||
import React from 'react'; | ||
import { RuleItemInfoBase } from '../../models/types'; | ||
|
||
export interface RuleContentViewerProps { | ||
rule: RuleItemInfoBase; | ||
} | ||
|
||
export const RuleContentViewer: React.FC<RuleContentViewerProps> = ({ | ||
rule: { prePackaged, _source: ruleData }, | ||
}) => { | ||
return ( | ||
<EuiModalBody> | ||
<EuiFlexGroup justifyContent="flexEnd"> | ||
<EuiFlexItem> | ||
<EuiFormLabel>Rule Name</EuiFormLabel> | ||
<EuiText>{ruleData.title}</EuiText> | ||
</EuiFlexItem> | ||
<EuiFlexItem> | ||
<EuiFormLabel>Log Type</EuiFormLabel> | ||
<EuiText>{ruleData.category}</EuiText> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
|
||
<EuiSpacer /> | ||
|
||
<EuiFormLabel>Description</EuiFormLabel> | ||
<EuiText>{ruleData.description || DEFAULT_EMPTY_DATA}</EuiText> | ||
<EuiSpacer /> | ||
|
||
<EuiFlexGroup justifyContent="flexEnd"> | ||
<EuiFlexItem> | ||
<EuiFormLabel>Last Updated</EuiFormLabel> | ||
{ruleData.last_update_time} | ||
</EuiFlexItem> | ||
<EuiFlexItem> | ||
<EuiFormLabel>Author</EuiFormLabel> | ||
{ruleData.author} | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
|
||
<EuiSpacer /> | ||
|
||
<EuiFlexGroup justifyContent="flexEnd"> | ||
<EuiFlexItem> | ||
<EuiFormLabel>Source</EuiFormLabel> | ||
{prePackaged ? 'Sigma' : 'Custom'} | ||
</EuiFlexItem> | ||
{prePackaged ? ( | ||
<EuiFlexItem> | ||
<EuiFormLabel>License</EuiFormLabel> | ||
<EuiLink | ||
target={'_blank'} | ||
href={'https://github.com/SigmaHQ/sigma/blob/master/LICENSE.Detection.Rules.md'} | ||
> | ||
Detection Rule License (DLR) | ||
</EuiLink> | ||
</EuiFlexItem> | ||
) : null} | ||
</EuiFlexGroup> | ||
|
||
<EuiSpacer /> | ||
|
||
<EuiFlexGroup justifyContent="flexEnd"> | ||
<EuiFlexItem> | ||
<EuiFormLabel>Rule level</EuiFormLabel> | ||
{ruleData.level} | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
|
||
<EuiSpacer /> | ||
|
||
<EuiFormLabel>Tags</EuiFormLabel> | ||
{ruleData.tags.length > 0 ? ( | ||
<EuiFlexGroup direction="row"> | ||
{ruleData.tags.map((tag: any, i: number) => ( | ||
<EuiFlexItem grow={false} key={i}> | ||
<EuiBadge color={'#DDD'}>{tag.value}</EuiBadge> | ||
</EuiFlexItem> | ||
))} | ||
</EuiFlexGroup> | ||
) : ( | ||
<div>{DEFAULT_EMPTY_DATA}</div> | ||
)} | ||
|
||
<EuiSpacer /> | ||
<EuiSpacer /> | ||
|
||
<EuiFormLabel>References</EuiFormLabel> | ||
{ruleData.references.length > 0 ? ( | ||
ruleData.references.map((reference: any, i: number) => ( | ||
<div key={i}> | ||
<EuiLink href={reference.value} target="_blank" key={reference}> | ||
{reference.value} | ||
</EuiLink> | ||
<EuiSpacer /> | ||
</div> | ||
)) | ||
) : ( | ||
<div>{DEFAULT_EMPTY_DATA}</div> | ||
)} | ||
|
||
<EuiSpacer /> | ||
|
||
<EuiFormLabel>False positive cases</EuiFormLabel> | ||
<div> | ||
{ruleData.false_positives.length > 0 ? ( | ||
ruleData.false_positives.map((falsepositive: any, i: number) => ( | ||
<div key={i}> | ||
{falsepositive.value} | ||
<EuiSpacer /> | ||
</div> | ||
)) | ||
) : ( | ||
<div>{DEFAULT_EMPTY_DATA}</div> | ||
)} | ||
</div> | ||
|
||
<EuiSpacer /> | ||
|
||
<EuiFormLabel>Rule Status</EuiFormLabel> | ||
<div>{ruleData.status}</div> | ||
|
||
<EuiSpacer /> | ||
|
||
<EuiFormRow label="Detection" fullWidth> | ||
<EuiCodeBlock language="yaml">{ruleData.detection}</EuiCodeBlock> | ||
</EuiFormRow> | ||
</EuiModalBody> | ||
); | ||
}; |
71 changes: 71 additions & 0 deletions
71
public/pages/Rules/components/RuleEditor/FieldTextArray.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { | ||
EuiButton, | ||
EuiFieldText, | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
EuiFormRow, | ||
EuiSpacer, | ||
} from '@elastic/eui'; | ||
import React, { ChangeEvent } from 'react'; | ||
|
||
export interface FieldTextArrayProps { | ||
label: string; | ||
fields: string[]; | ||
addButtonName: string; | ||
onFieldEdit: (value: string, fieldIndex: number) => void; | ||
onFieldRemove: (fieldIndex: number) => void; | ||
onFieldAdd: () => void; | ||
} | ||
|
||
export const FieldTextArray: React.FC<FieldTextArrayProps> = ({ | ||
addButtonName, | ||
label, | ||
fields, | ||
onFieldEdit, | ||
onFieldRemove, | ||
onFieldAdd, | ||
}) => { | ||
return ( | ||
<> | ||
<EuiFormRow label={label}> | ||
<> | ||
{fields.map((ref: string, index: number) => { | ||
return ( | ||
<EuiFlexGroup key={index}> | ||
<EuiFlexItem style={{ minWidth: '100%' }}> | ||
<EuiFieldText | ||
value={ref} | ||
onChange={(e: ChangeEvent<HTMLInputElement>) => { | ||
onFieldEdit(e.target.value, index); | ||
}} | ||
/> | ||
</EuiFlexItem> | ||
{index > 0 ? ( | ||
<EuiFlexItem grow={false}> | ||
<EuiButton onClick={() => onFieldRemove(index)}>Remove</EuiButton> | ||
</EuiFlexItem> | ||
) : null} | ||
</EuiFlexGroup> | ||
); | ||
})} | ||
<EuiSpacer size="s" /> | ||
<EuiButton | ||
type="button" | ||
className="secondary" | ||
onClick={() => { | ||
onFieldAdd(); | ||
}} | ||
> | ||
{addButtonName} | ||
</EuiButton> | ||
</> | ||
</EuiFormRow> | ||
<EuiSpacer /> | ||
</> | ||
); | ||
}; |
Oops, something went wrong.