Skip to content

Commit

Permalink
[Cloud Security] Cis section passed link (elastic#177083)
Browse files Browse the repository at this point in the history
## Summary

Summarize your PR. If it involves visual changes include a screenshot or
gif.
This PR has enabled CIS Section linking with a posture score of 100%.
**CIS Section** will 100% Posture score will allow you to navigate to
the findings page with `result.evaluation: passed`.

[Quick Wins](
elastic/security-team#8690)



https://github.com/elastic/kibana/assets/17135495/f3cdc650-4b29-425e-adb9-d18fe0144a35
  • Loading branch information
Omolola-Akinleye authored Feb 20, 2024
1 parent 37ae67a commit 5876cac
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import type {
PosturePolicyTemplate,
} from '../../../../common/types_old';
import { RisksTable } from '../compliance_charts/risks_table';
import { RULE_FAILED } from '../../../../common/constants';
import { RULE_FAILED, RULE_PASSED } from '../../../../common/constants';
import { LOCAL_STORAGE_DASHBOARD_BENCHMARK_SORT_KEY } from '../../../common/constants';
import { NavFilter, useNavigateFindings } from '../../../common/hooks/use_navigate_findings';
import { dashboardColumnsGrow, getPolicyTemplateQuery } from './summary_section';
Expand Down Expand Up @@ -70,13 +70,14 @@ export const BenchmarksSection = ({

const navToFailedFindingsByBenchmarkAndSection = (
benchmark: BenchmarkData,
ruleSection: string
ruleSection: string,
resultEvaluation: 'passed' | 'failed' = RULE_FAILED
) => {
navToFindings({
...getPolicyTemplateQuery(dashboardType),
...getBenchmarkIdQuery(benchmark),
'rule.section': ruleSection,
'result.evaluation': RULE_FAILED,
'result.evaluation': resultEvaluation,
});
};

Expand Down Expand Up @@ -190,9 +191,25 @@ export const BenchmarksSection = ({
compact
data={benchmark.groupedFindingsEvaluation}
maxItems={3}
onCellClick={(resourceTypeName) =>
navToFailedFindingsByBenchmarkAndSection(benchmark, resourceTypeName)
}
onCellClick={(resourceTypeName) => {
const cisSectionEvaluation = benchmark.groupedFindingsEvaluation.find(
(groupedFindingsEvaluation) =>
groupedFindingsEvaluation.name === resourceTypeName
);
// if the CIS Section posture score is 100, we should navigate with result evaluation as passed or result evaluation as failed
if (
cisSectionEvaluation?.postureScore &&
Math.trunc(cisSectionEvaluation?.postureScore) === 100
) {
navToFailedFindingsByBenchmarkAndSection(
benchmark,
resourceTypeName,
RULE_PASSED
);
} else {
navToFailedFindingsByBenchmarkAndSection(benchmark, resourceTypeName);
}
}}
viewAllButtonTitle={i18n.translate(
'xpack.csp.dashboard.risksTable.benchmarkCardViewAllButtonTitle',
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
CSPM_POLICY_TEMPLATE,
KSPM_POLICY_TEMPLATE,
RULE_FAILED,
RULE_PASSED,
} from '../../../../common/constants';
import { AccountsEvaluatedWidget } from '../../../components/accounts_evaluated_widget';

Expand Down Expand Up @@ -66,11 +67,14 @@ export const SummarySection = ({
navToFindings({ 'result.evaluation': evaluation, ...getPolicyTemplateQuery(dashboardType) });
};

const handleCellClick = (ruleSection: string) => {
const handleCellClick = (
ruleSection: string,
resultEvaluation: 'passed' | 'failed' = RULE_FAILED
) => {
navToFindings({
'rule.section': ruleSection,
'result.evaluation': RULE_FAILED,
...getPolicyTemplateQuery(dashboardType),
'rule.section': ruleSection,
'result.evaluation': resultEvaluation,
});
};

Expand Down Expand Up @@ -192,7 +196,21 @@ export const SummarySection = ({
<RisksTable
data={complianceData.groupedFindingsEvaluation}
maxItems={5}
onCellClick={handleCellClick}
onCellClick={(cisSection: string) => {
const cisSectionEvaluation = complianceData.groupedFindingsEvaluation.find(
(groupedFindingsEvaluation) => groupedFindingsEvaluation.name === cisSection
);

// if the CIS Section posture score is 100, we should navigate with result evaluation as passed or result evaluation as failed
if (
cisSectionEvaluation?.postureScore &&
Math.trunc(cisSectionEvaluation?.postureScore) === 100
) {
handleCellClick(cisSection, RULE_PASSED);
} else {
handleCellClick(cisSection);
}
}}
onViewAllClick={handleViewAllClick}
viewAllButtonTitle={i18n.translate(
'xpack.csp.dashboard.risksTable.viewAllButtonTitle',
Expand Down

0 comments on commit 5876cac

Please sign in to comment.