Skip to content

[Security Solution] Fix cloud logs exclusion#130069

Merged
stephmilovic merged 22 commits intoelastic:mainfrom
stephmilovic:cloud_logs_fix
May 11, 2022
Merged

[Security Solution] Fix cloud logs exclusion#130069
stephmilovic merged 22 commits intoelastic:mainfrom
stephmilovic:cloud_logs_fix

Conversation

@stephmilovic
Copy link
Copy Markdown
Contributor

@stephmilovic stephmilovic commented Apr 12, 2022

Summary

  1. The exclusion for elastic cloud logs needs to be at the end of the index pattern list. Moved the .sort() outside of the exclude. There are some other inconsistencies with exclude patterns that are being addressed by the ES team: Multi-target syntax bug with datastream backing indices and excluded targets elasticsearch#86019
  2. Added additional log excludes: .ds-logs-elastic_agent*, .ds-logs-system-* as proposed in an SDH
  3. Add support for exclude indices in the Advanced Settings index pattern as requested here: [Security Solution] [Sourcerer] Exclude patterns added to the securitySolution:defaultIndex should be applied to the default data view #130753
    exclude
  4. Move the Elastic cloud logs exclude from being appended on magically to the main Advanced Settings index pattern, giving control to the user

@stephmilovic stephmilovic added release_note:skip Skip the PR/issue when compiling release notes Team:Threat Hunting Security Solution Threat Hunting Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. auto-backport Deprecated - use backport:version if exact versions are needed Team:Threat Hunting:Explore v8.2.0 v8.3.0 labels Apr 12, 2022
@stephmilovic stephmilovic requested a review from a team as a code owner April 12, 2022 23:24
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/security-threat-hunting (Team:Threat Hunting)

@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/security-solution (Team: SecuritySolution)

@stephmilovic stephmilovic marked this pull request as draft April 12, 2022 23:41
@MadameSheema
Copy link
Copy Markdown
Contributor

@elasticmachine merge upstream

@stephmilovic stephmilovic marked this pull request as ready for review April 28, 2022 21:36
@stephmilovic stephmilovic requested review from a team as code owners April 28, 2022 21:36
Copy link
Copy Markdown
Contributor

@andrew-goldstein andrew-goldstein left a comment

Choose a reason for hiding this comment

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

Thanks @stephmilovic for fixing 130753, and for ensuring exclude patterns are always applied at the end as a workaround for 86019! 🙏

In addition to the fix and workaround above, making the -*elastic-cloud-logs-* exclude pattern an explicit part of the securitySolution:defaultIndex (and removing the code that appended it automatically in some cases) makes it easier to reason about exclusions, and makes the Security Data View return consistent results when the data view is used in other parts of Kibana (outside of the security solution).

Release notes

DOCS team, please include this fix in the release notes, and communicate the following:

  • This PR adds the -*elastic-cloud-logs-* exclude pattern to the default securitySolution:defaultIndex setting (in Kibana advanced settings)
  • Elastic Cloud users who modified the default securitySolution:defaultIndex setting may need to manually add -*elastic-cloud-logs-* to the securitySolution:defaultIndex setting to exclude logs from Elastic Cloud that were automatically excluded prior to this fix
  • This PR includes a fix for 130753, which enables arbitrary exclude patterns to be added to the securitySolution:defaultIndex setting
  • This PR includes a workaround for 86019 by ensuring exclude patterns always appear at the end of the list of indexes

✅ Desk tested locally

LGTM 🚀

@andrew-goldstein andrew-goldstein added release_note:fix and removed release_note:skip Skip the PR/issue when compiling release notes labels May 9, 2022
@andrew-goldstein
Copy link
Copy Markdown
Contributor

CC @paulewing

@stephmilovic stephmilovic requested review from a team as code owners May 10, 2022 13:45
Copy link
Copy Markdown
Contributor

@madirey madirey left a comment

Choose a reason for hiding this comment

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

LGTM!

strict: false,
}) != null;

export const isAlertsOrRulesDetailsPage = (pathname: string): boolean =>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Was this just dead code?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes. sorry, should've left a comment

import { SelectedDataViewPayload } from './actions';
import { sourcererModel } from '../model';

export const sortWithExcludesAtEnd = (indices: string[]) => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: Can we add a quick unit test for the new helper?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

➕ 1

];

/** The comma-delimited list of Elasticsearch indices from which the SIEM app collects events, and the exclude index pattern */
export const DEFAULT_INDEX_PATTERN = [...INCLUDE_INDEX_PATTERN, ...EXCLUDE_ELASTIC_CLOUD_INDICES];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does the change mean the elastic cloud index will always be excluded (unless the user modifies the advanced settings) as opposed to before when it was just if the logs-* existed or something?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes

Copy link
Copy Markdown
Contributor

@yctercero yctercero left a comment

Choose a reason for hiding this comment

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

LGTM - one question left where just trying to better understand the behavior related to the cloud logs and what functionality is missed if they're always excluded (if that is the case).

Copy link
Copy Markdown
Member

@machadoum machadoum left a comment

Choose a reason for hiding this comment

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

security-threat-hunting-explore changes LGTM!

});

it('Should NOT exclude elastic cloud alias when selected patterns does NOT include "logs-*" as an alias', async () => {
it('Should put any excludes in the index pattern at the end of the pattern list, and sort both the includes and excludes', async () => {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Nit: Can we add a quick unit test for the new helper?

@yctercero @machadoum the sortWithExcludesAtEnd function is tested through this test. would you prefer i explicitly add a test in helpers.test.ts?

@stephmilovic
Copy link
Copy Markdown
Contributor Author

@elasticmachine merge upstream

@stephmilovic
Copy link
Copy Markdown
Contributor Author

@elasticmachine merge upstream

@kibana-ci
Copy link
Copy Markdown

💚 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 4.8MB 4.8MB -562.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
securitySolution 246.3KB 246.6KB +268.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@stephmilovic stephmilovic merged commit 6fc82ba into elastic:main May 11, 2022
@kibanamachine
Copy link
Copy Markdown
Contributor

💔 All backports failed

Status Branch Result
8.2 Backport failed because of merge conflicts

Manual backport

To create the backport manually run:

node scripts/backport --pr 130069

Questions ?

Please refer to the Backport tool documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-backport Deprecated - use backport:version if exact versions are needed release_note:fix Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Team:Threat Hunting Security Solution Threat Hunting Team v8.2.0 v8.2.1 v8.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants