-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[SIEM] Final Shimming/Prep for Server NP Migration #56814
Commits on Feb 10, 2020
-
Route all our server setup through the plugin
Next we'll be trimming down ServerFacade to the final few dependencies, and using our plugin dependencies for the rest.
Configuration menu - View commit details
-
Copy full SHA for 38dbce7 - Browse repository at this point
Copy the full SHA 38dbce7View commit details -
Clean up server plugin exports
For now, let's try to simplify our typings by exporting our plugin's dependencies from the plugin itself, since we know it already knows about them.
Configuration menu - View commit details
-
Copy full SHA for b8a7000 - Browse repository at this point
Copy the full SHA b8a7000View commit details -
Move DE Routes to to conventional location
I'm throwing the alerting registration in the plugin for now, too.
Configuration menu - View commit details
-
Copy full SHA for 3d23690 - Browse repository at this point
Copy the full SHA 3d23690View commit details -
Now that we've audited our use of request objects, we can switch to the more friendly LegacyRequest that all our utilities are expecting. LegacyRequest doesn't have plugins, either, so our only remaining errant usage is retrieving clients from it, which we call out explicitly.
Configuration menu - View commit details
-
Copy full SHA for 2e284c5 - Browse repository at this point
Copy the full SHA 2e284c5View commit details -
This just threw an error on startup, so I'm fixing all of them to be safe.
Configuration menu - View commit details
-
Copy full SHA for 7a35eac - Browse repository at this point
Copy the full SHA 7a35eacView commit details -
Fix types of our GraphQL requests
These come through as new KibanaRequests and not as the LegacyRequest that I had incorrectly typed them as. I'm only caring about the `body` property right now, since that's all we really deal with, and in testing it was all that was populated in our actual requests, too.
Configuration menu - View commit details
-
Copy full SHA for 5360a87 - Browse repository at this point
Copy the full SHA 5360a87View commit details -
Initialize our routes with SetupServices
We're using the legacy version for now, but ServerFacade will be gone by the end of the migration.
Configuration menu - View commit details
-
Copy full SHA for e41d618 - Browse repository at this point
Copy the full SHA e41d618View commit details -
Swap legacy spaces plugin for NP
This changes the signature of getIndex, which is used in quite a few places. We'll see how bad that looks in the next commit.
Configuration menu - View commit details
-
Copy full SHA for faf8f77 - Browse repository at this point
Copy the full SHA faf8f77View commit details -
We're already ignoring another portion of the platform shim due to it being incompatibly typed, so we might as well remove this.
Configuration menu - View commit details
-
Copy full SHA for 9418447 - Browse repository at this point
Copy the full SHA 9418447View commit details -
WIP: Converting our DE routes to use consolidated services
This contains our legacy stuff for now. Eventually, it will only be our NP services. This breaks a few tests due to the way createMockServer works, but I'll clean that up momentarily.
Configuration menu - View commit details
-
Copy full SHA for 80c5826 - Browse repository at this point
Copy the full SHA 80c5826View commit details -
Fix DE routing tests following refactor
The createMockServer helper does a few things differently: * returns mocked LegacyServices that can be passed to our route factories * does not return a server object as we don't need it, except for: * returns an inject function that we can use to execute a request We're casting our services because we're only mocking a subset of what LegacySetupServices entails. Mainly, this allows me to continue moving things off of ServerFacade without significant refactoring of tests.
Configuration menu - View commit details
-
Copy full SHA for b0a7f93 - Browse repository at this point
Copy the full SHA b0a7f93View commit details -
Fix incompatible request types
Unfortunately, LegacyRequest does not allow a request's `query` values to be anything other than a string or string[]. However, in practice they can (and are) objects, booleans, etc. Our request types (e.g. QueryRequest) are correct, but because service functions are LegacyRequest's implementation of `query`, we need to cast them lest a type error occur. For now, the easiest solution is to do this in the request handler: intersecting with our RequestFacade (LegacyRequest) allows us to both a) pluck our query params off the request and b) pass the request to NP services.
Configuration menu - View commit details
-
Copy full SHA for aa7ae34 - Browse repository at this point
Copy the full SHA aa7ae34View commit details -
Move our use of encryptedSavedObjects to NP
We're just retrieving a boolean from it right now, which is also guarded against the plugin being unavailable. If this usage becomes more widespread, we'll make this available at a higher level, probably in redux.
Configuration menu - View commit details
-
Copy full SHA for b54235d - Browse repository at this point
Copy the full SHA b54235dView commit details -
* Simplifies our generic type to accept two arguments: params and the return value * Options is fixed and we were never specifying anything meaningful there * Updates all DE cluster calls to use callWithRequestFactory
Configuration menu - View commit details
-
Copy full SHA for 3742670 - Browse repository at this point
Copy the full SHA 3742670View commit details -
Update DE mocks with NP elasticsearch
* createMockServer now returns the callCluster mock, so that you can easily mock a client response without needing to know the details of how we define that function
Configuration menu - View commit details
-
Copy full SHA for 8ccaf4b - Browse repository at this point
Copy the full SHA 8ccaf4bView commit details -
Remove savedObjects dependency from our legacy dependencies
This was added during a refactor, but we were never actually using this code. We always retrieve the client from the request via getSavedObjectsClient. I think that the NP client has a slightly different interface, so we're going to create a helper to retrieve it from the request, same as we do with the elastic client. In the future, both of these will be available on the request context, and we can remove the helpers entirely.
Configuration menu - View commit details
-
Copy full SHA for 98d56b8 - Browse repository at this point
Copy the full SHA 98d56b8View commit details -
WIP: Convert services to stateful object
In trying to migrate over the savedObjectsClient, I realized that it is not available during setup in the same way that the ES client is. Since our routes need pieces from both setup and start phases, I've added a Services class to accumulate/transform these services and expose scoped clients when given a legacy request. In New Platform, these clients will be available upon the request context and we should be able to remove getScopedServicesFactory for our routes. A subset of Services' functionality may still be useful, we'll see.
Configuration menu - View commit details
-
Copy full SHA for 00d089d - Browse repository at this point
Copy the full SHA 00d089dView commit details -
WIP: Converting routes to use Services factory
I decided that config shouldn't live in here, as this is only client-related stuff. Probably going to rename this ClientsService. Things are still very much broken.
Configuration menu - View commit details
-
Copy full SHA for 35bfc0b - Browse repository at this point
Copy the full SHA 35bfc0bView commit details -
WIP: Qualifying our Service to ClientsService
This gets us client-related services (ES, SavedObjects, Alerts), but it is independent of any configuration, which is gonna be another service.
Configuration menu - View commit details
-
Copy full SHA for 7e7cd30 - Browse repository at this point
Copy the full SHA 7e7cd30View commit details -
Fix types on getIndex function
This is a weird helper, I'm not really sure where it should go.
Configuration menu - View commit details
-
Copy full SHA for c97f190 - Browse repository at this point
Copy the full SHA c97f190View commit details -
Our ClientsService is a clients ... service
Return clients, as this is closer to what we'll get in the request context.
Configuration menu - View commit details
-
Copy full SHA for 101993f - Browse repository at this point
Copy the full SHA 101993fView commit details -
* Declare legacy types at top-level file * Don't re-export from the plugin solely for convenience, that's a slippery slope straight to circular dependencies * Remove RequestFacade as it was a facade for LegacyRequest * Rename ServerFacade/LegacySetupServices to just LegacyServices
Configuration menu - View commit details
-
Copy full SHA for f7bb2fb - Browse repository at this point
Copy the full SHA f7bb2fbView commit details -
Refactor mocks for new architecture
* Separates config, server, and client mocks, as they're now independent in our system, route-wise. * gets one test working, the rest will follow.
Configuration menu - View commit details
-
Copy full SHA for 2502698 - Browse repository at this point
Copy the full SHA 2502698View commit details -
* Adds mock for our new clients service * Greatly simplifies both server and mock configs * Renames factory method of client service
Configuration menu - View commit details
-
Copy full SHA for 36398bc - Browse repository at this point
Copy the full SHA 36398bcView commit details -
Loosen graphQL endpoint validations
These work fine in production, but it's graphQL so we don't really need the additional validation of these endpoints, and we weren't leveraging these types anywhere in Typescript land. Additionally, these restrictive validations prevent the initial introspection calls done by graphiQL to get schema information, and without schemae graphiql wasn't very helpful. This is a dev-only problem, but that's the audience of graphiql.
Configuration menu - View commit details
-
Copy full SHA for 1e6f106 - Browse repository at this point
Copy the full SHA 1e6f106View commit details -
Remove unused graphql endpoint
This was only registered in dev mode; I thought that it was needed by graphiql. However, after digging further I realized that graphiQL also only makes POST calls to our real graphQL endpoint, so this route is unnecessary.
Configuration menu - View commit details
-
Copy full SHA for bcff5e1 - Browse repository at this point
Copy the full SHA bcff5e1View commit details -
Reduce our dependence on PluginInitializerContext
After a little more introspection I realized our FrameworkAdapter doesn't need the kibana version. It was only used in order to make a dev request via (graphiql), but even that can be performed with a simpler xsrf header. This meant that we really only wanted to know whether we're in production or not, so instead we pass that simple boolean to the constructor.
Configuration menu - View commit details
-
Copy full SHA for f84a3d7 - Browse repository at this point
Copy the full SHA f84a3d7View commit details -
Configuration menu - View commit details
-
Copy full SHA for 930b89a - Browse repository at this point
Copy the full SHA 930b89aView commit details -
Uses the new routes interfaces, and our corresponding new mocks.
Configuration menu - View commit details
-
Copy full SHA for c3c67f1 - Browse repository at this point
Copy the full SHA c3c67f1View commit details -
Remove unnecessary null checks
Our savedObjectsClient is always going to be there.
Configuration menu - View commit details
-
Copy full SHA for 79171ff - Browse repository at this point
Copy the full SHA 79171ffView commit details -
Configuration menu - View commit details
-
Copy full SHA for 156dd77 - Browse repository at this point
Copy the full SHA 156dd77View commit details -
Remove unused savedObjects client
Turns out we were only destructuring this client for the null check.
Configuration menu - View commit details
-
Copy full SHA for e309001 - Browse repository at this point
Copy the full SHA e309001View commit details -
Handle case where spaces is disabled
We already null-coalesce properly in the clients service, but this property access was missed.
Configuration menu - View commit details
-
Copy full SHA for 0816e62 - Browse repository at this point
Copy the full SHA 0816e62View commit details -
Configuration menu - View commit details
-
Copy full SHA for dfd81cd - Browse repository at this point
Copy the full SHA dfd81cdView commit details -
Remove unnecessary casting of our alerts client mock
I think that this was the result of us importing the wrong AlertsClient type, or perhaps the types were out of sync. Regardless, they work now.
Configuration menu - View commit details
-
Copy full SHA for 11f3581 - Browse repository at this point
Copy the full SHA 11f3581View commit details -
Return the 'default' space even when spaces are disabled
This will allow users with spaces disabled to enable spaces without losing data. The tradeoff is that they may be surprised when signals don't exist within their configured xpack.siem.signalsIndex.
Configuration menu - View commit details
-
Copy full SHA for 0e98dae - Browse repository at this point
Copy the full SHA 0e98daeView commit details
Commits on Feb 12, 2020
-
Merge branch 'master' into final_backend_prep
Conflicts: x-pack/legacy/plugins/siem/server/kibana.index.ts x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/index/create_index_route.ts x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/index/delete_index_route.ts x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/add_prepackaged_rules_route.test.ts x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/add_prepackaged_rules_route.ts x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/create_rules_route.ts x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/delete_rules_bulk_route.ts x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/find_rules_route.ts x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/update_rules_bulk_route.ts x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/update_rules_route.ts x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/types.ts x-pack/legacy/plugins/siem/server/lib/detection_engine/types.ts
Configuration menu - View commit details
-
Copy full SHA for 8dc5622 - Browse repository at this point
Copy the full SHA 8dc5622View commit details
Commits on Feb 13, 2020
-
Merge branch 'master' into final_backend_prep
Conflicts: x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/utils.test.ts x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/utils.ts
Configuration menu - View commit details
-
Copy full SHA for 4e9f8d8 - Browse repository at this point
Copy the full SHA 4e9f8d8View commit details -
Account for spaces being disabled in ClientsService
* Updates types to reflect that spaces may be unavailable * Adds a test for getSpaceId's behavior when spaces are disabled
Configuration menu - View commit details
-
Copy full SHA for f53e6f7 - Browse repository at this point
Copy the full SHA f53e6f7View commit details -
Configuration menu - View commit details
-
Copy full SHA for cb5d729 - Browse repository at this point
Copy the full SHA cb5d729View commit details -
Configuration menu - View commit details
-
Copy full SHA for 668702b - Browse repository at this point
Copy the full SHA 668702bView commit details -
Fix false positives in query signals routes tests
* Refactors mock expectations so that they're actually evaluated; they can't go within a mockImplementation call as it's evaluated in the wrong scope. * Fixes duplicated test to use the proper assertions
Configuration menu - View commit details
-
Copy full SHA for 56fc3f5 - Browse repository at this point
Copy the full SHA 56fc3f5View commit details -
Configuration menu - View commit details
-
Copy full SHA for 7162528 - Browse repository at this point
Copy the full SHA 7162528View commit details