Skip to content

Commit

Permalink
[Entity Analytics] Move all entity analytics API schemas into `entity…
Browse files Browse the repository at this point in the history
…_analytics` folder. (#172363)

## Summary

Create `security_solution/common/api/entity_analytics` to house all
entity analytics related apis, in this case `risk_score`, `risk_engine`
and `asset_criticality`.

This makes ownership clearer, simplifies the codeowners file, and will
enable the entity analytics team to have shared schema components in
`security_solution/common/api/entity_analytics/common` (something I want
to do in an upcoming PR)

I have removed `@elastic/security-threat-hunting-explore`'s ownersip of
`/x-pack/plugins/security_solution/common/api/risk_score` let me know if
you want to keep it!
  • Loading branch information
hop-dev authored Dec 1, 2023
1 parent 59982bf commit 18f8a95
Show file tree
Hide file tree
Showing 45 changed files with 20 additions and 21 deletions.
3 changes: 1 addition & 2 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,6 @@ x-pack/test/security_solution_cypress/cypress/tasks/expandable_flyout @elastic/

## Security Solution sub teams - Threat Hunting Explore
/x-pack/plugins/security_solution/common/api/tags @elastic/security-threat-hunting-explore
/x-pack/plugins/security_solution/common/api/risk_score @elastic/security-threat-hunting-explore
/x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts @elastic/security-threat-hunting-explore
/x-pack/plugins/security_solution/common/search_strategy/security_solution/matrix_histogram @elastic/security-threat-hunting-explore
/x-pack/plugins/security_solution/common/search_strategy/security_solution/network @elastic/security-threat-hunting-explore
Expand Down Expand Up @@ -1475,7 +1474,7 @@ x-pack/plugins/security_solution/server/lib/entity_analytics @elastic/security-e
x-pack/plugins/security_solution/server/lib/risk_score @elastic/security-entity-analytics
x-pack/test/security_solution_api_integration/test_suites/entity_analytics @elastic/security-entity-analytics
x-pack/plugins/security_solution/public/flyout/entity_details @elastic/security-entity-analytics
x-pack/plugins/security_solution/common/api/asset_criticality @elastic/security-entity-analytics
x-pack/plugins/security_solution/common/api/entity_analytics @elastic/security-entity-analytics
/x-pack/plugins/security_solution/public/entity_analytics @elastic/security-entity-analytics
/x-pack/test/security_solution_cypress/cypress/e2e/entity_analytics @elastic/security-entity-analytics

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { schema } from '@kbn/config-schema';
import { RiskScoreEntity } from '../../../search_strategy';
import { RiskScoreEntity } from '../../../../search_strategy';

export const onboardingRiskScoreRequestBody = {
body: schema.object({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
import type { Logger, ElasticsearchClient } from '@kbn/core/server';
import { mappingFromFieldMap } from '@kbn/alerting-plugin/common';
import type { AssetCriticalityRecord } from '../../../../common/api/asset_criticality';
import type { AssetCriticalityRecord } from '../../../../common/api/entity_analytics/asset_criticality';
import { createOrUpdateIndex } from '../utils/create_or_update_index';
import { getAssetCriticalityIndex } from '../../../../common/asset_criticality';
import { assetCriticalityFieldMap } from './configurations';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { buildSiemResponse } from '@kbn/lists-plugin/server/routes/utils';
import { transformError } from '@kbn/securitysolution-es-utils';
import { ASSET_CRITICALITY_URL, APP_ID } from '../../../../../common/constants';
import type { SecuritySolutionPluginRouter } from '../../../../types';
import { AssetCriticalityRecordIdParts } from '../../../../../common/api/asset_criticality';
import { AssetCriticalityRecordIdParts } from '../../../../../common/api/entity_analytics/asset_criticality';
import { buildRouteValidationWithZod } from '../../../../utils/build_validation/route_validation';
import { checkAndInitAssetCriticalityResources } from '../check_and_init_asset_criticality_resources';
export const assetCriticalityDeleteRoute = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { ASSET_CRITICALITY_URL, APP_ID } from '../../../../../common/constants';
import type { SecuritySolutionPluginRouter } from '../../../../types';
import { checkAndInitAssetCriticalityResources } from '../check_and_init_asset_criticality_resources';
import { buildRouteValidationWithZod } from '../../../../utils/build_validation/route_validation';
import { AssetCriticalityRecordIdParts } from '../../../../../common/api/asset_criticality';
import { AssetCriticalityRecordIdParts } from '../../../../../common/api/entity_analytics/asset_criticality';
export const assetCriticalityGetRoute = (router: SecuritySolutionPluginRouter, logger: Logger) => {
router.versioned
.get({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import type { Logger } from '@kbn/core/server';
import { buildSiemResponse } from '@kbn/lists-plugin/server/routes/utils';
import { transformError } from '@kbn/securitysolution-es-utils';
import type { AssetCriticalityStatusResponse } from '../../../../../common/api/asset_criticality';
import type { AssetCriticalityStatusResponse } from '../../../../../common/api/entity_analytics/asset_criticality';
import { ASSET_CRITICALITY_STATUS_URL, APP_ID } from '../../../../../common/constants';
import type { SecuritySolutionPluginRouter } from '../../../../types';
import { checkAndInitAssetCriticalityResources } from '../check_and_init_asset_criticality_resources';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { ASSET_CRITICALITY_URL, APP_ID } from '../../../../../common/constants';
import type { SecuritySolutionPluginRouter } from '../../../../types';
import { checkAndInitAssetCriticalityResources } from '../check_and_init_asset_criticality_resources';
import { buildRouteValidationWithZod } from '../../../../utils/build_validation/route_validation';
import { CreateAssetCriticalityRecord } from '../../../../../common/api/asset_criticality';
import { CreateAssetCriticalityRecord } from '../../../../../common/api/entity_analytics/asset_criticality';
export const assetCriticalityUpsertRoute = (
router: SecuritySolutionPluginRouter,
logger: Logger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { APP_ID, RISK_SCORE_INDEX_STATUS_API_URL } from '../../../../common/cons
import type { SecuritySolutionPluginRouter } from '../../../types';
import { buildRouteValidation } from '../../../utils/build_validation/route_validation';
import { buildSiemResponse } from '../../detection_engine/routes/utils';
import { indexStatusRequestQuery } from '../../../../common/api/risk_score';
import { indexStatusRequestQuery } from '../../../../common/api/entity_analytics/risk_score';

export const getRiskScoreIndexStatusRoute = (router: SecuritySolutionPluginRouter) => {
router.versioned
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { transformError } from '@kbn/securitysolution-es-utils';
import { RISK_SCORE_CREATE_INDEX } from '../../../../common/constants';
import type { SecuritySolutionPluginRouter } from '../../../types';
import { createIndex } from './lib/create_index';
import { createEsIndexRequestBody } from '../../../../common/api/risk_score';
import { createEsIndexRequestBody } from '../../../../common/api/entity_analytics/risk_score';

export const createEsIndexRoute = (router: SecuritySolutionPluginRouter, logger: Logger) => {
router.versioned
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { buildSiemResponse } from '@kbn/lists-plugin/server/routes/utils';
import { RISK_SCORE_DELETE_INDICES } from '../../../../common/constants';
import type { SecuritySolutionPluginRouter } from '../../../types';
import { deleteEsIndices } from './lib/delete_indices';
import { deleteIndicesRequestBody } from '../../../../common/api/risk_score';
import { deleteIndicesRequestBody } from '../../../../common/api/entity_analytics/risk_score';

export const deleteEsIndicesRoute = (router: SecuritySolutionPluginRouter) => {
router.versioned
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
import type { ElasticsearchClient, Logger } from '@kbn/core/server';
import { transformError } from '@kbn/securitysolution-es-utils';
import type { CreateEsIndexRequestBody } from '../../../../../common/api/risk_score';
import type { CreateEsIndexRequestBody } from '../../../../../common/api/entity_analytics/risk_score';

export const createIndex = async ({
esClient,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import type { SetupPlugins } from '../../../../plugin';
import { buildSiemResponse } from '../../../detection_engine/routes/utils';

import { installRiskScoreModule } from '../helpers/install_risk_score_module';
import { onboardingRiskScoreRequestBody } from '../../../../../common/api/risk_score';
import { onboardingRiskScoreRequestBody } from '../../../../../common/api/entity_analytics/risk_score';

export const installRiskScoresRoute = (
router: SecuritySolutionPluginRouter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { DEV_TOOL_PREBUILT_CONTENT } from '../../../../../common/constants';

import type { SecuritySolutionPluginRouter } from '../../../../types';
import { consoleMappings } from '../console_mappings';
import { readConsoleRequestBody } from '../../../../../common/api/risk_score';
import { readConsoleRequestBody } from '../../../../../common/api/entity_analytics/risk_score';

import { RiskScoreEntity } from '../../../../../common/search_strategy';
import { getView } from '../utils';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { readConsoleRequestBody } from '../../../../common/api/risk_score';
import { readConsoleRequestBody } from '../../../../common/api/entity_analytics/risk_score';

describe('ReadConsoleRequestSchema', () => {
it('should throw error', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { buildSiemResponse } from '../../../detection_engine/routes/utils';

import { buildFrameworkRequest } from '../../../timeline/utils/common';
import { bulkCreateSavedObjects } from '../helpers/bulk_create_saved_objects';
import { createPrebuiltSavedObjectsRequestBody } from '../../../../../common/api/risk_score';
import { createPrebuiltSavedObjectsRequestBody } from '../../../../../common/api/entity_analytics/risk_score';

export const createPrebuiltSavedObjectsRoute = (
router: SecuritySolutionPluginRouter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { buildSiemResponse } from '../../../detection_engine/routes/utils';

import { buildFrameworkRequest } from '../../../timeline/utils/common';
import { bulkDeleteSavedObjects } from '../helpers/bulk_delete_saved_objects';
import { deletePrebuiltSavedObjectsRequestBody } from '../../../../../common/api/risk_score';
import { deletePrebuiltSavedObjectsRequestBody } from '../../../../../common/api/entity_analytics/risk_score';

export const deletePrebuiltSavedObjectsRoute = (
router: SecuritySolutionPluginRouter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import type { Logger } from '@kbn/core/server';
import { buildSiemResponse } from '@kbn/lists-plugin/server/routes/utils';
import { transformError } from '@kbn/securitysolution-es-utils';
import { createStoredScriptRequestBody } from '../../../../common/api/risk_score';
import { createStoredScriptRequestBody } from '../../../../common/api/entity_analytics/risk_score';
import { RISK_SCORE_CREATE_STORED_SCRIPT } from '../../../../common/constants';
import type { SecuritySolutionPluginRouter } from '../../../types';
import { createStoredScript } from './lib/create_script';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { buildSiemResponse } from '@kbn/lists-plugin/server/routes/utils';
import { RISK_SCORE_DELETE_STORED_SCRIPT } from '../../../../common/constants';
import type { SecuritySolutionPluginRouter } from '../../../types';
import { deleteStoredScript } from './lib/delete_script';
import { deleteStoredScriptRequestBody } from '../../../../common/api/risk_score';
import { deleteStoredScriptRequestBody } from '../../../../common/api/entity_analytics/risk_score';

export const deleteStoredScriptRoute = (router: SecuritySolutionPluginRouter) => {
router.versioned
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
import type { ElasticsearchClient, Logger } from '@kbn/core/server';
import { transformError } from '@kbn/securitysolution-es-utils';
import type { CreateStoredScriptRequestBody } from '../../../../../common/api/risk_score';
import type { CreateStoredScriptRequestBody } from '../../../../../common/api/entity_analytics/risk_score';

export const createStoredScript = async ({
esClient,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/
import type { IScopedClusterClient } from '@kbn/core-elasticsearch-server';
import type { DeleteStoredScriptRequestBody } from '../../../../../common/api/risk_score';
import type { DeleteStoredScriptRequestBody } from '../../../../../common/api/entity_analytics/risk_score';

export const deleteStoredScript = async ({
client,
Expand Down

0 comments on commit 18f8a95

Please sign in to comment.