-
Notifications
You must be signed in to change notification settings - Fork 282
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
Add support for DLS Term Lookup Queries #1541
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks a lot for this PR!
i only gave this a cursory glance (i do not have the necessary understanding of the code for anything more + i'm theoretically on vacation).
mainly i did nit-pickings in two areas:
- formatting (i raised add .editorconfig #1547 to streamline this - i'm a big fan of using tools to avoid even having to talk about these topics 🙂)
- atomic commits (you mentioned two things also in the PR description which were unrelated)
furthermore: this is a huge commit, yet the commit-msg has one single line. but at the end, the commit-msg will be the only thing which'll survive (the commit history might well live longer than the github repo, due to renamings, moves, etc.). i'm a (very) big proponent of proper commit messages which explain all relevant things. some commit messages can be short, but with commits as complex as this one here a one-liner isn't cutting it. at the very least the description which you've now only added in the PR description should be (properly formatted!) in the commit message. and maybe this'll also show that the commit should be split further up (if that's possible, they should be atomic - but that also means that each should be consistent in itself) so that the necessary descriptions can be added to individual commits, making things clearer.
src/main/java/org/opensearch/security/configuration/DlsFilterLevelActionHandler.java
Outdated
Show resolved
Hide resolved
src/test/java/org/opensearch/security/dlic/dlsfls/DlsTermLookupQueryTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/opensearch/security/test/AbstractSecurityUnitTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/opensearch/security/dlic/dlsfls/DlsTermLookupQueryTest.java
Outdated
Show resolved
Hide resolved
Thanks @jochenkressin! In addition to addressing the comments above, this test seems to be failing (and based on the name could be related to these changes) |
src/main/java/org/opensearch/security/privileges/DocumentWhitelist.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/security/securityconf/ConfigModelV7.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/security/securityconf/ConfigModelV7.java
Outdated
Show resolved
Hide resolved
src/test/java/org/opensearch/security/dlic/dlsfls/AbstractDlsFlsTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/opensearch/security/dlic/dlsfls/DlsTermsLookupAsserts.java
Show resolved
Hide resolved
src/test/java/org/opensearch/security/dlic/dlsfls/DlsTermLookupQueryTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/opensearch/security/dlic/dlsfls/DlsTermLookupQueryTest.java
Show resolved
Hide resolved
src/test/java/org/opensearch/security/dlic/dlsfls/DlsTermLookupQueryTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/opensearch/security/dlic/dlsfls/AbstractDlsFlsTest.java
Show resolved
Hide resolved
src/main/java/org/opensearch/security/transport/SecurityInterceptor.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know there is some follow up, but I don't have any outstanding feedback. Thank you for this contribution!
Codecov Report
@@ Coverage Diff @@
## main #1541 +/- ##
============================================
- Coverage 63.68% 62.88% -0.80%
- Complexity 3165 3259 +94
============================================
Files 249 253 +4
Lines 17479 18127 +648
Branches 3096 3258 +162
============================================
+ Hits 11131 11399 +268
- Misses 4795 5079 +284
- Partials 1553 1649 +96
Continue to review full report at Codecov.
|
Please resolve the conflicts before merging.
@jochenkressin Could you resolve the merge conflicts so we can merge this PR? |
exclude replication requests from DLS/FLS, removed unused cluster action cleanup: removed sg references and outdated comments Make sure that SG_FILTER_LEVEL_DLS_DONE is reset after request finished handle masked field aggregations, reactivate buckeg merging Signed-off-by: Jochen Kressin <[email protected]>
Signed-off-by: Jochen Kressin <[email protected]>
Signed-off-by: Jochen Kressin <[email protected]>
Signed-off-by: Jochen Kressin <[email protected]>
@peternied I rebased to main |
LGTM! |
src/main/java/org/opensearch/security/configuration/DlsQueryParser.java
Outdated
Show resolved
Hide resolved
Sorry, forgot to post the comments on Log4j.
src/main/java/org/opensearch/security/configuration/DlsFilterLevelActionHandler.java
Outdated
Show resolved
Hide resolved
src/test/java/org/opensearch/security/dlic/dlsfls/AbstractDlsFlsTest.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Jochen Kressin <[email protected]>
@cliu123 @peternied I removed the references to log4j from the PR |
The backport to
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-1.3 1.3
# Navigate to the new working tree
cd .worktrees/backport-1.3
# Create a new branch
git switch --create backport/backport-1541-to-1.3
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 920701e236680b83e8aa25ef5d027884d3cf4768
# Push it to GitHub
git push --set-upstream origin backport/backport-1541-to-1.3
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-1.3 Then, create a pull request where the |
Signed-off-by: Jochen Kressin <[email protected]>
…1541) Signed-off-by: Craig Perkins <[email protected]>
Signed-off-by: Jochen Kressin [email protected]
opensearch-security pull request intake form
This PR adds support for Term Lookup Queries (TLQ) in Document-level security. It introduces two different modes for executing DLS filters which can either be set in opensearch.yml or are chosen automatically by Opensearch Security.
Lucene-level DLS
This mode implements DLS by modifying Lucene queries and data structures directly. This is the most efficient mode but does not allow certain advanced constructs in DLS queries, including TLQ. This is how DLS works currently.
Filter-level DLS
With this mode, DLS is applied by modifying queries as received by OpenSearch. This allows the use of term lookup queries in DLS queries but limits the set of operations that can be used to retrieve data from the protected index to
get
,search
,mget
,msearch
. Also, the use of Cross Cluster Searches is limited in this mode.By default, OpenSearch Security will detect if a DLS query contains a TLQ or not, and chooses the appropriate mode automatically at runtime. The mode can also be set explicitly in opensearch.yml:
plugins.security.dls.mode: <lucene-level | filter-level | adaptive>
Enhancement / New feature
#1508
As described above, this PR introduces two different approaches to executing DLS queries.
TLQ in DLS queries can only be supported if the query is executed on filter level.
If a DLS query contains a TLQ, an exception is thrown. Now a DLS query can also contain a TLQ. Per default, Opensearch Security detects a TLQ and sets the corresponding mode automatically.
Executed existing tests and added new tests for TLQ (DlsTermLookupQueryTest).
If this PR is accepted the documentation needs to be updated accordingly.
No.
Additional notes:
By making a contribution to this project, I certify that:
(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or
(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or
(c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.
(d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.
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.