mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[8.10] [Cloud Security] [Alerts] Fix Misconfigurations Flyout navigation to detection rule (#164654) (#164899)
# Backport This will backport the following commits from `main` to `8.10`: - [[Cloud Security] [Alerts] Fix Misconfigurations Flyout navigation to detection rule (#164654)](https://github.com/elastic/kibana/pull/164654) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Paulo Henrique","email":"paulo.henrique@elastic.co"},"sourceCommit":{"committedDate":"2023-08-25T20:45:08Z","message":"[Cloud Security] [Alerts] Fix Misconfigurations Flyout navigation to detection rule (#164654)","sha":"edca162329399eefe44ef3949fe38ea2f4d86082","branchLabelMapping":{"^v8.11.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Cloud Security","backport:prev-minor","v8.10.0","v8.11.0"],"number":164654,"url":"https://github.com/elastic/kibana/pull/164654","mergeCommit":{"message":"[Cloud Security] [Alerts] Fix Misconfigurations Flyout navigation to detection rule (#164654)","sha":"edca162329399eefe44ef3949fe38ea2f4d86082"}},"sourceBranch":"main","suggestedTargetBranches":["8.10"],"targetPullRequestStates":[{"branch":"8.10","label":"v8.10.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.11.0","labelRegex":"^v8.11.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/164654","number":164654,"mergeCommit":{"message":"[Cloud Security] [Alerts] Fix Misconfigurations Flyout navigation to detection rule (#164654)","sha":"edca162329399eefe44ef3949fe38ea2f4d86082"}}]}] BACKPORT--> Co-authored-by: Paulo Henrique <paulo.henrique@elastic.co>
This commit is contained in:
parent
841ad533c2
commit
a768f1cb2a
2 changed files with 23 additions and 3 deletions
|
@ -9,13 +9,19 @@ import type { HttpSetup } from '@kbn/core/public';
|
|||
import React from 'react';
|
||||
import { CspFinding } from '../../../../common/schemas/csp_finding';
|
||||
import { DetectionRuleCounter } from '../../../components/detection_rule_counter';
|
||||
import { createDetectionRuleFromFinding } from '../utils/create_detection_rule_from_finding';
|
||||
import {
|
||||
createDetectionRuleFromFinding,
|
||||
getFindingsDetectionRuleSearchTags,
|
||||
} from '../utils/create_detection_rule_from_finding';
|
||||
|
||||
export const FindingsDetectionRuleCounter = ({ finding }: { finding: CspFinding }) => {
|
||||
const createMisconfigurationRuleFn = async (http: HttpSetup) =>
|
||||
await createDetectionRuleFromFinding(http, finding);
|
||||
|
||||
return (
|
||||
<DetectionRuleCounter tags={finding.rule.tags} createRuleFn={createMisconfigurationRuleFn} />
|
||||
<DetectionRuleCounter
|
||||
tags={getFindingsDetectionRuleSearchTags(finding)}
|
||||
createRuleFn={createMisconfigurationRuleFn}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -50,9 +50,23 @@ const CSP_RULE_TAG_DATA_SOURCE_PREFIX = 'Data Source: ';
|
|||
|
||||
const STATIC_RULE_TAGS = [CSP_RULE_TAG, CSP_RULE_TAG_USE_CASE];
|
||||
|
||||
/*
|
||||
* Returns an array of CspFinding tags that can be used to search and filter a detection rule
|
||||
*/
|
||||
export const getFindingsDetectionRuleSearchTags = ({ rule }: CspFinding) => {
|
||||
// ex: cis_gcp to ['CIS', 'GCP']
|
||||
const benchmarkIdTags = rule.benchmark.id.split('_').map((tag) => tag.toUpperCase());
|
||||
// ex: 'CIS GCP 1.1'
|
||||
const benchmarkRuleNumberTag = `${rule.benchmark.id.replace('_', ' ').toUpperCase()} ${
|
||||
rule.benchmark.rule_number
|
||||
}`;
|
||||
|
||||
return benchmarkIdTags.concat([benchmarkRuleNumberTag]);
|
||||
};
|
||||
|
||||
const generateFindingsTags = (finding: CspFinding) => {
|
||||
return [STATIC_RULE_TAGS]
|
||||
.concat(finding.rule.tags)
|
||||
.concat(getFindingsDetectionRuleSearchTags(finding))
|
||||
.concat(
|
||||
finding.rule.benchmark.posture_type
|
||||
? [
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue