-
Notifications
You must be signed in to change notification settings - Fork 24.7k
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 Role Mapping Cleanup Security Migration #114830
Open
jfreden
wants to merge
13
commits into
elastic:8.16
Choose a base branch
from
jfreden:add_eck_migration_8_16
base: 8.16
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
c23b783
Add security migration for cleaning up ECK role mappings
jfreden 157be76
Update docs/changelog/114830.yaml
jfreden c4ad317
fixup! Use new API for role mapping cleanup
jfreden dda3c77
fixup! Test
jfreden c6e54e6
fixup! Test
jfreden e018eaf
fixup! Refactor and add tests
jfreden 3a7e61f
fixup! Fix cleanup test
jfreden 8b50d79
fixup! Add comments
jfreden d3259d5
fixup! merge build.gradle
jfreden 7299d19
fixup! another build.gradle
jfreden 11f775a
fixup! Formatting
jfreden 97abe3c
fixup! comments
jfreden 4d4f412
Merge remote-tracking branch 'upstream/8.16' into add_eck_migration_8_16
jfreden File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pr: 114830 | ||
summary: Add Role Mapping Cleanup Security Migration | ||
area: Security | ||
type: bug | ||
issues: [] |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -172,15 +172,15 @@ public RoleMapperExpression getExpression() { | |
* that match the {@link #getExpression() expression} in this mapping. | ||
*/ | ||
public List<String> getRoles() { | ||
return Collections.unmodifiableList(roles); | ||
return roles != null ? Collections.unmodifiableList(roles) : Collections.emptyList(); | ||
} | ||
|
||
/** | ||
* The list of {@link RoleDescriptor roles} (specified by a {@link TemplateRoleName template} that evaluates to one or more names) | ||
* that should be assigned to users that match the {@link #getExpression() expression} in this mapping. | ||
*/ | ||
public List<TemplateRoleName> getRoleTemplates() { | ||
return Collections.unmodifiableList(roleTemplates); | ||
return roleTemplates != null ? Collections.unmodifiableList(roleTemplates) : Collections.emptyList(); | ||
} | ||
|
||
/** | ||
|
@@ -189,7 +189,7 @@ public List<TemplateRoleName> getRoleTemplates() { | |
* This is not used within the mapping process, and does not affect whether the expression matches, nor which roles are assigned. | ||
*/ | ||
public Map<String, Object> getMetadata() { | ||
return Collections.unmodifiableMap(metadata); | ||
return metadata != null ? Collections.unmodifiableMap(metadata) : Collections.emptyMap(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are not set to null anywhere in production code, but could be in the future (since constructor is public) and can in tests (as I found out). |
||
} | ||
|
||
/** | ||
|
This file contains 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
This file contains 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
Oops, something went wrong.
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.
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.
This is needed to allow us to check if an index was created on the same version as the migration. This means that the index was created with all the settings/mappings/docs needed, so we don't need to run the migration (it can be short-circuit and skipped since there is nothing to migrate).