Skip to content

[EDR Workflows] Scripts selector component in Response Console#204965

Merged
tomsonpl merged 53 commits intoelastic:mainfrom
tomsonpl:runscript-cs-fetch-scripts
Jun 3, 2025
Merged

[EDR Workflows] Scripts selector component in Response Console#204965
tomsonpl merged 53 commits intoelastic:mainfrom
tomsonpl:runscript-cs-fetch-scripts

Conversation

@tomsonpl
Copy link
Contributor

@tomsonpl tomsonpl commented Dec 19, 2024

Description

This PR implements a custom scripts selector component for the Security Solution console, with initial support for CrowdStrike integration. The component allows users to select custom scripts that can be executed as part of response actions.


Changes

1. Custom Scripts API Implementation

  • Created a public method on response actions client to fetch scripts
  • Implemented CrowdStrike-specific client that fetches scripts via the CrowdStrike connector
  • Added server-side route handler for retrieving custom scripts http://localhost:5601//internal/api/endpoint/action/custom_scripts

2. UI Component Development

  • Developed a reusable CustomScriptSelector component that can be used as a command argument selector
  • Implemented searchable script selection with EuiSelectable
  • Added proper focus management and keyboard navigation
  • Applied consistent styling aligned with the console UI

3. Type Safety & Schema Validation

  • Added comprehensive TypeScript interfaces for custom scripts
  • Implemented schema validation for API requests
  • Ensured proper error handling and type safety throughout the implementation

4. Testing

  • Added unit tests for the new components and functionality

UI:

Screenshot 2025-05-23 at 13 37 29
Screen.Recording.2025-05-23.at.10.32.02.mov

Testing

Please contact @tomsonpl to get CS credentials

@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 19, 2024
@tomsonpl tomsonpl self-assigned this Dec 19, 2024
@tomsonpl tomsonpl added v9.1.0 and removed v8.18.0 labels May 19, 2025
@tomsonpl
Copy link
Contributor Author

/ci

@tomsonpl
Copy link
Contributor Author

/ci

@tomsonpl
Copy link
Contributor Author

/ci

@tomsonpl
Copy link
Contributor Author

/ci

@tomsonpl tomsonpl requested a review from Copilot May 20, 2025 20:11
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a custom scripts API and integrates a new SelectorComponent into the UI for cloud file selection. Key changes include the addition of server routes and API schemas for custom scripts, updates to the crowdstrike connector to support script retrieval, and comprehensive UI and test updates to integrate the new custom scripts selector.

Reviewed Changes

