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

[Security Solution][Investigations][Timeline] - Update getExceptions to use parameters #145889

Merged

Conversation

michaelolo24
Copy link
Contributor

@michaelolo24 michaelolo24 commented Nov 21, 2022

Summary

Fixes: #136772

The issue was introduced by a couple of changes:

First: https://github.com/elastic/kibana/pull/136163/files#diff-02d33a1ed6679f7775dc01941ca21b085d7c008ecffe5e029f5967407a5e5b13L23 in 8.4.

The bug: A filter on the timeline UI relied on the exceptions_list field provided on _source to auto-generate a filter when investigating in timeline labelled Not Exceptions which would filter out the exceptions from the timeline. This PR resolves that issue by pulling the exceptions_list field from kibana.alert.rule.parameters.

Second: https://github.com/elastic/kibana/pull/133254/files#diff-0f69b69fd9cefef6ed04a048d7df86b7e385e816bdf17309212437dc3f69726cL74

The filter actually stopped being passed to timeline entirely because of the above change.

With the fixes in place:

Screen.Recording.2022-11-21.at.11.40.17.AM.mov

@michaelolo24 michaelolo24 added bug Fixes for quality problems that affect the customer experience backport release_note:fix Team:Threat Hunting:Investigations Security Solution Investigations Team v8.5.0 v8.6.0 labels Nov 21, 2022
@michaelolo24 michaelolo24 requested a review from a team as a code owner November 21, 2022 16:20
@michaelolo24 michaelolo24 force-pushed the fix-threshold-exceptions-filter branch from 5acba6f to e77189e Compare November 21, 2022 16:43
@michaelolo24 michaelolo24 self-assigned this Nov 21, 2022
@michaelolo24 michaelolo24 enabled auto-merge (squash) November 21, 2022 20:56
@michaelolo24
Copy link
Contributor Author

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

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 9.6MB 9.6MB +762.0B
Unknown metric groups

ESLint disabled in files

id before after diff
osquery 1 2 +1

ESLint disabled line counts

id before after diff
enterpriseSearch 19 21 +2
fleet 59 65 +6
osquery 109 115 +6
securitySolution 443 449 +6
total +20

Total ESLint disabled count

id before after diff
enterpriseSearch 20 22 +2
fleet 68 74 +6
osquery 110 117 +7
securitySolution 520 526 +6
total +21

History

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

cc @michaelolo24

Copy link
Contributor

@logeekal logeekal left a comment

Choose a reason for hiding this comment

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

commented about some nit-picks otherwise LGTM 🚀

