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] Migrate remaining public Detection Engine APIs to OpenAPI and code generation #170330

Merged
merged 1 commit into from
Nov 8, 2023

Conversation

xcrzx
Copy link
Contributor

@xcrzx xcrzx commented Nov 1, 2023

Related to: https://github.com/elastic/security-team/issues/7491

Summary

Migrated remaining public Detection Engine endpoints to OpenAPI schema and code generation:

  • POST /api/detection_engine/rules/_bulk_action
  • GET /api/detection_engine/rules/_find

Also completed the migration of internal APIs:

  • GET /internal/detection_engine/rules/{ruleId}/execution/events
  • GET /internal/detection_engine/rules/{ruleId}/execution/results

Other notable changes

  • Changed how we compose Zod error messages for unions, see packages/kbn-zod-helpers/src/stringify_zod_error.ts. Now we are trying to list the validation errors of all union members but limiting the total number of validation errors displayed to users.
  • Addressed some remaining TODO https://github.com/elastic/security-team/issues/7491
  • Removed dependencies of the risk engine and timelines on detection engine schemas
  • Removed outdated legacy rule schemas that are no longer in use
  • Added new schema helpers that work with query params: BooleanFromString and ArrayFromString
    image
    image

@xcrzx xcrzx added Team:Detections and Resp Security Detection Response Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Team:Detection Rule Management Security Detection Rule Management Team labels Nov 1, 2023
@xcrzx xcrzx self-assigned this Nov 1, 2023
@xcrzx xcrzx force-pushed the openapi-migration-v2 branch 12 times, most recently from 3ebb54d to e9ec18a Compare November 6, 2023 12:51
@xcrzx xcrzx marked this pull request as ready for review November 6, 2023 13:44
@xcrzx xcrzx requested review from a team as code owners November 6, 2023 13:44
@xcrzx xcrzx requested review from dasansol92 and tomsonpl November 6, 2023 13:44
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-detections-response (Team:Detections and Resp)

@xcrzx xcrzx requested review from nkhristinin and spong November 6, 2023 13:44
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-solution (Team: SecuritySolution)

@xcrzx xcrzx changed the title [Security Solution] Migrate more public APIs to OpenAPI and code generation [Security Solution] Migrate remaining public Detection Engine APIs to OpenAPI and code generation Nov 6, 2023
@xcrzx xcrzx added release_note:skip Skip the PR/issue when compiling release notes v8.12.0 Project:Serverless Work as part of the Serverless project for its initial release labels Nov 6, 2023
@xcrzx xcrzx force-pushed the openapi-migration-v2 branch from e9ec18a to 899bf8e Compare November 6, 2023 15:14
@xcrzx xcrzx requested review from jpdjere and removed request for spong November 7, 2023 10:07
@xcrzx
Copy link
Contributor Author

xcrzx commented Nov 7, 2023

Files by Code Owner

elastic/security-defend-workflows
  • x-pack/plugins/security_solution/common/api/detection_engine/model/rule_response_actions/index.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/model/rule_schema_legacy/response_actions.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_response_actions/constants.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_response_actions/get_supported_response_actions.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_response_actions/response_action_type_form.tsx
  • x-pack/plugins/security_solution/public/detection_engine/rule_response_actions/utils.tsx
  • x-pack/plugins/security_solution/public/management/cypress/e2e/automated_response_actions/form.cy.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_response_actions/schedule_notification_response_actions.test.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_response_actions/schedule_notification_response_actions.ts
elastic/security-detection-engine
  • x-pack/plugins/security_solution/common/api/detection_engine/model/rule_schema/common_attributes.gen.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/model/rule_schema/common_attributes.schema.yaml
  • x-pack/plugins/security_solution/common/api/detection_engine/model/rule_schema/rule_request_schema.test.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/model/rule_schema/rule_response_schema.test.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_exceptions/create_rule_exceptions/create_rule_exceptions_route.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/signals_migration/create_signals_migration/create_signals_migration_route.ts
