-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security Solution][Serverless] Add schema validation to Search Strat…
…egies in security solution & timelines (#162539) ## Summary This PR specifies validation schemas for enpoints listed here: elastic/security-team#6486
- Loading branch information
Showing
306 changed files
with
2,780 additions
and
1,239 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
x-pack/plugins/security_solution/common/api/search_strategy/cti/cti.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
export * from './event_enrichment'; | ||
|
||
export * from './threat_intel_source'; |
23 changes: 23 additions & 0 deletions
23
x-pack/plugins/security_solution/common/api/search_strategy/cti/event_enrichment.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { z } from 'zod'; | ||
import { CtiQueries } from '../model/factory_query_type'; | ||
import { requestBasicOptionsSchema } from '../model/request_basic_options'; | ||
import { timerange } from '../model/timerange'; | ||
|
||
export const eventEnrichmentRequestOptionsSchema = requestBasicOptionsSchema.extend({ | ||
eventFields: z.record(z.unknown()), | ||
timerange, | ||
factoryQueryType: z.literal(CtiQueries.eventEnrichment), | ||
}); | ||
|
||
export type EventEnrichmentRequestOptionsInput = z.input< | ||
typeof eventEnrichmentRequestOptionsSchema | ||
>; | ||
|
||
export type EventEnrichmentRequestOptions = z.infer<typeof eventEnrichmentRequestOptionsSchema>; |
20 changes: 20 additions & 0 deletions
20
x-pack/plugins/security_solution/common/api/search_strategy/cti/threat_intel_source.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { z } from 'zod'; | ||
import { CtiQueries } from '../model/factory_query_type'; | ||
import { requestBasicOptionsSchema } from '../model/request_basic_options'; | ||
|
||
export const threatIntelSourceRequestOptionsSchema = requestBasicOptionsSchema.extend({ | ||
factoryQueryType: z.literal(CtiQueries.dataSource), | ||
}); | ||
|
||
export type ThreatIntelSourceRequestOptionsInput = z.input< | ||
typeof threatIntelSourceRequestOptionsSchema | ||
>; | ||
|
||
export type ThreatIntelSourceRequestOptions = z.infer<typeof threatIntelSourceRequestOptionsSchema>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
x-pack/plugins/security_solution/common/api/search_strategy/hosts/all.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { z } from 'zod'; | ||
import { HostsQueries } from '../model/factory_query_type'; | ||
import { pagination } from '../model/pagination'; | ||
import { requestBasicOptionsSchema } from '../model/request_basic_options'; | ||
import { timerange } from '../model/timerange'; | ||
import { sort } from './model/sort'; | ||
|
||
export const allHostsSchema = requestBasicOptionsSchema.extend({ | ||
sort, | ||
pagination, | ||
timerange, | ||
isNewRiskScoreModuleAvailable: z.boolean().default(false), | ||
factoryQueryType: z.literal(HostsQueries.hosts), | ||
}); | ||
|
||
export type HostsRequestOptionsInput = z.input<typeof allHostsSchema>; | ||
|
||
export type HostsRequestOptions = z.infer<typeof allHostsSchema>; |
28 changes: 28 additions & 0 deletions
28
x-pack/plugins/security_solution/common/api/search_strategy/hosts/details.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { z } from 'zod'; | ||
import { HostsQueries } from '../model/factory_query_type'; | ||
import { inspect } from '../model/inspect'; | ||
import { pagination } from '../model/pagination'; | ||
import { requestBasicOptionsSchema } from '../model/request_basic_options'; | ||
import { timerange } from '../model/timerange'; | ||
import { sort } from './model/sort'; | ||
|
||
export const hostDetailsSchema = requestBasicOptionsSchema.extend({ | ||
hostName: z.string(), | ||
skip: z.boolean().optional(), | ||
inspect, | ||
pagination: pagination.optional(), | ||
timerange, | ||
sort, | ||
factoryQueryType: z.literal(HostsQueries.details), | ||
}); | ||
|
||
export type HostDetailsRequestOptionsInput = z.input<typeof hostDetailsSchema>; | ||
|
||
export type HostDetailsRequestOptions = z.infer<typeof hostDetailsSchema>; |
18 changes: 18 additions & 0 deletions
18
x-pack/plugins/security_solution/common/api/search_strategy/hosts/hosts.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
export * from './all'; | ||
|
||
export * from './details'; | ||
|
||
export * from './overview'; | ||
|
||
export * from './uncommon_processes'; | ||
|
||
export * from './kpi_hosts'; | ||
|
||
export * from './kpi_unique_ips'; |
24 changes: 24 additions & 0 deletions
24
x-pack/plugins/security_solution/common/api/search_strategy/hosts/kpi_hosts.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { z } from 'zod'; | ||
import { HostsKpiQueries } from '../model/factory_query_type'; | ||
import { pagination } from '../model/pagination'; | ||
import { requestBasicOptionsSchema } from '../model/request_basic_options'; | ||
import { timerange } from '../model/timerange'; | ||
import { sort } from './model/sort'; | ||
|
||
export const kpiHostsSchema = requestBasicOptionsSchema.extend({ | ||
sort, | ||
pagination, | ||
timerange, | ||
factoryQueryType: z.literal(HostsKpiQueries.kpiHosts), | ||
}); | ||
|
||
export type KpiHostsRequestOptionsInput = z.input<typeof kpiHostsSchema>; | ||
|
||
export type KpiHostsRequestOptions = z.infer<typeof kpiHostsSchema>; |
24 changes: 24 additions & 0 deletions
24
x-pack/plugins/security_solution/common/api/search_strategy/hosts/kpi_unique_ips.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { z } from 'zod'; | ||
import { HostsKpiQueries } from '../model/factory_query_type'; | ||
import { pagination } from '../model/pagination'; | ||
import { requestBasicOptionsSchema } from '../model/request_basic_options'; | ||
import { timerange } from '../model/timerange'; | ||
import { sort } from './model/sort'; | ||
|
||
export const kpiUniqueIpsSchema = requestBasicOptionsSchema.extend({ | ||
sort, | ||
pagination, | ||
timerange, | ||
factoryQueryType: z.literal(HostsKpiQueries.kpiUniqueIps), | ||
}); | ||
|
||
export type KpiUniqueIpsRequestOptionsInput = z.input<typeof kpiUniqueIpsSchema>; | ||
|
||
export type KpiUniqueIpsRequestOptions = z.infer<typeof kpiUniqueIpsSchema>; |
16 changes: 16 additions & 0 deletions
16
x-pack/plugins/security_solution/common/api/search_strategy/hosts/model/sort.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
export enum HostsFields { | ||
lastSeen = 'lastSeen', | ||
hostName = 'hostName', | ||
success = 'success', | ||
} | ||
|
||
import { sort as baseSort } from '../../model/sort'; | ||
|
||
export const sort = baseSort; |
20 changes: 20 additions & 0 deletions
20
x-pack/plugins/security_solution/common/api/search_strategy/hosts/overview.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { z } from 'zod'; | ||
import { HostsQueries } from '../model/factory_query_type'; | ||
import { requestBasicOptionsSchema } from '../model/request_basic_options'; | ||
import { timerange } from '../model/timerange'; | ||
|
||
export const hostOverviewSchema = requestBasicOptionsSchema.extend({ | ||
factoryQueryType: z.literal(HostsQueries.overview), | ||
timerange, | ||
}); | ||
|
||
export type HostOverviewRequestOptionsInput = z.input<typeof hostOverviewSchema>; | ||
|
||
export type HostOverviewRequestOptions = z.infer<typeof hostOverviewSchema>; |
24 changes: 24 additions & 0 deletions
24
x-pack/plugins/security_solution/common/api/search_strategy/hosts/uncommon_processes.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { z } from 'zod'; | ||
import { HostsQueries } from '../model/factory_query_type'; | ||
import { pagination } from '../model/pagination'; | ||
import { requestBasicOptionsSchema } from '../model/request_basic_options'; | ||
import { sort } from '../model/sort'; | ||
import { timerange } from '../model/timerange'; | ||
|
||
export const hostUncommonProcessesSchema = requestBasicOptionsSchema.extend({ | ||
sort, | ||
pagination, | ||
timerange, | ||
factoryQueryType: z.literal(HostsQueries.uncommonProcesses), | ||
}); | ||
|
||
export type HostUncommonProcessesRequestOptionsInput = z.input<typeof hostUncommonProcessesSchema>; | ||
|
||
export type HostUncommonProcessesRequestOptions = z.infer<typeof hostUncommonProcessesSchema>; |
Oops, something went wrong.