Copilot reviewed 30 out of 30 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
x-pack/solutions/security/plugins/security_solution/server/endpoint/services/actions/clients/crowdstrike/utils.test.ts Adjusted test expectations for command output formatting
x-pack/solutions/security/plugins/security_solution/server/endpoint/routes/custom_scripts/* Added new routes, handlers, and tests for custom scripts API
x-pack/solutions/security/plugins/security_solution/public/management/* Integrated the CustomScriptSelector into console commands and related hooks/tests
x-pack/platform/plugins/shared/stack_connectors/server/connector_types/crowdstrike/crowdstrike.ts Updated the crowdstrike connector to retrieve scripts with a renamed endpoint and adjusted payload type
Other related files Updated types, constants, API schemas, and tests to support the new custom scripts feature
Comments suppressed due to low confidence (1)

x-pack/platform/plugins/shared/stack_connectors/server/connector_types/crowdstrike/crowdstrike.ts:99

  • The endpoint name has changed from 'getRTRCloudScriptsDetails' to 'getRTRCloudScripts'. Ensure that corresponding client code, documentation, and tests are updated to reflect this naming change consistently.
getRTRCloudScripts: `${this.config.url}/real-time-response/entities/scripts/v1`,

commandLine: 'echo Hello World',
});
expect(result).toBe('runscript --CommandLine=```echo Hello World```');
expect(result).toBe(`runscript --CommandLine='echo Hello World'`);
Copy link

Copilot AI May 20, 2025

Choose a reason for hiding this comment

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

Clarify in the test documentation whether the use of single quotes for the CommandLine parameter is the intended format compared to triple backticks for other parameters, to ensure consistency in expected output.

Copilot uses AI. Check for mistakes.
Copy link
Member

@ashokaditya ashokaditya 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 a few questions and suggestions but it looks good to go. Tested it out with you and we found some issues that might need a fix.

@@ -360,7 +360,7 @@ describe('EndpointActionsClient', () => {
type ResponseActionsMethodsOnly = keyof Omit<
ResponseActionsClient,
// TODO: not yet implemented
Copy link
Member

Choose a reason for hiding this comment

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

Is this TODO still relevant?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not relevant, thanks!

// TODO: for now just for testing purposes, will be a part of a following PR
public async getRTRCloudScripts(
payload: CrowdstrikeGetAgentsParams,
payload: {},
Copy link
Member

Choose a reason for hiding this comment

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

Consider removing the payload param. I don't see that it is being used anywhwere.

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 decided to keep it to have the same structure as other actions, especially that maybe we'll need some payload in the end when filtering data or something. Is it ok?

name: SUB_ACTION.GET_RTR_CLOUD_SCRIPTS,
method: 'getRTRCloudScripts',
schema: CrowdstrikeGetScriptsParamsSchema,
schema: CrowdstrikeRTRCommandParamsSchema, // Empty schema - this request do not have any parameters
Copy link
Member

Choose a reason for hiding this comment

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

Q: Is there a reason we don't use schema: null when we register this and all above actions if the request schema is empty?

Copy link
Contributor Author

@tomsonpl tomsonpl Jun 2, 2025

Choose a reason for hiding this comment

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

schema:null for RTR is is fine 👍 Thx! The other above still need to be adjusted. I'll try to do it when there's more time to work on CrowdStrike.

Comment on lines +199 to +214
test('sets search value based on valueText prop', async () => {
const SelectorComponent = CustomScriptSelector('endpoint');
await renderAndWaitForComponent(
<SelectorComponent
{...defaultProps}
value="Script 1"
valueText="Script 1"
store={{ isPopoverOpen: true }}
/>
);

const searchbox = screen.getByRole('searchbox', { name: 'Filter options' });
expect(searchbox).toHaveValue('Script 1');
});

test('filters options based on valueText prop', async () => {
Copy link
Member

Choose a reason for hiding this comment

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

These two test descriptions should be contextual to the UX. valueText prop seems like a EUI specific test which looking at the test doesn't look like that it is. Consider updating the description.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, I think it's our custom props - not EUI specific. How would you suggest to change it ?

@tomsonpl tomsonpl enabled auto-merge (squash) June 2, 2025 17:32
@elasticmachine
Copy link
Contributor

elasticmachine commented Jun 3, 2025

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
securitySolution 7451 7453 +2

Async chunks

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

id before after diff
securitySolution 9.2MB 9.2MB +3.7KB
Unknown metric groups

References to deprecated APIs

id before after diff
securitySolution 336 337 +1

History

cc @tomsonpl

@tomsonpl tomsonpl merged commit 4390ea8 into elastic:main Jun 3, 2025
10 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.19

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

@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.19

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

Questions ?

Please refer to the Backport tool documentation

zacharyparikh pushed a commit to zacharyparikh/kibana that referenced this pull request Jun 4, 2025
tomsonpl added a commit to tomsonpl/kibana that referenced this pull request Jun 5, 2025
@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Jun 5, 2025
@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create automatically backports add a backport:* label or prevent reminders by adding the backport:skip label.
You can also create backports manually by running node scripts/backport --pr 204965 locally
cc: @tomsonpl

2 similar comments
@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create automatically backports add a backport:* label or prevent reminders by adding the backport:skip label.
You can also create backports manually by running node scripts/backport --pr 204965 locally
cc: @tomsonpl

@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create automatically backports add a backport:* label or prevent reminders by adding the backport:skip label.
You can also create backports manually by running node scripts/backport --pr 204965 locally
cc: @tomsonpl

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 ci:cloud-deploy Create or update a Cloud deployment release_note:feature Makes this part of the condensed release notes Team:Defend Workflows “EDR Workflows” sub-team of Security Solution v8.19.0 v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants