-
Notifications
You must be signed in to change notification settings - Fork 26.1k
Refactor - extract ingest processors functionality into separate libraries #140206
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
Merged
eyalkoren
merged 21 commits into
elastic:main
from
eyalkoren:refactor-extract-ingest-processors-functionality
Feb 9, 2026
Merged
Changes from 18 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
4bef51f
Adding UriParts functionality
eyalkoren 7910794
spotless
eyalkoren 4745604
Merge remote-tracking branch 'upstream/main' into refactor-extract-in…
eyalkoren 65bedda
Refactoring registered_domain
eyalkoren 79d4cee
spotless
eyalkoren 0b6df99
Moving licences directory from ingest-common to web-utils
eyalkoren 2031df5
Ignore missing classes in thirdPartyAudit
eyalkoren 140c197
Merge remote-tracking branch 'upstream/main' into refactor-extract-in…
eyalkoren 71ccbd3
Refactor RegisteredDomain result to be a Map<String, String>
eyalkoren ab1ac33
Merge remote-tracking branch 'upstream/main' into refactor-extract-in…
eyalkoren 9f3488f
Merge remote-tracking branch 'upstream/main' into refactor-extract-in…
eyalkoren 7bb7c01
Merge remote-tracking branch 'upstream/main' into refactor-extract-in…
eyalkoren c5b1ea6
Match esql output collection requirements
eyalkoren 94e1214
Merge remote-tracking branch 'upstream/main' into refactor-extract-in…
eyalkoren b466607
Merge remote-tracking branch 'upstream/main' into refactor-extract-in…
eyalkoren 6d78b71
Applying review info
eyalkoren c5ab218
Merge remote-tracking branch 'upstream/main' into refactor-extract-in…
eyalkoren 30ce24c
Removing module exclusion in the test-framework dependency declaration
eyalkoren 6a7766a
Merge remote-tracking branch 'upstream/main' into refactor-extract-in…
eyalkoren 0d6968e
Disabling Entitlements check in test
eyalkoren d250f65
Merge branch 'main' into refactor-extract-ingest-processors-functiona…
eyalkoren File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the "Elastic License | ||
| * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
| * Public License v 1"; you may not use this file except in compliance with, at | ||
| * your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
| * License v3.0 only", or the "Server Side Public License, v 1". | ||
| */ | ||
|
|
||
| dependencies { | ||
| api project(':libs:core') | ||
| implementation "org.apache.httpcomponents:httpclient:${versions.httpclient}" | ||
| implementation "org.apache.httpcomponents:httpcore:${versions.httpcore}" | ||
|
|
||
| testImplementation(project(":test:framework")) | ||
| } | ||
|
|
||
| tasks.named('forbiddenApisMain').configure { | ||
| replaceSignatureFiles 'jdk-signatures' | ||
| } | ||
|
|
||
| tasks.named("thirdPartyAudit").configure { | ||
| ignoreMissingClasses( | ||
| 'org.apache.commons.codec.binary.Base64', | ||
| 'org.apache.commons.logging.Log', | ||
| 'org.apache.commons.logging.LogFactory', | ||
| ) | ||
| } |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the "Elastic License | ||
| * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
| * Public License v 1"; you may not use this file except in compliance with, at | ||
| * your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
| * License v3.0 only", or the "Server Side Public License, v 1". | ||
| */ | ||
|
|
||
| module org.elasticsearch.web { | ||
| requires org.elasticsearch.base; | ||
| requires org.apache.httpcomponents.httpclient; | ||
| requires org.apache.httpcomponents.httpcore; | ||
|
|
||
| exports org.elasticsearch.web; | ||
| } |
148 changes: 148 additions & 0 deletions
148
libs/web-utils/src/main/java/org/elasticsearch/web/RegisteredDomain.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,148 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the "Elastic License | ||
| * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
| * Public License v 1"; you may not use this file except in compliance with, at | ||
| * your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
| * License v3.0 only", or the "Server Side Public License, v 1". | ||
| */ | ||
|
|
||
| package org.elasticsearch.web; | ||
|
|
||
| import org.apache.http.conn.util.PublicSuffixMatcher; | ||
| import org.apache.http.conn.util.PublicSuffixMatcherLoader; | ||
| import org.elasticsearch.core.Nullable; | ||
|
|
||
| import java.util.LinkedHashMap; | ||
|
|
||
| /** | ||
| * Utility class for parsing fully qualified domain names (FQDNs) into their constituent parts: | ||
| * domain, registered domain, top-level domain (eTLD), and subdomain. | ||
| * <p> | ||
| * This class uses the public suffix list to accurately determine domain boundaries. | ||
| * For example, given "www.example.co.uk": | ||
| * <ul> | ||
| * <li>domain: www.example.co.uk</li> | ||
| * <li>registered_domain: example.co.uk</li> | ||
| * <li>top_level_domain: co.uk</li> | ||
| * <li>subdomain: www</li> | ||
| * </ul> | ||
| * | ||
| * @see <a href="https://publicsuffix.org/">Public Suffix List</a> | ||
| * @see <a href="https://developer.mozilla.org/en-US/docs/Glossary/eTLD">eTLD (effective Top-Level Domain)</a> | ||
| */ | ||
| public class RegisteredDomain { | ||
|
|
||
| public static final String DOMAIN = "domain"; | ||
| public static final String REGISTERED_DOMAIN = "registered_domain"; | ||
| public static final String eTLD = "top_level_domain"; | ||
| public static final String SUBDOMAIN = "subdomain"; | ||
|
|
||
| public static final LinkedHashMap<String, Class<?>> REGISTERED_DOMAIN_INFO_FIELDS; | ||
|
eyalkoren marked this conversation as resolved.
|
||
|
|
||
| static { | ||
| REGISTERED_DOMAIN_INFO_FIELDS = new LinkedHashMap<>(); | ||
| REGISTERED_DOMAIN_INFO_FIELDS.putLast(DOMAIN, String.class); | ||
| REGISTERED_DOMAIN_INFO_FIELDS.putLast(REGISTERED_DOMAIN, String.class); | ||
| REGISTERED_DOMAIN_INFO_FIELDS.putLast(eTLD, String.class); | ||
| REGISTERED_DOMAIN_INFO_FIELDS.putLast(SUBDOMAIN, String.class); | ||
| } | ||
|
|
||
| private static final PublicSuffixMatcher SUFFIX_MATCHER = PublicSuffixMatcherLoader.getDefault(); | ||
|
|
||
| public static boolean parseRegisteredDomainInfo(@Nullable final String fqdn, final RegisteredDomainInfoCollector collector) { | ||
| if (fqdn == null || fqdn.isBlank()) { | ||
| return false; | ||
| } | ||
| String registeredDomain = SUFFIX_MATCHER.getDomainRoot(fqdn); | ||
| if (registeredDomain == null) { | ||
| if (SUFFIX_MATCHER.matches(fqdn)) { | ||
| collector.topLevelDomain(fqdn); | ||
| collector.domain(fqdn); | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
| int indexOfDot = registeredDomain.indexOf('.') + 1; | ||
| if (indexOfDot > 0 && indexOfDot < registeredDomain.length()) { | ||
| collector.domain(fqdn); | ||
| collector.registeredDomain(registeredDomain); | ||
| collector.topLevelDomain(registeredDomain.substring(indexOfDot)); | ||
| int subdomainIndex = fqdn.lastIndexOf("." + registeredDomain); | ||
| if (subdomainIndex > 0) { | ||
| collector.subdomain(fqdn.substring(0, subdomainIndex)); | ||
| } | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| public static LinkedHashMap<String, Class<?>> getRegisteredDomainInfoFields() { | ||
| return REGISTERED_DOMAIN_INFO_FIELDS; | ||
| } | ||
|
|
||
| /** | ||
| * A collector for registered domain information. | ||
| * Implementation can be specific to the use case, for example - it can write parsed info directly to the collecting data structure. | ||
| */ | ||
| public interface RegisteredDomainInfoCollector { | ||
| /** | ||
| * @param domain the domain name | ||
| */ | ||
| void domain(String domain); | ||
|
|
||
| /** | ||
| * @param registeredDomain the registered domain name | ||
| */ | ||
| void registeredDomain(String registeredDomain); | ||
|
|
||
| /** | ||
| * @param topLevelDomain the top level domain, n.b. <a href="https://developer.mozilla.org/en-US/docs/Glossary/eTLD">eTLD</a> | ||
| */ | ||
| void topLevelDomain(String topLevelDomain); | ||
|
|
||
| /** | ||
| * @param subdomain the subdomain name | ||
| */ | ||
| void subdomain(String subdomain); | ||
| } | ||
|
|
||
| public record DomainInfo(String domain, String registeredDomain, String eTLD, String subdomain) { | ||
| static class Factory implements RegisteredDomainInfoCollector { | ||
| String domain; | ||
| String registeredDomain; | ||
| String topLevelDomain; | ||
| String subdomain; | ||
|
|
||
| @Override | ||
| public void domain(String domain) { | ||
| this.domain = domain; | ||
| } | ||
|
|
||
| @Override | ||
| public void registeredDomain(String registeredDomain) { | ||
| this.registeredDomain = registeredDomain; | ||
| } | ||
|
|
||
| @Override | ||
| public void topLevelDomain(String topLevelDomain) { | ||
| this.topLevelDomain = topLevelDomain; | ||
| } | ||
|
|
||
| @Override | ||
| public void subdomain(String subdomain) { | ||
| this.subdomain = subdomain; | ||
| } | ||
|
|
||
| public DomainInfo build() { | ||
| return new DomainInfo(domain, registeredDomain, topLevelDomain, subdomain); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public static DomainInfo parseRegisteredDomainInfo(@Nullable final String fqdn) { | ||
| DomainInfo.Factory factory = new DomainInfo.Factory(); | ||
| boolean infoFound = parseRegisteredDomainInfo(fqdn, factory); | ||
| return infoFound ? factory.build() : null; | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.