[Security Solution] Detection rules bootstrap endpoint#189518
[Security Solution] Detection rules bootstrap endpoint#189518xcrzx merged 1 commit intoelastic:mainfrom xcrzx:bootstrap-endpoint
Conversation
|
buildkite test this |
|
buildkite test this |
|
Pinging @elastic/security-detections-response (Team:Detections and Resp) |
|
Pinging @elastic/security-solution (Team: SecuritySolution) |
|
Pinging @elastic/security-detection-rule-management (Team:Detection Rule Management) |
|
Pinging @elastic/fleet (Team:Fleet) |
|
Pinging @elastic/obs-ux-management-team (Team:obs-ux-management) |
There was a problem hiding this comment.
Why is this additional check needed? Would it otherwise be possible to get a prerelease version in serverless, somehow?
There was a problem hiding this comment.
Prerelease packages are considered unstable, so should not be installed in Serverless. There's some context in this PR: #170975 (comment)
It should still be possible to install a prerelease version of a package by calling the Fleet API directly, if needed.
There was a problem hiding this comment.
Is it not necessary here to check that Fleet is initialized?
There was a problem hiding this comment.
This is a good question. On the front end, we were waiting for Fleet initialization before installing packages. However, on the backend, similar code simply doesn't exist, and I'm not sure why. I cannot find any initialization attempts or awaiting of initialization completion in the Fleet API. However, they do have a setup endpoint that is called from Kibana. I'll try to figure out if we need to call it before installing our packages.
There was a problem hiding this comment.
What is this change about?
I am trying to understand if returning installation.package changes the rest of the flow since I only see this change related to our team 🤔
There was a problem hiding this comment.
Previously, the package information was returned directly. Now, it is under the package prop. Therefore, no changes in the logic at this line.
There was a problem hiding this comment.
I see, I think the confusing part for me was the installation.package type which is Installation.
I checked the installation type, and I saw that it is now EnsurePackageResult. We could rename the installation to avoid confusion (to something that matches the type name).
There was a problem hiding this comment.
Under the hood, this endpoint still uses this Fleet method right? Just trying to understand if there's any performance gain here: you explained that some stuff that Fleet does on their side -like checking references- is not necessary for installing our pacakge. But I guess that's an improvement not for this PR, but when we get content-only packages?
There was a problem hiding this comment.
Nothing changes regarding the package installation method, that's right. We will implement optimizations in package installation separately. The only performance gain in this PR is that we do not invalidate prebuilt rules when the package is already installed.
Previously:
Fetch rules initially -> Upgrade rules package -(always)-> Re-fetch rules
Now:
Fetch rules initially -> Upgrade rules package -(only if there's a new package version)-> Re-fetch rules
This will result in fewer redundant API requests from Kibana.
jpdjere
left a comment
There was a problem hiding this comment.
Thanks for the explanations, and checking about Fleet initialisation 👍 ✅
💚 Build Succeeded
Metrics [docs]Module Count
Public APIs missing comments
Async chunks
Public APIs missing exports
History
To update your PR or re-run it, just comment with: cc @xcrzx |
flash1293
left a comment
There was a problem hiding this comment.
Onboarding changes LGTM
PhilippeOberti
left a comment
There was a problem hiding this comment.
LGTM for the Threat Hunting Investigations team
Resolves: #187647
Summary
Added a new API endpoint
POST /internal/detection_engine/prebuilt_rules/_bootstrap. This endpoint is responsible for installing the necessary packages for prebuilt detection rules to function properly. This allows us to avoid calling Fleet directly from FE and helps encapsulate complex logic of the package version selection in a single place on the backend.Currently, it installs or upgrades (if already installed) two packages:
endpointandsecurity_detection_engine.The response looks like this:
We call this endpoint from Kibana every time a user lands on any security solution page. The endpoint checks if the required packages are missing or if a newer version is available. If so, the newer version is installed, and the package status will be
installedin the response. If all packages are up-to-date, the package status will bealready_installedin the response. This allows us to invalidate prebuilt rule endpoints more efficiently and avoid sending extra requests from Kibana:The performance gain is that we do not invalidate prebuilt rules when the package is already installed.
Previously:
Fetch rules initially -> Upgrade rules package -(always)-> Re-fetch rulesNow:
Fetch rules initially -> Upgrade rules package -(only if there's a new package version)-> Re-fetch rulesThis will result in fewer redundant API requests from Kibana.