Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Security Solution] Disable deprecated rules bulk CRUD API endpoints in Serverless and 9.0 #197422

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ import type { SetupPlugins } from '../../../../plugin_contract';
import type { SecuritySolutionPluginRouter } from '../../../../types';

import { performBulkActionRoute } from './rules/bulk_actions/route';
import { bulkCreateRulesRoute } from './rules/bulk_create_rules/route';
import { bulkDeleteRulesRoute } from './rules/bulk_delete_rules/route';
import { bulkPatchRulesRoute } from './rules/bulk_patch_rules/route';
import { bulkUpdateRulesRoute } from './rules/bulk_update_rules/route';
import { createRuleRoute } from './rules/create_rule/route';
import { deleteRuleRoute } from './rules/delete_rule/route';
import { exportRulesRoute } from './rules/export_rules/route';
Expand All @@ -40,12 +36,6 @@ export const registerRuleManagementRoutes = (
patchRuleRoute(router);
deleteRuleRoute(router);

// Rules bulk CRUD
bulkCreateRulesRoute(router, logger);
bulkUpdateRulesRoute(router, logger);
bulkPatchRulesRoute(router, logger);
bulkDeleteRulesRoute(router, logger);

// Rules bulk actions
performBulkActionRoute(router, config, ml, logger);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import { getDeprecatedBulkEndpointHeader, logDeprecatedBulkEndpoint } from '../.

/**
* @deprecated since version 8.2.0. Use the detection_engine/rules/_bulk_action API instead
*
* TODO: https://github.com/elastic/kibana/issues/193184 Delete this route and clean up the code
*/
export const bulkCreateRulesRoute = (router: SecuritySolutionPluginRouter, logger: Logger) => {
router.versioned
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ type Handler = RequestHandler<

/**
* @deprecated since version 8.2.0. Use the detection_engine/rules/_bulk_action API instead
*
* TODO: https://github.com/elastic/kibana/issues/193184 Delete this route and clean up the code
*/
export const bulkDeleteRulesRoute = (router: SecuritySolutionPluginRouter, logger: Logger) => {
const handler: Handler = async (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import { RULE_MANAGEMENT_BULK_ACTION_SOCKET_TIMEOUT_MS } from '../../timeouts';

/**
* @deprecated since version 8.2.0. Use the detection_engine/rules/_bulk_action API instead
*
* TODO: https://github.com/elastic/kibana/issues/193184 Delete this route and clean up the code
*/
export const bulkPatchRulesRoute = (router: SecuritySolutionPluginRouter, logger: Logger) => {
router.versioned
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import { RULE_MANAGEMENT_BULK_ACTION_SOCKET_TIMEOUT_MS } from '../../timeouts';

/**
* @deprecated since version 8.2.0. Use the detection_engine/rules/_bulk_action API instead
*
* TODO: https://github.com/elastic/kibana/issues/193184 Delete this route and clean up the code
*/
export const bulkUpdateRulesRoute = (router: SecuritySolutionPluginRouter, logger: Logger) => {
router.versioned
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ export default ({ getService }: FtrProviderContext): void => {
});

it('exports a set of custom installed rules via the _export API', async () => {
await securitySolutionApi
.bulkCreateRules({
body: [
getCustomQueryRuleParams({ rule_id: 'rule-id-1' }),
getCustomQueryRuleParams({ rule_id: 'rule-id-2' }),
],
})
.expect(200);
await Promise.all([
securitySolutionApi
.createRule({ body: getCustomQueryRuleParams({ rule_id: 'rule-id-1' }) })
.expect(200),
securitySolutionApi
.createRule({ body: getCustomQueryRuleParams({ rule_id: 'rule-id-2' }) })
.expect(200),
]);
Comment on lines +49 to +56
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking if these changes to rules export tests should go in a separate PR so that we could backport them to 8.x to decrease the chance of introducing conflicts with any other follow-up PRs related to rule import/export that will be merged to 8.x.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'll open a new PR against 8.x after merging this one 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dplumlee Here we go, looking for a quick 👍 : #198953


const { body: exportResult } = await securitySolutionApi
.exportRules({ query: {}, body: null })
Expand Down Expand Up @@ -182,14 +182,14 @@ export default ({ getService }: FtrProviderContext): void => {
});

it('exports a set of custom and prebuilt installed rules via the _export API', async () => {
await securitySolutionApi
.bulkCreateRules({
body: [
getCustomQueryRuleParams({ rule_id: 'rule-id-1' }),
getCustomQueryRuleParams({ rule_id: 'rule-id-2' }),
],
})
.expect(200);
await Promise.all([
securitySolutionApi
.createRule({ body: getCustomQueryRuleParams({ rule_id: 'rule-id-1' }) })
.expect(200),
securitySolutionApi
.createRule({ body: getCustomQueryRuleParams({ rule_id: 'rule-id-2' }) })
.expect(200),
]);

const { body: exportResult } = await securitySolutionApi
.exportRules({ query: {}, body: null })
Expand Down Expand Up @@ -232,14 +232,14 @@ export default ({ getService }: FtrProviderContext): void => {
});

it('exports both custom and prebuilt rules when rule_ids are specified via the _export API', async () => {
await securitySolutionApi
.bulkCreateRules({
body: [
getCustomQueryRuleParams({ rule_id: 'rule-id-1' }),
getCustomQueryRuleParams({ rule_id: 'rule-id-2' }),
],
})
.expect(200);
await Promise.all([
securitySolutionApi
.createRule({ body: getCustomQueryRuleParams({ rule_id: 'rule-id-1' }) })
.expect(200),
securitySolutionApi
.createRule({ body: getCustomQueryRuleParams({ rule_id: 'rule-id-2' }) })
.expect(200),
]);

const { body: exportResult } = await securitySolutionApi
.exportRules({
Expand Down Expand Up @@ -277,14 +277,14 @@ export default ({ getService }: FtrProviderContext): void => {
});

it('exports a set of custom and prebuilt installed rules via the bulk_actions API', async () => {
await securitySolutionApi
.bulkCreateRules({
body: [
getCustomQueryRuleParams({ rule_id: 'rule-id-1' }),
getCustomQueryRuleParams({ rule_id: 'rule-id-2' }),
],
})
.expect(200);
await Promise.all([
securitySolutionApi
.createRule({ body: getCustomQueryRuleParams({ rule_id: 'rule-id-1' }) })
.expect(200),
securitySolutionApi
.createRule({ body: getCustomQueryRuleParams({ rule_id: 'rule-id-2' }) })
.expect(200),
]);

const { body: exportResult } = await securitySolutionApi
.performRulesBulkAction({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ export default ({ getService }: FtrProviderContext): void => {
const auditbeatPath = dataPathBuilder.getPath('auditbeat/hosts');
const utils = getService('securitySolutionUtils');

describe('@ess @serverless @skipInServerlessMKI create_rules_bulk', () => {
// TODO: https://github.com/elastic/kibana/issues/193184 Delete this file and clean up the code
describe.skip('@ess @serverless @skipInServerlessMKI create_rules_bulk', () => {
describe('creating rules in bulk', () => {
before(async () => {
await esArchiver.load(auditbeatPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { FtrProviderContext } from '../../../../../ftr_provider_context';
export default function ({ loadTestFile }: FtrProviderContext) {
describe('Rules Management - Rule Creation APIs', function () {
loadTestFile(require.resolve('./create_rules'));
loadTestFile(require.resolve('./create_rules_bulk'));
loadTestFile(require.resolve('./create_ml_rules_privileges'));
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export default ({ getService }: FtrProviderContext): void => {
const log = getService('log');
const es = getService('es');

// See https://github.com/elastic/kibana/issues/130963 for discussion on deprecation
describe('@ess @skipInServerless create_rules_bulk', () => {
// TODO: https://github.com/elastic/kibana/issues/193184 Delete this file and clean up the code
describe.skip('@ess @skipInServerless create_rules_bulk', () => {
describe('deprecations', () => {
afterEach(async () => {
await deleteAllRules(supertest, log);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ export default ({ getService }: FtrProviderContext): void => {
const es = getService('es');
const utils = getService('securitySolutionUtils');

describe('@ess @serverless @skipInServerlessMKI delete_rules_bulk', () => {
// TODO: https://github.com/elastic/kibana/issues/193184 Unskip and rewrite using the _bulk_action API endpoint
describe.skip('@ess @serverless @skipInServerlessMKI delete_rules_bulk', () => {
describe('deleting rules bulk using DELETE', () => {
beforeEach(async () => {
await createAlertsIndex(supertest, log);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ export default ({ getService }: FtrProviderContext): void => {
const es = getService('es');
const utils = getService('securitySolutionUtils');

// See https://github.com/elastic/kibana/issues/130963 for discussion on deprecation
describe('@ess @skipInServerlesMKI delete_rules_bulk', () => {
// TODO: https://github.com/elastic/kibana/issues/193184 Unskip and rewrite using the _bulk_action API endpoint
describe.skip('@ess @skipInServerlesMKI delete_rules_bulk', () => {
describe('deprecations', () => {
it('should return a warning header', async () => {
await createRule(supertest, log, getSimpleRule());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export default ({ getService }: FtrProviderContext): void => {
const log = getService('log');
const es = getService('es');

describe('@ess delete_rules_bulk_legacy', () => {
// TODO: https://github.com/elastic/kibana/issues/193184 Unskip and rewrite using the _bulk_action API endpoint
describe.skip('@ess delete_rules_bulk_legacy', () => {
describe('deleting rules bulk using POST', () => {
beforeEach(async () => {
await createAlertsIndex(supertest, log);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { FtrProviderContext } from '../../../../../ftr_provider_context';

export default function ({ loadTestFile }: FtrProviderContext) {
describe('Rules Management - Rule Patch APIs', function () {
loadTestFile(require.resolve('./patch_rules_bulk'));
loadTestFile(require.resolve('./patch_rules'));
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ export default ({ getService }: FtrProviderContext) => {
const es = getService('es');
const utils = getService('securitySolutionUtils');

describe('@ess @serverless @skipInServerlessMKI patch_rules_bulk', () => {
// TODO: https://github.com/elastic/kibana/issues/193184 Delete this file and clean up the code
describe.skip('@ess @serverless @skipInServerlessMKI patch_rules_bulk', () => {
describe('patch rules bulk', () => {
beforeEach(async () => {
await createAlertsIndex(supertest, log);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { FtrProviderContext } from '../../../../../ftr_provider_context';

export default function ({ loadTestFile }: FtrProviderContext) {
describe('Rules Management - Rule Patch APIs', function () {
loadTestFile(require.resolve('./patch_rules_bulk'));
loadTestFile(require.resolve('./patch_rules'));
loadTestFile(require.resolve('./patch_rules_ess'));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ export default ({ getService }: FtrProviderContext) => {
const es = getService('es');
const utils = getService('securitySolutionUtils');

// See https://github.com/elastic/kibana/issues/130963 for discussion on deprecation
describe('@ess @skipInServerless patch_rules_bulk', () => {
// TODO: https://github.com/elastic/kibana/issues/193184 Delete this file and clean up the code
describe.skip('@ess @skipInServerless patch_rules_bulk', () => {
describe('deprecations', () => {
afterEach(async () => {
await deleteAllRules(supertest, log);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { FtrProviderContext } from '../../../../../ftr_provider_context';

export default function ({ loadTestFile }: FtrProviderContext) {
describe('Rules Management - Rule Update APIs', function () {
loadTestFile(require.resolve('./update_rules_bulk'));
loadTestFile(require.resolve('./update_rules'));
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ export default ({ getService }: FtrProviderContext) => {
const es = getService('es');
const utils = getService('securitySolutionUtils');

describe('@ess @serverless @skipInServerlessMKI update_rules_bulk', () => {
// TODO: https://github.com/elastic/kibana/issues/193184 Delete this file and clean up the code
describe.skip('@ess @serverless @skipInServerlessMKI update_rules_bulk', () => {
describe('update rules bulk', () => {
beforeEach(async () => {
await createAlertsIndex(supertest, log);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { FtrProviderContext } from '../../../../../ftr_provider_context';

export default function ({ loadTestFile }: FtrProviderContext) {
describe('Rules Management - Rule Update APIs', function () {
loadTestFile(require.resolve('./update_rules_bulk'));
loadTestFile(require.resolve('./update_rules'));
loadTestFile(require.resolve('./update_rules_ess'));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ export default ({ getService }: FtrProviderContext) => {
const utils = getService('securitySolutionUtils');
let username: string;

// See https://github.com/elastic/kibana/issues/130963 for discussion on deprecation
describe('@ess update_rules_bulk', () => {
// TODO: https://github.com/elastic/kibana/issues/193184 Delete this file and clean up the code
describe.skip('@ess update_rules_bulk', () => {
before(async () => {
username = await utils.getUsername();
});
Expand Down