Skip to content

Commit

Permalink
added addition check for filtering rendered rules (#1022)
Browse files Browse the repository at this point in the history
Signed-off-by: Amardeepsingh Siglani <[email protected]>
  • Loading branch information
amsiglan authored May 9, 2024
1 parent b413066 commit 74f8c84
Showing 1 changed file with 79 additions and 70 deletions.
149 changes: 79 additions & 70 deletions public/pages/Findings/components/FindingDetailsFlyout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -234,79 +234,88 @@ export default class FindingDetailsFlyout extends Component<
this.setState({ ...this.state, ruleViewerFlyoutData: null });
};

shouldRenderRule = ({ id }: Query) => {
const { allRules = {} } = this.state;
const isSigmaRule = !!allRules[id];

if (!isSigmaRule) {
return false;
}

return !isThreatIntelQuery(id);
};

renderRuleDetails = (rules: Query[] = []) => {
const { allRules = {} } = this.state;
return rules
.filter(({ id }) => !isThreatIntelQuery(id))
.map((rule, key) => {
const fullRule = allRules[rule.id];
const severity = capitalizeFirstLetter(fullRule.level);
return (
<div key={key}>
<EuiAccordion
id={`${key}`}
buttonClassName="euiAccordionForm__button"
buttonContent={
<div data-test-subj={'finding-details-flyout-rule-accordion-button'}>
<EuiText size={'s'}>{fullRule.title}</EuiText>
<EuiText size={'s'} color={'subdued'}>
Severity: {severity}
</EuiText>
</div>
}
initialIsOpen={rules.length === 1}
data-test-subj={`finding-details-flyout-rule-accordion-${key}`}
>
<EuiPanel color="subdued">
<EuiFlexGroup>
<EuiFlexItem>
<EuiFormRow label={'Rule name'}>
<EuiLink
onClick={() => this.showRuleDetails(fullRule, rule.id)}
data-test-subj={`finding-details-flyout-${fullRule.title}-details`}
>
{fullRule.title || DEFAULT_EMPTY_DATA}
</EuiLink>
</EuiFormRow>
</EuiFlexItem>

<EuiFlexItem>
<EuiFormRow
label={'Rule severity'}
data-test-subj={'finding-details-flyout-rule-severity'}
>
<EuiText>{severity || DEFAULT_EMPTY_DATA}</EuiText>
</EuiFormRow>
</EuiFlexItem>

<EuiFlexItem>
<EuiFormRow
label={'Log type'}
data-test-subj={'finding-details-flyout-rule-category'}
return rules.filter(this.shouldRenderRule).map((rule, key) => {
const fullRule = allRules[rule.id];
const severity = capitalizeFirstLetter(fullRule.level);
return (
<div key={key}>
<EuiAccordion
id={`${key}`}
buttonClassName="euiAccordionForm__button"
buttonContent={
<div data-test-subj={'finding-details-flyout-rule-accordion-button'}>
<EuiText size={'s'}>{fullRule.title}</EuiText>
<EuiText size={'s'} color={'subdued'}>
Severity: {severity}
</EuiText>
</div>
}
initialIsOpen={rules.length === 1}
data-test-subj={`finding-details-flyout-rule-accordion-${key}`}
>
<EuiPanel color="subdued">
<EuiFlexGroup>
<EuiFlexItem>
<EuiFormRow label={'Rule name'}>
<EuiLink
onClick={() => this.showRuleDetails(fullRule, rule.id)}
data-test-subj={`finding-details-flyout-${fullRule.title}-details`}
>
<EuiText>{getLogTypeLabel(fullRule.category) || DEFAULT_EMPTY_DATA}</EuiText>
</EuiFormRow>
</EuiFlexItem>
</EuiFlexGroup>

<EuiFormRow
label={'Description'}
data-test-subj={'finding-details-flyout-rule-description'}
>
<EuiText>{fullRule.description || DEFAULT_EMPTY_DATA}</EuiText>
</EuiFormRow>

<EuiSpacer size={'m'} />

<EuiFormRow label={'Tags'} data-test-subj={'finding-details-flyout-rule-tags'}>
<EuiText>{this.renderTags(rule.tags) || DEFAULT_EMPTY_DATA}</EuiText>
</EuiFormRow>
</EuiPanel>
</EuiAccordion>
{rules.length > 1 && <EuiHorizontalRule margin={'xs'} />}
</div>
);
});
{fullRule.title || DEFAULT_EMPTY_DATA}
</EuiLink>
</EuiFormRow>
</EuiFlexItem>

<EuiFlexItem>
<EuiFormRow
label={'Rule severity'}
data-test-subj={'finding-details-flyout-rule-severity'}
>
<EuiText>{severity || DEFAULT_EMPTY_DATA}</EuiText>
</EuiFormRow>
</EuiFlexItem>

<EuiFlexItem>
<EuiFormRow
label={'Log type'}
data-test-subj={'finding-details-flyout-rule-category'}
>
<EuiText>{getLogTypeLabel(fullRule.category) || DEFAULT_EMPTY_DATA}</EuiText>
</EuiFormRow>
</EuiFlexItem>
</EuiFlexGroup>

<EuiFormRow
label={'Description'}
data-test-subj={'finding-details-flyout-rule-description'}
>
<EuiText>{fullRule.description || DEFAULT_EMPTY_DATA}</EuiText>
</EuiFormRow>

<EuiSpacer size={'m'} />

<EuiFormRow label={'Tags'} data-test-subj={'finding-details-flyout-rule-tags'}>
<EuiText>{this.renderTags(rule.tags) || DEFAULT_EMPTY_DATA}</EuiText>
</EuiFormRow>
</EuiPanel>
</EuiAccordion>
{rules.length > 1 && <EuiHorizontalRule margin={'xs'} />}
</div>
);
});
};

getIndexPatternId = async () => {
Expand Down

0 comments on commit 74f8c84

Please sign in to comment.