Repository navigation
fixed throw exception for DLS user attributes #5975
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
Changes from 5 commits
5c77a2d
e0373eb
4377cfb
42dc139
5a47c7b
523ac56
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,8 +10,13 @@ | |
| */ | ||
| package org.opensearch.security.privileges; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.Set; | ||
| import java.util.regex.Matcher; | ||
| import java.util.regex.Pattern; | ||
|
|
||
| import com.google.common.base.Joiner; | ||
| import com.google.common.collect.Iterables; | ||
|
|
@@ -25,10 +30,25 @@ | |
| * This code was moved over from ConfigModelV7. | ||
| */ | ||
| public class UserAttributes { | ||
| private static final Pattern UNRESOLVED_ATTRIBUTE_PATTERN = Pattern.compile("\\$\\{([^}]+)\\}"); | ||
|
|
||
| public static boolean needsAttributeSubstitution(String patternString) { | ||
| return patternString.contains("${"); | ||
| } | ||
|
|
||
| /** | ||
| * Returns the names of all unresolved ${...} attribute references remaining | ||
| * in {@code s} after substitution has been performed. | ||
| */ | ||
| public static List<String> findUnresolvedAttributes(String s) { | ||
| List<String> result = new ArrayList<>(); | ||
| Matcher matcher = UNRESOLVED_ATTRIBUTE_PATTERN.matcher(s); | ||
| while (matcher.find()) { | ||
|
Collaborator
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. this whole method can be simplified to (stumbled over it by chance while reviewing a bug)
Contributor
Author
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. hmmm that's interesting. It seems to be cleaner with Matcher#results().
Collaborator
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. i raised #6122 |
||
| result.add(matcher.group(1)); | ||
| } | ||
| return Collections.unmodifiableList(result); | ||
| } | ||
|
|
||
| public static String replaceProperties(String orig, PrivilegesEvaluationContext context) { | ||
| User user = context.getUser(); | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.