Skip to content

Commit

Permalink
[Security Solution][Endpoint][UI] Add agentTypes filter to action h…
Browse files Browse the repository at this point in the history
…istory (elastic#175810)

## Summary

Adds agent type filter values to the `Type` filter on actions history.
So in addition to filtering by action type one can also filter with
agent types.

- With the feature flag enabled, the filter name changes to `Types` as
it now holds Action and Agent types filter options. A new URL param
called `agentTypes` is added when agent type options are selected. The
existing `types` URL param works the way it does now.
- Without the feature flag enabled the filter behaves and looks the way
it does currently.

**with feature flag `responseActionsSentinelOneV1Enabled` on**
<img width="2056" alt="Screenshot 2024-02-01 at 11 27 52 AM"
src="https://github.com/elastic/kibana/assets/1849116/83e17587-5e49-481e-9a85-cbb3642873b7">

### Checklist

- [x] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [x] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [x] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [x] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)
  • Loading branch information
ashokaditya authored Feb 2, 2024
1 parent 5b20552 commit 0c743a5
Show file tree
Hide file tree
Showing 19 changed files with 982 additions and 445 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,28 @@ const commandsSchema = schema.oneOf(
RESPONSE_ACTION_API_COMMANDS_NAMES.map((command) => schema.literal(command))
);

// TODO: fix the odd TS error
// @ts-expect-error TS2769: No overload matches this call
const statusesSchema = schema.oneOf(RESPONSE_ACTION_STATUS.map((status) => schema.literal(status)));
// @ts-expect-error TS2769: No overload matches this call
const typesSchema = schema.oneOf(RESPONSE_ACTION_TYPE.map((type) => schema.literal(type)));
const statusesSchema = {
// @ts-expect-error TS2769: No overload matches this call
schema: schema.oneOf(RESPONSE_ACTION_STATUS.map((status) => schema.literal(status))),
options: { minSize: 1, maxSize: RESPONSE_ACTION_STATUS.length },
};

const agentTypesSchema = schema.oneOf(
const actionTypesSchema = {
// @ts-expect-error TS2769: No overload matches this call
RESPONSE_ACTION_AGENT_TYPE.map((agentType) => schema.literal(agentType))
);
schema: schema.oneOf(RESPONSE_ACTION_TYPE.map((type) => schema.literal(type))),
options: { minSize: 1, maxSize: RESPONSE_ACTION_TYPE.length },
};

const agentTypesSchema = {
schema: schema.oneOf(
// @ts-expect-error TS2769: No overload matches this call
RESPONSE_ACTION_AGENT_TYPE.map((agentType) => schema.literal(agentType))
),
options: {
minSize: 1,
maxSize: RESPONSE_ACTION_AGENT_TYPE.length,
},
};

export const EndpointActionListRequestSchema = {
query: schema.object({
Expand All @@ -42,10 +54,8 @@ export const EndpointActionListRequestSchema = {
),
agentTypes: schema.maybe(
schema.oneOf([
schema.arrayOf(agentTypesSchema, {
minSize: 1,
}),
agentTypesSchema,
schema.arrayOf(agentTypesSchema.schema, agentTypesSchema.options),
agentTypesSchema.schema,
])
),
commands: schema.maybe(
Expand All @@ -58,7 +68,10 @@ export const EndpointActionListRequestSchema = {
startDate: schema.maybe(schema.string()), // date ISO strings or moment date
endDate: schema.maybe(schema.string()), // date ISO strings or moment date
statuses: schema.maybe(
schema.oneOf([schema.arrayOf(statusesSchema, { minSize: 1, maxSize: 3 }), statusesSchema])
schema.oneOf([
schema.arrayOf(statusesSchema.schema, statusesSchema.options),
statusesSchema.schema,
])
),
userIds: schema.maybe(
schema.oneOf([
Expand Down Expand Up @@ -86,8 +99,12 @@ export const EndpointActionListRequestSchema = {
}),
])
),
// action types
types: schema.maybe(
schema.oneOf([schema.arrayOf(typesSchema, { minSize: 1, maxSize: 2 }), typesSchema])
schema.oneOf([
schema.arrayOf(actionTypesSchema.schema, actionTypesSchema.options),
actionTypesSchema.schema,
])
),
}),
};
Expand Down
Loading

0 comments on commit 0c743a5

Please sign in to comment.