exceptionsList = parametersObject?.exceptions_list ?? [];
}
} catch (error) {
// do nothing, just fail silently as parametersObject is initialized
Copy link
Contributor

Choose a reason for hiding this comment

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

parametersObject

Did you mean exceptionList?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea, I updated the code, but not the comment, will do a follow up cleanup PR for this. Thanks!

const exceptionsLists = (getField(ecsData, ALERT_RULE_EXCEPTIONS_LIST) ?? []).reduce(
(acc: ExceptionListId[], next: string) => {
const parsedList = JSON.parse(next);
// This pulls exceptions list information from `_source`
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for context here.

const detectionExceptionsLists = exceptionsList.reduce(
(acc: ExceptionListId[], next: string | object) => {
// parsed rule.parameters returns an object else use the default string representation
const parsedList = typeof next === 'string' ? JSON.parse(next) : next;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think that this line(JSON.parse) might result in exception when ......next === ''

Copy link
Contributor Author

@michaelolo24 michaelolo24 Nov 28, 2022

Choose a reason for hiding this comment

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

I'm not sure exceptions list will ever actually be ''. The existing code didn't have checks for this either, but it may be worth guarding against, will add a change for this as well, thanks!

@michaelolo24 michaelolo24 merged commit b32c8b9 into elastic:main Nov 28, 2022
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Nov 28, 2022
…to use parameters (elastic#145889)

## Summary

Fixes: elastic#136772

The issue was introduced by a couple of changes:

First:
https://github.com/elastic/kibana/pull/136163/files#diff-02d33a1ed6679f7775dc01941ca21b085d7c008ecffe5e029f5967407a5e5b13L23
in 8.4.

The bug: A filter on the timeline UI relied on the `exceptions_list`
field provided on `_source` to auto-generate a filter when investigating
in timeline labelled `Not Exceptions` which would filter out the
exceptions from the timeline. This PR resolves that issue by pulling the
`exceptions_list` field from `kibana.alert.rule.parameters`.

Second:
https://github.com/elastic/kibana/pull/133254/files#diff-0f69b69fd9cefef6ed04a048d7df86b7e385e816bdf17309212437dc3f69726cL74

The filter actually stopped being passed to timeline entirely because of
the above change.

With the fixes in place:

https://user-images.githubusercontent.com/17211684/203111748-7a0c2eb5-a46f-4f88-9d77-3628204625ac.mov
(cherry picked from commit b32c8b9)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Nov 28, 2022
…to use parameters (elastic#145889)

## Summary

Fixes: elastic#136772

The issue was introduced by a couple of changes:

First:
https://github.com/elastic/kibana/pull/136163/files#diff-02d33a1ed6679f7775dc01941ca21b085d7c008ecffe5e029f5967407a5e5b13L23
in 8.4.

The bug: A filter on the timeline UI relied on the `exceptions_list`
field provided on `_source` to auto-generate a filter when investigating
in timeline labelled `Not Exceptions` which would filter out the
exceptions from the timeline. This PR resolves that issue by pulling the
`exceptions_list` field from `kibana.alert.rule.parameters`.

Second:
https://github.com/elastic/kibana/pull/133254/files#diff-0f69b69fd9cefef6ed04a048d7df86b7e385e816bdf17309212437dc3f69726cL74

The filter actually stopped being passed to timeline entirely because of
the above change.

With the fixes in place:

https://user-images.githubusercontent.com/17211684/203111748-7a0c2eb5-a46f-4f88-9d77-3628204625ac.mov
(cherry picked from commit b32c8b9)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.5
8.6

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

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Nov 28, 2022
…tions to use parameters (#145889) (#146414)

# Backport

This will backport the following commits from `main` to `8.5`:
- [[Security Solution][Investigations][Timeline] - Update getExceptions
to use parameters
(#145889)](#145889)

<!--- Backport version: 8.9.7 -->

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

<!--BACKPORT [{"author":{"name":"Michael
Olorunnisola","email":"[email protected]"},"sourceCommit":{"committedDate":"2022-11-28T15:08:48Z","message":"[Security
Solution][Investigations][Timeline] - Update getExceptions to use
parameters (#145889)\n\n## Summary\r\n\r\nFixes:
https://github.com/elastic/kibana/issues/136772\r\n\r\nThe issue was
introduced by a couple of
changes:\r\n\r\nFirst:\r\nhttps://github.com//pull/136163/files#diff-02d33a1ed6679f7775dc01941ca21b085d7c008ecffe5e029f5967407a5e5b13L23\r\nin
8.4.\r\n\r\nThe bug: A filter on the timeline UI relied on the
`exceptions_list`\r\nfield provided on `_source` to auto-generate a
filter when investigating\r\nin timeline labelled `Not Exceptions` which
would filter out the\r\nexceptions from the timeline. This PR resolves
that issue by pulling the\r\n`exceptions_list` field from
`kibana.alert.rule.parameters`.\r\n\r\nSecond:\r\nhttps://github.com//pull/133254/files#diff-0f69b69fd9cefef6ed04a048d7df86b7e385e816bdf17309212437dc3f69726cL74\r\n\r\nThe
filter actually stopped being passed to timeline entirely because
of\r\nthe above change.\r\n\r\nWith the fixes in
place:\r\n\r\n\r\nhttps://user-images.githubusercontent.com/17211684/203111748-7a0c2eb5-a46f-4f88-9d77-3628204625ac.mov","sha":"b32c8b9df89188cdcb149bd1d9494d3f99999ad6","branchLabelMapping":{"^v8.7.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","backport","release_note:fix","Team:Threat
Hunting:Investigations","v8.5.0","v8.6.0","v8.7.0"],"number":145889,"url":"https://github.com/elastic/kibana/pull/145889","mergeCommit":{"message":"[Security
Solution][Investigations][Timeline] - Update getExceptions to use
parameters (#145889)\n\n## Summary\r\n\r\nFixes:
https://github.com/elastic/kibana/issues/136772\r\n\r\nThe issue was
introduced by a couple of
changes:\r\n\r\nFirst:\r\nhttps://github.com//pull/136163/files#diff-02d33a1ed6679f7775dc01941ca21b085d7c008ecffe5e029f5967407a5e5b13L23\r\nin
8.4.\r\n\r\nThe bug: A filter on the timeline UI relied on the
`exceptions_list`\r\nfield provided on `_source` to auto-generate a
filter when investigating\r\nin timeline labelled `Not Exceptions` which
would filter out the\r\nexceptions from the timeline. This PR resolves
that issue by pulling the\r\n`exceptions_list` field from
`kibana.alert.rule.parameters`.\r\n\r\nSecond:\r\nhttps://github.com//pull/133254/files#diff-0f69b69fd9cefef6ed04a048d7df86b7e385e816bdf17309212437dc3f69726cL74\r\n\r\nThe
filter actually stopped being passed to timeline entirely because
of\r\nthe above change.\r\n\r\nWith the fixes in
place:\r\n\r\n\r\nhttps://user-images.githubusercontent.com/17211684/203111748-7a0c2eb5-a46f-4f88-9d77-3628204625ac.mov","sha":"b32c8b9df89188cdcb149bd1d9494d3f99999ad6"}},"sourceBranch":"main","suggestedTargetBranches":["8.5","8.6"],"targetPullRequestStates":[{"branch":"8.5","label":"v8.5.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.6","label":"v8.6.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.7.0","labelRegex":"^v8.7.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/145889","number":145889,"mergeCommit":{"message":"[Security
Solution][Investigations][Timeline] - Update getExceptions to use
parameters (#145889)\n\n## Summary\r\n\r\nFixes:
https://github.com/elastic/kibana/issues/136772\r\n\r\nThe issue was
introduced by a couple of
changes:\r\n\r\nFirst:\r\nhttps://github.com//pull/136163/files#diff-02d33a1ed6679f7775dc01941ca21b085d7c008ecffe5e029f5967407a5e5b13L23\r\nin
8.4.\r\n\r\nThe bug: A filter on the timeline UI relied on the
`exceptions_list`\r\nfield provided on `_source` to auto-generate a
filter when investigating\r\nin timeline labelled `Not Exceptions` which
would filter out the\r\nexceptions from the timeline. This PR resolves
that issue by pulling the\r\n`exceptions_list` field from
`kibana.alert.rule.parameters`.\r\n\r\nSecond:\r\nhttps://github.com//pull/133254/files#diff-0f69b69fd9cefef6ed04a048d7df86b7e385e816bdf17309212437dc3f69726cL74\r\n\r\nThe
filter actually stopped being passed to timeline entirely because
of\r\nthe above change.\r\n\r\nWith the fixes in
place:\r\n\r\n\r\nhttps://user-images.githubusercontent.com/17211684/203111748-7a0c2eb5-a46f-4f88-9d77-3628204625ac.mov","sha":"b32c8b9df89188cdcb149bd1d9494d3f99999ad6"}}]}]
BACKPORT-->

Co-authored-by: Michael Olorunnisola <[email protected]>
kibanamachine added a commit that referenced this pull request Nov 28, 2022
…tions to use parameters (#145889) (#146415)

# Backport

This will backport the following commits from `main` to `8.6`:
- [[Security Solution][Investigations][Timeline] - Update getExceptions
to use parameters
(#145889)](#145889)

<!--- Backport version: 8.9.7 -->

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

<!--BACKPORT [{"author":{"name":"Michael
Olorunnisola","email":"[email protected]"},"sourceCommit":{"committedDate":"2022-11-28T15:08:48Z","message":"[Security
Solution][Investigations][Timeline] - Update getExceptions to use
parameters (#145889)\n\n## Summary\r\n\r\nFixes:
https://github.com/elastic/kibana/issues/136772\r\n\r\nThe issue was
introduced by a couple of
changes:\r\n\r\nFirst:\r\nhttps://github.com//pull/136163/files#diff-02d33a1ed6679f7775dc01941ca21b085d7c008ecffe5e029f5967407a5e5b13L23\r\nin
8.4.\r\n\r\nThe bug: A filter on the timeline UI relied on the
`exceptions_list`\r\nfield provided on `_source` to auto-generate a
filter when investigating\r\nin timeline labelled `Not Exceptions` which
would filter out the\r\nexceptions from the timeline. This PR resolves
that issue by pulling the\r\n`exceptions_list` field from
`kibana.alert.rule.parameters`.\r\n\r\nSecond:\r\nhttps://github.com//pull/133254/files#diff-0f69b69fd9cefef6ed04a048d7df86b7e385e816bdf17309212437dc3f69726cL74\r\n\r\nThe
filter actually stopped being passed to timeline entirely because
of\r\nthe above change.\r\n\r\nWith the fixes in
place:\r\n\r\n\r\nhttps://user-images.githubusercontent.com/17211684/203111748-7a0c2eb5-a46f-4f88-9d77-3628204625ac.mov","sha":"b32c8b9df89188cdcb149bd1d9494d3f99999ad6","branchLabelMapping":{"^v8.7.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","backport","release_note:fix","Team:Threat
Hunting:Investigations","v8.5.0","v8.6.0","v8.7.0"],"number":145889,"url":"https://github.com/elastic/kibana/pull/145889","mergeCommit":{"message":"[Security
Solution][Investigations][Timeline] - Update getExceptions to use
parameters (#145889)\n\n## Summary\r\n\r\nFixes:
https://github.com/elastic/kibana/issues/136772\r\n\r\nThe issue was
introduced by a couple of
changes:\r\n\r\nFirst:\r\nhttps://github.com//pull/136163/files#diff-02d33a1ed6679f7775dc01941ca21b085d7c008ecffe5e029f5967407a5e5b13L23\r\nin
8.4.\r\n\r\nThe bug: A filter on the timeline UI relied on the
`exceptions_list`\r\nfield provided on `_source` to auto-generate a
filter when investigating\r\nin timeline labelled `Not Exceptions` which
would filter out the\r\nexceptions from the timeline. This PR resolves
that issue by pulling the\r\n`exceptions_list` field from
`kibana.alert.rule.parameters`.\r\n\r\nSecond:\r\nhttps://github.com//pull/133254/files#diff-0f69b69fd9cefef6ed04a048d7df86b7e385e816bdf17309212437dc3f69726cL74\r\n\r\nThe
filter actually stopped being passed to timeline entirely because
of\r\nthe above change.\r\n\r\nWith the fixes in
place:\r\n\r\n\r\nhttps://user-images.githubusercontent.com/17211684/203111748-7a0c2eb5-a46f-4f88-9d77-3628204625ac.mov","sha":"b32c8b9df89188cdcb149bd1d9494d3f99999ad6"}},"sourceBranch":"main","suggestedTargetBranches":["8.5","8.6"],"targetPullRequestStates":[{"branch":"8.5","label":"v8.5.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.6","label":"v8.6.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.7.0","labelRegex":"^v8.7.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/145889","number":145889,"mergeCommit":{"message":"[Security
Solution][Investigations][Timeline] - Update getExceptions to use
parameters (#145889)\n\n## Summary\r\n\r\nFixes:
https://github.com/elastic/kibana/issues/136772\r\n\r\nThe issue was
introduced by a couple of
changes:\r\n\r\nFirst:\r\nhttps://github.com//pull/136163/files#diff-02d33a1ed6679f7775dc01941ca21b085d7c008ecffe5e029f5967407a5e5b13L23\r\nin
8.4.\r\n\r\nThe bug: A filter on the timeline UI relied on the
`exceptions_list`\r\nfield provided on `_source` to auto-generate a
filter when investigating\r\nin timeline labelled `Not Exceptions` which
would filter out the\r\nexceptions from the timeline. This PR resolves
that issue by pulling the\r\n`exceptions_list` field from
`kibana.alert.rule.parameters`.\r\n\r\nSecond:\r\nhttps://github.com//pull/133254/files#diff-0f69b69fd9cefef6ed04a048d7df86b7e385e816bdf17309212437dc3f69726cL74\r\n\r\nThe
filter actually stopped being passed to timeline entirely because
of\r\nthe above change.\r\n\r\nWith the fixes in
place:\r\n\r\n\r\nhttps://user-images.githubusercontent.com/17211684/203111748-7a0c2eb5-a46f-4f88-9d77-3628204625ac.mov","sha":"b32c8b9df89188cdcb149bd1d9494d3f99999ad6"}}]}]
BACKPORT-->

Co-authored-by: Michael Olorunnisola <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport bug Fixes for quality problems that affect the customer experience release_note:fix Team:Threat Hunting:Investigations Security Solution Investigations Team v8.5.0 v8.5.3 v8.6.0 v8.7.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Security Solution][Timeline] Threshold rule exceptions are no longer included when sending alerts to timeline
4 participants