Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.13] Added addition check for filtering rendered rules in finding flyout #1024

Open
wants to merge 1 commit into
base: 2.13
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
149 changes: 79 additions & 70 deletions public/pages/Findings/components/FindingDetailsFlyout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -233,79 +233,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
Loading