From 7ba09669136909a1fd39c03f45ee8d975374d47b Mon Sep 17 00:00:00 2001 From: Tiago Vila Verde Date: Mon, 30 Sep 2024 13:58:02 +0200 Subject: [PATCH] [8.x] [Security Solution] Support for kibana spaces in openapi generated securitySolutionApi service for integration tests (#194029) (#194400) # Backport This will backport the following commits from `main` to `8.x`: - [[Security Solution] Support for kibana spaces in openapi generated securitySolutionApi service for integration tests (#194029)](https://github.com/elastic/kibana/pull/194029) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> --- .../templates/api_client_supertest.handlebars | 6 +- .../services/security_solution_api.gen.ts | 530 +++++++++++------- ...ty_solution_endpoint_exceptions_api.gen.ts | 25 +- .../security_solution_exceptions_api.gen.ts | 79 +-- .../security_solution_lists_api.gen.ts | 73 +-- .../security_solution_osquery_api.gen.ts | 143 +++-- 6 files changed, 526 insertions(+), 330 deletions(-) diff --git a/packages/kbn-openapi-generator/src/template_service/templates/api_client_supertest.handlebars b/packages/kbn-openapi-generator/src/template_service/templates/api_client_supertest.handlebars index a51be66f1019b..330df21d191c4 100644 --- a/packages/kbn-openapi-generator/src/template_service/templates/api_client_supertest.handlebars +++ b/packages/kbn-openapi-generator/src/template_service/templates/api_client_supertest.handlebars @@ -11,6 +11,8 @@ import { ELASTIC_HTTP_VERSION_HEADER, X_ELASTIC_INTERNAL_ORIGIN_REQUEST } from ' import { replaceParams } from '@kbn/openapi-common/shared'; import { FtrProviderContext } from 'x-pack/test/api_integration/ftr_provider_context'; +import { routeWithNamespace } from 'x-pack/test/common/utils/security_solution'; + {{#each operations}} import { {{operationId}}RequestQueryInput, @@ -29,9 +31,9 @@ export function SecuritySolutionApiProvider({ getService }: FtrProviderContext) * {{{description}}} */ {{/if}} - {{camelCase operationId}}({{#if (or requestQuery requestParams requestBody)}}props: {{operationId}}Props{{/if}}) { + {{camelCase operationId}}({{#if (or requestQuery requestParams requestBody)}}props: {{operationId}}Props, {{/if}}kibanaSpace: string = 'default') { return supertest - .{{method}}({{#if requestParams}}replaceParams('{{path}}', props.params){{else}}'{{path}}'{{/if}}) + .{{method}}(routeWithNamespace({{#if requestParams}}replaceParams('{{path}}', props.params){{else}}'{{path}}'{{/if}}, kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '{{version}}') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') diff --git a/x-pack/test/api_integration/services/security_solution_api.gen.ts b/x-pack/test/api_integration/services/security_solution_api.gen.ts index 2fe38ad33aeb9..6f3a2c6aacd6d 100644 --- a/x-pack/test/api_integration/services/security_solution_api.gen.ts +++ b/x-pack/test/api_integration/services/security_solution_api.gen.ts @@ -129,6 +129,7 @@ import { StopEntityEngineRequestParamsInput } from '@kbn/security-solution-plugi import { SuggestUserProfilesRequestQueryInput } from '@kbn/security-solution-plugin/common/api/detection_engine/users/suggest_user_profiles_route.gen'; import { TriggerRiskScoreCalculationRequestBodyInput } from '@kbn/security-solution-plugin/common/api/entity_analytics/risk_engine/entity_calculation_route.gen'; import { UpdateRuleRequestBodyInput } from '@kbn/security-solution-plugin/common/api/detection_engine/rule_management/crud/update_rule/update_rule_route.gen'; +import { routeWithNamespace } from '../../common/utils/security_solution'; import { FtrProviderContext } from '../ftr_provider_context'; export function SecuritySolutionApiProvider({ getService }: FtrProviderContext) { @@ -145,17 +146,17 @@ the endpoint accomplishes this task by applying a deletion policy to the relevan after 30 days. It also deletes other artifacts specific to the migration implementation. */ - alertsMigrationCleanup(props: AlertsMigrationCleanupProps) { + alertsMigrationCleanup(props: AlertsMigrationCleanupProps, kibanaSpace: string = 'default') { return supertest - .delete('/api/detection_engine/signals/migration') + .delete(routeWithNamespace('/api/detection_engine/signals/migration', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .send(props.body as object); }, - assetCriticalityGetPrivileges() { + assetCriticalityGetPrivileges(kibanaSpace: string = 'default') { return supertest - .get('/internal/asset_criticality/privileges') + .get(routeWithNamespace('/internal/asset_criticality/privileges', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '1') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); @@ -163,9 +164,11 @@ after 30 days. It also deletes other artifacts specific to the migration impleme /** * Ensures that the packages needed for prebuilt detection rules to work are installed and up to date */ - bootstrapPrebuiltRules() { + bootstrapPrebuiltRules(kibanaSpace: string = 'default') { return supertest - .post('/internal/detection_engine/prebuilt_rules/_bootstrap') + .post( + routeWithNamespace('/internal/detection_engine/prebuilt_rules/_bootstrap', kibanaSpace) + ) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '1') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); @@ -173,9 +176,9 @@ after 30 days. It also deletes other artifacts specific to the migration impleme /** * Create new detection rules in bulk. */ - bulkCreateRules(props: BulkCreateRulesProps) { + bulkCreateRules(props: BulkCreateRulesProps, kibanaSpace: string = 'default') { return supertest - .post('/api/detection_engine/rules/_bulk_create') + .post(routeWithNamespace('/api/detection_engine/rules/_bulk_create', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -184,9 +187,9 @@ after 30 days. It also deletes other artifacts specific to the migration impleme /** * Delete detection rules in bulk. */ - bulkDeleteRules(props: BulkDeleteRulesProps) { + bulkDeleteRules(props: BulkDeleteRulesProps, kibanaSpace: string = 'default') { return supertest - .delete('/api/detection_engine/rules/_bulk_delete') + .delete(routeWithNamespace('/api/detection_engine/rules/_bulk_delete', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -195,9 +198,9 @@ after 30 days. It also deletes other artifacts specific to the migration impleme /** * Deletes multiple rules. */ - bulkDeleteRulesPost(props: BulkDeleteRulesPostProps) { + bulkDeleteRulesPost(props: BulkDeleteRulesPostProps, kibanaSpace: string = 'default') { return supertest - .post('/api/detection_engine/rules/_bulk_delete') + .post(routeWithNamespace('/api/detection_engine/rules/_bulk_delete', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -206,9 +209,9 @@ after 30 days. It also deletes other artifacts specific to the migration impleme /** * Update specific fields of existing detection rules using the `rule_id` or `id` field. */ - bulkPatchRules(props: BulkPatchRulesProps) { + bulkPatchRules(props: BulkPatchRulesProps, kibanaSpace: string = 'default') { return supertest - .patch('/api/detection_engine/rules/_bulk_update') + .patch(routeWithNamespace('/api/detection_engine/rules/_bulk_update', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -220,9 +223,9 @@ after 30 days. It also deletes other artifacts specific to the migration impleme > You cannot modify the `id` or `rule_id` values. */ - bulkUpdateRules(props: BulkUpdateRulesProps) { + bulkUpdateRules(props: BulkUpdateRulesProps, kibanaSpace: string = 'default') { return supertest - .put('/api/detection_engine/rules/_bulk_update') + .put(routeWithNamespace('/api/detection_engine/rules/_bulk_update', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -231,9 +234,12 @@ after 30 days. It also deletes other artifacts specific to the migration impleme /** * Bulk upsert up to 1000 asset criticality records, creating or updating them as needed. */ - bulkUpsertAssetCriticalityRecords(props: BulkUpsertAssetCriticalityRecordsProps) { + bulkUpsertAssetCriticalityRecords( + props: BulkUpsertAssetCriticalityRecordsProps, + kibanaSpace: string = 'default' + ) { return supertest - .post('/api/asset_criticality/bulk') + .post(routeWithNamespace('/api/asset_criticality/bulk', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -243,9 +249,9 @@ after 30 days. It also deletes other artifacts specific to the migration impleme * Retrieves a clean draft timeline. If a draft timeline does not exist, it is created and returned. */ - cleanDraftTimelines(props: CleanDraftTimelinesProps) { + cleanDraftTimelines(props: CleanDraftTimelinesProps, kibanaSpace: string = 'default') { return supertest - .post('/api/timeline/_draft') + .post(routeWithNamespace('/api/timeline/_draft', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -254,16 +260,16 @@ after 30 days. It also deletes other artifacts specific to the migration impleme /** * Cleaning up the the Risk Engine by removing the indices, mapping and transforms */ - cleanUpRiskEngine() { + cleanUpRiskEngine(kibanaSpace: string = 'default') { return supertest - .delete('/api/risk_score/engine/dangerously_delete_data') + .delete(routeWithNamespace('/api/risk_score/engine/dangerously_delete_data', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '1') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); }, - createAlertsIndex() { + createAlertsIndex(kibanaSpace: string = 'default') { return supertest - .post('/api/detection_engine/index') + .post(routeWithNamespace('/api/detection_engine/index', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); @@ -273,9 +279,9 @@ after 30 days. It also deletes other artifacts specific to the migration impleme Migrations are initiated per index. While the process is neither destructive nor interferes with existing data, it may be resource-intensive. As such, it is recommended that you plan your migrations accordingly. */ - createAlertsMigration(props: CreateAlertsMigrationProps) { + createAlertsMigration(props: CreateAlertsMigrationProps, kibanaSpace: string = 'default') { return supertest - .post('/api/detection_engine/signals/migration') + .post(routeWithNamespace('/api/detection_engine/signals/migration', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -284,9 +290,12 @@ Migrations are initiated per index. While the process is neither destructive nor /** * Create or update a criticality record for a specific asset. */ - createAssetCriticalityRecord(props: CreateAssetCriticalityRecordProps) { + createAssetCriticalityRecord( + props: CreateAssetCriticalityRecordProps, + kibanaSpace: string = 'default' + ) { return supertest - .post('/api/asset_criticality') + .post(routeWithNamespace('/api/asset_criticality', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -295,35 +304,44 @@ Migrations are initiated per index. While the process is neither destructive nor /** * Create a new detection rule. */ - createRule(props: CreateRuleProps) { + createRule(props: CreateRuleProps, kibanaSpace: string = 'default') { return supertest - .post('/api/detection_engine/rules') + .post(routeWithNamespace('/api/detection_engine/rules', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .send(props.body as object); }, - createTimelines(props: CreateTimelinesProps) { + createTimelines(props: CreateTimelinesProps, kibanaSpace: string = 'default') { return supertest - .post('/api/timeline') + .post(routeWithNamespace('/api/timeline', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .send(props.body as object); }, - createUpdateProtectionUpdatesNote(props: CreateUpdateProtectionUpdatesNoteProps) { + createUpdateProtectionUpdatesNote( + props: CreateUpdateProtectionUpdatesNoteProps, + kibanaSpace: string = 'default' + ) { return supertest .post( - replaceParams('/api/endpoint/protection_updates_note/{package_policy_id}', props.params) + routeWithNamespace( + replaceParams( + '/api/endpoint/protection_updates_note/{package_policy_id}', + props.params + ), + kibanaSpace + ) ) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .send(props.body as object); }, - deleteAlertsIndex() { + deleteAlertsIndex(kibanaSpace: string = 'default') { return supertest - .delete('/api/detection_engine/index') + .delete(routeWithNamespace('/api/detection_engine/index', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); @@ -331,25 +349,33 @@ Migrations are initiated per index. While the process is neither destructive nor /** * Delete the asset criticality record for a specific asset if it exists. */ - deleteAssetCriticalityRecord(props: DeleteAssetCriticalityRecordProps) { + deleteAssetCriticalityRecord( + props: DeleteAssetCriticalityRecordProps, + kibanaSpace: string = 'default' + ) { return supertest - .delete('/api/asset_criticality') + .delete(routeWithNamespace('/api/asset_criticality', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .query(props.query); }, - deleteEntityEngine(props: DeleteEntityEngineProps) { + deleteEntityEngine(props: DeleteEntityEngineProps, kibanaSpace: string = 'default') { return supertest - .delete(replaceParams('/api/entity_store/engines/{entityType}', props.params)) + .delete( + routeWithNamespace( + replaceParams('/api/entity_store/engines/{entityType}', props.params), + kibanaSpace + ) + ) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .query(props.query); }, - deleteNote(props: DeleteNoteProps) { + deleteNote(props: DeleteNoteProps, kibanaSpace: string = 'default') { return supertest - .delete('/api/note') + .delete(routeWithNamespace('/api/note', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -358,17 +384,17 @@ Migrations are initiated per index. While the process is neither destructive nor /** * Delete a detection rule using the `rule_id` or `id` field. */ - deleteRule(props: DeleteRuleProps) { + deleteRule(props: DeleteRuleProps, kibanaSpace: string = 'default') { return supertest - .delete('/api/detection_engine/rules') + .delete(routeWithNamespace('/api/detection_engine/rules', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .query(props.query); }, - deleteTimelines(props: DeleteTimelinesProps) { + deleteTimelines(props: DeleteTimelinesProps, kibanaSpace: string = 'default') { return supertest - .delete('/api/timeline') + .delete(routeWithNamespace('/api/timeline', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -377,24 +403,27 @@ Migrations are initiated per index. While the process is neither destructive nor /** * Calculates and persists Risk Scores for an entity, returning the calculated risk score. */ - deprecatedTriggerRiskScoreCalculation(props: DeprecatedTriggerRiskScoreCalculationProps) { + deprecatedTriggerRiskScoreCalculation( + props: DeprecatedTriggerRiskScoreCalculationProps, + kibanaSpace: string = 'default' + ) { return supertest - .post('/api/risk_scores/calculation/entity') + .post(routeWithNamespace('/api/risk_scores/calculation/entity', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '1') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .send(props.body as object); }, - disableRiskEngine() { + disableRiskEngine(kibanaSpace: string = 'default') { return supertest - .post('/internal/risk_score/engine/disable') + .post(routeWithNamespace('/internal/risk_score/engine/disable', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '1') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); }, - enableRiskEngine() { + enableRiskEngine(kibanaSpace: string = 'default') { return supertest - .post('/internal/risk_score/engine/enable') + .post(routeWithNamespace('/internal/risk_score/engine/enable', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '1') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); @@ -402,9 +431,9 @@ Migrations are initiated per index. While the process is neither destructive nor /** * Run a shell command on an endpoint. */ - endpointExecuteAction(props: EndpointExecuteActionProps) { + endpointExecuteAction(props: EndpointExecuteActionProps, kibanaSpace: string = 'default') { return supertest - .post('/api/endpoint/action/execute') + .post(routeWithNamespace('/api/endpoint/action/execute', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -413,10 +442,13 @@ Migrations are initiated per index. While the process is neither destructive nor /** * Download a file from an endpoint. */ - endpointFileDownload(props: EndpointFileDownloadProps) { + endpointFileDownload(props: EndpointFileDownloadProps, kibanaSpace: string = 'default') { return supertest .get( - replaceParams('/api/endpoint/action/{action_id}/file/{file_id}/download', props.params) + routeWithNamespace( + replaceParams('/api/endpoint/action/{action_id}/file/{file_id}/download', props.params), + kibanaSpace + ) ) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') @@ -425,9 +457,14 @@ Migrations are initiated per index. While the process is neither destructive nor /** * Get information for the specified file using the file ID. */ - endpointFileInfo(props: EndpointFileInfoProps) { + endpointFileInfo(props: EndpointFileInfoProps, kibanaSpace: string = 'default') { return supertest - .get(replaceParams('/api/endpoint/action/{action_id}/file/{file_id}', props.params)) + .get( + routeWithNamespace( + replaceParams('/api/endpoint/action/{action_id}/file/{file_id}', props.params), + kibanaSpace + ) + ) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); @@ -435,9 +472,17 @@ Migrations are initiated per index. While the process is neither destructive nor /** * Get the details of a response action using the action ID. */ - endpointGetActionsDetails(props: EndpointGetActionsDetailsProps) { + endpointGetActionsDetails( + props: EndpointGetActionsDetailsProps, + kibanaSpace: string = 'default' + ) { return supertest - .get(replaceParams('/api/endpoint/action/{action_id}', props.params)) + .get( + routeWithNamespace( + replaceParams('/api/endpoint/action/{action_id}', props.params), + kibanaSpace + ) + ) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); @@ -445,9 +490,9 @@ Migrations are initiated per index. While the process is neither destructive nor /** * Get a list of all response actions. */ - endpointGetActionsList(props: EndpointGetActionsListProps) { + endpointGetActionsList(props: EndpointGetActionsListProps, kibanaSpace: string = 'default') { return supertest - .get('/api/endpoint/action') + .get(routeWithNamespace('/api/endpoint/action', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -456,9 +501,9 @@ Migrations are initiated per index. While the process is neither destructive nor /** * Get a response actions state, which reports whether encryption is enabled. */ - endpointGetActionsState() { + endpointGetActionsState(kibanaSpace: string = 'default') { return supertest - .get('/api/endpoint/action/state') + .get(routeWithNamespace('/api/endpoint/action/state', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); @@ -466,9 +511,12 @@ Migrations are initiated per index. While the process is neither destructive nor /** * Get the status of response actions for the specified agent IDs. */ - endpointGetActionsStatus(props: EndpointGetActionsStatusProps) { + endpointGetActionsStatus( + props: EndpointGetActionsStatusProps, + kibanaSpace: string = 'default' + ) { return supertest - .get('/api/endpoint/action_status') + .get(routeWithNamespace('/api/endpoint/action_status', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -477,9 +525,9 @@ Migrations are initiated per index. While the process is neither destructive nor /** * Get a file from an endpoint. */ - endpointGetFileAction(props: EndpointGetFileActionProps) { + endpointGetFileAction(props: EndpointGetFileActionProps, kibanaSpace: string = 'default') { return supertest - .post('/api/endpoint/action/get_file') + .post(routeWithNamespace('/api/endpoint/action/get_file', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -488,9 +536,12 @@ Migrations are initiated per index. While the process is neither destructive nor /** * Get a list of all processes running on an endpoint. */ - endpointGetProcessesAction(props: EndpointGetProcessesActionProps) { + endpointGetProcessesAction( + props: EndpointGetProcessesActionProps, + kibanaSpace: string = 'default' + ) { return supertest - .post('/api/endpoint/action/running_procs') + .post(routeWithNamespace('/api/endpoint/action/running_procs', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -499,9 +550,9 @@ Migrations are initiated per index. While the process is neither destructive nor /** * Isolate an endpoint from the network. The endpoint remains isolated until it's released. */ - endpointIsolateAction(props: EndpointIsolateActionProps) { + endpointIsolateAction(props: EndpointIsolateActionProps, kibanaSpace: string = 'default') { return supertest - .post('/api/endpoint/action/isolate') + .post(routeWithNamespace('/api/endpoint/action/isolate', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -513,9 +564,9 @@ Migrations are initiated per index. While the process is neither destructive nor > This URL will return a 308 permanent redirect to `POST :/api/endpoint/action/isolate`. */ - endpointIsolateRedirect(props: EndpointIsolateRedirectProps) { + endpointIsolateRedirect(props: EndpointIsolateRedirectProps, kibanaSpace: string = 'default') { return supertest - .post('/api/endpoint/isolate') + .post(routeWithNamespace('/api/endpoint/isolate', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -524,9 +575,12 @@ Migrations are initiated per index. While the process is neither destructive nor /** * Terminate a running process on an endpoint. */ - endpointKillProcessAction(props: EndpointKillProcessActionProps) { + endpointKillProcessAction( + props: EndpointKillProcessActionProps, + kibanaSpace: string = 'default' + ) { return supertest - .post('/api/endpoint/action/kill_process') + .post(routeWithNamespace('/api/endpoint/action/kill_process', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -535,9 +589,9 @@ Migrations are initiated per index. While the process is neither destructive nor /** * Scan a specific file or directory on an endpoint for malware. */ - endpointScanAction(props: EndpointScanActionProps) { + endpointScanAction(props: EndpointScanActionProps, kibanaSpace: string = 'default') { return supertest - .post('/api/endpoint/action/scan') + .post(routeWithNamespace('/api/endpoint/action/scan', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -546,9 +600,12 @@ Migrations are initiated per index. While the process is neither destructive nor /** * Suspend a running process on an endpoint. */ - endpointSuspendProcessAction(props: EndpointSuspendProcessActionProps) { + endpointSuspendProcessAction( + props: EndpointSuspendProcessActionProps, + kibanaSpace: string = 'default' + ) { return supertest - .post('/api/endpoint/action/suspend_process') + .post(routeWithNamespace('/api/endpoint/action/suspend_process', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -557,9 +614,9 @@ Migrations are initiated per index. While the process is neither destructive nor /** * Release an isolated endpoint, allowing it to rejoin a network. */ - endpointUnisolateAction(props: EndpointUnisolateActionProps) { + endpointUnisolateAction(props: EndpointUnisolateActionProps, kibanaSpace: string = 'default') { return supertest - .post('/api/endpoint/action/unisolate') + .post(routeWithNamespace('/api/endpoint/action/unisolate', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -571,9 +628,12 @@ Migrations are initiated per index. While the process is neither destructive nor > This URL will return a 308 permanent redirect to `POST :/api/endpoint/action/unisolate`. */ - endpointUnisolateRedirect(props: EndpointUnisolateRedirectProps) { + endpointUnisolateRedirect( + props: EndpointUnisolateRedirectProps, + kibanaSpace: string = 'default' + ) { return supertest - .post('/api/endpoint/unisolate') + .post(routeWithNamespace('/api/endpoint/unisolate', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -582,9 +642,9 @@ Migrations are initiated per index. While the process is neither destructive nor /** * Upload a file to an endpoint. */ - endpointUploadAction(props: EndpointUploadActionProps) { + endpointUploadAction(props: EndpointUploadActionProps, kibanaSpace: string = 'default') { return supertest - .post('/api/endpoint/action/upload') + .post(routeWithNamespace('/api/endpoint/action/upload', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -598,18 +658,18 @@ Migrations are initiated per index. While the process is neither destructive nor > You cannot export prebuilt rules. */ - exportRules(props: ExportRulesProps) { + exportRules(props: ExportRulesProps, kibanaSpace: string = 'default') { return supertest - .post('/api/detection_engine/rules/_export') + .post(routeWithNamespace('/api/detection_engine/rules/_export', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .send(props.body as object) .query(props.query); }, - exportTimelines(props: ExportTimelinesProps) { + exportTimelines(props: ExportTimelinesProps, kibanaSpace: string = 'default') { return supertest - .post('/api/timeline/_export') + .post(routeWithNamespace('/api/timeline/_export', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -622,9 +682,9 @@ The endpoint is idempotent; therefore, it can safely be used to poll a given mig finalize it. */ - finalizeAlertsMigration(props: FinalizeAlertsMigrationProps) { + finalizeAlertsMigration(props: FinalizeAlertsMigrationProps, kibanaSpace: string = 'default') { return supertest - .post('/api/detection_engine/signals/finalize_migration') + .post(routeWithNamespace('/api/detection_engine/signals/finalize_migration', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -633,9 +693,12 @@ finalize it. /** * List asset criticality records, paging, sorting and filtering as needed. */ - findAssetCriticalityRecords(props: FindAssetCriticalityRecordsProps) { + findAssetCriticalityRecords( + props: FindAssetCriticalityRecordsProps, + kibanaSpace: string = 'default' + ) { return supertest - .get('/api/asset_criticality/list') + .get(routeWithNamespace('/api/asset_criticality/list', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -644,17 +707,17 @@ finalize it. /** * Retrieve a paginated list of detection rules. By default, the first page is returned, with 20 results per page. */ - findRules(props: FindRulesProps) { + findRules(props: FindRulesProps, kibanaSpace: string = 'default') { return supertest - .get('/api/detection_engine/rules/_find') + .get(routeWithNamespace('/api/detection_engine/rules/_find', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .query(props.query); }, - getAgentPolicySummary(props: GetAgentPolicySummaryProps) { + getAgentPolicySummary(props: GetAgentPolicySummaryProps, kibanaSpace: string = 'default') { return supertest - .get('/api/endpoint/policy/summaries') + .get(routeWithNamespace('/api/endpoint/policy/summaries', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -663,55 +726,73 @@ finalize it. /** * Get the criticality record for a specific asset. */ - getAssetCriticalityRecord(props: GetAssetCriticalityRecordProps) { + getAssetCriticalityRecord( + props: GetAssetCriticalityRecordProps, + kibanaSpace: string = 'default' + ) { return supertest - .get('/api/asset_criticality') + .get(routeWithNamespace('/api/asset_criticality', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .query(props.query); }, - getAssetCriticalityStatus() { + getAssetCriticalityStatus(kibanaSpace: string = 'default') { return supertest - .get('/internal/asset_criticality/status') + .get(routeWithNamespace('/internal/asset_criticality/status', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '1') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); }, - getDraftTimelines(props: GetDraftTimelinesProps) { + getDraftTimelines(props: GetDraftTimelinesProps, kibanaSpace: string = 'default') { return supertest - .get('/api/timeline/_draft') + .get(routeWithNamespace('/api/timeline/_draft', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .query(props.query); }, - getEndpointMetadataList(props: GetEndpointMetadataListProps) { + getEndpointMetadataList(props: GetEndpointMetadataListProps, kibanaSpace: string = 'default') { return supertest - .get('/api/endpoint/metadata') + .get(routeWithNamespace('/api/endpoint/metadata', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .query(props.query); }, - getEndpointSuggestions(props: GetEndpointSuggestionsProps) { + getEndpointSuggestions(props: GetEndpointSuggestionsProps, kibanaSpace: string = 'default') { return supertest - .post(replaceParams('/api/endpoint/suggestions/{suggestion_type}', props.params)) + .post( + routeWithNamespace( + replaceParams('/api/endpoint/suggestions/{suggestion_type}', props.params), + kibanaSpace + ) + ) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .send(props.body as object); }, - getEntityEngine(props: GetEntityEngineProps) { + getEntityEngine(props: GetEntityEngineProps, kibanaSpace: string = 'default') { return supertest - .get(replaceParams('/api/entity_store/engines/{entityType}', props.params)) + .get( + routeWithNamespace( + replaceParams('/api/entity_store/engines/{entityType}', props.params), + kibanaSpace + ) + ) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); }, - getEntityEngineStats(props: GetEntityEngineStatsProps) { + getEntityEngineStats(props: GetEntityEngineStatsProps, kibanaSpace: string = 'default') { return supertest - .post(replaceParams('/api/entity_store/engines/{entityType}/stats', props.params)) + .post( + routeWithNamespace( + replaceParams('/api/entity_store/engines/{entityType}/stats', props.params), + kibanaSpace + ) + ) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); @@ -719,26 +800,35 @@ finalize it. /** * Gets notes */ - getNotes(props: GetNotesProps) { + getNotes(props: GetNotesProps, kibanaSpace: string = 'default') { return supertest - .get('/api/note') + .get(routeWithNamespace('/api/note', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .query(props.query); }, - getPolicyResponse(props: GetPolicyResponseProps) { + getPolicyResponse(props: GetPolicyResponseProps, kibanaSpace: string = 'default') { return supertest - .get('/api/endpoint/policy_response') + .get(routeWithNamespace('/api/endpoint/policy_response', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .query(props.query); }, - getProtectionUpdatesNote(props: GetProtectionUpdatesNoteProps) { + getProtectionUpdatesNote( + props: GetProtectionUpdatesNoteProps, + kibanaSpace: string = 'default' + ) { return supertest .get( - replaceParams('/api/endpoint/protection_updates_note/{package_policy_id}', props.params) + routeWithNamespace( + replaceParams( + '/api/endpoint/protection_updates_note/{package_policy_id}', + props.params + ), + kibanaSpace + ) ) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') @@ -747,44 +837,56 @@ finalize it. /** * Returns the status of both the legacy transform-based risk engine, as well as the new risk engine */ - getRiskEngineStatus() { + getRiskEngineStatus(kibanaSpace: string = 'default') { return supertest - .get('/internal/risk_score/engine/status') + .get(routeWithNamespace('/internal/risk_score/engine/status', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '1') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); }, - getRuleExecutionEvents(props: GetRuleExecutionEventsProps) { + getRuleExecutionEvents(props: GetRuleExecutionEventsProps, kibanaSpace: string = 'default') { return supertest .put( - replaceParams('/internal/detection_engine/rules/{ruleId}/execution/events', props.params) + routeWithNamespace( + replaceParams( + '/internal/detection_engine/rules/{ruleId}/execution/events', + props.params + ), + kibanaSpace + ) ) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '1') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .query(props.query); }, - getRuleExecutionResults(props: GetRuleExecutionResultsProps) { + getRuleExecutionResults(props: GetRuleExecutionResultsProps, kibanaSpace: string = 'default') { return supertest .put( - replaceParams('/internal/detection_engine/rules/{ruleId}/execution/results', props.params) + routeWithNamespace( + replaceParams( + '/internal/detection_engine/rules/{ruleId}/execution/results', + props.params + ), + kibanaSpace + ) ) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '1') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .query(props.query); }, - getTimeline(props: GetTimelineProps) { + getTimeline(props: GetTimelineProps, kibanaSpace: string = 'default') { return supertest - .get('/api/timeline') + .get(routeWithNamespace('/api/timeline', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .query(props.query); }, - getTimelines(props: GetTimelinesProps) { + getTimelines(props: GetTimelinesProps, kibanaSpace: string = 'default') { return supertest - .get('/api/timelines') + .get(routeWithNamespace('/api/timelines', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -796,25 +898,30 @@ finalize it. - A link to the `.ndjson` file containing the rules. */ - importRules(props: ImportRulesProps) { + importRules(props: ImportRulesProps, kibanaSpace: string = 'default') { return supertest - .post('/api/detection_engine/rules/_import') + .post(routeWithNamespace('/api/detection_engine/rules/_import', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .query(props.query); }, - importTimelines(props: ImportTimelinesProps) { + importTimelines(props: ImportTimelinesProps, kibanaSpace: string = 'default') { return supertest - .post('/api/timeline/_import') + .post(routeWithNamespace('/api/timeline/_import', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .send(props.body as object); }, - initEntityEngine(props: InitEntityEngineProps) { + initEntityEngine(props: InitEntityEngineProps, kibanaSpace: string = 'default') { return supertest - .post(replaceParams('/api/entity_store/engines/{entityType}/init', props.params)) + .post( + routeWithNamespace( + replaceParams('/api/entity_store/engines/{entityType}/init', props.params), + kibanaSpace + ) + ) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -823,9 +930,9 @@ finalize it. /** * Initializes the Risk Engine by creating the necessary indices and mappings, removing old transforms, and starting the new risk engine */ - initRiskEngine() { + initRiskEngine(kibanaSpace: string = 'default') { return supertest - .post('/internal/risk_score/engine/init') + .post(routeWithNamespace('/internal/risk_score/engine/init', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '1') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); @@ -833,24 +940,27 @@ finalize it. /** * Install and update all Elastic prebuilt detection rules and Timelines. */ - installPrebuiltRulesAndTimelines() { + installPrebuiltRulesAndTimelines(kibanaSpace: string = 'default') { return supertest - .put('/api/detection_engine/rules/prepackaged') + .put(routeWithNamespace('/api/detection_engine/rules/prepackaged', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); }, - installPrepackedTimelines(props: InstallPrepackedTimelinesProps) { + installPrepackedTimelines( + props: InstallPrepackedTimelinesProps, + kibanaSpace: string = 'default' + ) { return supertest - .post('/api/timeline/_prepackaged') + .post(routeWithNamespace('/api/timeline/_prepackaged', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .send(props.body as object); }, - internalUploadAssetCriticalityRecords() { + internalUploadAssetCriticalityRecords(kibanaSpace: string = 'default') { return supertest - .post('/internal/asset_criticality/upload_csv') + .post(routeWithNamespace('/internal/asset_criticality/upload_csv', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '1') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); @@ -858,17 +968,17 @@ finalize it. /** * List entities records, paging, sorting and filtering as needed. */ - listEntities(props: ListEntitiesProps) { + listEntities(props: ListEntitiesProps, kibanaSpace: string = 'default') { return supertest - .get('/api/entity_store/entities/list') + .get(routeWithNamespace('/api/entity_store/entities/list', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .query(props.query); }, - listEntityEngines() { + listEntityEngines(kibanaSpace: string = 'default') { return supertest - .get('/api/entity_store/engines') + .get(routeWithNamespace('/api/entity_store/engines', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); @@ -876,9 +986,9 @@ finalize it. /** * Update specific fields of an existing detection rule using the `rule_id` or `id` field. */ - patchRule(props: PatchRuleProps) { + patchRule(props: PatchRuleProps, kibanaSpace: string = 'default') { return supertest - .patch('/api/detection_engine/rules') + .patch(routeWithNamespace('/api/detection_engine/rules', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -887,9 +997,9 @@ finalize it. /** * Updates an existing timeline. This API is used to update the title, description, date range, pinned events, pinned queries, and/or pinned saved queries of an existing timeline. */ - patchTimeline(props: PatchTimelineProps) { + patchTimeline(props: PatchTimelineProps, kibanaSpace: string = 'default') { return supertest - .patch('/api/timeline') + .patch(routeWithNamespace('/api/timeline', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -898,34 +1008,34 @@ finalize it. /** * Apply a bulk action, such as bulk edit, duplicate, or delete, to multiple detection rules. The bulk action is applied to all rules that match the query or to the rules listed by their IDs. */ - performRulesBulkAction(props: PerformRulesBulkActionProps) { + performRulesBulkAction(props: PerformRulesBulkActionProps, kibanaSpace: string = 'default') { return supertest - .post('/api/detection_engine/rules/_bulk_action') + .post(routeWithNamespace('/api/detection_engine/rules/_bulk_action', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .send(props.body as object) .query(props.query); }, - persistFavoriteRoute(props: PersistFavoriteRouteProps) { + persistFavoriteRoute(props: PersistFavoriteRouteProps, kibanaSpace: string = 'default') { return supertest - .patch('/api/timeline/_favorite') + .patch(routeWithNamespace('/api/timeline/_favorite', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .send(props.body as object); }, - persistNoteRoute(props: PersistNoteRouteProps) { + persistNoteRoute(props: PersistNoteRouteProps, kibanaSpace: string = 'default') { return supertest - .patch('/api/note') + .patch(routeWithNamespace('/api/note', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .send(props.body as object); }, - persistPinnedEventRoute(props: PersistPinnedEventRouteProps) { + persistPinnedEventRoute(props: PersistPinnedEventRouteProps, kibanaSpace: string = 'default') { return supertest - .patch('/api/pinned_event') + .patch(routeWithNamespace('/api/pinned_event', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -934,17 +1044,17 @@ finalize it. /** * Calculates and returns a list of Risk Scores, sorted by identifier_type and risk score. */ - previewRiskScore(props: PreviewRiskScoreProps) { + previewRiskScore(props: PreviewRiskScoreProps, kibanaSpace: string = 'default') { return supertest - .post('/internal/risk_score/preview') + .post(routeWithNamespace('/internal/risk_score/preview', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '1') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .send(props.body as object); }, - readAlertsIndex() { + readAlertsIndex(kibanaSpace: string = 'default') { return supertest - .get('/api/detection_engine/index') + .get(routeWithNamespace('/api/detection_engine/index', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); @@ -952,9 +1062,12 @@ finalize it. /** * Retrieve indices that contain detection alerts of a particular age, along with migration information for each of those indices. */ - readAlertsMigrationStatus(props: ReadAlertsMigrationStatusProps) { + readAlertsMigrationStatus( + props: ReadAlertsMigrationStatusProps, + kibanaSpace: string = 'default' + ) { return supertest - .post('/api/detection_engine/signals/migration_status') + .post(routeWithNamespace('/api/detection_engine/signals/migration_status', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -963,9 +1076,9 @@ finalize it. /** * Retrieve the status of all Elastic prebuilt detection rules and Timelines. */ - readPrebuiltRulesAndTimelinesStatus() { + readPrebuiltRulesAndTimelinesStatus(kibanaSpace: string = 'default') { return supertest - .get('/api/detection_engine/rules/prepackaged/_status') + .get(routeWithNamespace('/api/detection_engine/rules/prepackaged/_status', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); @@ -977,16 +1090,16 @@ index for the Elastic Security alerts generated by detection engine rules. */ - readPrivileges() { + readPrivileges(kibanaSpace: string = 'default') { return supertest - .get('/api/detection_engine/privileges') + .get(routeWithNamespace('/api/detection_engine/privileges', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); }, - readRiskEngineSettings() { + readRiskEngineSettings(kibanaSpace: string = 'default') { return supertest - .get('/internal/risk_score/engine/settings') + .get(routeWithNamespace('/internal/risk_score/engine/settings', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '1') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); @@ -994,9 +1107,9 @@ detection engine rules. /** * Retrieve a detection rule using the `rule_id` or `id` field. */ - readRule(props: ReadRuleProps) { + readRule(props: ReadRuleProps, kibanaSpace: string = 'default') { return supertest - .get('/api/detection_engine/rules') + .get(routeWithNamespace('/api/detection_engine/rules', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -1005,40 +1118,40 @@ detection engine rules. /** * List all unique tags from all detection rules. */ - readTags() { + readTags(kibanaSpace: string = 'default') { return supertest - .get('/api/detection_engine/tags') + .get(routeWithNamespace('/api/detection_engine/tags', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); }, - resolveTimeline(props: ResolveTimelineProps) { + resolveTimeline(props: ResolveTimelineProps, kibanaSpace: string = 'default') { return supertest - .get('/api/timeline/resolve') + .get(routeWithNamespace('/api/timeline/resolve', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .query(props.query); }, - riskEngineGetPrivileges() { + riskEngineGetPrivileges(kibanaSpace: string = 'default') { return supertest - .get('/internal/risk_engine/privileges') + .get(routeWithNamespace('/internal/risk_engine/privileges', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '1') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); }, - rulePreview(props: RulePreviewProps) { + rulePreview(props: RulePreviewProps, kibanaSpace: string = 'default') { return supertest - .post('/api/detection_engine/rules/preview') + .post(routeWithNamespace('/api/detection_engine/rules/preview', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .send(props.body as object) .query(props.query); }, - scheduleRiskEngineNow() { + scheduleRiskEngineNow(kibanaSpace: string = 'default') { return supertest - .post('/api/risk_score/engine/schedule_now') + .post(routeWithNamespace('/api/risk_score/engine/schedule_now', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); @@ -1046,9 +1159,9 @@ detection engine rules. /** * Find and/or aggregate detection alerts that match the given query. */ - searchAlerts(props: SearchAlertsProps) { + searchAlerts(props: SearchAlertsProps, kibanaSpace: string = 'default') { return supertest - .post('/api/detection_engine/signals/search') + .post(routeWithNamespace('/api/detection_engine/signals/search', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -1060,9 +1173,9 @@ detection engine rules. > You cannot add and remove the same assignee in the same request. */ - setAlertAssignees(props: SetAlertAssigneesProps) { + setAlertAssignees(props: SetAlertAssigneesProps, kibanaSpace: string = 'default') { return supertest - .post('/api/detection_engine/signals/assignees') + .post(routeWithNamespace('/api/detection_engine/signals/assignees', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -1071,9 +1184,9 @@ detection engine rules. /** * Set the status of one or more detection alerts. */ - setAlertsStatus(props: SetAlertsStatusProps) { + setAlertsStatus(props: SetAlertsStatusProps, kibanaSpace: string = 'default') { return supertest - .post('/api/detection_engine/signals/status') + .post(routeWithNamespace('/api/detection_engine/signals/status', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -1085,24 +1198,34 @@ detection engine rules. > You cannot add and remove the same alert tag in the same request. */ - setAlertTags(props: SetAlertTagsProps) { + setAlertTags(props: SetAlertTagsProps, kibanaSpace: string = 'default') { return supertest - .post('/api/detection_engine/signals/tags') + .post(routeWithNamespace('/api/detection_engine/signals/tags', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .send(props.body as object); }, - startEntityEngine(props: StartEntityEngineProps) { + startEntityEngine(props: StartEntityEngineProps, kibanaSpace: string = 'default') { return supertest - .post(replaceParams('/api/entity_store/engines/{entityType}/start', props.params)) + .post( + routeWithNamespace( + replaceParams('/api/entity_store/engines/{entityType}/start', props.params), + kibanaSpace + ) + ) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); }, - stopEntityEngine(props: StopEntityEngineProps) { + stopEntityEngine(props: StopEntityEngineProps, kibanaSpace: string = 'default') { return supertest - .post(replaceParams('/api/entity_store/engines/{entityType}/stop', props.params)) + .post( + routeWithNamespace( + replaceParams('/api/entity_store/engines/{entityType}/stop', props.params), + kibanaSpace + ) + ) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); @@ -1110,9 +1233,9 @@ detection engine rules. /** * Suggests user profiles. */ - suggestUserProfiles(props: SuggestUserProfilesProps) { + suggestUserProfiles(props: SuggestUserProfilesProps, kibanaSpace: string = 'default') { return supertest - .post('/internal/detection_engine/users/_find') + .post(routeWithNamespace('/internal/detection_engine/users/_find', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '1') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -1121,9 +1244,12 @@ detection engine rules. /** * Calculates and persists Risk Scores for an entity, returning the calculated risk score. */ - triggerRiskScoreCalculation(props: TriggerRiskScoreCalculationProps) { + triggerRiskScoreCalculation( + props: TriggerRiskScoreCalculationProps, + kibanaSpace: string = 'default' + ) { return supertest - .post('/internal/risk_score/calculation/entity') + .post(routeWithNamespace('/internal/risk_score/calculation/entity', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '1') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -1135,17 +1261,17 @@ detection engine rules. > You cannot modify the `id` or `rule_id` values. */ - updateRule(props: UpdateRuleProps) { + updateRule(props: UpdateRuleProps, kibanaSpace: string = 'default') { return supertest - .put('/api/detection_engine/rules') + .put(routeWithNamespace('/api/detection_engine/rules', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .send(props.body as object); }, - uploadAssetCriticalityRecords() { + uploadAssetCriticalityRecords(kibanaSpace: string = 'default') { return supertest - .post('/api/asset_criticality/upload_csv') + .post(routeWithNamespace('/api/asset_criticality/upload_csv', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '1') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); diff --git a/x-pack/test/api_integration/services/security_solution_endpoint_exceptions_api.gen.ts b/x-pack/test/api_integration/services/security_solution_endpoint_exceptions_api.gen.ts index 9f77c4575828a..30e2c4d8dc7f4 100644 --- a/x-pack/test/api_integration/services/security_solution_endpoint_exceptions_api.gen.ts +++ b/x-pack/test/api_integration/services/security_solution_endpoint_exceptions_api.gen.ts @@ -24,6 +24,7 @@ import { DeleteEndpointListItemRequestQueryInput } from '@kbn/securitysolution-e import { FindEndpointListItemsRequestQueryInput } from '@kbn/securitysolution-endpoint-exceptions-common/api/find_endpoint_list_item/find_endpoint_list_item.gen'; import { ReadEndpointListItemRequestQueryInput } from '@kbn/securitysolution-endpoint-exceptions-common/api/read_endpoint_list_item/read_endpoint_list_item.gen'; import { UpdateEndpointListItemRequestBodyInput } from '@kbn/securitysolution-endpoint-exceptions-common/api/update_endpoint_list_item/update_endpoint_list_item.gen'; +import { routeWithNamespace } from '../../common/utils/security_solution'; import { FtrProviderContext } from '../ftr_provider_context'; export function SecuritySolutionApiProvider({ getService }: FtrProviderContext) { @@ -33,48 +34,48 @@ export function SecuritySolutionApiProvider({ getService }: FtrProviderContext) /** * Creates an endpoint list or does nothing if the list already exists */ - createEndpointList() { + createEndpointList(kibanaSpace: string = 'default') { return supertest - .post('/api/endpoint_list') + .post(routeWithNamespace('/api/endpoint_list', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); }, - createEndpointListItem(props: CreateEndpointListItemProps) { + createEndpointListItem(props: CreateEndpointListItemProps, kibanaSpace: string = 'default') { return supertest - .post('/api/endpoint_list/items') + .post(routeWithNamespace('/api/endpoint_list/items', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .send(props.body as object); }, - deleteEndpointListItem(props: DeleteEndpointListItemProps) { + deleteEndpointListItem(props: DeleteEndpointListItemProps, kibanaSpace: string = 'default') { return supertest - .delete('/api/endpoint_list/items') + .delete(routeWithNamespace('/api/endpoint_list/items', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .query(props.query); }, - findEndpointListItems(props: FindEndpointListItemsProps) { + findEndpointListItems(props: FindEndpointListItemsProps, kibanaSpace: string = 'default') { return supertest - .get('/api/endpoint_list/items/_find') + .get(routeWithNamespace('/api/endpoint_list/items/_find', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .query(props.query); }, - readEndpointListItem(props: ReadEndpointListItemProps) { + readEndpointListItem(props: ReadEndpointListItemProps, kibanaSpace: string = 'default') { return supertest - .get('/api/endpoint_list/items') + .get(routeWithNamespace('/api/endpoint_list/items', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .query(props.query); }, - updateEndpointListItem(props: UpdateEndpointListItemProps) { + updateEndpointListItem(props: UpdateEndpointListItemProps, kibanaSpace: string = 'default') { return supertest - .put('/api/endpoint_list/items') + .put(routeWithNamespace('/api/endpoint_list/items', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') diff --git a/x-pack/test/api_integration/services/security_solution_exceptions_api.gen.ts b/x-pack/test/api_integration/services/security_solution_exceptions_api.gen.ts index e7426a737b39c..bc51326425ab1 100644 --- a/x-pack/test/api_integration/services/security_solution_exceptions_api.gen.ts +++ b/x-pack/test/api_integration/services/security_solution_exceptions_api.gen.ts @@ -39,63 +39,75 @@ import { ReadExceptionListItemRequestQueryInput } from '@kbn/securitysolution-ex import { ReadExceptionListSummaryRequestQueryInput } from '@kbn/securitysolution-exceptions-common/api/read_exception_list_summary/read_exception_list_summary.gen'; import { UpdateExceptionListRequestBodyInput } from '@kbn/securitysolution-exceptions-common/api/update_exception_list/update_exception_list.gen'; import { UpdateExceptionListItemRequestBodyInput } from '@kbn/securitysolution-exceptions-common/api/update_exception_list_item/update_exception_list_item.gen'; +import { routeWithNamespace } from '../../common/utils/security_solution'; import { FtrProviderContext } from '../ftr_provider_context'; export function SecuritySolutionApiProvider({ getService }: FtrProviderContext) { const supertest = getService('supertest'); return { - createExceptionList(props: CreateExceptionListProps) { + createExceptionList(props: CreateExceptionListProps, kibanaSpace: string = 'default') { return supertest - .post('/api/exception_lists') + .post(routeWithNamespace('/api/exception_lists', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .send(props.body as object); }, - createExceptionListItem(props: CreateExceptionListItemProps) { + createExceptionListItem(props: CreateExceptionListItemProps, kibanaSpace: string = 'default') { return supertest - .post('/api/exception_lists/items') + .post(routeWithNamespace('/api/exception_lists/items', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .send(props.body as object); }, - createRuleExceptionListItems(props: CreateRuleExceptionListItemsProps) { + createRuleExceptionListItems( + props: CreateRuleExceptionListItemsProps, + kibanaSpace: string = 'default' + ) { return supertest - .post(replaceParams('/api/detection_engine/rules/{id}/exceptions', props.params)) + .post( + routeWithNamespace( + replaceParams('/api/detection_engine/rules/{id}/exceptions', props.params), + kibanaSpace + ) + ) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .send(props.body as object); }, - createSharedExceptionList(props: CreateSharedExceptionListProps) { + createSharedExceptionList( + props: CreateSharedExceptionListProps, + kibanaSpace: string = 'default' + ) { return supertest - .post('/api/exceptions/shared') + .post(routeWithNamespace('/api/exceptions/shared', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .send(props.body as object); }, - deleteExceptionList(props: DeleteExceptionListProps) { + deleteExceptionList(props: DeleteExceptionListProps, kibanaSpace: string = 'default') { return supertest - .delete('/api/exception_lists') + .delete(routeWithNamespace('/api/exception_lists', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .query(props.query); }, - deleteExceptionListItem(props: DeleteExceptionListItemProps) { + deleteExceptionListItem(props: DeleteExceptionListItemProps, kibanaSpace: string = 'default') { return supertest - .delete('/api/exception_lists/items') + .delete(routeWithNamespace('/api/exception_lists/items', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .query(props.query); }, - duplicateExceptionList(props: DuplicateExceptionListProps) { + duplicateExceptionList(props: DuplicateExceptionListProps, kibanaSpace: string = 'default') { return supertest - .post('/api/exception_lists/_duplicate') + .post(routeWithNamespace('/api/exception_lists/_duplicate', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -104,25 +116,25 @@ export function SecuritySolutionApiProvider({ getService }: FtrProviderContext) /** * Exports an exception list and its associated items to an .ndjson file */ - exportExceptionList(props: ExportExceptionListProps) { + exportExceptionList(props: ExportExceptionListProps, kibanaSpace: string = 'default') { return supertest - .post('/api/exception_lists/_export') + .post(routeWithNamespace('/api/exception_lists/_export', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .query(props.query); }, - findExceptionListItems(props: FindExceptionListItemsProps) { + findExceptionListItems(props: FindExceptionListItemsProps, kibanaSpace: string = 'default') { return supertest - .get('/api/exception_lists/items/_find') + .get(routeWithNamespace('/api/exception_lists/items/_find', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .query(props.query); }, - findExceptionLists(props: FindExceptionListsProps) { + findExceptionLists(props: FindExceptionListsProps, kibanaSpace: string = 'default') { return supertest - .get('/api/exception_lists/_find') + .get(routeWithNamespace('/api/exception_lists/_find', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -131,49 +143,52 @@ export function SecuritySolutionApiProvider({ getService }: FtrProviderContext) /** * Imports an exception list and associated items */ - importExceptionList(props: ImportExceptionListProps) { + importExceptionList(props: ImportExceptionListProps, kibanaSpace: string = 'default') { return supertest - .post('/api/exception_lists/_import') + .post(routeWithNamespace('/api/exception_lists/_import', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .query(props.query); }, - readExceptionList(props: ReadExceptionListProps) { + readExceptionList(props: ReadExceptionListProps, kibanaSpace: string = 'default') { return supertest - .get('/api/exception_lists') + .get(routeWithNamespace('/api/exception_lists', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .query(props.query); }, - readExceptionListItem(props: ReadExceptionListItemProps) { + readExceptionListItem(props: ReadExceptionListItemProps, kibanaSpace: string = 'default') { return supertest - .get('/api/exception_lists/items') + .get(routeWithNamespace('/api/exception_lists/items', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .query(props.query); }, - readExceptionListSummary(props: ReadExceptionListSummaryProps) { + readExceptionListSummary( + props: ReadExceptionListSummaryProps, + kibanaSpace: string = 'default' + ) { return supertest - .get('/api/exception_lists/summary') + .get(routeWithNamespace('/api/exception_lists/summary', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .query(props.query); }, - updateExceptionList(props: UpdateExceptionListProps) { + updateExceptionList(props: UpdateExceptionListProps, kibanaSpace: string = 'default') { return supertest - .put('/api/exception_lists') + .put(routeWithNamespace('/api/exception_lists', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .send(props.body as object); }, - updateExceptionListItem(props: UpdateExceptionListItemProps) { + updateExceptionListItem(props: UpdateExceptionListItemProps, kibanaSpace: string = 'default') { return supertest - .put('/api/exception_lists/items') + .put(routeWithNamespace('/api/exception_lists/items', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') diff --git a/x-pack/test/api_integration/services/security_solution_lists_api.gen.ts b/x-pack/test/api_integration/services/security_solution_lists_api.gen.ts index 4ebd688bf296a..6c04c76baf482 100644 --- a/x-pack/test/api_integration/services/security_solution_lists_api.gen.ts +++ b/x-pack/test/api_integration/services/security_solution_lists_api.gen.ts @@ -33,53 +33,54 @@ import { ReadListRequestQueryInput } from '@kbn/securitysolution-lists-common/ap import { ReadListItemRequestQueryInput } from '@kbn/securitysolution-lists-common/api/read_list_item/read_list_item.gen'; import { UpdateListRequestBodyInput } from '@kbn/securitysolution-lists-common/api/update_list/update_list.gen'; import { UpdateListItemRequestBodyInput } from '@kbn/securitysolution-lists-common/api/update_list_item/update_list_item.gen'; +import { routeWithNamespace } from '../../common/utils/security_solution'; import { FtrProviderContext } from '../ftr_provider_context'; export function SecuritySolutionApiProvider({ getService }: FtrProviderContext) { const supertest = getService('supertest'); return { - createList(props: CreateListProps) { + createList(props: CreateListProps, kibanaSpace: string = 'default') { return supertest - .post('/api/lists') + .post(routeWithNamespace('/api/lists', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .send(props.body as object); }, - createListIndex() { + createListIndex(kibanaSpace: string = 'default') { return supertest - .post('/api/lists/index') + .post(routeWithNamespace('/api/lists/index', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); }, - createListItem(props: CreateListItemProps) { + createListItem(props: CreateListItemProps, kibanaSpace: string = 'default') { return supertest - .post('/api/lists/items') + .post(routeWithNamespace('/api/lists/items', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .send(props.body as object); }, - deleteList(props: DeleteListProps) { + deleteList(props: DeleteListProps, kibanaSpace: string = 'default') { return supertest - .delete('/api/lists') + .delete(routeWithNamespace('/api/lists', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .query(props.query); }, - deleteListIndex() { + deleteListIndex(kibanaSpace: string = 'default') { return supertest - .delete('/api/lists/index') + .delete(routeWithNamespace('/api/lists/index', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); }, - deleteListItem(props: DeleteListItemProps) { + deleteListItem(props: DeleteListItemProps, kibanaSpace: string = 'default') { return supertest - .delete('/api/lists/items') + .delete(routeWithNamespace('/api/lists/items', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -88,25 +89,25 @@ export function SecuritySolutionApiProvider({ getService }: FtrProviderContext) /** * Exports list item values from the specified list */ - exportListItems(props: ExportListItemsProps) { + exportListItems(props: ExportListItemsProps, kibanaSpace: string = 'default') { return supertest - .post('/api/lists/items/_export') + .post(routeWithNamespace('/api/lists/items/_export', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .query(props.query); }, - findListItems(props: FindListItemsProps) { + findListItems(props: FindListItemsProps, kibanaSpace: string = 'default') { return supertest - .get('/api/lists/items/_find') + .get(routeWithNamespace('/api/lists/items/_find', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .query(props.query); }, - findLists(props: FindListsProps) { + findLists(props: FindListsProps, kibanaSpace: string = 'default') { return supertest - .get('/api/lists/_find') + .get(routeWithNamespace('/api/lists/_find', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -118,71 +119,71 @@ export function SecuritySolutionApiProvider({ getService }: FtrProviderContext) You can import items to a new or existing list. */ - importListItems(props: ImportListItemsProps) { + importListItems(props: ImportListItemsProps, kibanaSpace: string = 'default') { return supertest - .post('/api/lists/items/_import') + .post(routeWithNamespace('/api/lists/items/_import', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .query(props.query); }, - patchList(props: PatchListProps) { + patchList(props: PatchListProps, kibanaSpace: string = 'default') { return supertest - .patch('/api/lists') + .patch(routeWithNamespace('/api/lists', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .send(props.body as object); }, - patchListItem(props: PatchListItemProps) { + patchListItem(props: PatchListItemProps, kibanaSpace: string = 'default') { return supertest - .patch('/api/lists/items') + .patch(routeWithNamespace('/api/lists/items', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .send(props.body as object); }, - readList(props: ReadListProps) { + readList(props: ReadListProps, kibanaSpace: string = 'default') { return supertest - .get('/api/lists') + .get(routeWithNamespace('/api/lists', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .query(props.query); }, - readListIndex() { + readListIndex(kibanaSpace: string = 'default') { return supertest - .get('/api/lists/index') + .get(routeWithNamespace('/api/lists/index', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); }, - readListItem(props: ReadListItemProps) { + readListItem(props: ReadListItemProps, kibanaSpace: string = 'default') { return supertest - .get('/api/lists/items') + .get(routeWithNamespace('/api/lists/items', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .query(props.query); }, - readListPrivileges() { + readListPrivileges(kibanaSpace: string = 'default') { return supertest - .get('/api/lists/privileges') + .get(routeWithNamespace('/api/lists/privileges', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); }, - updateList(props: UpdateListProps) { + updateList(props: UpdateListProps, kibanaSpace: string = 'default') { return supertest - .put('/api/lists') + .put(routeWithNamespace('/api/lists', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .send(props.body as object); }, - updateListItem(props: UpdateListItemProps) { + updateListItem(props: UpdateListItemProps, kibanaSpace: string = 'default') { return supertest - .put('/api/lists/items') + .put(routeWithNamespace('/api/lists/items', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') diff --git a/x-pack/test/api_integration/services/security_solution_osquery_api.gen.ts b/x-pack/test/api_integration/services/security_solution_osquery_api.gen.ts index c133ebce15c90..7f553041d53d1 100644 --- a/x-pack/test/api_integration/services/security_solution_osquery_api.gen.ts +++ b/x-pack/test/api_integration/services/security_solution_osquery_api.gen.ts @@ -51,43 +51,54 @@ import { } from '@kbn/osquery-plugin/common/api/saved_query/saved_query.gen'; import { ReadAssetsStatusRequestQueryInput } from '@kbn/osquery-plugin/common/api/asset/assets.gen'; import { UpdateAssetsStatusRequestQueryInput } from '@kbn/osquery-plugin/common/api/asset/assets.gen'; +import { routeWithNamespace } from '../../common/utils/security_solution'; import { FtrProviderContext } from '../ftr_provider_context'; export function SecuritySolutionApiProvider({ getService }: FtrProviderContext) { const supertest = getService('supertest'); return { - getAgentDetails(props: GetAgentDetailsProps) { + getAgentDetails(props: GetAgentDetailsProps, kibanaSpace: string = 'default') { return supertest - .get(replaceParams('/internal/osquery/fleet_wrapper/agents/{id}', props.params)) + .get( + routeWithNamespace( + replaceParams('/internal/osquery/fleet_wrapper/agents/{id}', props.params), + kibanaSpace + ) + ) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '1') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); }, - getAgentPackagePolicies() { + getAgentPackagePolicies(kibanaSpace: string = 'default') { return supertest - .get('/internal/osquery/fleet_wrapper/package_policies') + .get(routeWithNamespace('/internal/osquery/fleet_wrapper/package_policies', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '1') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); }, - getAgentPolicies() { + getAgentPolicies(kibanaSpace: string = 'default') { return supertest - .get('/internal/osquery/fleet_wrapper/agent_policies') + .get(routeWithNamespace('/internal/osquery/fleet_wrapper/agent_policies', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '1') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); }, - getAgentPolicy(props: GetAgentPolicyProps) { + getAgentPolicy(props: GetAgentPolicyProps, kibanaSpace: string = 'default') { return supertest - .get(replaceParams('/internal/osquery/fleet_wrapper/agent_policies/{id}', props.params)) + .get( + routeWithNamespace( + replaceParams('/internal/osquery/fleet_wrapper/agent_policies/{id}', props.params), + kibanaSpace + ) + ) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '1') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); }, - getAgents(props: GetAgentsProps) { + getAgents(props: GetAgentsProps, kibanaSpace: string = 'default') { return supertest - .get('/internal/osquery/fleet_wrapper/agents') + .get(routeWithNamespace('/internal/osquery/fleet_wrapper/agents', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '1') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -96,9 +107,9 @@ export function SecuritySolutionApiProvider({ getService }: FtrProviderContext) /** * Create and run a live query. */ - osqueryCreateLiveQuery(props: OsqueryCreateLiveQueryProps) { + osqueryCreateLiveQuery(props: OsqueryCreateLiveQueryProps, kibanaSpace: string = 'default') { return supertest - .post('/api/osquery/live_queries') + .post(routeWithNamespace('/api/osquery/live_queries', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -107,9 +118,9 @@ export function SecuritySolutionApiProvider({ getService }: FtrProviderContext) /** * Create a query pack. */ - osqueryCreatePacks(props: OsqueryCreatePacksProps) { + osqueryCreatePacks(props: OsqueryCreatePacksProps, kibanaSpace: string = 'default') { return supertest - .post('/api/osquery/packs') + .post(routeWithNamespace('/api/osquery/packs', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -118,9 +129,9 @@ export function SecuritySolutionApiProvider({ getService }: FtrProviderContext) /** * Create and run a saved query. */ - osqueryCreateSavedQuery(props: OsqueryCreateSavedQueryProps) { + osqueryCreateSavedQuery(props: OsqueryCreateSavedQueryProps, kibanaSpace: string = 'default') { return supertest - .post('/api/osquery/saved_queries') + .post(routeWithNamespace('/api/osquery/saved_queries', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -129,9 +140,11 @@ export function SecuritySolutionApiProvider({ getService }: FtrProviderContext) /** * Delete a query pack using the pack ID. */ - osqueryDeletePacks(props: OsqueryDeletePacksProps) { + osqueryDeletePacks(props: OsqueryDeletePacksProps, kibanaSpace: string = 'default') { return supertest - .delete(replaceParams('/api/osquery/packs/{id}', props.params)) + .delete( + routeWithNamespace(replaceParams('/api/osquery/packs/{id}', props.params), kibanaSpace) + ) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); @@ -139,9 +152,14 @@ export function SecuritySolutionApiProvider({ getService }: FtrProviderContext) /** * Delete a saved query using the query ID. */ - osqueryDeleteSavedQuery(props: OsqueryDeleteSavedQueryProps) { + osqueryDeleteSavedQuery(props: OsqueryDeleteSavedQueryProps, kibanaSpace: string = 'default') { return supertest - .delete(replaceParams('/api/osquery/saved_queries/{id}', props.params)) + .delete( + routeWithNamespace( + replaceParams('/api/osquery/saved_queries/{id}', props.params), + kibanaSpace + ) + ) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); @@ -149,9 +167,9 @@ export function SecuritySolutionApiProvider({ getService }: FtrProviderContext) /** * Get a list of all live queries. */ - osqueryFindLiveQueries(props: OsqueryFindLiveQueriesProps) { + osqueryFindLiveQueries(props: OsqueryFindLiveQueriesProps, kibanaSpace: string = 'default') { return supertest - .get('/api/osquery/live_queries') + .get(routeWithNamespace('/api/osquery/live_queries', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -160,9 +178,9 @@ export function SecuritySolutionApiProvider({ getService }: FtrProviderContext) /** * Get a list of all query packs. */ - osqueryFindPacks(props: OsqueryFindPacksProps) { + osqueryFindPacks(props: OsqueryFindPacksProps, kibanaSpace: string = 'default') { return supertest - .get('/api/osquery/packs') + .get(routeWithNamespace('/api/osquery/packs', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -171,9 +189,9 @@ export function SecuritySolutionApiProvider({ getService }: FtrProviderContext) /** * Get a list of all saved queries. */ - osqueryFindSavedQueries(props: OsqueryFindSavedQueriesProps) { + osqueryFindSavedQueries(props: OsqueryFindSavedQueriesProps, kibanaSpace: string = 'default') { return supertest - .get('/api/osquery/saved_queries') + .get(routeWithNamespace('/api/osquery/saved_queries', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -182,9 +200,17 @@ export function SecuritySolutionApiProvider({ getService }: FtrProviderContext) /** * Get the details of a live query using the query ID. */ - osqueryGetLiveQueryDetails(props: OsqueryGetLiveQueryDetailsProps) { + osqueryGetLiveQueryDetails( + props: OsqueryGetLiveQueryDetailsProps, + kibanaSpace: string = 'default' + ) { return supertest - .get(replaceParams('/api/osquery/live_queries/{id}', props.params)) + .get( + routeWithNamespace( + replaceParams('/api/osquery/live_queries/{id}', props.params), + kibanaSpace + ) + ) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -193,9 +219,17 @@ export function SecuritySolutionApiProvider({ getService }: FtrProviderContext) /** * Get the results of a live query using the query action ID. */ - osqueryGetLiveQueryResults(props: OsqueryGetLiveQueryResultsProps) { + osqueryGetLiveQueryResults( + props: OsqueryGetLiveQueryResultsProps, + kibanaSpace: string = 'default' + ) { return supertest - .get(replaceParams('/api/osquery/live_queries/{id}/results/{actionId}', props.params)) + .get( + routeWithNamespace( + replaceParams('/api/osquery/live_queries/{id}/results/{actionId}', props.params), + kibanaSpace + ) + ) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -204,9 +238,11 @@ export function SecuritySolutionApiProvider({ getService }: FtrProviderContext) /** * Get the details of a query pack using the pack ID. */ - osqueryGetPacksDetails(props: OsqueryGetPacksDetailsProps) { + osqueryGetPacksDetails(props: OsqueryGetPacksDetailsProps, kibanaSpace: string = 'default') { return supertest - .get(replaceParams('/api/osquery/packs/{id}', props.params)) + .get( + routeWithNamespace(replaceParams('/api/osquery/packs/{id}', props.params), kibanaSpace) + ) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); @@ -214,9 +250,17 @@ export function SecuritySolutionApiProvider({ getService }: FtrProviderContext) /** * Get the details of a saved query using the query ID. */ - osqueryGetSavedQueryDetails(props: OsqueryGetSavedQueryDetailsProps) { + osqueryGetSavedQueryDetails( + props: OsqueryGetSavedQueryDetailsProps, + kibanaSpace: string = 'default' + ) { return supertest - .get(replaceParams('/api/osquery/saved_queries/{id}', props.params)) + .get( + routeWithNamespace( + replaceParams('/api/osquery/saved_queries/{id}', props.params), + kibanaSpace + ) + ) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); @@ -227,9 +271,11 @@ export function SecuritySolutionApiProvider({ getService }: FtrProviderContext) > You cannot update a prebuilt pack. */ - osqueryUpdatePacks(props: OsqueryUpdatePacksProps) { + osqueryUpdatePacks(props: OsqueryUpdatePacksProps, kibanaSpace: string = 'default') { return supertest - .put(replaceParams('/api/osquery/packs/{id}', props.params)) + .put( + routeWithNamespace(replaceParams('/api/osquery/packs/{id}', props.params), kibanaSpace) + ) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') @@ -241,39 +287,44 @@ export function SecuritySolutionApiProvider({ getService }: FtrProviderContext) > You cannot update a prebuilt saved query. */ - osqueryUpdateSavedQuery(props: OsqueryUpdateSavedQueryProps) { + osqueryUpdateSavedQuery(props: OsqueryUpdateSavedQueryProps, kibanaSpace: string = 'default') { return supertest - .put(replaceParams('/api/osquery/saved_queries/{id}', props.params)) + .put( + routeWithNamespace( + replaceParams('/api/osquery/saved_queries/{id}', props.params), + kibanaSpace + ) + ) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .send(props.body as object); }, - readAssetsStatus(props: ReadAssetsStatusProps) { + readAssetsStatus(props: ReadAssetsStatusProps, kibanaSpace: string = 'default') { return supertest - .get('/internal/osquery/assets') + .get(routeWithNamespace('/internal/osquery/assets', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '1') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .query(props.query); }, - readInstallationStatus() { + readInstallationStatus(kibanaSpace: string = 'default') { return supertest - .get('/internal/osquery/status') + .get(routeWithNamespace('/internal/osquery/status', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '1') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); }, - readPrivilegesCheck() { + readPrivilegesCheck(kibanaSpace: string = 'default') { return supertest - .get('/internal/osquery/privileges_check') + .get(routeWithNamespace('/internal/osquery/privileges_check', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '1') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); }, - updateAssetsStatus(props: UpdateAssetsStatusProps) { + updateAssetsStatus(props: UpdateAssetsStatusProps, kibanaSpace: string = 'default') { return supertest - .post('/internal/osquery/assets/update') + .post(routeWithNamespace('/internal/osquery/assets/update', kibanaSpace)) .set('kbn-xsrf', 'true') .set(ELASTIC_HTTP_VERSION_HEADER, '1') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana')