From 0dd74fb13b6bd210b17be83ab2d2a54e8c54898a Mon Sep 17 00:00:00 2001 From: Justin Cranford Date: Thu, 20 Jan 2022 16:21:24 -0500 Subject: [PATCH 1/3] Test example.com, googleapis.com, and content-autofill.googleapis.com --- .../RegisteredDomainProcessorTests.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RegisteredDomainProcessorTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RegisteredDomainProcessorTests.java index f63aff0518072..da539df401d41 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RegisteredDomainProcessorTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RegisteredDomainProcessorTests.java @@ -41,6 +41,27 @@ public void testBasic() throws Exception { "1" ); testRegisteredDomainProcessor(buildEvent("www.books.amazon.co.uk"), "www.books.amazon.co.uk", "amazon.co.uk", "co.uk", "www.books"); + testRegisteredDomainProcessor( + buildEvent("example.com"), + "example.com", + "example.com", + "com", + null + ); + testRegisteredDomainProcessor( + buildEvent("googleapis.com"), + "googleapis.com", + null, + "googleapis.com", + null + ); + testRegisteredDomainProcessor( + buildEvent("content-autofill.googleapis.com"), + "content-autofill.googleapis.com", + "content-autofill.googleapis.com", + "googleapis.com", + null + ); } public void testUseRoot() throws Exception { From 4d52b38a9b5f178eac0ea29ce6fb5c744752e05b Mon Sep 17 00:00:00 2001 From: Justin Cranford Date: Thu, 20 Jan 2022 16:41:59 -0500 Subject: [PATCH 2/3] checkStyle --- .../common/RegisteredDomainProcessorTests.java | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RegisteredDomainProcessorTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RegisteredDomainProcessorTests.java index da539df401d41..3b27076cb573d 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RegisteredDomainProcessorTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RegisteredDomainProcessorTests.java @@ -41,20 +41,8 @@ public void testBasic() throws Exception { "1" ); testRegisteredDomainProcessor(buildEvent("www.books.amazon.co.uk"), "www.books.amazon.co.uk", "amazon.co.uk", "co.uk", "www.books"); - testRegisteredDomainProcessor( - buildEvent("example.com"), - "example.com", - "example.com", - "com", - null - ); - testRegisteredDomainProcessor( - buildEvent("googleapis.com"), - "googleapis.com", - null, - "googleapis.com", - null - ); + testRegisteredDomainProcessor(buildEvent("example.com"), "example.com", "example.com", "com", null); + testRegisteredDomainProcessor(buildEvent("googleapis.com"), "googleapis.com", null, "googleapis.com", null); testRegisteredDomainProcessor( buildEvent("content-autofill.googleapis.com"), "content-autofill.googleapis.com", From 012236efd9c6c13a9ac7057de5fe2d702fa1d931 Mon Sep 17 00:00:00 2001 From: Justin Cranford Date: Wed, 26 Jan 2022 09:44:58 -0500 Subject: [PATCH 3/3] Resolve PR feedback --- .../RegisteredDomainProcessorTests.java | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RegisteredDomainProcessorTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RegisteredDomainProcessorTests.java index 3b27076cb573d..f9d35b902c9d8 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RegisteredDomainProcessorTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RegisteredDomainProcessorTests.java @@ -17,6 +17,13 @@ import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; +/** + * Test parsing of an eTLD from a FQDN. The list of eTLDs is maintained here: + * https://github.com/publicsuffix/list/blob/master/public_suffix_list.dat + * + * Effective TLDs (eTLS) are not the same as DNS TLDs. Uses for eTLDs are listed here. + * https://publicsuffix.org/learn/ + */ public class RegisteredDomainProcessorTests extends ESTestCase { private Map buildEvent(String domain) { return new HashMap<>() { @@ -33,15 +40,11 @@ public void testBasic() throws Exception { testRegisteredDomainProcessor(buildEvent("."), null, null, null, null); testRegisteredDomainProcessor(buildEvent("$"), null, null, null, null); testRegisteredDomainProcessor(buildEvent("foo.bar.baz"), null, null, null, null); - testRegisteredDomainProcessor( - buildEvent("1.www.global.ssl.fastly.net"), - "1.www.global.ssl.fastly.net", - "www.global.ssl.fastly.net", - "global.ssl.fastly.net", - "1" - ); testRegisteredDomainProcessor(buildEvent("www.books.amazon.co.uk"), "www.books.amazon.co.uk", "amazon.co.uk", "co.uk", "www.books"); + // Verify "com" is returned as the eTLD, for that FQDN or subdomain + testRegisteredDomainProcessor(buildEvent("com"), "com", null, "com", null); testRegisteredDomainProcessor(buildEvent("example.com"), "example.com", "example.com", "com", null); + // Verify "googleapis.com" is returned as the eTLD, for that FQDN or subdomain testRegisteredDomainProcessor(buildEvent("googleapis.com"), "googleapis.com", null, "googleapis.com", null); testRegisteredDomainProcessor( buildEvent("content-autofill.googleapis.com"), @@ -50,6 +53,15 @@ public void testBasic() throws Exception { "googleapis.com", null ); + // Verify "global.ssl.fastly.net" is returned as the eTLD, for that FQDN or subdomain + testRegisteredDomainProcessor(buildEvent("global.ssl.fastly.net"), "global.ssl.fastly.net", null, "global.ssl.fastly.net", null); + testRegisteredDomainProcessor( + buildEvent("1.www.global.ssl.fastly.net"), + "1.www.global.ssl.fastly.net", + "www.global.ssl.fastly.net", + "global.ssl.fastly.net", + "1" + ); } public void testUseRoot() throws Exception {