Prohibit some RDAP domain and nameserver lookups by nameserver name

We had been allowing lookups by nameserver name using a wildcard and suffix if the suffix was a domain name. That's ok if the domain name is one we manage, but doesn't work efficiently otherwise. A lookup of ns*.zombo.com would require us to search for all nameservers beginning with ns (which could be almost all of them), then loop through until we found those ending with .zombo.com. So we are going to prohibit suffixes after the TLD unless the suffix is an in-bailiwick domain.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=168835732
This commit is contained in:
mountford 2017-09-15 08:00:36 -07:00 committed by jianglai
parent 3a9d7f9b70
commit 80ff106e4c
4 changed files with 76 additions and 70 deletions

View file

@ -815,8 +815,8 @@ public class RdapDomainSearchActionTest {
}
@Test
public void testNameserverMatchWithWildcardAndTldSuffix_notFound() throws Exception {
generateActualJson(RequestType.NS_LDH_NAME, "ns2.cat*.lol");
public void testNameserverMatchWithWildcardAndDomainSuffix_notFound() throws Exception {
generateActualJson(RequestType.NS_LDH_NAME, "ns5*.cat.lol");
assertThat(response.getStatus()).isEqualTo(404);
}
@ -849,6 +849,12 @@ public class RdapDomainSearchActionTest {
assertThat(response.getStatus()).isEqualTo(422);
}
@Test
public void testNameserverMatchWithWildcardAndInvalidSuffix_unprocessable() throws Exception {
generateActualJson(RequestType.NS_LDH_NAME, "ns*.google.com");
assertThat(response.getStatus()).isEqualTo(422);
}
@Test
public void testNameserverMatch_ns2_cat_lol_found() throws Exception {
generateActualJson(RequestType.NS_LDH_NAME, "ns2.cat.lol");
@ -887,9 +893,9 @@ public class RdapDomainSearchActionTest {
}
@Test
public void testNameserverMatch_nsstar_test_notFound() throws Exception {
public void testNameserverMatch_nsstar_test_unprocessable() throws Exception {
generateActualJson(RequestType.NS_LDH_NAME, "ns*.1.test");
assertThat(response.getStatus()).isEqualTo(404);
assertThat(response.getStatus()).isEqualTo(422);
}
@Test
@ -949,10 +955,11 @@ public class RdapDomainSearchActionTest {
}
@Test
public void testNameserverMatchDeletedNameserverWithWildcardAndTld_notFound() throws Exception {
public void testNameserverMatchDeletedNameserverWithWildcardAndSuffix_notFound()
throws Exception {
persistResource(
hostNs1CatLol.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
assertThat(generateActualJson(RequestType.NS_LDH_NAME, "ns1.cat*.lol"))
assertThat(generateActualJson(RequestType.NS_LDH_NAME, "ns1*.cat.lol"))
.isEqualTo(generateExpectedJson("No matching nameservers found", "rdap_error_404.json"));
assertThat(response.getStatus()).isEqualTo(404);
}