elastic/security-detection-rule-management
  • packages/kbn-openapi-generator/src/template_service/templates/zod_operation_schema.handlebars
  • packages/kbn-openapi-generator/src/template_service/templates/zod_query_item.handlebars
  • packages/kbn-zod-helpers/index.ts
  • packages/kbn-zod-helpers/src/array_from_string.test.ts
  • packages/kbn-zod-helpers/src/array_from_string.ts
  • packages/kbn-zod-helpers/src/boolean_from_string.test.ts
  • packages/kbn-zod-helpers/src/boolean_from_string.ts
  • packages/kbn-zod-helpers/src/expect_parse_success.ts
  • packages/kbn-zod-helpers/src/safe_parse_result.ts
  • packages/kbn-zod-helpers/src/stringify_zod_error.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/model/rule_schema/common_attributes.gen.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/model/rule_schema/common_attributes.schema.yaml
  • x-pack/plugins/security_solution/common/api/detection_engine/model/rule_schema/rule_request_schema.test.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/model/rule_schema/rule_response_schema.test.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_management/bulk_actions/bulk_actions_route.gen.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_management/bulk_actions/bulk_actions_route.mock.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_management/bulk_actions/bulk_actions_route.schema.yaml
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_management/bulk_actions/bulk_actions_route.test.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_management/bulk_actions/bulk_actions_route.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_management/bulk_actions/bulk_actions_types.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_management/bulk_crud/bulk_create_rules/bulk_create_rules_route.test.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_management/bulk_crud/bulk_patch_rules/bulk_patch_rules_route.test.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_management/bulk_crud/bulk_update_rules/bulk_update_rules_route.test.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_management/bulk_crud/response_schema.test.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_management/crud/patch_rule/patch_rule_route.test.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_management/export_rules/export_rules_route.gen.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_management/export_rules/export_rules_route.test.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_management/find_rules/find_rules_route.gen.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_management/find_rules/find_rules_route.schema.yaml
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_management/find_rules/find_rules_route.test.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_management/find_rules/find_rules_route.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_management/find_rules/request_schema_validation.test.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_management/find_rules/request_schema_validation.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_management/import_rules/import_rules_route.gen.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_management/index.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/index.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/model/execution_event.gen.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/model/execution_event.mock.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/model/execution_event.schema.yaml
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/model/execution_event.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/model/execution_metrics.gen.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/model/execution_metrics.schema.yaml
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/model/execution_metrics.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/model/execution_status.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/model/execution_summary.mock.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/model/execution_summary.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/model/index.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/model/log_level.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/rule_execution_logs/get_rule_execution_events/get_rule_execution_events_route.gen.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/rule_execution_logs/get_rule_execution_events/get_rule_execution_events_route.mock.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/rule_execution_logs/get_rule_execution_events/get_rule_execution_events_route.schema.yaml
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/rule_execution_logs/get_rule_execution_events/get_rule_execution_events_route.test.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/rule_execution_logs/get_rule_execution_events/get_rule_execution_events_route.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/rule_execution_logs/get_rule_execution_results/get_rule_execution_results_route.gen.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_management/api/api.test.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_management/api/api.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_management/api/hooks/use_bulk_action_mutation.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_management/logic/bulk_actions/translations.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_management/logic/bulk_actions/use_bulk_export.test.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_management/logic/bulk_actions/use_bulk_export.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_management/logic/bulk_actions/use_download_exported_rules.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_management/logic/bulk_actions/use_execute_bulk_action.test.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_management/logic/bulk_actions/use_execute_bulk_action.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_management/logic/bulk_actions/use_guess_rule_ids_for_bulk_action.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_management/logic/bulk_actions/use_show_bulk_error_toast.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_management/logic/bulk_actions/use_show_bulk_success_toast.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_management/logic/types.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/bulk_actions/bulk_action_dry_run_confirmation.tsx
  • x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/bulk_actions/bulk_action_rule_errors_list.test.tsx
  • x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/bulk_actions/bulk_action_rule_errors_list.tsx
  • x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/bulk_actions/bulk_edit_flyout.tsx
  • x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/bulk_actions/forms/index_patterns_form.tsx
  • x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/bulk_actions/forms/rule_actions_form.tsx
  • x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/bulk_actions/forms/schedule_form.tsx
  • x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/bulk_actions/forms/tags_form.tsx
  • x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/bulk_actions/forms/timeline_template_form.tsx
  • x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/bulk_actions/types.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/bulk_actions/use_bulk_actions.tsx
  • x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/bulk_actions/use_bulk_actions_confirmation.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/bulk_actions/use_bulk_edit_form_flyout.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/bulk_actions/utils/compute_dry_run_edit_payload.test.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/bulk_actions/utils/compute_dry_run_edit_payload.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/rules_table/guided_onboarding/rules_management_tour.tsx
  • x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/rules_table/rules_table_saved_state.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/rules_table/use_rules_table_saved_state.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/use_columns.tsx
  • x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/use_rules_table_actions.tsx
  • x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/pages/coverage_overview/coverage_overview_dashboard_context.tsx
  • x-pack/plugins/security_solution/public/detection_engine/rule_monitoring/api/mocks/api_client.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_monitoring/api/api_client.test.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_monitoring/components/basic/filters/event_type_filter/index.tsx
  • x-pack/plugins/security_solution/public/detection_engine/rule_monitoring/components/basic/indicators/event_type_indicator/utils.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_monitoring/components/basic/indicators/log_level_indicator/utils.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_monitoring/components/basic/tables/use_sorting.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_monitoring/components/execution_events_table/use_execution_events.test.tsx
  • x-pack/plugins/security_solution/public/detections/components/rules/rule_actions_overflow/index.tsx
  • x-pack/plugins/security_solution/public/detections/components/rules/rule_switch/index.tsx
  • x-pack/plugins/security_solution/server/lib/detection_engine/prebuilt_rules/model/rule_assets/prebuilt_rule_asset.test.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/api/rules/bulk_actions/route.test.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/api/rules/bulk_actions/route.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/api/rules/bulk_patch_rules/route.test.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/api/rules/create_rule/route.test.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/api/rules/find_rules/route.test.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/api/rules/find_rules/route.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/api/rules/patch_rule/route.test.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/api/rules/update_rule/route.test.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/bulk_actions/action_to_rules_client_operation.test.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/bulk_actions/action_to_rules_client_operation.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/bulk_actions/bulk_edit_rules.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/bulk_actions/rule_params_modifier.test.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/bulk_actions/rule_params_modifier.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/bulk_actions/split_bulk_edit_actions.test.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/bulk_actions/split_bulk_edit_actions.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/bulk_actions/utils.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/bulk_actions/validations.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/search/find_rules.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/search/transform_sort_field.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/utils/validate.test.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/api/rule_execution_logs/get_rule_execution_events/get_rule_execution_events_route.test.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/api/rule_execution_logs/get_rule_execution_events/get_rule_execution_events_route.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/logic/detection_engine_health/event_log/aggregations/rule_execution_stats.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/logic/event_log/register_event_log_provider.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/logic/rule_execution_log/client_for_executors/client.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/logic/rule_execution_log/event_log/event_log_reader.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/logic/rule_execution_log/event_log/event_log_writer.ts
