[analytics engine] Execute analytics engine plan as a local transport action to provide ActionFilter authorization#21789
Conversation
PR Reviewer Guide 🔍(Review updated until commit ae0e73b)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to ae0e73b Explore these optional code suggestions:
Previous suggestionsSuggestions up to commit f653ac9
Suggestions up to commit a31a6b0
Suggestions up to commit d2296be
Suggestions up to commit 31474ea
Suggestions up to commit 106fe3a
|
387c737 to
106fe3a
Compare
PR Code Analyzer ❗AI-powered 'Code-Diff-Analyzer' found issues on commit 6892705.
The table above displays the top 10 most important findings. Pull Requests Author(s): Please update your Pull Request according to the report above. Repository Maintainer(s): You can Thanks. |
|
Persistent review updated to latest commit 106fe3a |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #21789 +/- ##
============================================
+ Coverage 73.46% 73.50% +0.03%
- Complexity 75205 75219 +14
============================================
Files 6023 6023
Lines 341475 341475
Branches 49141 49141
============================================
+ Hits 250878 251006 +128
+ Misses 70627 70526 -101
+ Partials 19970 19943 -27 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
106fe3a to
31474ea
Compare
|
Persistent review updated to latest commit 31474ea |
31474ea to
d2296be
Compare
|
Persistent review updated to latest commit d2296be |
|
Persistent review updated to latest commit a31a6b0 |
a31a6b0 to
f653ac9
Compare
|
Persistent review updated to latest commit f653ac9 |
|
Associated initial IT suite in SQL plugin: Currently still running these locally and working on having them run correctly in CI with all analytics plugin + security dependencies. |
cwperks
left a comment
There was a problem hiding this comment.
This PR LGTM! Looks like there's now a merge conflict that needs to be resolved. TY for fixing this @finnegancarroll !
f653ac9 to
ae0e73b
Compare
|
Persistent review updated to latest commit ae0e73b |
…spatch This change routes all analytics query execution through the existing AnalyticsQueryAction TransportAction via NodeClient.execute(), which triggers the ActionFilter chain (including SecurityFilter) before any planning or execution begins. Signed-off-by: Finn Carroll <carrofin@amazon.com>
ae0e73b to
6892705
Compare
Description
The analytics engine's query execution path (PPL, SQL) bypasses the security plugin's index-level privilege evaluation. The
FragmentExecutionRequeston the data node is executed withdispatchFragmentStreamingand never evaluated for index permissions by the security pluginSecurityFilter(wraps theActionFilter).SQL / PPL queries with analytics engine
In a typical SQL / PPL query authorization is handled at the node-to-node transport layer on the coordinator as the request is being dispatched to shards. The security plugin provides an ActionFilter which every TransportAction child holds a reference to, and executes on new requests.
The overall flow for a regular DSL search query is then:
The path for an analytics engine SQL / PPL query avoids the
RequestFilterChainentirely. TheShardTaskRunneris responsible for dispatching aFragmentExecutionRequeston the transport layer.The
FragmentExecutionRequestfetches a new connection from the transport service, and directly executes the request itself. Skipping theTransportActionframework which typically holds and applies theActionFilter.DSL queries with analytics engine
DSL permissions are actually evaluated correctly already. This comes from how DSL is routed into the analytics plugin. DSL queries construct a regular
SearchRequestwhich is handled by theTransportSearchActionand are executed on the transport layer with the local node client as usual.Handling of DSL queries is done by a new
SearchActionFilterwhich is also injected into theRequestFilterChainand redirects theseSearchRequests to theDslExecuteAction.INSTANCEhandler instead of executing them as normal search requests. Since thisSearchActionFilterexecutes AFTER the security plugin ActionFilter (which has highest priority), privileges are evaluated correctly.POST /{index}/_search)POST /_plugins/_ppl)POST /_plugins/_sql)Proposed fix
These changes somewhat mimic the functionality of DSL queries for SQL and PPL by adding a pre-planning authorization check which passes a no-op
AnalyticsAuthRequestthrough theActionFilterto determine if permissions are valid for the equivalent set ofFragmentExecutionRequests.No actual request is executed on the transport layer, the
AnalyticsAuthRequestis passed through the fullActionFilterchain to invoke security plugin privilege evaluation, and proceeds with the analytics engine planning + query only if this probingAnalyticsAuthRequestis authorized for the same indices.Testing
These changes route all analytics engine query execution through the existing
AnalyticsQueryActionandTransportActionviaNodeClient.execute()duringDefaultPlanExecutor.execute(). This triggers theActionFilterchain (including SecurityFilter) before even planning begins.Test implementation is pending. Currently changes are validated with local single node testing.
Related Issues
N/A
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.