-
Notifications
You must be signed in to change notification settings - Fork 26
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
[SLING-11742] Provide alternative equitable terminology for properties #89
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 for the PR @cristic83 ! I've addede a few comments.
description ="This setting can contain a list of path prefixes, e.g. /libs/, /content/. If " + | ||
"such a list is configured, only vanity paths from resources starting with this prefix " + | ||
" are considered. If the list is empty, all vanity paths are used.") | ||
String[] resource_resolver_vanitypath_allowedlist(); |
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.
Please use 'allowlist' instead of 'allowedlist' . See also https://cwiki.apache.org/confluence/display/SLING/Removal+of+problematic+language
description ="This setting can contain a list of path prefixes, e.g. /misc/. If " + | ||
"such a list is configured,vanity paths from resources starting with this prefix " + | ||
" are not considered. If the list is empty, all vanity paths are used.") | ||
String[] resource_resolver_vanitypath_deniedlist(); |
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.
Please use 'denylist' instead of 'deniedlist'
@@ -195,6 +195,11 @@ public String[] resource_resolver_virtual() { | |||
|
|||
@Override | |||
public String[] resource_resolver_vanitypath_whitelist() { | |||
return resource_resolver_vanitypath_allowedlist(); |
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 can get confusing, please return just null
.
@@ -215,6 +220,11 @@ public int resource_resolver_vanitypath_bloomfilter_maxBytes() { | |||
|
|||
@Override | |||
public String[] resource_resolver_vanitypath_blacklist() { | |||
return resource_resolver_vanitypath_deniedlist(); |
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 can get confusing, please return just null
.
@@ -79,6 +81,45 @@ private static final class FactoryRegistration { | |||
public volatile CommonResourceResolverFactoryImpl commonFactory; | |||
} | |||
|
|||
private static final class VanityPathConfigurer { |
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.
Please extract a test for this class, having the logic separated makes it easy.
String pathPrefixesPropertyName, String pathPrefixesFallbackPropertyName, | ||
Consumer<String[]> filteredPathPrefixesConsumer) { | ||
if (pathPrefixes != null) { | ||
configureVanityPathPrefixes(pathPrefixes, filteredPathPrefixesConsumer); |
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.
Please log a WARN in the case where both the regular prefixes and the fallback ones are defined; this is probably a customer error. We should rely on the old behaviour in this case and only take information from config.resource_resolver_vanitypath_whitelist()
.
private static final class VanityPathConfigurer { | ||
private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
|
||
void configureVanityPathPrefixes(String[] pathPrefixes, String[] pathPrefixesFallback, |
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 wonder if it makes sense to pass in the whole config object, so simplify the signature ; now we pass to fields and their names, passing in the object might make things nicer.
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 attempted to implement this suggestion and the result looks like below. I don't think it's all that nicer,what do you think?
void configureVanityPAthPrefix(ResourceResolverFactoryConfig config, Consumer<String[]> allowVanityPathConsumer, Consumer<String[]> denyVanityPathConsumer) { configureVanityPathPrefixes(config.resource_resolver_vanitypath_whitelist(), config.resource_resolver_vanitypath_allowlist(), "resource_resolver_vanitypath_whitelist", "resource_resolver_vanitypath_allowlist", allowVanityPathConsumer); configureVanityPathPrefixes(config.resource_resolver_vanitypath_blacklist(), config.resource_resolver_vanitypath_denylist(), "resource_resolver_vanitypath_blacklist", "resource_resolver_vanitypath_denylist", denyVanityPathConsumer); }
Kudos, SonarCloud Quality Gate passed! |
I've assigned myself as a reviewer to make sure it's on my TODO list. Not sure when I will get around to it, if anyone beats me to it I won't mind :-) |
@cristic83 I suggest we use an approach where we keep the existing code out of doing conversions from old to new. With a ConfigurationPlugin we can convert transparently the old properties to the new ones. The plugin can then also trigger to update the configuration in configuration admin (async). The components consuming the configurations should implement modified events and check for changes and only act on a real configuration change |
Kudos, SonarCloud Quality Gate passed! |
@@ -163,15 +163,27 @@ | |||
@AttributeDefinition(name = "Allowed Vanity Path Location", | |||
description ="This setting can contain a list of path prefixes, e.g. /libs/, /content/. If " + | |||
"such a list is configured, only vanity paths from resources starting with this prefix " + | |||
" are considered. If the list is empty, all vanity paths are used.") | |||
" are considered. If the list is empty, we fallback to resource.resolver.vanitypath.allowlist.") |
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 think the fallback should be in the opposite direction: if the new property is not used, the old one will be used
@AttributeDefinition(name = "Denied Vanity Path Location", | ||
description ="This setting can contain a list of path prefixes, e.g. /misc/. If " + | ||
"such a list is configured,vanity paths from resources starting with this prefix " + | ||
" are not considered. If the list is empty, all vanity paths are used.") | ||
" are not considered. If the list is empty, we fallback to resource.resolver.vanitypath.denylist.") |
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.
same as above
"such a list is configured, only vanity paths from resources starting with this prefix " + | ||
" are considered. If the list is empty, all vanity paths are used.") | ||
String[] resource_resolver_vanitypath_allowlist(); | ||
|
||
@AttributeDefinition(name = "Denied Vanity Path Location", |
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.
We should remove the metatype information for this property
@@ -163,15 +163,27 @@ | |||
@AttributeDefinition(name = "Allowed Vanity Path Location", |
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.
we should remove the metatype info for this property
class VanityPathConfigurer { | ||
private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
|
||
void configureVanityPathPrefixes(String[] pathPrefixes, String[] pathPrefixesFallback, |
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 could be a static method just taking the Config object as a parameter and returning a String[]
@cristic83 I think we were a little bit unfair here with all our comments and nit picking. I think you did very good work so far. In order to spare you the burden of applying all our nitpicking, I put your code changes into a new branch and applied our comments there. |
Kudos, SonarCloud Quality Gate passed! |
This has been implemented a while ago by #97 |
This PR introduces alternative terminology for terms that are considered un-appropriate for vanity paths, as described in [1]. The approach taken was to provide additional properties to the existing properties so that backwards compatibility is kept. For the sake of backwards compatibility, the existing vanity paths properties are checked first and if these are not defined, the newly introduced properties are checked. A log message is produced in this case.
[1] https://issues.apache.org/jira/browse/SLING-11742