elastic/security-entity-analytics
  • x-pack/plugins/security_solution/common/risk_engine/risk_score_calculation/request_schema.ts
  • x-pack/plugins/security_solution/common/risk_engine/risk_score_preview/request_schema.ts
elastic/security-solution
  • x-pack/plugins/security_solution/common/api/detection_engine/model/error_schema.mock.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/model/index.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/model/pagination.gen.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/model/pagination.schema.yaml
  • x-pack/plugins/security_solution/common/api/detection_engine/model/pagination.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/model/rule_response_actions/index.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/model/rule_schema/common_attributes.gen.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/model/rule_schema/common_attributes.schema.yaml
  • x-pack/plugins/security_solution/common/api/detection_engine/model/rule_schema/rule_request_schema.test.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/model/rule_schema/rule_response_schema.test.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/model/rule_schema_legacy/response_actions.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/model/rule_schema_legacy/rule_schemas.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/model/schemas.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/model/sorting.test.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/model/sorting_legacy.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_exceptions/create_rule_exceptions/create_rule_exceptions_route.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_management/bulk_actions/bulk_actions_route.gen.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_management/bulk_actions/bulk_actions_route.mock.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_management/bulk_actions/bulk_actions_route.schema.yaml
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_management/bulk_actions/bulk_actions_route.test.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_management/bulk_actions/bulk_actions_route.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_management/bulk_actions/bulk_actions_types.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_management/bulk_crud/bulk_create_rules/bulk_create_rules_route.test.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_management/bulk_crud/bulk_patch_rules/bulk_patch_rules_route.test.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_management/bulk_crud/bulk_update_rules/bulk_update_rules_route.test.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_management/bulk_crud/response_schema.test.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_management/crud/patch_rule/patch_rule_route.test.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_management/export_rules/export_rules_route.gen.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_management/export_rules/export_rules_route.test.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_management/find_rules/find_rules_route.gen.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_management/find_rules/find_rules_route.schema.yaml
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_management/find_rules/find_rules_route.test.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_management/find_rules/find_rules_route.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_management/find_rules/request_schema_validation.test.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_management/find_rules/request_schema_validation.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_management/import_rules/import_rules_route.gen.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_management/index.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/index.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/model/execution_event.gen.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/model/execution_event.mock.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/model/execution_event.schema.yaml
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/model/execution_event.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/model/execution_metrics.gen.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/model/execution_metrics.schema.yaml
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/model/execution_metrics.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/model/execution_status.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/model/execution_summary.mock.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/model/execution_summary.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/model/index.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/model/log_level.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/rule_execution_logs/get_rule_execution_events/get_rule_execution_events_route.gen.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/rule_execution_logs/get_rule_execution_events/get_rule_execution_events_route.mock.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/rule_execution_logs/get_rule_execution_events/get_rule_execution_events_route.schema.yaml
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/rule_execution_logs/get_rule_execution_events/get_rule_execution_events_route.test.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/rule_execution_logs/get_rule_execution_events/get_rule_execution_events_route.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/rule_execution_logs/get_rule_execution_results/get_rule_execution_results_route.gen.ts
  • x-pack/plugins/security_solution/common/api/detection_engine/signals_migration/create_signals_migration/create_signals_migration_route.ts
  • x-pack/plugins/security_solution/common/api/timeline/model/api.ts
  • x-pack/plugins/security_solution/common/api/timeline/model/error_schema.mock.ts
  • x-pack/plugins/security_solution/common/api/timeline/model/error_schema.test.ts
  • x-pack/plugins/security_solution/common/api/timeline/model/error_schema.ts
  • x-pack/plugins/security_solution/common/detection_engine/transform_actions.test.ts
  • x-pack/plugins/security_solution/common/detection_engine/transform_actions.ts
  • x-pack/plugins/security_solution/common/risk_engine/risk_score_calculation/request_schema.ts
  • x-pack/plugins/security_solution/common/risk_engine/risk_score_preview/request_schema.ts
  • x-pack/plugins/security_solution/common/types/response_actions/index.ts
  • x-pack/plugins/security_solution/public/common/components/event_details/osquery_tab.tsx
  • x-pack/plugins/security_solution/public/detection_engine/rule_management/api/api.test.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_management/api/api.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_management/api/hooks/use_bulk_action_mutation.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_management/logic/bulk_actions/translations.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_management/logic/bulk_actions/use_bulk_export.test.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_management/logic/bulk_actions/use_bulk_export.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_management/logic/bulk_actions/use_download_exported_rules.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_management/logic/bulk_actions/use_execute_bulk_action.test.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_management/logic/bulk_actions/use_execute_bulk_action.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_management/logic/bulk_actions/use_guess_rule_ids_for_bulk_action.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_management/logic/bulk_actions/use_show_bulk_error_toast.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_management/logic/bulk_actions/use_show_bulk_success_toast.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_management/logic/types.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/bulk_actions/bulk_action_dry_run_confirmation.tsx
  • x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/bulk_actions/bulk_action_rule_errors_list.test.tsx
  • x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/bulk_actions/bulk_action_rule_errors_list.tsx
  • x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/bulk_actions/bulk_edit_flyout.tsx
  • x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/bulk_actions/forms/index_patterns_form.tsx
  • x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/bulk_actions/forms/rule_actions_form.tsx
  • x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/bulk_actions/forms/schedule_form.tsx
  • x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/bulk_actions/forms/tags_form.tsx
  • x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/bulk_actions/forms/timeline_template_form.tsx
  • x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/bulk_actions/types.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/bulk_actions/use_bulk_actions.tsx
  • x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/bulk_actions/use_bulk_actions_confirmation.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/bulk_actions/use_bulk_edit_form_flyout.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/bulk_actions/utils/compute_dry_run_edit_payload.test.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/bulk_actions/utils/compute_dry_run_edit_payload.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/rules_table/guided_onboarding/rules_management_tour.tsx
  • x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/rules_table/rules_table_saved_state.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/rules_table/use_rules_table_saved_state.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/use_columns.tsx
  • x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/use_rules_table_actions.tsx
  • x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/pages/coverage_overview/coverage_overview_dashboard_context.tsx
  • x-pack/plugins/security_solution/public/detection_engine/rule_monitoring/api/mocks/api_client.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_monitoring/api/api_client.test.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_monitoring/components/basic/filters/event_type_filter/index.tsx
  • x-pack/plugins/security_solution/public/detection_engine/rule_monitoring/components/basic/indicators/event_type_indicator/utils.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_monitoring/components/basic/indicators/log_level_indicator/utils.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_monitoring/components/basic/tables/use_sorting.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_monitoring/components/execution_events_table/use_execution_events.test.tsx
  • x-pack/plugins/security_solution/public/detection_engine/rule_response_actions/constants.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_response_actions/get_supported_response_actions.ts
  • x-pack/plugins/security_solution/public/detection_engine/rule_response_actions/response_action_type_form.tsx
  • x-pack/plugins/security_solution/public/detection_engine/rule_response_actions/utils.tsx
  • x-pack/plugins/security_solution/public/detections/components/rules/rule_actions_overflow/index.tsx
  • x-pack/plugins/security_solution/public/detections/components/rules/rule_switch/index.tsx
  • x-pack/plugins/security_solution/public/management/cypress/e2e/automated_response_actions/form.cy.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/prebuilt_rules/model/rule_assets/prebuilt_rule_asset.test.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/api/rules/bulk_actions/route.test.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/api/rules/bulk_actions/route.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/api/rules/bulk_patch_rules/route.test.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/api/rules/create_rule/route.test.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/api/rules/find_rules/route.test.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/api/rules/find_rules/route.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/api/rules/patch_rule/route.test.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/api/rules/update_rule/route.test.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/bulk_actions/action_to_rules_client_operation.test.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/bulk_actions/action_to_rules_client_operation.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/bulk_actions/bulk_edit_rules.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/bulk_actions/rule_params_modifier.test.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/bulk_actions/rule_params_modifier.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/bulk_actions/split_bulk_edit_actions.test.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/bulk_actions/split_bulk_edit_actions.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/bulk_actions/utils.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/bulk_actions/validations.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/search/find_rules.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/search/transform_sort_field.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/utils/validate.test.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/api/rule_execution_logs/get_rule_execution_events/get_rule_execution_events_route.test.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/api/rule_execution_logs/get_rule_execution_events/get_rule_execution_events_route.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/logic/detection_engine_health/event_log/aggregations/rule_execution_stats.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/logic/event_log/register_event_log_provider.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/logic/rule_execution_log/client_for_executors/client.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/logic/rule_execution_log/event_log/event_log_reader.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/logic/rule_execution_log/event_log/event_log_writer.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_response_actions/schedule_notification_response_actions.test.ts
  • x-pack/plugins/security_solution/server/lib/detection_engine/rule_response_actions/schedule_notification_response_actions.ts
  • x-pack/test/detection_engine_api_integration/security_and_spaces/group1/create_rules_bulk.ts
  • x-pack/test/detection_engine_api_integration/security_and_spaces/group10/patch_rules.ts
  • x-pack/test/detection_engine_api_integration/security_and_spaces/group10/patch_rules_bulk.ts
  • x-pack/test/detection_engine_api_integration/security_and_spaces/group10/perform_bulk_action.ts
  • x-pack/test/detection_engine_api_integration/security_and_spaces/group10/perform_bulk_action_dry_run.ts
  • x-pack/test/detection_engine_api_integration/security_and_spaces/group10/update_rules.ts
  • x-pack/test/detection_engine_api_integration/security_and_spaces/group10/update_rules_bulk.ts
  • x-pack/test/detection_engine_api_integration/security_and_spaces/rule_execution_logic/query.ts
