Skip to content

Commit

Permalink
[Cloud Security] Rules counters (elastic#174687)
Browse files Browse the repository at this point in the history
  • Loading branch information
JordanSh authored Jan 23, 2024
1 parent 47bc2c9 commit aea41ca
Show file tree
Hide file tree
Showing 3 changed files with 373 additions and 42 deletions.
1 change: 1 addition & 0 deletions x-pack/plugins/cloud_security_posture/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export const LATEST_FINDINGS_INDEX_TEMPLATE_NAME = 'logs-cloud_security_posture.
export const LATEST_FINDINGS_INDEX_PATTERN = 'logs-cloud_security_posture.findings_latest-*';
export const LATEST_FINDINGS_INDEX_DEFAULT_NS =
'logs-cloud_security_posture.findings_latest-default';

export const LATEST_FINDINGS_RETENTION_POLICY = '26h';

export const BENCHMARK_SCORE_INDEX_TEMPLATE_NAME = 'logs-cloud_security_posture.scores';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/
import React, { useState, useMemo } from 'react';
import { EuiPanel, EuiSpacer } from '@elastic/eui';
import { EuiSpacer } from '@elastic/eui';
import { useParams } from 'react-router-dom';
import { buildRuleKey } from '../../../common/utils/rules_states';
import { extractErrorMessage } from '../../../common/utils/helpers';
Expand All @@ -22,6 +22,7 @@ import type {
RuleStateAttributes,
} from '../../../common/types/latest';
import { useCspGetRulesStates } from './use_csp_rules_state';
import { RulesCounters } from './rules_counters';

export interface CspBenchmarkRulesWithStates {
metadata: CspBenchmarkRule['metadata'];
Expand Down Expand Up @@ -173,47 +174,47 @@ export const RulesContainer = () => {

return (
<div data-test-subj={TEST_SUBJECTS.CSP_RULES_CONTAINER}>
<EuiPanel hasBorder={false} hasShadow={false}>
<RulesTableHeader
onSectionChange={(value) =>
setRulesQuery((currentQuery) => ({ ...currentQuery, section: value }))
}
onRuleNumberChange={(value) =>
setRulesQuery((currentQuery) => ({ ...currentQuery, ruleNumber: value }))
}
sectionSelectOptions={cleanedSectionList}
ruleNumberSelectOptions={cleanedRuleNumberList}
search={(value) => setRulesQuery((currentQuery) => ({ ...currentQuery, search: value }))}
searchValue={rulesQuery.search || ''}
totalRulesCount={rulesPageData.all_rules.length}
pageSize={rulesPageData.rules_page.length}
isSearching={status === 'loading'}
selectedRules={selectedRules}
refetchRulesStates={rulesStates.refetch}
setEnabledDisabledItemsFilter={setEnabledDisabledItemsFilter}
currentEnabledDisabledItemsFilterState={enabledDisabledItemsFilter}
setSelectAllRules={setSelectAllRules}
setSelectedRules={setSelectedRules}
/>
<EuiSpacer />
<RulesTable
rules_page={rulesPageData.rules_page}
total={rulesPageData.total}
error={rulesPageData.error}
loading={rulesPageData.loading}
perPage={pageSize || rulesQuery.perPage}
page={rulesQuery.page}
setPagination={(paginationQuery) => {
setPageSize(paginationQuery.perPage);
setRulesQuery((currentQuery) => ({ ...currentQuery, ...paginationQuery }));
}}
setSelectedRuleId={setSelectedRuleId}
selectedRuleId={selectedRuleId}
refetchRulesStates={rulesStates.refetch}
selectedRules={selectedRules}
setSelectedRules={setSelectedRules}
/>
</EuiPanel>
<RulesCounters />
<EuiSpacer />
<RulesTableHeader
onSectionChange={(value) =>
setRulesQuery((currentQuery) => ({ ...currentQuery, section: value }))
}
onRuleNumberChange={(value) =>
setRulesQuery((currentQuery) => ({ ...currentQuery, ruleNumber: value }))
}
sectionSelectOptions={cleanedSectionList}
ruleNumberSelectOptions={cleanedRuleNumberList}
search={(value) => setRulesQuery((currentQuery) => ({ ...currentQuery, search: value }))}
searchValue={rulesQuery.search || ''}
totalRulesCount={rulesPageData.all_rules.length}
pageSize={rulesPageData.rules_page.length}
isSearching={status === 'loading'}
selectedRules={selectedRules}
refetchRulesStates={rulesStates.refetch}
setEnabledDisabledItemsFilter={setEnabledDisabledItemsFilter}
currentEnabledDisabledItemsFilterState={enabledDisabledItemsFilter}
setSelectAllRules={setSelectAllRules}
setSelectedRules={setSelectedRules}
/>
<EuiSpacer />
<RulesTable
rules_page={rulesPageData.rules_page}
total={rulesPageData.total}
error={rulesPageData.error}
loading={rulesPageData.loading}
perPage={pageSize || rulesQuery.perPage}
page={rulesQuery.page}
setPagination={(paginationQuery) => {
setPageSize(paginationQuery.perPage);
setRulesQuery((currentQuery) => ({ ...currentQuery, ...paginationQuery }));
}}
setSelectedRuleId={setSelectedRuleId}
selectedRuleId={selectedRuleId}
refetchRulesStates={rulesStates.refetch}
selectedRules={selectedRules}
setSelectedRules={setSelectedRules}
/>
{selectedRuleId && (
<RuleFlyout
rule={rulesFlyoutData}
Expand Down
Loading

0 comments on commit aea41ca

Please sign in to comment.