fixed throw exception for DLS user attributes#5975
fixed throw exception for DLS user attributes#5975cwperks merged 6 commits intoopensearch-project:mainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5975 +/- ##
==========================================
- Coverage 73.81% 73.79% -0.02%
==========================================
Files 439 439
Lines 27087 27110 +23
Branches 4018 4023 +5
==========================================
+ Hits 19993 20007 +14
- Misses 5188 5195 +7
- Partials 1906 1908 +2
🚀 New features to boost your workflow:
|
|
Thank you for this! Mostly looks good to me. Can you review the CI failures? Mainly, you'd need to add an entry to CHANGELOG.md and run |
Hi @nibix I updated changelog. Can you review it please? Thank you. |
src/main/java/org/opensearch/security/privileges/dlsfls/DocumentPrivileges.java
Outdated
Show resolved
Hide resolved
|
Hi @cwperks I think the PR is ready for review. Thank you. |
|
@ThyTran1402 apologies for not being able to get comments to you yesterday. I will take another look shortly. |
src/test/java/org/opensearch/security/privileges/UserAttributesUnitTest.java
Outdated
Show resolved
Hide resolved
|
Changes LGTM. Thank you for the PR @ThyTran1402 ! I'll get another maintainer to take a look as well. |
|
@ThyTran1402 one other thing, can you run |
src/main/java/org/opensearch/security/privileges/dlsfls/DocumentPrivileges.java
Outdated
Show resolved
Hide resolved
|
@ThyTran1402 FYI I pushed a commit to fix a conflict in the changelog as another pr just merged. If you need to make a change, please pull before pushing. Hopefully no more changes needed though bc the PR lgtm. |
c559a22
Signed-off-by: Thy Tran <58045538+ThyTran1402@users.noreply.github.com>
Signed-off-by: Thy Tran <58045538+ThyTran1402@users.noreply.github.com>
Signed-off-by: Thy Tran <58045538+ThyTran1402@users.noreply.github.com>
Signed-off-by: Thy Tran <58045538+ThyTran1402@users.noreply.github.com>
Signed-off-by: Thy Tran <58045538+ThyTran1402@users.noreply.github.com>
c559a22 to
5a47c7b
Compare
Hi @cwperks I added unit test recently since I see it did not pass tests coverage 😢 . Thank you! |
Co-authored-by: Craig Perkins <craig5008@gmail.com> Signed-off-by: Thy Tran <58045538+ThyTran1402@users.noreply.github.com>
|
Are there anything that I need to do from my side to pass these tests? 😭 @cwperks |
|
@ThyTran1402 no worries, those CI checks can be flaky and pass on re-run. I think test coverage is more than sufficient already in this PR. |
Description
When a DLS query references a user attribute ${attr.jwt.array} that is not present in the authenticated user's JWT/custom attributes, UserAttributes.replaceProperties() leaves the placeholder in the query string. The guard in DocumentPrivileges.Dynamic.evaluate() correctly detects this and throws a PrivilegesEvaluationException, but the previous error message ("Invalid DLS query: ") gave operators no indication of which attribute was missing or what attributes were available — forcing manual inspection of both the query and the user's token.
Issues Resolved
Testing
[Please provide details of testing done: unit testing, integration testing and manual testing]
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.