-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Cloud Security] handle both rule.references and rule.reference in misconfiguraiton flyout #195932
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,111 +13,115 @@ import type { CspFinding } from '@kbn/cloud-security-posture-common'; | |
import { RulesDetectionRuleCounter } from '../../rules/rules_detection_rule_counter'; | ||
import { BenchmarkIcons, CspFlyoutMarkdown, EMPTY_VALUE, RuleNameLink } from './findings_flyout'; | ||
|
||
const getReferenceFromRule = (rule?: CspFinding['rule']) => { | ||
return rule?.reference || rule?.references; | ||
}; | ||
|
||
export const getRuleList = ( | ||
rule?: CspFinding['rule'], | ||
ruleState = 'unmuted', | ||
ruleFlyoutLink?: string | ||
) => [ | ||
{ | ||
title: i18n.translate('xpack.csp.findings.findingsFlyout.ruleTab.nameTitle', { | ||
defaultMessage: 'Name', | ||
}), | ||
description: rule?.name ? ( | ||
<RuleNameLink ruleFlyoutLink={ruleFlyoutLink} ruleName={rule.name} /> | ||
) : ( | ||
EMPTY_VALUE | ||
), | ||
}, | ||
{ | ||
title: i18n.translate('xpack.csp.findings.findingsFlyout.ruleTab.descriptionTitle', { | ||
defaultMessage: 'Description', | ||
}), | ||
description: rule?.description ? ( | ||
<CspFlyoutMarkdown>{rule.description}</CspFlyoutMarkdown> | ||
) : ( | ||
EMPTY_VALUE | ||
), | ||
}, | ||
{ | ||
title: i18n.translate('xpack.csp.findings.findingsFlyout.ruleTab.AlertsTitle', { | ||
defaultMessage: 'Alerts', | ||
}), | ||
description: | ||
ruleState === 'muted' ? ( | ||
<FormattedMessage | ||
id="xpack.csp.findings.findingsFlyout.ruleTab.disabledRuleText" | ||
defaultMessage="Disabled" | ||
/> | ||
) : rule?.benchmark?.name ? ( | ||
<RulesDetectionRuleCounter benchmarkRule={rule} /> | ||
) => { | ||
const reference = getReferenceFromRule(rule); | ||
|
||
return [ | ||
{ | ||
title: i18n.translate('xpack.csp.findings.findingsFlyout.ruleTab.nameTitle', { | ||
defaultMessage: 'Name', | ||
}), | ||
description: rule?.name ? ( | ||
<RuleNameLink ruleFlyoutLink={ruleFlyoutLink} ruleName={rule.name} /> | ||
) : ( | ||
EMPTY_VALUE | ||
), | ||
}, | ||
{ | ||
title: i18n.translate('xpack.csp.findings.findingsFlyout.ruleTab.descriptionTitle', { | ||
defaultMessage: 'Description', | ||
}), | ||
description: rule?.description ? ( | ||
<CspFlyoutMarkdown>{rule.description}</CspFlyoutMarkdown> | ||
) : ( | ||
EMPTY_VALUE | ||
), | ||
}, | ||
{ | ||
title: i18n.translate('xpack.csp.findings.findingsFlyout.ruleTab.tagsTitle', { | ||
defaultMessage: 'Tags', | ||
}), | ||
description: rule?.tags?.length ? ( | ||
<> | ||
{rule.tags.map((tag) => ( | ||
<EuiBadge key={tag}>{tag}</EuiBadge> | ||
))} | ||
</> | ||
) : ( | ||
EMPTY_VALUE | ||
), | ||
}, | ||
{ | ||
title: i18n.translate('xpack.csp.findings.findingsFlyout.ruleTab.frameworkSourcesTitle', { | ||
defaultMessage: 'Framework Sources', | ||
}), | ||
description: | ||
rule?.benchmark?.id && rule?.benchmark?.name ? ( | ||
<BenchmarkIcons benchmarkId={rule.benchmark.id} benchmarkName={rule.benchmark.name} /> | ||
}, | ||
{ | ||
title: i18n.translate('xpack.csp.findings.findingsFlyout.ruleTab.AlertsTitle', { | ||
defaultMessage: 'Alerts', | ||
}), | ||
description: | ||
ruleState === 'muted' ? ( | ||
<FormattedMessage | ||
id="xpack.csp.findings.findingsFlyout.ruleTab.disabledRuleText" | ||
defaultMessage="Disabled" | ||
/> | ||
) : rule?.benchmark?.name ? ( | ||
<RulesDetectionRuleCounter benchmarkRule={rule} /> | ||
) : ( | ||
EMPTY_VALUE | ||
), | ||
}, | ||
{ | ||
title: i18n.translate('xpack.csp.findings.findingsFlyout.ruleTab.tagsTitle', { | ||
defaultMessage: 'Tags', | ||
}), | ||
description: rule?.tags?.length ? ( | ||
<> | ||
{rule.tags.map((tag) => ( | ||
<EuiBadge key={tag}>{tag}</EuiBadge> | ||
))} | ||
</> | ||
) : ( | ||
EMPTY_VALUE | ||
), | ||
}, | ||
{ | ||
title: i18n.translate('xpack.csp.findings.findingsFlyout.ruleTab.cisSectionTitle', { | ||
defaultMessage: 'Framework Section', | ||
}), | ||
description: rule?.section || EMPTY_VALUE, | ||
}, | ||
{ | ||
title: i18n.translate('xpack.csp.findings.findingsFlyout.ruleTab.profileApplicabilityTitle', { | ||
defaultMessage: 'Profile Applicability', | ||
}), | ||
description: rule?.profile_applicability ? ( | ||
<CspFlyoutMarkdown>{rule.profile_applicability}</CspFlyoutMarkdown> | ||
) : ( | ||
EMPTY_VALUE | ||
), | ||
}, | ||
{ | ||
title: i18n.translate('xpack.csp.findings.findingsFlyout.ruleTab.benchmarkTitle', { | ||
defaultMessage: 'Benchmark', | ||
}), | ||
description: rule?.benchmark?.name || EMPTY_VALUE, | ||
}, | ||
{ | ||
title: i18n.translate('xpack.csp.findings.findingsFlyout.ruleTab.auditTitle', { | ||
defaultMessage: 'Audit', | ||
}), | ||
description: rule?.audit ? <CspFlyoutMarkdown>{rule.audit}</CspFlyoutMarkdown> : EMPTY_VALUE, | ||
}, | ||
{ | ||
title: i18n.translate('xpack.csp.findings.findingsFlyout.ruleTab.referencesTitle', { | ||
defaultMessage: 'References', | ||
}), | ||
description: rule?.references ? ( | ||
<CspFlyoutMarkdown>{rule.references}</CspFlyoutMarkdown> | ||
) : ( | ||
EMPTY_VALUE | ||
), | ||
}, | ||
]; | ||
}, | ||
{ | ||
title: i18n.translate('xpack.csp.findings.findingsFlyout.ruleTab.frameworkSourcesTitle', { | ||
defaultMessage: 'Framework Sources', | ||
}), | ||
description: | ||
rule?.benchmark?.id && rule?.benchmark?.name ? ( | ||
<BenchmarkIcons benchmarkId={rule.benchmark.id} benchmarkName={rule.benchmark.name} /> | ||
) : ( | ||
EMPTY_VALUE | ||
), | ||
}, | ||
{ | ||
title: i18n.translate('xpack.csp.findings.findingsFlyout.ruleTab.cisSectionTitle', { | ||
defaultMessage: 'Framework Section', | ||
}), | ||
description: rule?.section || EMPTY_VALUE, | ||
}, | ||
{ | ||
title: i18n.translate('xpack.csp.findings.findingsFlyout.ruleTab.profileApplicabilityTitle', { | ||
defaultMessage: 'Profile Applicability', | ||
}), | ||
description: rule?.profile_applicability ? ( | ||
<CspFlyoutMarkdown>{rule.profile_applicability}</CspFlyoutMarkdown> | ||
) : ( | ||
EMPTY_VALUE | ||
), | ||
}, | ||
{ | ||
title: i18n.translate('xpack.csp.findings.findingsFlyout.ruleTab.benchmarkTitle', { | ||
defaultMessage: 'Benchmark', | ||
}), | ||
description: rule?.benchmark?.name || EMPTY_VALUE, | ||
}, | ||
{ | ||
title: i18n.translate('xpack.csp.findings.findingsFlyout.ruleTab.auditTitle', { | ||
defaultMessage: 'Audit', | ||
}), | ||
description: rule?.audit ? <CspFlyoutMarkdown>{rule.audit}</CspFlyoutMarkdown> : EMPTY_VALUE, | ||
}, | ||
{ | ||
title: i18n.translate('xpack.csp.findings.findingsFlyout.ruleTab.referencesTitle', { | ||
defaultMessage: 'References', | ||
}), | ||
description: reference ? <CspFlyoutMarkdown>{reference}</CspFlyoutMarkdown> : EMPTY_VALUE, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the only meaningful change in the returned array is here |
||
}, | ||
]; | ||
}; | ||
|
||
export const RuleTab = ({ | ||
data, | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a suggestion: maybe it would be simpler to fix it in the ingest pipeline and rely on it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kfirpeled do you mean in the ingest pipeline of
cloud_security_posture
copy the value ofrule.references
intorule.reference
to be able to removerule.references
completely? We could do that, but as the change to support both is quite small, I thought it would be safer just to support both at first and then depreciaterule.references
. Otherwise I need to think how the UI will work out with the older version of the integration, as integration update is not a given when you update the stack version. Am I missing smth?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope, you are not missing anything.
However, since we do have automatic updates of the integration, after 24 hours all the misconfigurations will have the updated field. so it shortens your migration process.
both ways work