elastic/security-threat-hunting-investigations
  • x-pack/plugins/security_solution/common/api/timeline/model/api.ts
  • x-pack/plugins/security_solution/common/api/timeline/model/error_schema.mock.ts
  • x-pack/plugins/security_solution/common/api/timeline/model/error_schema.test.ts
  • x-pack/plugins/security_solution/common/api/timeline/model/error_schema.ts
  • x-pack/plugins/security_solution/public/common/components/event_details/osquery_tab.tsx

Copy link
Contributor

@tomsonpl tomsonpl left a comment

Choose a reason for hiding this comment

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

Hey, Defend Workflows LGTM :)

Not sure why we use ResponseActionTypesEnum['.osquery'] instead of ResponseActionTypesEnum.OSQUERY here (same for .endpoint) - but it's not a big deal. However would be great to see what you think about this :)
Thanks!

@@ -47,13 +38,13 @@ export const OsqueryParamsCamelCase = t.type({
// When we create new response action types, create a union of types
export type RuleResponseOsqueryAction = t.TypeOf<typeof RuleResponseOsqueryAction>;
export const RuleResponseOsqueryAction = t.strict({
actionTypeId: t.literal(RESPONSE_ACTION_TYPES.OSQUERY),
actionTypeId: t.literal('.osquery'),
Copy link
Contributor

@tomsonpl tomsonpl Nov 7, 2023

Choose a reason for hiding this comment

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

can we use ResponseActionTypesEnum.OSQUERY , or at least ResponseActionTypesEnum['.osquery'] ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since this is a legacy schema set for removal in upcoming PRs, I've inlined the literal to prevent creating dependencies between the new and the old schemas.

@@ -85,7 +90,7 @@ export const transformRuleToAlertResponseAction = ({
action_type_id: actionTypeId,
params,
}: ResponseAction): RuleResponseAction => {
if (actionTypeId === RESPONSE_ACTION_TYPES.OSQUERY) {
if (actionTypeId === ResponseActionTypesEnum['.osquery']) {
Copy link
Contributor

Choose a reason for hiding this comment

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

why not ResponseActionTypesEnum.OSQUERY ?

Copy link
Contributor Author

@xcrzx xcrzx Nov 7, 2023

Choose a reason for hiding this comment

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

Since the OpenAPI schema is now the source of truth for data structures and enums in our codebase, I am replacing legacy structures with the generated ones. The generated enum looks as follows:

export const ResponseActionTypes = z.enum(['.osquery', '.endpoint']);
export type ResponseActionTypes = z.infer<typeof ResponseActionTypes>;
export const ResponseActionTypesEnum = ResponseActionTypes.enum;

The enum keys mirror the enum values, which is why we reference them using ResponseActionTypesEnum['.osquery'].

But for convenience, we could introduce an alias like this and use it everywhere:

const RESPONSE_ACTION_TYPES = {
  OSQUERY: ResponseActionTypesEnum['.osquery'],
  ENDPOINT: ResponseActionTypesEnum['.endpoint'],
};

I don't have a strong opinion on that tbh.

Copy link
Contributor

@nkhristinin nkhristinin left a comment

Choose a reason for hiding this comment

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

LGTM!

.default('false')
.transform((value) => value === 'true')
),
exclude_export_details: BooleanFromString.optional().default(false),
Copy link
Contributor

Choose a reason for hiding this comment

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

So, just to understand what happened here:

You created the BooleanFromString helper in this same PR, but the schema file for export_rules_route wasn't updated in any way.
So how did this get updated? Did you do it manually?

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've updated the code generator for booleans and arrays in request queries. You can find the changes in the template file at packages/kbn-openapi-generator/src/template_service/templates/zod_query_item.handlebars.

Comment on lines 85 to 98
- 'created_at'
- 'createdAt'
- 'enabled'
- 'execution_summary.last_execution.date'
- 'execution_summary.last_execution.metrics.execution_gap_duration_s'
- 'execution_summary.last_execution.metrics.total_indexing_duration_ms'
- 'execution_summary.last_execution.metrics.total_search_duration_ms'
- 'execution_summary.last_execution.status'
- 'name'
- 'risk_score'
- 'riskScore'
- 'severity'
- 'updated_at'
- 'updatedAt'
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we keep the comments here for the camelCase fields being legacy, and we're keeping them for backwards compatibility?


/**
* An array of supported log levels.
*/
export const LOG_LEVELS = Object.values(LogLevel);
export const LOG_LEVELS = LogLevel.options;
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the purpose of this variable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It holds an array of all possible LogLevel values: ["trace", "debug", "info", "warn", "error"]

description: End date of the time range to query
schema:
type: string
format: date-time
Copy link
Contributor

@jpdjere jpdjere Nov 7, 2023

Choose a reason for hiding this comment

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

Not modified in this PR, but I see that the parms sort_order, page and per_page are marked as required: false, while in GetRuleExecutionEventsRequestQuery in the deleted x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/rule_execution_logs/get_rule_execution_events/get_rule_execution_events_route.ts they are not marked as partial.

I realize that these three fields have a default value here in the schema, but just wanted to note the difference in the schemas.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it looks like a mistake in the previous schema. Defaultable fields should not be required

*/
import type { ErrorSchema } from './error_schema';

export const getErrorSchemaMock = (
Copy link
Contributor

Choose a reason for hiding this comment

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

Where's this used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, there was a wrong import. It is used in adjacent error_schema.test.ts.

Copy link
Contributor

@jpdjere jpdjere left a comment

Choose a reason for hiding this comment

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

Tested all affected endpoints and found no regressions 👍

Left some questions/small comments, but overall LGTM!

Thanks for this refactor!

Comment on lines 29 to 34
page: Page.optional(),
per_page: PerPage.optional(),
/**
* Total number of items
*/
total: z.number().int().min(0).optional(),
Copy link
Contributor

Choose a reason for hiding this comment

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

@xcrzx Are all of these really optional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They should not be optional, and thanks for pointing that out! 👍

@xcrzx xcrzx force-pushed the openapi-migration-v2 branch from 899bf8e to 68464e2 Compare November 8, 2023 09:32
Copy link
Contributor

@janmonschke janmonschke left a comment

Choose a reason for hiding this comment

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

Threat Hunting changes lgtm 🎉

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #39 / EPM Endpoints Install endpoint package install should have installed the [endpoint.metadata_current-default] transform

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
securitySolution 4670 4669 -1

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
securitySolution 13.1MB 13.0MB -108.0KB
Unknown metric groups

API count

id before after diff
@kbn/zod-helpers 12 18 +6

ESLint disabled line counts

id before after diff
securitySolution 479 466 -13

Total ESLint disabled count

id before after diff
securitySolution 547 534 -13

History

  • 💚 Build #173536 succeeded 899bf8e2aa4a6d348e9b5175b4902870f5e2ddaf
  • 💔 Build #173468 failed e9ec18ad47ffaa7e032f5a00f845b0dc8e12905e
  • 💔 Build #173431 failed 3ebb54dbe33773e9e1e49f1ab6c3d5f04ec584e1
  • 💔 Build #173240 failed 3a66a0786c813b61359506ec9bf1ce84c870c8b7
  • 💔 Build #173209 failed 2d4aea9f71b4ab11c1372a9dfc76e587772205dc
  • 💔 Build #173185 failed b4fe259e19205fc098ff337dd4901981284274b7

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @xcrzx

@xcrzx xcrzx merged commit e00566f into elastic:main Nov 8, 2023
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Nov 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Project:Serverless Work as part of the Serverless project for its initial release release_note:skip Skip the PR/issue when compiling release notes Team:Detection Rule Management Security Detection Rule Management Team Team:Detections and Resp Security Detection Response Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. v8.12.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants