Skip to content

Commit

Permalink
refactor cspRuleTemplate to cspRule
Browse files Browse the repository at this point in the history
  • Loading branch information
CohenIdo committed Dec 7, 2023
1 parent 9cc8af6 commit d9d2723
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import { useFindCspBenchmarkRule } from './use_csp_benchmark_rules';
import * as TEST_SUBJECTS from './test_subjects';
import { Chance } from 'chance';
import { TestProvider } from '../../test/test_provider';
import type { CspBenchmarkRule } from '../../../common/types/latest';
import { useParams } from 'react-router-dom';
import { coreMock } from '@kbn/core/public/mocks';
import type { CspBenchmarkRule } from '@kbn/cloud-security-posture-plugin/common/types/latest';

const chance = new Chance();

jest.mock('./use_csp_rules', () => ({
jest.mock('./use_csp_benchmark_rules', () => ({
useFindCspBenchmarkRule: jest.fn(),
useBulkUpdateCspBenchmarkRule: jest.fn(),
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import React, { useState, useMemo } from 'react';
import { EuiPanel, EuiSpacer } from '@elastic/eui';
import { useParams } from 'react-router-dom';
import { CspBenchmarkRule } from '@kbn/cloud-security-posture-plugin/common/types/latest';
import { CspBenchmarkRule } from '../../../common/types/latest';
import { extractErrorMessage } from '../../../common/utils/helpers';
import { RulesTable } from './rules_table';
import { RulesTableHeader } from './rules_table_header';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@
* 2.0.
*/
import { useQuery } from '@tanstack/react-query';

import {
FindCspBenchmarkRuleRequest,
FindCspBenchmarkRuleResponse,
} from '../../../common/types/latest';
import { useKibana } from '../../common/hooks/use_kibana';

import {
CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE,
FIND_CSP_BENCHMARK_RULE_API_CURRENT_VERSION,
FIND_CSP_BENCHMARK_RULE_ROUTE_PATH,
} from '../../../common/constants';
import {
FindCspBenchmarkRuleRequest,
FindCspBenchmarkRuleResponse,
} from '@kbn/cloud-security-posture-plugin/common/types/latest';

export type RulesQuery = Pick<
FindCspBenchmarkRuleRequest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import type { SavedObjectsClientContract } from '@kbn/core/server';
import { transformError } from '@kbn/securitysolution-es-utils';
import type { AgentPolicy, ListResult, PackagePolicy } from '@kbn/fleet-plugin/common';
import { CspBenchmarkRule } from '@kbn/cloud-security-posture-plugin/common/types/latest';
import { CspBenchmarkRule } from '../../../common/types/latest';
import { CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE } from '../../../common/constants';
import {
BENCHMARKS_ROUTE_PATH,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { getSortedCspBenchmarkRulesTemplates } from './find_csp_benchmark_rule';
import { CspBenchmarkRule } from '@kbn/cloud-security-posture-plugin/common/types/latest';
import { CspBenchmarkRule } from '../../../../common/types/latest';

describe('getSortedCspBenchmarkRules', () => {
it('sorts by metadata.benchmark.rule_number, invalid semantic version still should still get sorted and empty values should be sorted last', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
FindCspBenchmarkRuleRequest,
FindCspBenchmarkRuleResponse,
findCspBenchmarkRuleRequestSchema,
} from '@kbn/cloud-security-posture-plugin/common/types/latest';
} from '../../../../common/types/latest';
import { getBenchmarkFromPackagePolicy } from '../../../../common/utils/helpers';

import { FIND_CSP_BENCHMARK_RULE_ROUTE_PATH } from '../../../../common/constants';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,17 @@
*/

import { SavedObjectsClientContract } from '@kbn/core-saved-objects-api-server';
import { getBenchmarkFilter } from '../../../../common/utils/helpers';
import { CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE } from '../../../../common/constants';
import {
getBenchmarkIdFromPackagePolicyId,
getSortedCspBenchmarkRulesTemplates,
} from './find_csp_benchmark_rule';

import type {
CspBenchmarkRule,
FindCspBenchmarkRuleRequest,
FindCspBenchmarkRuleResponse,
} from '@kbn/cloud-security-posture-plugin/common/types/latest';
} from '../../../../common/types/latest';
import {
getBenchmarkIdFromPackagePolicyId,
getSortedCspBenchmarkRulesTemplates,
} from './find_csp_benchmark_rule';
import { getBenchmarkFilter } from '../../../../common/utils/helpers';
import { CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE } from '../../../../common/constants';

export const findRuleHandler = async (
soClient: SavedObjectsClientContract,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

import { SECURITY_SOLUTION_SAVED_OBJECT_INDEX } from '@kbn/core-saved-objects-server';
import { SavedObjectsType } from '@kbn/core/server';
import { rulesV1, rulesV2, rulesV3 } from '../../common/types';
import { CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE } from '../../common/constants';
import { cspBenchmarkRuleMigrations } from './migrations';
import { cspBenchmarkRuleSavedObjectMapping } from './mappings';
import { rulesV1, rulesV2, rulesV3 } from '@kbn/cloud-security-posture-plugin/common/types/';

export const cspBenchmarkRule: SavedObjectsType = {
name: CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
* 2.0.
*/

import { rulesV1, rulesV2, rulesV3 } from '@kbn/cloud-security-posture-plugin/common/types/';
import {
SavedObjectMigrationMap,
SavedObjectUnsanitizedDoc,
SavedObjectMigrationContext,
} from '@kbn/core/server';
import { rulesV1, rulesV2, rulesV3 } from '../../../common/types';

function migrateCspBenchmarkRuleToV840(
doc: SavedObjectUnsanitizedDoc<rulesV1.CspBenchmarkRule>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

import { SavedObjectsServiceSetup } from '@kbn/core/server';
import { SECURITY_SOLUTION_SAVED_OBJECT_INDEX } from '@kbn/core-saved-objects-server';
import { rulesV1, rulesV2, rulesV3 } from '../../common/types/index';
import { cspBenchmarkRuleSavedObjectMapping } from './mappings';
import { cspBenchmarkRuleMigrations } from './migrations';

import { rulesV1, rulesV2, rulesV3 } from '@kbn/cloud-security-posture-plugin/common/types/';
import { CspBenchmarkRule } from '@kbn/cloud-security-posture-plugin/common/types/latest';
import { CspBenchmarkRule } from '../../common/types/latest';

import { CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE } from '../../common/constants';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
*/
import expect from '@kbn/expect';
import { ELASTIC_HTTP_VERSION_HEADER } from '@kbn/core-http-common';
import { FtrProviderContext } from '../../ftr_provider_context';
import { createPackagePolicy } from './helper';

import type {
CspBenchmarkRule,
FindCspBenchmarkRuleResponse,
} from '@kbn/cloud-security-posture-plugin/common/types/latest';
import { FtrProviderContext } from '../../ftr_provider_context';
import { createPackagePolicy } from './helper';

export default function ({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import {
ELASTIC_HTTP_VERSION_HEADER,
X_ELASTIC_INTERNAL_ORIGIN_REQUEST,
} from '@kbn/core-http-common';
import { FtrProviderContext } from '../../../ftr_provider_context';
import { createPackagePolicy } from '../../../apis/cloud_security_posture/helper'; // eslint-disable-line @kbn/imports/no_boundary_crossing

import type {
CspBenchmarkRule,
FindCspBenchmarkRuleResponse,
} from '@kbn/cloud-security-posture-plugin/common/types/latest';

import { FtrProviderContext } from '../../../ftr_provider_context';
import { createPackagePolicy } from '../../../apis/cloud_security_posture/helper';

export default function ({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
const esArchiver = getService('esArchiver');
Expand Down

0 comments on commit d9d2723

Please sign in to comment.