Fix parent-child query detection across classloaders - #6346
Draft
cwperks wants to merge 1 commit into
Draft
Conversation
Signed-off-by: Craig Perkins <craig5008@gmail.com>
Contributor
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6346 +/- ##
==========================================
- Coverage 75.39% 75.37% -0.02%
==========================================
Files 456 456
Lines 29924 29925 +1
Branches 4530 4531 +1
==========================================
- Hits 22560 22557 -3
- Misses 5265 5271 +6
+ Partials 2099 2097 -2
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Detect
has_parentandhas_childqueries by their registeredNamedWriteablenames instead of usinginstanceofagainst the concrete parent-join query builder classes.The Security plugin bundles
parent-join-client, while an installed OpenSearch distribution loads the parent-join module with a separate classloader. As a result, the query builder instance created by Core and the class referenced by Security have the same class name but different class identities, causing bothinstanceofchecks to return false.This could bypass the filter-level DLS guard for parent/child queries. In a locally installed distribution, the affected TLQ-DLS
has_parentrequest returned HTTP 200 before this change instead of the expected rejection. With this change, it returns HTTP 500 withUnable to handle filter level DLS for parent or child queries.The existing integration test did not expose this because it loads both plugins on the test JVM application classloader.
Changes
QueryBuilder#getWriteableName()with the registeredhas_parentandhas_childnames.QueryBuilderinstances to verify detection is based on the registered name rather than concrete class identity.Validation
./gradlew :test --tests 'org.opensearch.security.util.ParentChildrenQueryDetectorTest' -Pcrypto.standard=FIPS-140-3./gradlew :integrationTest --tests 'org.opensearch.security.ParentChildRelationTests.hasParentWithTlqDls' -Pcrypto.standard=FIPS-140-3./gradlew :precommit -Pcrypto.standard=FIPS-140-3has_parentrequest is rejected with the expected HTTP 500 response under the real separated classloader topology.The aggregate multi-project
precommitinvocation additionally encountered pre-existing forbidden-API findings forURL.openStream()in the sample-resource plugin; the scoped root:precommittask passes.