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

Incorrect response at '/domains?name' search when using partial U-Labels and 'allow_search_wildcards_anywhere = false' #62

Closed
pcarana opened this issue Sep 25, 2017 · 2 comments

Comments

@pcarana
Copy link
Contributor

pcarana commented Sep 25, 2017

According to RFC 7482 section 3.2.1 the form "domains?name=XXXX" allows the search of names either in LDH format or as U-Label. Currently at the server there's a problem when the next variables are met (all at the same time):

  • Server configured with the property 'allow_search_wildcards_anywhere' as 'false'.
  • Search a domain as U-Label at /domains?name.
  • Use a wildcard at the end of the label being searched (eg. /domains?name=exámplé*).

When the search is made the server will respond with a 422 error code and the message 'Partial search can only have wildcards at the end of each label'.

The response is incorrect. First of all is a valid search (the search should reach to the implementation at least), and second, the error message is wrong since the configuration allows to have a wilcard at the end of the label.

The issue is at mx.nic.rdap.server.servlet.RdapSearchRequest.validatePartialSearchValue(String, boolean), exactly below the commented line:

// validates that asterisk are only in the end of the search pattern
if (isEntity) {
	if (!valuePattern.endsWith("*")) {
		throw new UnprocessableEntityException(
				"Partial search can only have a wildcard at the end of the search");
	}
	int asteriskCount = valuePattern.length() - valuePattern.replaceAll("\\*", "").length();
	if (asteriskCount > 1) {
		throw new UnprocessableEntityException("Partial search can only have one wildcard");
	}
} else {
	// FIXME Right here is the issue: this REGEX doesn't allow U-Labels
	if (!PARTIAL_DOMAIN_SEARCH_PATTERN.matcher(valuePattern).matches()) {
		throw new UnprocessableEntityException(
				"Partial search can only have wildcards at the end of each label");
	}
}
@pcarana pcarana added this to the v1.1.3 milestone Sep 26, 2017
@pcarana
Copy link
Contributor Author

pcarana commented Oct 2, 2017

The validation has been refactored, the regex used to validate the labels was incomplete since it wasn't allowing searches using unicode characters.

The refactor was made at the use of wildcards and its validations whenever a search pattern is used (applies to "/domains?(name | nsLdhName | nsIp)", "/nameservers?(name | ip)", "/entities?(fn | handle)"):

  • A new configuration property was added: 'allow_multiple_search_wildcards'. If set to true then multiple wildcards can be used at the search patterns, if false then only one wildcard can be used.
  • The property 'allow_search_wildcards_anywhere' was renamed to 'allow_search_wildcard_anywhere', its value is ignored when the new property 'allow_multiple_search_wildcards' is set to true. The behaviour is basically the same (true means that the only wildcard allowed can be anywhere in the search pattern, false means that it must be at the end).
  • Multiple wildcards are treated as one. Eg. 'fo**.bar' will be treated as 'fo*.bar'. This is to avoid "bad" searches, such as "/domains?name=*****" that will surpass the default validation of 'minimum_search_pattern_length' (it's default value is 5).

@pcarana pcarana added the Solved label Oct 2, 2017
@TheRedTrainer
Copy link

Verified.

  • The new 'allow_multiple_search_wildcards' property can be configured and loaded from WEB-INF/configuration.properties. If the property is setted "true", the search module allows multiple wildcars (for each label/segment), no matter the place they took (at begging, in the middle, at the end). This property applies for domains, nameserver and entities searches.
  • If multiple wildcards are used together (for example name=******domain.com ) , they are treated now as one (name=*domain.com)
  • If the allow_multiple_search_wildcards property is setted true, the allow_search_wildcard_anywhere property is ignored.

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

No branches or pull requests

2 participants