Skip to content

Commit

Permalink
pr comments and ftr fix
Browse files Browse the repository at this point in the history
  • Loading branch information
animehart committed Jan 24, 2024
1 parent 5aaeffe commit 28fa96d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ export const findCspBenchmarkRuleRequestSchema = schema.object({
/**
* rule section
*/
section: schema.maybe(schema.arrayOf(schema.string())),
ruleNumber: schema.maybe(schema.arrayOf(schema.string())),
section: schema.maybe(schema.string()),
ruleNumber: schema.maybe(schema.string()),
});

export interface BenchmarkRuleSelectParams {
Expand Down
15 changes: 8 additions & 7 deletions x-pack/plugins/cloud_security_posture/common/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import type {
RuleSection,
} from '../types_old';
import type { BenchmarkRuleSelectParams, BenchmarksCisId } from '../types/latest';
import type { BenchmarkRuleSelectParams as BenchmarkRuleSelectParamsV1 } from '../types/rules/v4';

/**
* @example
Expand Down Expand Up @@ -205,11 +206,11 @@ export const getBenchmarkApplicableTo = (benchmarkId: BenchmarksCisId) => {
};

export const getBenchmarkFilterQuery = (
id: BenchmarkId,
version?: string,
selectParams?: BenchmarkRuleSelectParams
benchmarkId: BenchmarkId,
benchmarkVersion?: string,
selectParams?: BenchmarkRuleSelectParamsV1
): string => {
const baseQuery = `${CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE}.attributes.metadata.benchmark.id:${id} AND ${CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE}.attributes.metadata.benchmark.version:"v${version}"`;
const baseQuery = `${CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE}.attributes.metadata.benchmark.id:${benchmarkId} AND ${CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE}.attributes.metadata.benchmark.version:"v${benchmarkVersion}"`;
const sectionQuery = selectParams?.section
? ` AND ${CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE}.attributes.metadata.section: "${selectParams.section}"`
: '';
Expand All @@ -220,11 +221,11 @@ export const getBenchmarkFilterQuery = (
};

export const getBenchmarkFilterQueryV2 = (
id: BenchmarkId,
version?: string,
benchmarkId: BenchmarkId,
benchmarkVersion?: string,
selectParams?: BenchmarkRuleSelectParams
): string => {
const baseQuery = `${CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE}.attributes.metadata.benchmark.id:${id} AND ${CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE}.attributes.metadata.benchmark.version:"v${version}"`;
const baseQuery = `${CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE}.attributes.metadata.benchmark.id:${benchmarkId} AND ${CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE}.attributes.metadata.benchmark.version:"v${benchmarkVersion}"`;

let sectionQuery = '';
let ruleNumberQuery = '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import { CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE } from '../../../../common/constan

import type {
CspBenchmarkRule,
FindCspBenchmarkRuleRequest,
FindCspBenchmarkRuleResponse,
} from '../../../../common/types/latest';
import type { FindCspBenchmarkRuleRequest } from '../../../../common/types/rules/v4';
} from '../../../../common/types/rules/v4';
import { getSortedCspBenchmarkRulesTemplates } from './utils';

export const findBenchmarkRuleHandler = async (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export const RULES_CLEAR_ALL_RULES_SELECTION = 'clear-rules-selection-button';
export const RULES_ROWS_ENABLE_SWITCH_BUTTON = 'rules-row-enable-switch-button';
export const RULES_DISABLED_FILTER = 'rules-disabled-filter';
export const RULES_ENABLED_FILTER = 'rules-enabled-filter';
export const CIS_SECTION_FILTER = 'options-filter-popover-button-section';
export const RULE_NUMBER_FILTER = 'options-filter-popover-button-rule-number';
export const CIS_SECTION_FILTER = 'options-filter-popover-button-cis-section-multi-select-filter';
export const RULE_NUMBER_FILTER = 'options-filter-popover-button-rule-number-multi-select-filter';
export const RULE_NUMBER_FILTER_SEARCH_FIELD = 'rule-number-search-input';

export function RulePagePageProvider({ getService, getPageObjects }: FtrProviderContext) {
Expand Down
3 changes: 0 additions & 3 deletions x-pack/test/cloud_security_posture_functional/pages/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import type { FtrProviderContext } from '../ftr_provider_context';
import {
RULES_BULK_ACTION_OPTION_DISABLE,
RULES_BULK_ACTION_OPTION_ENABLE,
RULE_NUMBER_FILTER_SEARCH_FIELD,
} from '../page_objects/rule_page';

// eslint-disable-next-line import/no-default-export
Expand Down Expand Up @@ -160,8 +159,6 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
await rule.rulePage.clickFilterPopOverOption('Control-Plane-Node-Configuration-Files');
await rule.rulePage.clickFilterPopover('section');
await rule.rulePage.clickFilterPopover('ruleNumber');
await rule.rulePage.filterTextInput(RULE_NUMBER_FILTER_SEARCH_FIELD, '1.1.5');
await pageObjects.header.waitUntilLoadingHasFinished();
await rule.rulePage.clickFilterPopOverOption('1.1.5');
expect((await rule.rulePage.getEnableRulesRowSwitchButton()) === 1).to.be(true);
});
Expand Down

0 comments on commit 28fa96d

Please sign in to comment.