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

[EDR Workflows] Add RunScript API route (supporting CrowdStrike) #203101

Merged
merged 15 commits into from
Dec 11, 2024

Conversation

tomsonpl
Copy link
Contributor

@tomsonpl tomsonpl commented Dec 5, 2024

Summary

This PR introduces support for the CrowdStrike runscript API route. Below are detailed highlights of the changes.


Key Changes

  • Introduced runscript route at /api/endpoint//action/run_script
  • Currently runscript is only enabled for CrowdStrike hosts
  • Validated and ensured type safety for the following parameters:
    • --Raw
    • --HostPath
    • --CloudFile
    • --CommandLine
    • --Timeout

Previous Steps

Next Steps

  • Connector changes to execute runscript on CrowdStrike host
  • CrowdStrike Actions Client changes to save Action and Responses
  • UI Results Component for Response Console
  • Get and display CloudFiles (custom scripts)
  • Document examples of adding new commands and agent integrations.

@tomsonpl tomsonpl added Team:Defend Workflows “EDR Workflows” sub-team of Security Solution release_note:feature Makes this part of the condensed release notes backport:version Backport to applied version labels v8.18.0 labels Dec 5, 2024
@tomsonpl tomsonpl self-assigned this Dec 5, 2024
@tomsonpl
Copy link
Contributor Author

tomsonpl commented Dec 5, 2024

/ci

@tomsonpl
Copy link
Contributor Author

tomsonpl commented Dec 5, 2024

/ci

@tomsonpl
Copy link
Contributor Author

tomsonpl commented Dec 5, 2024

/ci

@tomsonpl
Copy link
Contributor Author

tomsonpl commented Dec 6, 2024

/ci

@tomsonpl
Copy link
Contributor Author

tomsonpl commented Dec 6, 2024

/ci

@tomsonpl
Copy link
Contributor Author

tomsonpl commented Dec 9, 2024

/ci

@tomsonpl tomsonpl marked this pull request as ready for review December 9, 2024 14:55
@tomsonpl tomsonpl requested review from a team as code owners December 9, 2024 14:55
@tomsonpl tomsonpl requested review from pzl and parkiino December 9, 2024 14:55
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-defend-workflows (Team:Defend Workflows)

@tomsonpl tomsonpl requested review from szwarckonrad and paul-tavares and removed request for pzl and parkiino December 9, 2024 15:00
Copy link
Contributor

@szwarckonrad szwarckonrad left a comment

Choose a reason for hiding this comment

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

I’ve reviewed the code but will leave the design/implementation review to Paul since I’m not too familiar with the response actions part of our codebase. Overall, it looks good -I’ve left some comments for you to consider.

Comment on lines 22 to 29
schema.string({
minLength: 1,
validate: (value) => {
if (!value.trim().length) {
return 'Raw cannot be an empty string';
}
},
})
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: extract to const nullableNonEmptyString = schema.maybe(schema.string...). We have those defined in multiple places too, maybe try looking for existing one

@@ -73,7 +74,9 @@ describe('When displaying Endpoint Response Actions', () => {
HELP_GROUPS.responseActions.label
);

const expectedCommands: string[] = [...CONSOLE_RESPONSE_ACTION_COMMANDS];
const expectedCommands: string[] = [
...CONSOLE_RESPONSE_ACTION_COMMANDS.filter((command) => command !== 'runscript'),
Copy link
Contributor

Choose a reason for hiding this comment

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

filter returns new array, I don`t see the need to spread

/**
* The script to run
*/
Raw: schema.maybe(
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe the other side expects properties with capital letters, but that’s not how we handle things. Since this endpoint is maintained by us, I’d suggest sticking to our standards and introducing a mapper or transformation to align with the standards of the next API we’ll be calling.

@@ -299,6 +299,13 @@ const CODES = Object.freeze({
'xpack.securitySolution.endpointActionResponseCodes.scan.success',
{ defaultMessage: 'Scan complete' }
),

// Dev:
// runscript success/competed
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// runscript success/competed
// runscript success/completed

# Conflicts:
#	x-pack/plugins/security_solution/common/endpoint/data_generators/endpoint_action_generator.ts
#	x-pack/plugins/security_solution/public/management/components/endpoint_responder/lib/integration_tests/console_commands_definition.test.tsx
#	x-pack/plugins/security_solution/public/management/cypress/screens/responder.ts
#	x-pack/plugins/security_solution/server/endpoint/services/actions/action_list.test.ts
@tomsonpl
Copy link
Contributor Author

@szwarckonrad thanks for the review, I applied all the suggestions - besides the CapitalCase change to lowerCase in API params. We discussed this offline and it would be requiring transformations multiple times to reflect CrowdStrike UI and API, eg. UI Capital > Kibana API camel > CS Capital.

For now we decided to go with the CapitalCase. Hope this is fine 👍

@tomsonpl
Copy link
Contributor Author

/ci

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

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

id before after diff
securitySolution 14.7MB 14.7MB -12.0B
Unknown metric groups

References to deprecated APIs

id before after diff
securitySolution 463 464 +1

History

cc @tomsonpl

@tomsonpl tomsonpl merged commit e993f23 into elastic:main Dec 11, 2024
8 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/12272304321

@kibanamachine
Copy link
Contributor

💔 All backports failed

Status Branch Result
8.x Backport failed because of merge conflicts

Manual backport

To create the backport manually run:

node scripts/backport --pr 203101

Questions ?

Please refer to the Backport tool documentation

@tomsonpl
Copy link
Contributor Author

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

tomsonpl added a commit to tomsonpl/kibana that referenced this pull request Dec 11, 2024
…stic#203101)

(cherry picked from commit e993f23)

# Conflicts:
#	x-pack/plugins/security_solution/server/endpoint/routes/actions/response_actions.ts
@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Dec 12, 2024
@kibanamachine
Copy link
Contributor

Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync.

@kibanamachine
Copy link
Contributor

Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync.

tomsonpl added a commit that referenced this pull request Dec 13, 2024
#203101) (#203722)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[EDR Workflows] Add RunScript API route (supporting CrowdStrike)
(#203101)](#203101)

<!--- Backport version: 8.9.8 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Tomasz
Ciecierski","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-12-11T08:18:35Z","message":"[EDR
Workflows] Add RunScript API route (supporting CrowdStrike)
(#203101)","sha":"e993f2388111cf16798014e7c857f23df5ab7cdb","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["v9.0.0","Team:Defend
Workflows","release_note:feature","backport:version","v8.18.0"],"number":203101,"url":"https://github.com/elastic/kibana/pull/203101","mergeCommit":{"message":"[EDR
Workflows] Add RunScript API route (supporting CrowdStrike)
(#203101)","sha":"e993f2388111cf16798014e7c857f23df5ab7cdb"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/203101","number":203101,"mergeCommit":{"message":"[EDR
Workflows] Add RunScript API route (supporting CrowdStrike)
(#203101)","sha":"e993f2388111cf16798014e7c857f23df5ab7cdb"}},{"branch":"8.x","label":"v8.18.0","labelRegex":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->
@kibanamachine kibanamachine removed the backport missing Added to PRs automatically when the are determined to be missing a backport. label Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:version Backport to applied version labels release_note:feature Makes this part of the condensed release notes Team:Defend Workflows “EDR Workflows” sub-team of Security Solution v8.18.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants