-
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.
[EDR Workflows] Add RunScript API route (supporting CrowdStrike) (#20…
- Loading branch information
Showing
15 changed files
with
282 additions
and
21 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
...lugins/security_solution/common/api/endpoint/actions/response_actions/run_script/index.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,8 @@ | ||
/* | ||
* 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 './run_script'; |
58 changes: 58 additions & 0 deletions
58
...s/security_solution/common/api/endpoint/actions/response_actions/run_script/run_script.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,58 @@ | ||
/* | ||
* 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 type { TypeOf } from '@kbn/config-schema'; | ||
import { schema } from '@kbn/config-schema'; | ||
import { BaseActionRequestSchema } from '../../common/base'; | ||
|
||
const { parameters, ...restBaseSchema } = BaseActionRequestSchema; | ||
const NonEmptyString = schema.string({ | ||
minLength: 1, | ||
validate: (value) => { | ||
if (!value.trim().length) { | ||
return 'Raw cannot be an empty string'; | ||
} | ||
}, | ||
}); | ||
export const RunScriptActionRequestSchema = { | ||
body: schema.object({ | ||
...restBaseSchema, | ||
parameters: schema.object( | ||
{ | ||
/** | ||
* The script to run | ||
*/ | ||
Raw: schema.maybe(NonEmptyString), | ||
/** | ||
* The path to the script on the host to run | ||
*/ | ||
HostPath: schema.maybe(NonEmptyString), | ||
/** | ||
* The path to the script in the cloud to run | ||
*/ | ||
CloudFile: schema.maybe(NonEmptyString), | ||
/** | ||
* The command line to run | ||
*/ | ||
CommandLine: schema.maybe(NonEmptyString), | ||
/** | ||
* The max timeout value before the command is killed. Number represents milliseconds | ||
*/ | ||
Timeout: schema.maybe(schema.number({ min: 1 })), | ||
}, | ||
{ | ||
validate: (params) => { | ||
if (!params.Raw && !params.HostPath && !params.CloudFile) { | ||
return 'At least one of Raw, HostPath, or CloudFile must be provided'; | ||
} | ||
}, | ||
} | ||
), | ||
}), | ||
}; | ||
|
||
export type RunScriptActionRequestBody = TypeOf<typeof RunScriptActionRequestSchema.body>; |
74 changes: 74 additions & 0 deletions
74
...security_solution/common/api/endpoint/actions/response_actions/run_script/run_script.yaml
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,74 @@ | ||
openapi: 3.0.0 | ||
info: | ||
title: RunScript Action Schema | ||
version: '2023-10-31' | ||
paths: | ||
/api/endpoint/action/runscript: | ||
post: | ||
summary: Run a script | ||
operationId: RunScriptAction | ||
description: Run a shell command on an endpoint. | ||
x-codegen-enabled: true | ||
x-labels: [ ess, serverless ] | ||
requestBody: | ||
required: true | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/RunScriptRouteRequestBody' | ||
responses: | ||
'200': | ||
description: OK | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '../../../model/schema/common.schema.yaml#/components/schemas/SuccessResponse' | ||
|
||
components: | ||
schemas: | ||
RunScriptRouteRequestBody: | ||
allOf: | ||
- $ref: '../../../model/schema/common.schema.yaml#/components/schemas/BaseActionSchema' | ||
- type: object | ||
required: | ||
- parameters | ||
properties: | ||
parameters: | ||
oneOf: | ||
- type: object | ||
properties: | ||
Raw: | ||
type: string | ||
minLength: 1 | ||
description: Raw script content. | ||
required: | ||
- Raw | ||
- type: object | ||
properties: | ||
HostPath: | ||
type: string | ||
minLength: 1 | ||
description: Absolute or relative path of script on host machine. | ||
required: | ||
- HostPath | ||
- type: object | ||
properties: | ||
CloudFile: | ||
type: string | ||
minLength: 1 | ||
description: Script name in cloud storage. | ||
required: | ||
- CloudFile | ||
- type: object | ||
properties: | ||
CommandLine: | ||
type: string | ||
minLength: 1 | ||
description: Command line arguments. | ||
required: | ||
- CommandLine | ||
properties: | ||
Timeout: | ||
type: integer | ||
minimum: 1 | ||
description: Timeout in seconds. |
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
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
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
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
Oops, something went wrong.