Skip to content

Commit e2d2cbf

Browse files
committed
[Cloud Security] handle both rule.references and rule.reference in misconfiguraiton flyout (#195932)
## Summary Fixes: - elastic/security-team#10793 (cherry picked from commit cc46549)
1 parent 93e770c commit e2d2cbf

2 files changed

Lines changed: 100 additions & 95 deletions

File tree

  • x-pack
    • packages/kbn-cloud-security-posture-common/schema/rules
    • plugins/cloud_security_posture/public/pages/configurations/findings_flyout

x-pack/packages/kbn-cloud-security-posture-common/schema/rules/v3.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export const cspBenchmarkRuleMetadataSchema = schema.object({
3737
profile_applicability: schema.string(),
3838
rationale: schema.string(),
3939
references: schema.maybe(schema.string()),
40+
reference: schema.maybe(schema.string()),
4041
rego_rule_id: schema.string(),
4142
remediation: schema.string(),
4243
section: schema.string(),

x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/rule_tab.tsx

Lines changed: 99 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -13,111 +13,115 @@ import type { CspFinding } from '@kbn/cloud-security-posture-common';
1313
import { RulesDetectionRuleCounter } from '../../rules/rules_detection_rule_counter';
1414
import { BenchmarkIcons, CspFlyoutMarkdown, EMPTY_VALUE, RuleNameLink } from './findings_flyout';
1515

16+
const getReferenceFromRule = (rule?: CspFinding['rule']) => {
17+
return rule?.reference || rule?.references;
18+
};
19+
1620
export const getRuleList = (
1721
rule?: CspFinding['rule'],
1822
ruleState = 'unmuted',
1923
ruleFlyoutLink?: string
20-
) => [
21-
{
22-
title: i18n.translate('xpack.csp.findings.findingsFlyout.ruleTab.nameTitle', {
23-
defaultMessage: 'Name',
24-
}),
25-
description: rule?.name ? (
26-
<RuleNameLink ruleFlyoutLink={ruleFlyoutLink} ruleName={rule.name} />
27-
) : (
28-
EMPTY_VALUE
29-
),
30-
},
31-
{
32-
title: i18n.translate('xpack.csp.findings.findingsFlyout.ruleTab.descriptionTitle', {
33-
defaultMessage: 'Description',
34-
}),
35-
description: rule?.description ? (
36-
<CspFlyoutMarkdown>{rule.description}</CspFlyoutMarkdown>
37-
) : (
38-
EMPTY_VALUE
39-
),
40-
},
41-
{
42-
title: i18n.translate('xpack.csp.findings.findingsFlyout.ruleTab.AlertsTitle', {
43-
defaultMessage: 'Alerts',
44-
}),
45-
description:
46-
ruleState === 'muted' ? (
47-
<FormattedMessage
48-
id="xpack.csp.findings.findingsFlyout.ruleTab.disabledRuleText"
49-
defaultMessage="Disabled"
50-
/>
51-
) : rule?.benchmark?.name ? (
52-
<RulesDetectionRuleCounter benchmarkRule={rule} />
24+
) => {
25+
const reference = getReferenceFromRule(rule);
26+
27+
return [
28+
{
29+
title: i18n.translate('xpack.csp.findings.findingsFlyout.ruleTab.nameTitle', {
30+
defaultMessage: 'Name',
31+
}),
32+
description: rule?.name ? (
33+
<RuleNameLink ruleFlyoutLink={ruleFlyoutLink} ruleName={rule.name} />
34+
) : (
35+
EMPTY_VALUE
36+
),
37+
},
38+
{
39+
title: i18n.translate('xpack.csp.findings.findingsFlyout.ruleTab.descriptionTitle', {
40+
defaultMessage: 'Description',
41+
}),
42+
description: rule?.description ? (
43+
<CspFlyoutMarkdown>{rule.description}</CspFlyoutMarkdown>
5344
) : (
5445
EMPTY_VALUE
5546
),
56-
},
57-
{
58-
title: i18n.translate('xpack.csp.findings.findingsFlyout.ruleTab.tagsTitle', {
59-
defaultMessage: 'Tags',
60-
}),
61-
description: rule?.tags?.length ? (
62-
<>
63-
{rule.tags.map((tag) => (
64-
<EuiBadge key={tag}>{tag}</EuiBadge>
65-
))}
66-
</>
67-
) : (
68-
EMPTY_VALUE
69-
),
70-
},
71-
{
72-
title: i18n.translate('xpack.csp.findings.findingsFlyout.ruleTab.frameworkSourcesTitle', {
73-
defaultMessage: 'Framework Sources',
74-
}),
75-
description:
76-
rule?.benchmark?.id && rule?.benchmark?.name ? (
77-
<BenchmarkIcons benchmarkId={rule.benchmark.id} benchmarkName={rule.benchmark.name} />
47+
},
48+
{
49+
title: i18n.translate('xpack.csp.findings.findingsFlyout.ruleTab.AlertsTitle', {
50+
defaultMessage: 'Alerts',
51+
}),
52+
description:
53+
ruleState === 'muted' ? (
54+
<FormattedMessage
55+
id="xpack.csp.findings.findingsFlyout.ruleTab.disabledRuleText"
56+
defaultMessage="Disabled"
57+
/>
58+
) : rule?.benchmark?.name ? (
59+
<RulesDetectionRuleCounter benchmarkRule={rule} />
60+
) : (
61+
EMPTY_VALUE
62+
),
63+
},
64+
{
65+
title: i18n.translate('xpack.csp.findings.findingsFlyout.ruleTab.tagsTitle', {
66+
defaultMessage: 'Tags',
67+
}),
68+
description: rule?.tags?.length ? (
69+
<>
70+
{rule.tags.map((tag) => (
71+
<EuiBadge key={tag}>{tag}</EuiBadge>
72+
))}
73+
</>
7874
) : (
7975
EMPTY_VALUE
8076
),
81-
},
82-
{
83-
title: i18n.translate('xpack.csp.findings.findingsFlyout.ruleTab.cisSectionTitle', {
84-
defaultMessage: 'Framework Section',
85-
}),
86-
description: rule?.section || EMPTY_VALUE,
87-
},
88-
{
89-
title: i18n.translate('xpack.csp.findings.findingsFlyout.ruleTab.profileApplicabilityTitle', {
90-
defaultMessage: 'Profile Applicability',
91-
}),
92-
description: rule?.profile_applicability ? (
93-
<CspFlyoutMarkdown>{rule.profile_applicability}</CspFlyoutMarkdown>
94-
) : (
95-
EMPTY_VALUE
96-
),
97-
},
98-
{
99-
title: i18n.translate('xpack.csp.findings.findingsFlyout.ruleTab.benchmarkTitle', {
100-
defaultMessage: 'Benchmark',
101-
}),
102-
description: rule?.benchmark?.name || EMPTY_VALUE,
103-
},
104-
{
105-
title: i18n.translate('xpack.csp.findings.findingsFlyout.ruleTab.auditTitle', {
106-
defaultMessage: 'Audit',
107-
}),
108-
description: rule?.audit ? <CspFlyoutMarkdown>{rule.audit}</CspFlyoutMarkdown> : EMPTY_VALUE,
109-
},
110-
{
111-
title: i18n.translate('xpack.csp.findings.findingsFlyout.ruleTab.referencesTitle', {
112-
defaultMessage: 'References',
113-
}),
114-
description: rule?.references ? (
115-
<CspFlyoutMarkdown>{rule.references}</CspFlyoutMarkdown>
116-
) : (
117-
EMPTY_VALUE
118-
),
119-
},
120-
];
77+
},
78+
{
79+
title: i18n.translate('xpack.csp.findings.findingsFlyout.ruleTab.frameworkSourcesTitle', {
80+
defaultMessage: 'Framework Sources',
81+
}),
82+
description:
83+
rule?.benchmark?.id && rule?.benchmark?.name ? (
84+
<BenchmarkIcons benchmarkId={rule.benchmark.id} benchmarkName={rule.benchmark.name} />
85+
) : (
86+
EMPTY_VALUE
87+
),
88+
},
89+
{
90+
title: i18n.translate('xpack.csp.findings.findingsFlyout.ruleTab.cisSectionTitle', {
91+
defaultMessage: 'Framework Section',
92+
}),
93+
description: rule?.section || EMPTY_VALUE,
94+
},
95+
{
96+
title: i18n.translate('xpack.csp.findings.findingsFlyout.ruleTab.profileApplicabilityTitle', {
97+
defaultMessage: 'Profile Applicability',
98+
}),
99+
description: rule?.profile_applicability ? (
100+
<CspFlyoutMarkdown>{rule.profile_applicability}</CspFlyoutMarkdown>
101+
) : (
102+
EMPTY_VALUE
103+
),
104+
},
105+
{
106+
title: i18n.translate('xpack.csp.findings.findingsFlyout.ruleTab.benchmarkTitle', {
107+
defaultMessage: 'Benchmark',
108+
}),
109+
description: rule?.benchmark?.name || EMPTY_VALUE,
110+
},
111+
{
112+
title: i18n.translate('xpack.csp.findings.findingsFlyout.ruleTab.auditTitle', {
113+
defaultMessage: 'Audit',
114+
}),
115+
description: rule?.audit ? <CspFlyoutMarkdown>{rule.audit}</CspFlyoutMarkdown> : EMPTY_VALUE,
116+
},
117+
{
118+
title: i18n.translate('xpack.csp.findings.findingsFlyout.ruleTab.referencesTitle', {
119+
defaultMessage: 'References',
120+
}),
121+
description: reference ? <CspFlyoutMarkdown>{reference}</CspFlyoutMarkdown> : EMPTY_VALUE,
122+
},
123+
];
124+
};
121125

122126
export const RuleTab = ({
123127
data,

0 commit comments

Comments
 (0)