Skip to content
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

Fix logic for determining if a role has no DLS/FLS/FieldMasking restrictions #5184

Merged
merged 4 commits into from
Mar 18, 2025

Conversation

cwperks
Copy link
Member

@cwperks cwperks commented Mar 17, 2025

Description

This PR fixes the logic for determining whether a role is unrestricted with regards to FLS/DLS/FieldMasking restrictions. A role is considered unrestricted if the respective fls:, dls:, or masked_fields: portions are either an empty list or left out of the role definition altogether.

The gist of the problem is that we bypass the FlsDlsValveImpl if a role has no restrictions, but we are not computing whether a role has no restrictions correctly because we are resolving to concrete indices for cluster actions and then applying the default of {"match_none": {}} to any resolvable indices such as .opendistro_security.

There was a bug seen in CCR tests w/ security: opensearch-project/cross-cluster-replication#1518

The issue can be reproduced by checking out the CCR repo and running:

./gradlew integTest -Dbuild.snapshot=true -Psecurity=true --tests "org.opensearch.replication.integ.rest.SecurityCustomRolesIT.test for FOLLOWER that AutoFollow works for user with valid permissions" -i

Ensure that any local snapshots for core, security and common-utils are up to date.

For core and common-utils run ./gradlew publishToMavenLocal

For security run ./gradlew publishZipToMavenLocal

  • Category (Enhancement, New feature, Bug fix, Test fix, Refactoring, Maintenance, Documentation)

Bug fix

Issues Resolved

Resolves opensearch-project/cross-cluster-replication#1518

Check List

  • New functionality includes testing
  • New functionality has been documented
  • New Roles/Permissions have a corresponding security dashboards plugin PR
  • API changes companion pull request created
  • Commits are signed per the DCO using --signoff

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.

…LS/FieldMasking restrictions

Signed-off-by: Craig Perkins <[email protected]>
Signed-off-by: Craig Perkins <[email protected]>
@cwperks
Copy link
Member Author

cwperks commented Mar 17, 2025

FYI @nibix

Copy link
Collaborator

@derek-ho derek-ho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - should we add a test case for this?

Copy link

codecov bot commented Mar 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 71.69%. Comparing base (00ea10a) to head (0692e9a).
Report is 4 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #5184      +/-   ##
==========================================
- Coverage   71.71%   71.69%   -0.02%     
==========================================
  Files         337      337              
  Lines       22783    22786       +3     
  Branches     3604     3606       +2     
==========================================
- Hits        16338    16336       -2     
- Misses       4642     4644       +2     
- Partials     1803     1806       +3     
Files with missing lines Coverage Δ
...search/security/configuration/DlsFlsValveImpl.java 62.71% <100.00%> (-1.58%) ⬇️
...security/privileges/dlsfls/DocumentPrivileges.java 100.00% <100.00%> (ø)

... and 10 files with indirect coverage changes

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

cwperks added 2 commits March 17, 2025 16:01
Signed-off-by: Craig Perkins <[email protected]>
Signed-off-by: Craig Perkins <[email protected]>
@cwperks cwperks changed the title Only consider regular indices when determining if a role has no DLS/FLS/FieldMasking restrictions Fix logic for determining if a role has no DLS/FLS/FieldMasking restrictions Mar 17, 2025
@cwperks
Copy link
Member Author

cwperks commented Mar 18, 2025

@shikharj05 @nibix This PR is needed to unblock opensearch-3.0.0-alpha1 release. Do either of you have concerns with merging in the current state?

@derek-ho derek-ho merged commit 44b5c0d into opensearch-project:main Mar 18, 2025
41 of 42 checks passed
@shikharj05
Copy link
Contributor

@shikharj05 @nibix This PR is needed to unblock opensearch-3.0.0-alpha1 release. Do either of you have concerns with merging in the current state?

Sure, let's create a separate issue to continue the conversation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] AutoFollow Integ test are breaking due to FLS/DLS permission issue
5 participants