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] Gracefully handle errors in detection rules install #83306

Merged
merged 2 commits into from
Nov 16, 2020

Conversation

pzl
Copy link
Member

@pzl pzl commented Nov 12, 2020

Summary

Gracefully handle errors that were getting missed.

fixes #83277

installPrepackagedRules returns an Array of promises (not a singular promise). Apparently, this does not sit well with Promise.all, and errors/exceptions in any member of that array are not appropriately caught, and result in an unhandled exception (no matter how many try/catches you wrap it in).

Instead, handing the Array right to Promise.all handles the errors just fine.

Also, typescript would not let me do:

await Promise.all([
    ...installPrepackagedRules(alertsClient, rulesToInstall, signalsIndex),
    installPrepackagedTimelines(maxTimelineImportExportSize, frameworkRequest, true),
])

because of argument type mismatches or something to that effect. Error looked like this: microsoft/TypeScript#35617

So it was pulled to the next line.

@pzl pzl added v8.0.0 release_note:skip Skip the PR/issue when compiling release notes Feature:Endpoint Elastic Endpoint feature Team:Defend Workflows “EDR Workflows” sub-team of Security Solution v7.11 labels Nov 12, 2020
@pzl pzl requested review from a team as code owners November 12, 2020 16:30
@elasticmachine
Copy link
Contributor

Pinging @elastic/endpoint-app-team (Feature:Endpoint)

@spalger spalger added v7.11.0 and removed v7.11 labels Nov 12, 2020
@spong spong requested a review from a team November 13, 2020 03:17
@pzl
Copy link
Member Author

pzl commented Nov 16, 2020

@elasticmachine merge upstream

@FrankHassanabad
Copy link
Contributor

A lot of different authors in this file which kind of is what is making a few of the odd bugs and behaviors showing up.

installPrepackagedRules

That already returns an array so the code adding yet another array within an array is a problem. Glad you didn't do a spread here as that would just pull apart all of the array which isn't what you want.

This code should work as is. I will approve it.

Copy link
Contributor

@FrankHassanabad FrankHassanabad left a comment

Choose a reason for hiding this comment

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

LGTM, this should work as it is laid out.

Side notes are we have a lot of authors and different ways of loading things at this point from one technique being auto-generating an index and then loading that with a require statement, and then some streams that are auto scanning directories and files on the system and loading from there.

It makes it a bit tricky to understand what is going on and validate the code is working as intended (has nothing to do with this PR though, this PR is 👍 ), just some general notes.

@FrankHassanabad FrankHassanabad added release_note:fix and removed release_note:skip Skip the PR/issue when compiling release notes labels Nov 16, 2020
@FrankHassanabad
Copy link
Contributor

@pzl , I changed the release not to be "fix" as this does fix a bug.

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

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

@pzl pzl merged commit b8b8806 into elastic:master Nov 16, 2020
pzl added a commit to pzl/kibana that referenced this pull request Nov 16, 2020
phillipb added a commit to phillipb/kibana that referenced this pull request Nov 19, 2020
…ode-details

* 'master' of github.com:elastic/kibana:
  Remove dependency of tests on strict SyntaxKind values (elastic#83440)
  [SecuritySolution] override timerange for prebuilt templates (elastic#82468)
  [Enterprise Search] Added a shouldShowActiveForSubroutes option (elastic#83338)
  [Lens] Make the dimension flyout panel stay close on outside click (elastic#83059)
  [Security Solution] Gracefully handle errors in detection rules install (elastic#83306)
  Fix advanced settings category sorting (elastic#83394)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Endpoint Elastic Endpoint feature release_note:fix Team:Defend Workflows “EDR Workflows” sub-team of Security Solution v7.11.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Security Solution] Kibana crash on adding endpoint integration
6 participants