Commit graph

884 commits

Author SHA1 Message Date
Nick Peihl
6689169687
Move @elastic/kibana-gis ownership to @elastic/kibana-presentation (#192521)
## Summary

The legacy `@elastic/kibana-gis` team is now a part of
`@elastic/kibana-presentation`. So we should move ownership of all code
to the correct team.
2024-09-16 09:50:50 -05:00
Kevin Lacabane
1e6b13c8e0
[eem] top_value metadata aggregation (#188243) 2024-09-16 03:01:41 +02:00
Rickyanto Ang
28becfdce9
[Cloud Security] Host Name Misconfiguration Datagrid & Refactor CSP Plugin PHASE 2 (#192535)
In an attempt to make Reviewing easier and more accurate, the
implementation of Misconfiguration Data grid on Host.name flyout in
Alerts Page will be split into 2 Phases

Phase 1: Move Functions, Utils or Helpers, Hooks, constants to Package
Phase 2: Implementing the feature

This is **Phase 2** of the process
<img width="1712" alt="Screenshot 2024-09-11 at 2 16 20 PM"
src="https://github.com/user-attachments/assets/29ab56db-8561-486c-ae8d-c254b932cea4">

How to test:
Pre req: In order to test this, you need to generate some fake alerts.
This [repo](https://github.com/elastic/security-documents-generator)
will help you do that
1. Generate Some Alerts
2. Use the Reindex API to get some Findings data in (change the
host.name field to match the host.name from alerts generated if you want
to test Findings table in the left panel flyout)
3. Turn on Risky Entity Score if you want to test if both Risk
Contribution and Insights tabs shows up, follow this
[guide](https://www.elastic.co/guide/en/security/current/turn-on-risk-engine.html)
to turn on Risk Entity Score
2024-09-13 21:41:41 -07:00
Steph Milovic
cabaf7a077
[Security GenAI] Re-add telemetry for isEnabledKnowledgeBase (#192785) 2024-09-13 17:17:08 -06:00
Saarika Bhasi
7264d3a548
[Index Management] [Onboarding] Create new package folder for index_management (#192594)
## Summary

We have to extract few components from `index_management` plugin to
shared packages for onboarding project. These extracted files would be
separated into small subject matter packages within a common folder -
`index-management` in `x-pack/packages/`.


What is covered in this PR? 

* Created new folder `index-management` under [
x-pack/packages/](https://github.com/elastic/kibana/tree/main/x-pack/packages)
as a home for subject matter packages.
* moved existing package -
[@kbn/index-management](https://github.com/elastic/kibana/tree/main/x-pack/packages/index-management)
under `x-pack/packages/index-management`
* update name of
[@kbn/index-management](https://github.com/elastic/kibana/tree/main/x-pack/packages/index-management)
to `@kbn/index-management-shared-types`
* updated related files which use `@kbn/index-management` to use
`@kbn/index-management-shared-types`

**Note** 
Extracting components required for onboarding project will be part of
another PR
2024-09-13 07:46:00 -04:00
Kevin Lacabane
2f1d0cd9b3
[eem] add entity definition state (#191933)
~blocked by https://github.com/elastic/kibana/issues/192004~

This change adds an `includeState: boolean` option to methods querying
entity definitions. When true this adds an `EntityDefinitionState`
object containing all the definition components and their state
(installed or not) and stats. Since this may only be used internally (eg
builtin definition installation process) and for troubleshooting,
`includeState` is false by default

#### Testing
- install a definition
- call `GET
kbn:/internal/entities/definition/<definition-id>?includeState=true`
- check and validate the definition `state` block
- manually remove transform/pipeline/template components
- check and validate the definition `state` block
2024-09-13 09:53:50 +02:00
Elena Shostak
a71c9ba38a
Added scope field to features config. (#191634)
## Summary
Kibana needs to more tightly control the set of visible features within
a space, in order to support the new solution-based navigation.
Added `scope` field to the features configuration. This enhancement is
intended to prevent new features from appearing in Space Visibility
Toggles.


### Checklist

- [x]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [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


__Fixes: https://github.com/elastic/kibana/issues/191299__

## Release Note

Added `scope` field to the features configuration. This enhancement is
intended to prevent new features from appearing in Space Visibility
Toggles.

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2024-09-12 19:22:20 -05:00
Melissa Alvarez
e5600b18b1
[ML] Anomaly Detection supplied configurations: adds page in ML UI for Supplied configurations (ML Modules) (#191564)
## Summary

This PR adds a page in the UI for 'Supplied configurations'
Dependent on this fix to the endpoint schema going in first:
https://github.com/elastic/kibana/pull/191633

NOTE: This item will be added to the side-nav of oblt serverless once
this update is in: https://github.com/elastic/kibana/issues/190458

Adds dedicated UI page for preconfigured job packages - subitem of the
Anomaly Detection navigation:
<img width="1721" alt="image"
src="https://github.com/user-attachments/assets/194bbf44-aa7c-4afa-94e3-587fb9e5f601">

When they can't be run in the ML UI: 
<img width="1467" alt="image"
src="https://github.com/user-attachments/assets/487463e8-7520-48de-8806-1d45a82e452e">

When selected - flyout opens to reveal package assets:
<img width="1098" alt="image"
src="https://github.com/user-attachments/assets/a648a6d8-df79-4bb3-a797-61f02e246c9b">

Clicking the `Run data recognizer` button shows matching data views (if
any) with link to job creation:
<img width="1099" alt="image"
src="https://github.com/user-attachments/assets/05e9f7f7-e41f-486d-ba41-84cacf534cd0">

Empty table when no matching dataviews are found:
<img width="999" alt="image"
src="https://github.com/user-attachments/assets/d8bbf3be-7035-4e2f-956e-83dfbc26b247">

Jobs tab of flyout:
<img width="1102" alt="image"
src="https://github.com/user-attachments/assets/e94efb2e-1f21-4883-aa2b-2c42db5be970">

kibana tab of flyout:
<img width="1100" alt="image"
src="https://github.com/user-attachments/assets/0021a527-8d9d-4e06-9fae-d832015f7f7d">




### Checklist

Delete any items that are not applicable to this PR.

- [ ] 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)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [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
- [ ] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [ ] 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))
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] 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))
- [ ] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2024-09-12 10:30:09 -06:00
Steph Milovic
ea6bb9e0b7
[Security solution] Attack Discovery "View in AI Assistant" button fix (#192416) 2024-09-12 08:35:44 -06:00
Dario Gieselaar
98aa1ab769
[Inventory] Inventory plugin (#191798)
## Description

This PR adds an inventory plugin, which renders an inventory UI.
Currently only data streams are rendered. This is part of the LogsAI
initiative - basically we need a UI for tasks like structuring data,
extracting entities, listing the results etc. This is mostly POC-level
stuff. Eventually some of this code might be handed over to ECO but
let's cross that bridge when we get to it.

## Notes for reviewers:

@elastic/appex-ai-infra @elastic/security-generative-ai: added a
`truncateList` utility function that takes the first n elements of an
array and appends a `{l-n} more` string value if there are more values
than n. Really simple but I expect will also be very often used because
we cannot send a huge amount of items to the LLM.

@elastic/kibana-core @elastic/kibana-operations: just boiler plate stuff
for adding a new plugin (and thank you for enabling us to run
`quick_checks` locally!

@elastic/obs-knowledge-team: added support for streaming using an
Observable.

@elastic/obs-ux-management-team: added links to the Inventory UI in the
Observability plugin

@elastic/obs-entities: I've added an entity manager client to be able to
fetch entity definitions on the server. Maybe there's a better way? LMK.

@elastic/obs-ux-logs-team: added a deeplink to the Inventory UI. I've
also moved CODEOWNERS for this package to
@elastic/obs-ux-management-team as they own the Observability plugin
where this is mostly used.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2024-09-12 15:07:09 +02:00
Steph Milovic
2dc1aca175
[Security Solution] AI Assistant - System prompt move (#191847) 2024-09-11 15:56:00 -06:00
Steph Milovic
53e88ec03a
[Security solution] Handle Gemini finishReason: SAFETY (#192304) 2024-09-11 12:18:44 -06:00
Cee Chen
20566d0262
Upgrade EUI to v95.10.1 (#192026)
`v95.9.0``v95.10.1`

> [!note]
> **EuiDataGrid**'s header cells have received a major UX change in
order to support interactive children within header content. Column
header actions now must be hovered and then clicked directly, or opened
with the Enter key, as opposed to being able to click the entire header
cell to see the actions popover.

_[Questions? Please see our Kibana upgrade
FAQ.](https://github.com/elastic/eui/blob/main/wiki/eui-team-processes/upgrading-kibana.md#faq-for-kibana-teams)_

---

## [`v95.10.0`](https://github.com/elastic/eui/releases/v95.10.0)

- Updated `EuiDataGrid` to support interactive header cell content
([#7898](https://github.com/elastic/eui/pull/7898))
- Updated `EuiSearchBar`'s `field_value_selection` filter type with a
new `autoSortOptions` config, allowing consumers to configure whether or
not selected options are automatically sorted to the top of the filter
list ([#7958](https://github.com/elastic/eui/pull/7958))
- Updated `getDefaultEuiMarkdownPlugins` to support the following new
default plugin configurations:
([#7985](https://github.com/elastic/eui/pull/7985))
- `parsingConfig.linkValidator`, which allows configuring
`allowRelative` and `allowProtocols`
  - `parsingConfig.emoji`, which allows configuring emoticon parsing
- `processingConfig.linkProps`, which allows configuring rendered links
with any props that `EuiLink` accepts
- See our **Markdown plugins** documentation for example
`EuiMarkdownFormat` and `EuiMarkdownEditor` usage
- Updated `EuiDatePicker` to support `append` and `prepend` nodes in its
form control layout ([#7987](https://github.com/elastic/eui/pull/7987))

**Bug fixes**

- Fixed border rendering bug with inline `EuiDatePicker`s with
`shadow={false}` ([#7987](https://github.com/elastic/eui/pull/7987))
- Fixed `EuiSuperSelect`'s placeholder text color to match other form
controls ([#7995](https://github.com/elastic/eui/pull/7995))

**Accessibility**

- Improved the keyboard navigation and screen reader output for
`EuiDataGrid` header cells
([#7898](https://github.com/elastic/eui/pull/7898))

## [`v95.10.1`](https://github.com/elastic/eui/releases/v95.10.1)

**Bug fixes**

- Fixed a visual bug in compact density `EuiDataGrid`s, where the header
cell height would increase when the actions button became visible
([#7999](https://github.com/elastic/eui/pull/7999))

---------

Co-authored-by: Lene Gadewoll <lene.gadewoll@elastic.co>
2024-09-10 16:06:21 -05:00
Paul Tavares
ce63cd8b07
[Security Solution] Add description attribute to the Security grouping of Kibana security sub-feature privileges (#192273)
## Summary

- Adds text under the `security` group that clarifies what actions the
user must do in order to customize the grouping privileges

closes #191592 

<img width="765" alt="image"
src="https://github.com/user-attachments/assets/81f88a59-9e97-4c4d-a5b9-4326d95f8ac5">
2024-09-10 08:46:13 -04:00
Walter Rafelsberger
6a270cf4d6
Upgrade @testing-library/user-event to latest ^14.5.2 (#189949)
## Summary

Upgrades `@testing-library/user-event` to `^14.5.2`. See the release
notes for `v14` for breaking changes:
https://github.com/testing-library/user-event/releases/tag/v14.0.0

I was facing an
[issue](https://github.com/testing-library/user-event/issues/662) with
`v13.5.0` with `userEvent.click()` in a PR
(https://github.com/elastic/kibana/pull/189729) and was able to verify
that `v14.4.3` onwards fixes it so I decided to update that package.
What a rabbit hole 😅 !

- In `user-event` `v14` events return a promise, so this PR updates
usage of the likes of `userEvent.click` with `await userEvent.click`.
Regex to search for `userEvent` calls that miss `await` except `.setup`:
`(?<!await\s)userEvent\.(?!setup\b)`
- The way to handle pointer events needed changing from `, undefined, {
skipPointerEventsCheck: true });` to `, { pointerEventsCheck: 0 });`.
- I tried a bit to do the refactor with codemods, but there were quite
some edge cases so it ended up being done manually.
- I looked into all failing tests and tried my best to update them, but
for some of them I lacked the context to make them work again. If you're
a code owner and find a skipped test in this PR please give it a try to
fix and push in this PR or let me know if it's fine for you to fix in
follow ups.

List of files where I had to skip tests (`git diff main...HEAD
-G'\.skip' --name-only`):

### `packages/kbn-dom-drag-drop`

- `packages/kbn-dom-drag-drop/src/droppable.test.tsx`

### `x-pack/plugins/cases`

- `x-pack/plugins/cases/public/components/templates/form.test.tsx`
-
`x-pack/plugins/cases/public/components/user_actions/user_actions_list.test.tsx`

### `x-pack/plugins/cloud_security_posture`

-
`x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/policy_template_form.test.tsx`

### `x-pack/plugins/lens`

-
`x-pack/plugins/lens/public/datasources/form_based/dimension_panel/format_selector.test.tsx`

### `x-pack/plugins/observability_solution`

-
`x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/monitor_add_edit/fields/request_body_field.test.tsx`

### `x-pack/plugins/security_solution`

-
`x-pack/plugins/security_solution/public/management/components/console/components/command_input/integration_tests/command_input.test.tsx`
-
`x-pack/plugins/security_solution/public/management/components/endpoint_responder/command_render_components/integration_tests/kill_process_action.test.tsx`
-
`x-pack/plugins/security_solution/public/management/components/endpoint_responder/command_render_components/integration_tests/release_action.test.tsx`
-
`x-pack/plugins/security_solution/public/management/components/endpoint_responder/command_render_components/integration_tests/status_action.test.tsx`
-
`x-pack/plugins/security_solution/public/management/components/endpoint_responder/command_render_components/integration_tests/upload_action.test.tsx`
-
`x-pack/plugins/security_solution/public/management/components/endpoint_response_actions_list/integration_tests/response_actions_log.test.tsx`
-
`x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/event_filters_flyout.test.tsx`
-
`x-pack/plugins/security_solution/public/management/pages/response_actions/view/response_actions_list_page.test.tsx`

----

I plan to do a talk on Kibana Demo Days to walk through some of the
breaking changes and learnings.

### Checklist

- [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] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
2024-09-10 14:31:27 +02:00
Garrett Spong
47d308604f
[Security Assistant] Updates Knowledge Base ES Schema, OAS, and API to support IndexEntries (#186566)
## Summary

This is a follow-up to https://github.com/elastic/kibana/pull/184974
that updates the KB Entries API's (and underlying schema) to support
`IndexEntries` in addition to `DocumentEntries`. `IndexEntries` are
entries in the Knowledge Base that are not backed by an embedded raw
text source, but rather by an entire Index or Data Stream. The user can
set the data source name, the specific field to query (must be ELSER
embeddings in this initial implementation), and a description for when
the assistant should search this data source for Knowledge Base content.
This essentially enables the user to create custom retrieval tools
backed by their own data.


The changes in this PR, as with the other recent KB enhancements, are
behind the following feature flag:
```
xpack.securitySolution.enableExperimental:
  - 'assistantKnowledgeBaseByDefault'
```

however as code change is required to test the new mappings. For this
you can update the `knowledgeBaseDataStream` in
`x-pack/plugins/elastic_assistant/server/ai_assistant_service/index.ts`
to

```ts
    this.knowledgeBaseDataStream = this.createDataStream({
      resource: 'knowledgeBase',
      kibanaVersion: options.kibanaVersion,
      fieldMap: knowledgeBaseFieldMapV2, // Update this to the V2 mapping
    });
```

Change set includes:
- [X] ES Knowledge Base data stream schema and OAS has been updated to
support `IndexEntries`.
- [X] OAS schema files have been moved to the `/entries` sub-directory
- [ ] Backend KB services have been updated to support `IndexEntries`
  - [X] Storage methods updated
- [ ] Retrieval methods updated (will round out these endpoint when
working the UI next)

---

With these API changes, I've also introduced a few sample `*.http` files
for easier development/testing. These files are supported out of the box
in JetBrains IDE's or in VSCode with the
[httpyac](https://httpyac.github.io/) (and many other) extensions. Since
the configuration for these files includes a `-` in the name, that's why
you'll see a few @elastic/kibana-operations files updated.

You can read more about `http` files
[here](https://www.jetbrains.com/help/webstorm/http-client-in-product-code-editor.html)
and for the spec see this repo
[here](https://github.com/JetBrains/http-request-in-editor-spec/blob/master/spec.md).
If we find these useful, we could add support to our [OpenAPI
Generator](https://openapi-generator.tech/docs/generators/jetbrains-http-client)
to create these automatically. They currently live co-located next to
the OAS and generated schema files here:

```
x-pack/packages/kbn-elastic-assistant-common/impl/schemas/knowledge_base/entries/bulk_crud_knowledge_base_entries_route.http
x-pack/packages/kbn-elastic-assistant-common/impl/schemas/knowledge_base/entries/crud_knowledge_base_entries_route.http
```

and the main config here:

```
x-pack/packages/kbn-elastic-assistant-common/env/http-client.env.json
```

The `x-pack/packages/kbn-elastic-assistant-common/.gitignore` has been
updated to ignore `http-client.private.env.json` files locally, which is
how you can override the config as you'd like. This is helpful to add
variables like `basePath` as below:

```
{
  "dev": {
    "basePath": "/kbn"
  }
}
```

To use them, just open the corresponding `*.http` for the API you want
to test, and click `Send`, and the response will open in another tab.
Here is what that looks like for creating one of the new `IndexEntry` KB
documents that have been introduced in this PR:

<p align="center">
<img width="500"
src="https://github.com/user-attachments/assets/c9e70d1a-28d2-4eb3-9853-ab6d8e1c7acf"
/>
</p> 





### Checklist

Delete any items that are not applicable to this PR.

- [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)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
* Feature currently behind feature flag. Documentation to be added
before flag is removed. Tracked in
https://github.com/elastic/security-docs/issues/5337
- [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

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2024-09-10 02:01:59 -06:00
Konrad Szwarc
66ab8ab60c
[EDR Workflows][Serverless] Fix Host Isolation Exceptions PLIs (#191954)
This PR establishes appropriate privileges across Endpoint tiers. In
Endpoint Complete, users will be able to create, update, and delete Host
Isolation Exceptions. Upon downgrading to Endpoint Essentials, users
should still be able to view and remove items from the Blocklist but
will not have the ability to edit or create new entries.

Please see linked issue for more details on current behaviour.

Expected privileges:
Endpoint Essentials - User can read and delete HIE
Endpoint Complete - User can read, delete and write HIE


https://github.com/user-attachments/assets/69d14a51-6004-45b7-9c78-62066441f4ab
2024-09-10 09:20:25 +02:00
Anton Dosov
fccfd4cf75
[react@18] Implicit children type fixes (#192011)
## Summary

Part of https://github.com/elastic/kibana/issues/138222

in @types/react@18 types [have become more
strict](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/56210).
This PR addresses a bunch of easy fixes. The most common are:

### 1 Removal of implicit children

For components that do implement children but relied on their implicit
declaration from React.FunctionComponent or React.Component:

```diff
 interface Props {
+  children?: React.ReactNode;
 }

 class SomeClassComponents React.Component<Props> {
   render() {
     return  <div>{this.props.children}</div>
   }
 }
 const SomeFunctionComponent: React.FunctionComponent<Props> = props => <div>{props.children}</div>
```

or 

```diff
- const SomeFunctionComponent: React.FunctionComponent<Props> = props => <div>{props.children}</div>
+ const SomeFunctionComponent: React.FunctionComponent<React.PropsWithChildren<Props>> = props => <div>{props.children}</div>
```


*Note 1:*
The most common change occurs in unit tests where `renderHook` and
`wrapper` are used. I had to re-type the props so that `children` were
there

```diff
const { result } = renderHook(
         () => {
           return useLicense();
         },
         {
-           wrapper: ({ children }) => (
+           wrapper: ({ children }: React.PropsWithChildren<{}>) => (
             <TestProviders license={license}>{children}</TestProviders>
           ),
         }
       );
```

```diff
- const { result } = renderHook<GetCasesColumn, UseCasesColumnsReturnValue>(
+ const { result } = renderHook<React.PropsWithChildren<GetCasesColumn>, UseCasesColumnsReturnValue>(
       () => useCasesColumns(defaultColumnArgs),
       {
         wrapper: ({ children }) => <TestProviders>{children}</TestProviders>,
       }
     );
```



*Note 2:*
With @types/react@17 the components that don't have any props apart from
`children` I had to use `React.PropsWithChildren<{}>`, whereas in
@types/react@18 the argument becomes optional, so it can be omitted, and
type simpler with `React.PropsWithChildren` without an argument



### 2 `this.context` becomes `unknown` (was `any`)

In a couple of places where `this.context` is used, I had to type it

### 3 `ComponentType` from enzyme is no longer compatible with
`ComponentType` from react

This one is a bummer, but where `wrappingComponent` with enzyme is used
I had to cast it to type from `enzyme`

```diff
- import { mount } from 'enzyme'
+ import { mount, ComponentType } from 'enzyme'

 wrapper = mount(<ClosureOptions {...props} />, {
-       wrappingComponent: TestProviders,
+       wrappingComponent: TestProviders as ComponentType<{}>,
});
```
2024-09-09 13:56:02 +02:00
Jordan
a36b22aa6c
[Cloud Security] Support for missing fields in vulnerabilities and removing integration installation block (#191504) 2024-09-09 11:23:50 +02:00
Philippe Oberti
d968cc0929
[Security Solution][Alert Details] - push and overlay expandable flyout (#182615)
## Summary

This PR adds a new functionality to the `kbn-expandable-flyout` package
and its usage in the Security Solution application.

The package's flyout now support to be rendered in `overlay` or `push`
mode, following [EUI's
recommendation](https://eui.elastic.co/#/layout/flyout#push-versus-overlay).
A gear icon button is rendered in the top right corner, next to the
close button. When clicked, a menu appears where users can select `push`
or `overlay` values. `overlay` is the default value. If `push` is
selected, a `Reset to default` empty button can be used to reset to
`overlay`.

Overlay option selected (by default)
![Screenshot 2024-09-04 at 12 10
34 PM](https://github.com/user-attachments/assets/87f57238-9b44-4d29-9516-9eb329c49bb2)

Push option selected
![Screenshot 2024-09-04 at 12 10
42 PM](https://github.com/user-attachments/assets/80e7879a-b238-46ba-9c13-2c8e236e138f)

The flyout should be toggled between `overlay` and `push` mode in all
the pages it's been currently used in:
- alerts page
- rule creation page
- explore pages (host, users...)
- case detail page


https://github.com/user-attachments/assets/b4cec138-802c-430d-8f37-01258e6afef3

But the flyout cannot be set to `push` mode when opened from Timeline.
Timeline is a modal (an EUI Portal to be precise), and getting the
portal as well as the overlay mask to correctly resize according to the
flyout's width (which is dynamic, changes with the screen size and also
changes if the flyout is in collapsed or expanded mode) is very
difficult.
A future PR might add this functionality to TImeline. At this time, the
flyout offers the option to disable the `push/overlay` toggle as well as
an icon to show a tooltip to explain why.


https://github.com/user-attachments/assets/e00961c8-cc75-4eb9-b34d-544bc4391d5c

#### Notes

The package also offers a way to hide the gear icon entirely. In the
future, we might need a bit more flexibility if we want to be able to
show the gear icon with options others than the `push/overlay` entry.

Finally the state of the flyout type (`overlay` vs `push`) is saved in
local storage so that users don't have to set the value over and over
again. This state is persisted within the `kbn-expandable-flyout`
package so that developers don't have to worry about setting it up. The
package uses its internal `urlKey` to guarantee that the key used to
save in localStorage is unique. This means that `memory` flyouts cannot
persist the `push` or `overlay` states, this is expected.


500315b5-07d4-4498-aab9-ee2e2be0253b

### Notes

The package's README has been updated.
New Storybook stories have been added to reflect the new push/overlay
functionality.

https://github.com/elastic/kibana/issues/182593
2024-09-06 15:16:47 -05:00
Rickyanto Ang
d177d11719
[Cloud Security] Host Name Misconfiguration Datagrid & Refactor CSP Plugin PHASE 1 (#192114)
## Summary

In an attempt to make Reviewing easier and more accurate, the
implementation of Misconfiguration Data grid on Host.name flyout in
Alerts Page will be split into 2 Phases

Phase 1: Move Functions, Utils or Helpers, Hooks, constants to Package
Phase 2: Implementing the feature

This is Phase 1 of the process

This PR also include a small bug fix mentioned here
https://github.com/elastic/kibana/pull/191677#pullrequestreview-2279906960

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2024-09-06 12:42:55 -07:00
natasha-moore-elastic
842caa2cbc
Improves Security AI Assistant API docs content (#192254)
## Summary

Resolves https://github.com/elastic/security-docs-internal/issues/36 by
improving the Security AI Assistant API docs content. Adds missing and
improves existing operation summaries and operation descriptions to
adhere to our [OAS
standards](450494532/API+reference+docs).

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2024-09-06 18:11:47 +01:00
Milton Hultgren
b9319a6ad4
[EEM] Migrate to using @kbn/server-route-repository (#191102)
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2024-09-06 04:11:28 -05:00
Anton Dosov
8199dd0407
[react@18] (Part 2) fix useCallback breaking type changes (#191659)
## Summary

This is a prep for https://github.com/elastic/kibana/issues/138222 and
follow up to https://github.com/elastic/kibana/pull/182344. These are
post-merge leftovers and new instances from the previous
[run](https://github.com/elastic/kibana/pull/182344)

In React@18 useCallback types have changed that introducing breaking
changes:
https://github.com/DefinitelyTyped/DefinitelyTyped/issues/46691

Found potential issues using:

https://github.com/eps1lon/types-react-codemod?tab=readme-ov-file#usecallback-implicit-any

I tried to do my best to fix the type where possible, but there are some
complicated cases where I kept `any` after some struggling. Please feel
free to push improvements directly.

---------
Co-authored-by: Jatin Kathuria <jtn.kathuria@gmail.com>
2024-09-04 10:00:40 -05:00
Rickyanto Ang
8b7d965752
[Cloud Security] Misconfiguration preview & Refactor CSP Plugin to include new package PHASE 4 (#191677)
The previous https://github.com/elastic/kibana/pull/190105 was way too
big and made it hard to review without missing any bugs or potential
bugs, Thus we decided we are going to make series of smaller PR to make
things more manageable

We will be splitting it into 4 PR
Phase 1: Creating empty packages for csp and csp-common
Phase 2: Move Types from CSP plugin to the Package + Deleting duplicates
in the CSP plugin where possible
Phase 3: Move Functions, Utils or Helpers, Hooks to Package
Phase 4: Misconfiguration Preview feature (with Cypress test and other
required test)

<img width="681" alt="353329193-5ad22c4e-81c2-4a8b-89f7-fdbc2a686c2d"
src="https://github.com/user-attachments/assets/b369625a-efc5-4292-a690-2c5dffb5483d">


This is Phase 4 of the Process,

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2024-09-04 07:32:06 -07:00
Vitalii Dmyterko
3c9198abeb
[Security Solution][Detection Engine] update query automatically in rule create form through AI assistant (#190963)
## Summary

 - addresses https://github.com/elastic/kibana/issues/187270


### UX

Introduced button in code block

<img width="1218" alt="Screenshot 2024-08-21 at 16 35 51"
src="https://github.com/user-attachments/assets/69c82d7c-7305-41a6-9a29-5f27755727a6">

### DEMO


https://github.com/user-attachments/assets/32419edc-4bfa-4f4e-892b-2a6abb3c0f27




### Checklist


- [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
- [x] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [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 was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2024-09-03 12:37:36 -05:00
Ido Cohen
c594254fb4
[Cloud Security] use global cdr vuln data view (#191581) 2024-09-03 16:08:19 +03:00
James Gowdy
e204184a2a
[ML] Improving empty object creation in ML packages (#191901)
Replacing instances of empty object creation with Object.create(null) to
remove any risk of prototype pollution.
Related to https://github.com/elastic/kibana/pull/191518
2024-09-03 10:08:21 +01:00
Alejandro Fernández Haro
4ec0dbe64d
[Move @kbn/config-schema to server] @kbn/alerting-state-types (#191786) 2024-09-02 16:46:48 -05:00
Steph Milovic
a2315ab94c
[Security solution] Security Assistant Cypress (#191000) 2024-08-29 14:21:33 -06:00
Kevin Lacabane
b5dbcd8fb8
[eem] definition update endpoint (#190648)
Create `PATCH kbn:/internal/entities/definition` allowing update of
stored definition. The endpoint accepts an update object representing a
partial entity definition with a few key properties that cannot be
updated. The update process will stop and delete the existing transforms
and create new ones, there's
https://github.com/elastic/elastic-entity-model/issues/136 logged as a
follow up improvement.

### Testing
- call `PUT kbn:/internal/entities/definition/{id}` with an update
payload (see [update
schema](7a7fbdf1cd/x-pack/packages/kbn-entities-schema/src/schema/entity_definition.ts (L62)))
- call `GET kbn:/internal/entities/definition` and verify the update in
reflected in the stored definition
- verify the updated properties are reflected in the corresponding
transform/pipeline components

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2024-08-29 21:17:28 +02:00
Sander Philipse
3de8133a5a
[Search] Fix inference endpoints ignoring different deployments (#191223)
## Summary

Inference endpoints were ignoring different deployments, only looking at
the first deployment. This is wrong: we should be checking the specific
inference endpoint's trained model reference deployment. This fixes
that.
2024-08-29 08:13:10 -05:00
Rickyanto Ang
a78c69b273
[Cloud Security] Misconfiguration preview & Refactor CSP Plugin to include new package PHASE 3 (#191317)
The previous https://github.com/elastic/kibana/pull/190105 was way too
big and made it hard to review without missing any bugs or potential
bugs, Thus we decided we are going to make series of smaller PR to make
things more manageable

We will be splitting it into 4 PR
Phase 1: Creating empty packages for csp and csp-common
Phase 2: Move Types from CSP plugin to the Package + Deleting duplicates
in the CSP plugin where possible
Phase 3: Move Functions, Utils or Helpers, Hooks to Package
Phase 4: Misconfiguration Preview feature (with Cypress test and other
required test)

This is **Phase 3** of the Process,
This also includes moving rule versions type

This PR is the continuation of this PR
https://github.com/elastic/kibana/pull/190933

NOTE:
Merge phase 2 first before this

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2024-08-28 12:40:43 -07:00
Patryk Kopyciński
2d1d592a3b
[react@18] Fix useCallback breaking type changes (#182344)
## Summary

Prep work for React@18 bump
https://github.com/elastic/kibana/issues/138222

In React@18 `useCallback` types has changed that introduced breaking
changes:
https://github.com/DefinitelyTyped/DefinitelyTyped/issues/46691

Fixed using:

https://github.com/eps1lon/types-react-codemod?tab=readme-ov-file#usecallback-implicit-any

**Tried to do my best with fixing the types, but if you disagree or have
a better idea how it should be solved feel free to suggest changes or
commit directly to the branch 🙏**

---------

Co-authored-by: Sergi Massaneda <sergi.massaneda@elastic.co>
Co-authored-by: Sébastien Loix <sabee77@gmail.com>
Co-authored-by: Nick Peihl <nick.peihl@elastic.co>
Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
Co-authored-by: Felix Stürmer <felix.stuermer@elastic.co>
Co-authored-by: nickofthyme <nicholas.partridge@elastic.co>
Co-authored-by: Davis McPhee <davis.mcphee@elastic.co>
Co-authored-by: Vitalii Dmyterko <92328789+vitaliidm@users.noreply.github.com>
Co-authored-by: Maxim Palenov <maxim.palenov@elastic.co>
Co-authored-by: Christos Nasikas <christos.nasikas@elastic.co>
Co-authored-by: Anton Dosov <anton.dosov@elastic.co>
2024-08-28 16:33:35 +02:00
Karen Grigoryan
f79b714fda
[Security Solution][DQD][Tech Debt] Dissolve index properties markdown (#191264)
addresses https://github.com/elastic/kibana/issues/190964

Fifth in the series of PRs to address general DQD tech debt

This one builds on previous 4 PRs

https://github.com/elastic/kibana/pull/190970
https://github.com/elastic/kibana/pull/190978
https://github.com/elastic/kibana/pull/191233
https://github.com/elastic/kibana/pull/191245

Gist of changes:

- split gigantic markdown helper file and colocate the parts where they
belong
- dedupe translations
- cleanup dead code
2024-08-28 07:25:49 -05:00
Walter Rafelsberger
3c2ce3c839
[ML] AIOps: Adds log rate analysis to alert details page contextual insight. (#187690)
## Summary

Part of #178501.

This adds log rate analysis results to the prompt used for contextual
insights on alert details pages:

<img width="1149" alt="image"
src="https://github.com/user-attachments/assets/80b0f8e6-1ea1-4dbf-86ff-82c2ef175aa6">

<img width="1129" alt="image"
src="https://github.com/user-attachments/assets/a538cc3c-6f13-43e4-ad7d-8a93a779d349">


### Checklist

- [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
- [x] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2024-08-28 13:37:15 +02:00
Dario Gieselaar
ecec57ca52
[Obs utils] Add Observability utils package (#189712)
Adds a `@kbn/observability-utils` package.

```md
# @kbn/observability-utils

This package contains utilities for Observability plugins. It's a separate package
to get out of dependency hell. You can put anything in here that is stateless and
has no dependency on other plugins (either directly or via other packages).

The utility functions should be used via direct imports to minimize impact on
bundle size and limit the risk on importing browser code to the server and vice versa.
```

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2024-08-28 06:03:25 -05:00
Ash
74ba0b4f54
[SecuritySolution][Endpoint][Response Actions] Remove scan feature flag and branch logic. (#190601) 2024-08-28 11:54:36 +02:00
Karen Grigoryan
7f22ca5cf3
[Security Solution][DQD][Tech Debt] Refactor lower level helpers (#191245)
addresses https://github.com/elastic/kibana/issues/190964

Fourth in the series of PRs to address general DQD tech debt

This one builds on previous 3 PRs

https://github.com/elastic/kibana/pull/190970
https://github.com/elastic/kibana/pull/190978
https://github.com/elastic/kibana/pull/191233

Gist of changes:

split lower level helpers into series of utils/* files
each utils/ file is named after common behavior it export or works with.
cleanup dead code
2024-08-28 10:12:08 +02:00
Eyo O. Eyo
fd312e30db
Extract Kibana Privilege Feature table into package (#189871)
## Summary

This PR extracts the kibana privilege component into a package, to
support the work that's been done to integrate role privilege selection
within the newly improved spaces administration app, and is the last in
the series of PR to make this possible. Without this undertaken we would
be creating cyclic dependency between the security and spaces plugin,
the image below provides a visual representation on how this PR resolves
the aforementioned issue;


![image](https://github.com/user-attachments/assets/3de515a4-3f8b-4708-99af-d175d5bab282)[^legend]

[^legend]: item marked in blue is the package created in this PR.

This particular component, alongside the components that it's composed
of will now be housed in `@kbn/security-ui-components` (P.S. I'm not too
entirely sure about the naming, suggestions welcome).

<!--
### Checklist

Delete any items that are not applicable to this PR.

- [ ] 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)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [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
- [ ] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [ ] 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))
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] 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))
- [ ] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)


### Risk Matrix

Delete this section if it is not applicable to this PR.

Before closing this PR, invite QA, stakeholders, and other developers to
identify risks that should be tested prior to the change/feature
release.

When forming the risk matrix, consider some of the following examples
and how they may potentially impact the change:

| Risk | Probability | Severity | Mitigation/Notes |

|---------------------------|-------------|----------|-------------------------|
| Multiple Spaces&mdash;unexpected behavior in non-default Kibana Space.
| Low | High | Integration tests will verify that all features are still
supported in non-default Kibana Space and when user switches between
spaces. |
| Multiple nodes&mdash;Elasticsearch polling might have race conditions
when multiple Kibana nodes are polling for the same tasks. | High | Low
| Tasks are idempotent, so executing them multiple times will not result
in logical error, but will degrade performance. To test for this case we
add plenty of unit tests around this logic and document manual testing
procedure. |
| Code should gracefully handle cases when feature X or plugin Y are
disabled. | Medium | High | Unit tests will verify that any feature flag
or plugin combination still results in our service operational. |
| [See more potential risk
examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) |


### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
-->

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2024-08-27 16:17:08 +02:00
Eyo O. Eyo
90f2eb3a08
Expose privilege API client to spaces (#189819)
## Summary

Expose privilege API client to be injected into the spaces app, to
facilitate new spaces UX

<!--
### Checklist

Delete any items that are not applicable to this PR.

- [ ] 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)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [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
- [ ] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [ ] 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))
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] 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))
- [ ] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)


### Risk Matrix

Delete this section if it is not applicable to this PR.

Before closing this PR, invite QA, stakeholders, and other developers to
identify risks that should be tested prior to the change/feature
release.

When forming the risk matrix, consider some of the following examples
and how they may potentially impact the change:

| Risk | Probability | Severity | Mitigation/Notes |

|---------------------------|-------------|----------|-------------------------|
| Multiple Spaces&mdash;unexpected behavior in non-default Kibana Space.
| Low | High | Integration tests will verify that all features are still
supported in non-default Kibana Space and when user switches between
spaces. |
| Multiple nodes&mdash;Elasticsearch polling might have race conditions
when multiple Kibana nodes are polling for the same tasks. | High | Low
| Tasks are idempotent, so executing them multiple times will not result
in logical error, but will degrade performance. To test for this case we
add plenty of unit tests around this logic and document manual testing
procedure. |
| Code should gracefully handle cases when feature X or plugin Y are
disabled. | Medium | High | Unit tests will verify that any feature flag
or plugin combination still results in our service operational. |
| [See more potential risk
examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) |


### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
-->

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2024-08-27 15:56:04 +02:00
Jatin Kathuria
9293bc1917
[Security Solution] One Discover - Enable Security Solution Expandable Flyout in One Discover entities (#189633)
>[!Note]
> This Change is only applicable to Serverless Security Solution as of
now. In follow-up PRs, support will be added to ESS as well based
data-sources such as index or intergrations.
## Summary

Resolves https://github.com/elastic/kibana/issues/189151

This PR is foundation for the work described in
https://github.com/elastic/kibana/issues/186783. This just enables
expandable flyout for entity details, which is currently only used in
security solution, in discover as well.

As a part of **One Discover** work, we need to make sure that cell
rendering in Discover should behave exactly like it does in security
solution.

To enable this, a new `shared-browser` package
`@kbn/security-solution-common` in `x-pack/packages/security-solution`
has been created which can used to share components between `security
solution` and `discover`. Below is the usage pattern

```mermaid
flowchart TD
    disc-utils[@kbn/discover-utils] --> sscommon
    sscommon[@kbn/security-solution-common] --> ssplugin[security_solution]
    sscommon[@kbn/security-solution-common] --> discover[discover]
    disc-utils[@kbn/discover-utils] --> discover
```


## Desk Testing Guide.

1. Enable Security profile in serverless by adding below to `kibana.yml`

```yaml
discover.experimental.enabledProfiles: ['security-root-profile']
```

2. Load Some data

4. Navigate to discover and add `host.name` as one of the column.

5. Should open an expandable flyout as shown below.


https://github.com/user-attachments/assets/92b84c89-8769-45dd-bf7e-a9fe527fdcf0

## Code Review Guide

Most of the changes in the PR are code-organization. There are NO
changes in security solution but only the changes to import statements.

You can focus regarding the changes in below packages:

- x-pack/packages/security-solution/common
- packages/kbn-discover-utils
- packages/kbn-expandable-flyout

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2024-08-27 10:39:12 +02:00
Rickyanto Ang
6d3721a493
[Cloud Security] Misconfiguration preview & Refactor CSP Plugin to include new package PHASE 2 (#190933)
## Summary

The previous https://github.com/elastic/kibana/pull/190105 was way too
big and made it hard to review without missing any bugs or potential
bugs, Thus we decided we are going to make series of smaller PR to make
things more manageable

We will be splitting it into 4 PR
Phase 1: Creating empty packages for csp and csp-common
Phase 2: Move Types from CSP plugin to the Package + Deleting duplicates
in the CSP plugin where possible
Phase 3: Move Functions, Utils or Helpers, Hooks to Package
Phase 4: Misconfiguration Preview feature (with Cypress test and other
required test)

This is **Phase 2** of the Process

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2024-08-27 00:43:16 -07:00
Karen Grigoryan
ad360403bc
[Security Solution][DQD][Tech Debt] Refactor top level helpers (#191233)
addresses https://github.com/elastic/kibana/issues/190964

Third in the series of PRs to address general DQD tech debt

This one builds on previous 2 PRs 

https://github.com/elastic/kibana/pull/190970
https://github.com/elastic/kibana/pull/190978 

Gist of changes:

- split top level helpers into series of utils/* files
- each utils/ file is named after common behavior it export or works
with.
- cleanup dead code
2024-08-26 09:12:33 -05:00
Karen Grigoryan
dd18bc7c4d
[Security Solution][DQD][Tech Debt] Colocate components (#190978)
addresses https://github.com/elastic/kibana/issues/190964

Second in the series of PRs to address general DQD tech debt. Currently
this PR build on the work of
https://github.com/elastic/kibana/pull/190970.

So this PR restructures components to colocate component throughout the
hierarchy.

So instead of:

```bash
root/
  component1/
  childOfComponent1/
  grandChildOfComponent1/
  component2/
  use_hook_used_for_1/
  use_hook_used_for_2/
```

we use:

```bash
root/
  component1/
    hooks/
      use_hook_used_for_1/
    childOfComponent1/
      grandChildOfComponent1/
  component2/
    hooks/
      use_hook_used_for_2/
```

PROs of such scaffold:
- complete and clear hierarchical visibility into component structure of
the entire DQD codebase
- ability to easily introduce and integrate a new change and calculate
its impact on the tree of components
- ability to easily remove colocated functionality without having to
scout through the convoluted DQD code
- clear understanding of where shared code should live as opposed to
know when its shoved into top level by default with other non shared
code
- since nesting too deep has an import name readability tax it forces us
to think about not splitting our components into too many small parts
but rather keep it balanced, as opposed to now where flat structure
incentivizes free and cheap fragmentation as seen with component like
<body />.

CONS:

- import names have too many `../../../../../../../../../`. It is
fixable by ts paths/webpack aliases, but on the other hand especially if
there are many of those it's an indication of potential architectural
smell, that needs to be addressed (which is a PRO).

Imho, overall visibility trumps any cons and facilitates greater ease of
adding new and changing existing functionality with more confidence.

## Before

![image](https://github.com/user-attachments/assets/89062883-c40a-410d-af43-8dbe3e712475)

## After

![image](https://github.com/user-attachments/assets/83e33a85-cf3e-4cb1-a56d-c7f4f27a1f37)
2024-08-26 14:28:20 +02:00
Eyo O. Eyo
44fafb88d5
Extract authorization logic and it's peripherals into packages (#190028)
## Summary

This PR is a precursor to https://github.com/elastic/kibana/pull/189871,
as part of the spaces improvement initiative there's a need to be able
to share the user privilege assignment component between the roles
experience and the new spaces experience to prevent duplication of
business logic and cohesiveness in the privilege assignment experience.

The aforementioned PR extracts the required component into it's own
package so it might be consumed as needed, this PR is particularly
concerned with extracting business logic said UI component depends on
that exists still within the security plugin. For context; the security
plugin already depends on the spaces plugin, so having the spaces plugin
in turn statically depend on the security plugin creates a cyclic
dependency. That being said to complement the eventual state of said
component so it might be imported elsewhere outside of the security
plugin there's a need to extract further logic into standalone packages,
so that the spaces plugin can consume this plugin without the afore
mentioned cyclic dependency problem.


#### Visually; 

##### Problem;


![image](https://github.com/user-attachments/assets/6be85fb0-3ba3-4d5f-b614-3c0ff2cf7c69)

##### Proposal

![image](https://github.com/user-attachments/assets/5c4f423d-4ad4-48f4-b5bd-2ea0a99b196e)[^legend]

[^legend]: items marked in blue are the packages created in this PR,
whilst the entire diagram is the proposed future state

<!--### Checklist

Delete any items that are not applicable to this PR.

- [ ] 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)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [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
- [ ] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [ ] 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))
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] 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))
- [ ] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)


### Risk Matrix

Delete this section if it is not applicable to this PR.

Before closing this PR, invite QA, stakeholders, and other developers to
identify risks that should be tested prior to the change/feature
release.

When forming the risk matrix, consider some of the following examples
and how they may potentially impact the change:

| Risk | Probability | Severity | Mitigation/Notes |

|---------------------------|-------------|----------|-------------------------|
| Multiple Spaces&mdash;unexpected behavior in non-default Kibana Space.
| Low | High | Integration tests will verify that all features are still
supported in non-default Kibana Space and when user switches between
spaces. |
| Multiple nodes&mdash;Elasticsearch polling might have race conditions
when multiple Kibana nodes are polling for the same tasks. | High | Low
| Tasks are idempotent, so executing them multiple times will not result
in logical error, but will degrade performance. To test for this case we
add plenty of unit tests around this logic and document manual testing
procedure. |
| Code should gracefully handle cases when feature X or plugin Y are
disabled. | Medium | High | Unit tests will verify that any feature flag
or plugin combination still results in our service operational. |
| [See more potential risk
examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) |


### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
-->

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2024-08-22 15:44:54 +02:00
Steph Milovic
730f8eae87
[Security solution] Assistant package assistant/index.tsx cleanup (#190151) 2024-08-21 08:59:24 -06:00
Kurt
bcc46b60e9
Changing load/dump in source files (#190641)
## Summary

Updates usage of `js-yaml` `load` and `dump` to `safeLoad` and
`safeDump`, in preparation for a major version update of dependency,
where the default behavior will be that of the safe function variants.


## Note to reviewers
`safeDump` will throw if it encounters invalid types (e.g. `undefined`),
whereas the `dump` function will still write the file including the
invalid types. This may have an affect within your use cases - if
throwing is not acceptable or is unhandled. To avoid this the
`skipInvalid` option can be used (see
https://github.com/nodeca/js-yaml#dump-object---options-) - this will
write the file, stripping out any invalid types from the input.

Please consider this when reviewing the changes to your code. If the
`skipInvalid` option is needed, please add it, or let us know to make
the change.

---------

Co-authored-by: Sid <siddharthmantri1@gmail.com>
Co-authored-by: “jeramysoucy” <jeramy.soucy@elastic.co>
Co-authored-by: Elena Shostak <elena.shostak@elastic.co>
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Maxim Palenov <maxim.palenov@elastic.co>
2024-08-21 07:29:36 -04:00
Karen Grigoryan
51764fa076
[Secuity Solution][DQD] add list view and latest flyout (Phase 1) (#188468)
addresses #185881

## Data Quality Dashboard UI Overhaul (Phase 1)

This PR introduces UI changes to the Data Quality Dashboard, focusing on
improving user experience and improving on existing data quality check
process.

## Notable changes:

- Update List View UI
- Move in-row check expansion into a Flyout
- Remove summary tab from index check 
- Update index check UI
- Add table action to trigger manual individual index check without
opening index check properties
- Add in-flyout button to trigger manual individual check
- Add additional index stats panel within flyout

## Notable technical changes:

- remove prop drilling of new and existing omnipresent props by unifying
them in a series of context providers at the top of DQ dashboard
- introduce TestDataQualityProviders separate from external
TestProviders (renamed to TestExternalProviders) in tests. Change
affected tests.
- introduce `useIndicesCheck` hook to unify logic of index checking to
be able to call index checking from anywhere within DQD code without
relying on flaky and complicated useEffect driven logic of state
updates.
- introduce `useIsMounted`, hook to resolve issues with react state
update leaks
- introduce throttled `useCurrentWindowWidth` to handle custom index
flyout sizing for different screens.
- cleanup and refactor whatever is directly related or affected by
aforementioned code/test changes (including traces of removal of summary
tab)
- add extensive behavioral unit tests

# UI Changes (Before / After)

## List View Layout made more spacious

![image](https://github.com/user-attachments/assets/8cc25285-9a7b-45d9-82f2-55bb7ad4680b)

## Check All Layout made more spacious

![image](https://github.com/user-attachments/assets/c254cfa9-92cf-4971-9737-9c85e253696e)

## Total Stats Rollup converted to badges

![image](https://github.com/user-attachments/assets/68831c84-274d-40d8-b9fa-813e169e8f1e)

## ILM Phase Filter repositioned

![image](https://github.com/user-attachments/assets/85227737-1217-48b9-82b9-dc2d6a24e58c)

## Pattern Title Section

- Rearranged into accordion trigger button. Initially open by default.
- IlmPhase badges and Pattern title are now  stacked horizontally.
- Index check result emoji converted to 'Pass' | 'Fail' badge
- Pattern stats text rearranged as badged text. Incompatible fields show
as red badges (when present), the rest - hollow.


![image](https://github.com/user-attachments/assets/ca3c6e3e-a7ed-4a49-a7a6-9ea4842ac2de)

## Latest Pattern Indices Check Table

- Added a new actions column with 2 actions (from left to right): 
- View details (replaces row expander functionality (and icon) and
instead opens the index check results in a flyout)
- Check now **(NEW)** (adds ability to inline check the index without
opening it.)
- Index check result emoji turned to 'Pass' | 'Fail' badge
- `IlmPhase`, `Size`, `Last Check` columns width is shrunk to give more
space for index name


![image](https://github.com/user-attachments/assets/d9c83d9b-de3a-4153-9ed7-a9823e62f67d)

## Flyout Header

- Added index name with result check badge as title
- Added last check time as subtitle
- Added Tabs section for Latest Check and History **(REMOVED in latest
revision)**


![image](https://github.com/user-attachments/assets/b66617de-2b59-44d5-908b-3fabb3f7087e)

## Flyout Stats Panel

- Added new index stats panel


![image](https://github.com/user-attachments/assets/f21974f5-72b5-4a38-90de-f2ff5b9d1fd0)

## Index Check Fields Tab

- Tabs converted to a button group
- Summary Tab is **REMOVED**
- All field count badges have hollow color, except for red color for
`incompatible fields` tab (when count > 0) and `ecs compliant fields`
tab (when `@timestamp` is missing)


![image](https://github.com/user-attachments/assets/e78218d4-237f-4ad1-95f3-0eb4d57356fa)

## Index Check Fields Callouts

- Callout header is removed (to avoid duplication with active tab name)
- Actions are converted into sticky footer (shows when scrolled sticky
to bottom, otherwise renders after the table)
- Same for every index check fields tab


![image](https://github.com/user-attachments/assets/d8a192e8-cdfd-4691-b862-91abdedcb9b8)

## Compare Table List Values

- List values in compare tables are now horizontally stacked instead of
vertical to save space (applies to all compare tables in each index
check fields tab)


![image](https://github.com/user-attachments/assets/7ef3341d-1be9-41e7-a789-15262fac6de6)

## Compare Table Columns

- `ECS description` field width increased at the expense of `field`
field, to make room for more readable description (applies respectively
to all compare tables within index check fields tabs)


![image](https://github.com/user-attachments/assets/b45235a9-cf3d-4b6d-b65a-eaadc577cf2f)

## Flyout footer

- Add `Check now` button, that checks currently open index again and
updates the results in place.


![image](https://github.com/user-attachments/assets/02b9a63d-6c0c-4eff-aeb6-452ae78f28ea)
2024-08-21 12:13:26 +02:00
Maryam Saeidi
51736afd24
Import zod from @kbn/zod and add an eslint rule (#190581)
Closes #187638

## Summary

In this [PR](https://github.com/elastic/kibana/pull/186190), we
introduced @kbn/zod package and an OAS convertor to automatically
generate Open API Specifications for the routes that use zod for their
validation. In this PR, we add an eslint rule to enforce importing from
@kbn/zod instead of zod directly.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2024-08-21 04:14:55 -05:00