Skip to content

Commit

Permalink
Added support for Elasticsearch 7.7.0 to 7.10.1. Compatibility with o…
Browse files Browse the repository at this point in the history
…lder versions of Elasticsearch will not be maintained. Updated Jackson dependency to resolve security vulnerability CVE-2020-14062.
  • Loading branch information
davemoore- committed Jan 4, 2021
1 parent af1c681 commit 44b908c
Show file tree
Hide file tree
Showing 19 changed files with 222 additions and 214 deletions.
19 changes: 10 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ jdk:
- oraclejdk11
env:
matrix:
- ELASTICSEARCH_VERSION=7.6.2
- ELASTICSEARCH_VERSION=7.6.1
- ELASTICSEARCH_VERSION=7.6.0
- ELASTICSEARCH_VERSION=7.5.2
- ELASTICSEARCH_VERSION=7.5.1
- ELASTICSEARCH_VERSION=7.5.0
- ELASTICSEARCH_VERSION=7.4.2
- ELASTICSEARCH_VERSION=7.4.1
- ELASTICSEARCH_VERSION=7.4.0
- ELASTICSEARCH_VERSION=7.10.1
- ELASTICSEARCH_VERSION=7.10.0
- ELASTICSEARCH_VERSION=7.9.3
- ELASTICSEARCH_VERSION=7.9.2
- ELASTICSEARCH_VERSION=7.9.1
- ELASTICSEARCH_VERSION=7.9.0
- ELASTICSEARCH_VERSION=7.8.1
- ELASTICSEARCH_VERSION=7.8.0
- ELASTICSEARCH_VERSION=7.7.1
- ELASTICSEARCH_VERSION=7.7.0

script: "mvn clean install -Delasticsearch.version=${ELASTICSEARCH_VERSION}"

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Once you have installed Elasticsearch, you can install zentity from a remote URL

Example:

`elasticsearch-plugin install https://zentity.io/releases/zentity-1.6.0-elasticsearch-7.6.2.zip`
`elasticsearch-plugin install https://zentity.io/releases/zentity-1.6.1-elasticsearch-7.8.0.zip`

Read the [installation](https://zentity.io/docs/installation) docs for more details.

Expand Down
20 changes: 10 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@
<zentity.author>Dave Moore</zentity.author>
<zentity.classname>org.elasticsearch.plugin.zentity.ZentityPlugin</zentity.classname>
<zentity.website>https://zentity.io</zentity.website>
<zentity.version>1.6.0</zentity.version>
<zentity.version>1.6.1</zentity.version>
<!-- dependency versions -->
<elasticsearch.version>7.6.2</elasticsearch.version>
<jackson.core.version>2.9.10</jackson.core.version>
<jackson.databind.version>2.9.10.3</jackson.databind.version>
<elasticsearch.version>7.10.1</elasticsearch.version>
<jackson.core.version>2.10.4</jackson.core.version>
<jackson.databind.version>2.10.4</jackson.databind.version>
<jdk.version>1.11</jdk.version>
<log4j.version>2.9.1</log4j.version>
<commons-io.version>2.6</commons-io.version>
<log4j.version>2.11.1</log4j.version>
<commons-io.version>2.8.0</commons-io.version>
<!-- maven plugin versions -->
<maven.assembly.version>2.6</maven.assembly.version>
<maven.junit.version>2.5.3</maven.junit.version>
<maven.surefire.version>2.20.1</maven.surefire.version>
<maven.junit.version>2.7.8</maven.junit.version>
<maven.surefire.version>2.22.2</maven.surefire.version>
<!-- test properties -->
<skipTests>false</skipTests>
<skipUnitTests>${skipTests}</skipUnitTests>
Expand Down Expand Up @@ -80,8 +80,8 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<source>9</source>
<target>9</target>
</configuration>
</plugin>
<plugin>
Expand Down
21 changes: 11 additions & 10 deletions src/main/java/io/zentity/resolution/Job.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,7 @@
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.DeprecationHandler;
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.common.xcontent.*;
import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.search.SearchModule;
import org.elasticsearch.search.builder.SearchSourceBuilder;
Expand Down Expand Up @@ -115,7 +110,7 @@ public Job(NodeClient client) {

public static String serializeException(Exception e, boolean includeErrorTrace) {
List<String> errorParts = new ArrayList<>();
if (e instanceof ElasticsearchException)
if (e instanceof ElasticsearchException || e instanceof XContentParseException)
errorParts.add("\"by\":\"elasticsearch\"");
else
errorParts.add("\"by\":\"zentity\"");
Expand Down Expand Up @@ -1241,9 +1236,15 @@ else if (!resolversClause.isEmpty())
}
responseString = responseDataCopyObj.toString();
} else {
ElasticsearchException e = (ElasticsearchException) responseError;
String cause = Strings.toString(e.toXContent(jsonBuilder().startObject(), ToXContent.EMPTY_PARAMS).endObject());
responseString = "{\"error\":{\"root_cause\":[" + cause + "],\"type\":\"" + ElasticsearchException.getExceptionName(e) + "\",\"reason\":\"" + e.getMessage() + "\"},\"status\":" + e.status().getStatus() + "}";
if (responseError instanceof XContentParseException) {
XContentParseException e = (XContentParseException) responseError;
String cause = "{\"type\":\"parsing_exception\",\"reason\":\"" + e.getMessage() + "\",\"line\":" + e.getLineNumber() + ",\"col\":" + e.getColumnNumber() + "}";
responseString = "{\"error\":{\"root_cause\":[" + cause + "],\"type\":\"parsing_exception\",\"reason\":\"" + e.getMessage() + "\",\"line\":" + e.getLineNumber() + ",\"col\":" + e.getColumnNumber() + "},\"status\":400}";
} else {
ElasticsearchException e = (ElasticsearchException) responseError;
String cause = Strings.toString(e.toXContent(jsonBuilder().startObject(), ToXContent.EMPTY_PARAMS).endObject());
responseString = "{\"error\":{\"root_cause\":[" + cause + "],\"type\":\"" + ElasticsearchException.getExceptionName(e) + "\",\"reason\":\"" + e.getMessage() + "\"},\"status\":" + e.status().getStatus() + "}";
}
}
String logged = serializeLoggedQuery(this.input, this.hop, _query, indexName, query, responseString, resolvers, resolversFilterTreeGrouped, termResolvers, termResolversFilterTree);
this.queries.add(logged);
Expand Down
12 changes: 7 additions & 5 deletions src/main/java/org/elasticsearch/plugin/zentity/HomeAction.java
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
package org.elasticsearch.plugin.zentity;

import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.BytesRestResponse;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.RestStatus;

import java.util.List;
import java.util.Properties;

import static org.elasticsearch.rest.RestRequest.Method.GET;


public class HomeAction extends BaseRestHandler {

@Inject
public HomeAction(RestController controller) {
controller.registerHandler(GET, "_zentity", this);
@Override
public List<Route> routes() {
return List.of(
new Route(GET, "_zentity")
);
}

@Override
Expand Down
20 changes: 11 additions & 9 deletions src/main/java/org/elasticsearch/plugin/zentity/ModelsAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.BytesRestResponse;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.RestStatus;

import java.util.List;

import static org.elasticsearch.rest.RestRequest.Method;
import static org.elasticsearch.rest.RestRequest.Method.DELETE;
import static org.elasticsearch.rest.RestRequest.Method.GET;
Expand All @@ -36,13 +36,15 @@ public class ModelsAction extends BaseRestHandler {

public static final String INDEX_NAME = ".zentity-models";

@Inject
public ModelsAction(RestController controller) {
controller.registerHandler(GET, "_zentity/models", this);
controller.registerHandler(GET, "_zentity/models/{entity_type}", this);
controller.registerHandler(POST, "_zentity/models/{entity_type}", this);
controller.registerHandler(PUT, "_zentity/models/{entity_type}", this);
controller.registerHandler(DELETE, "_zentity/models/{entity_type}", this);
@Override
public List<Route> routes() {
return List.of(
new Route(GET, "_zentity/models"),
new Route(GET, "_zentity/models/{entity_type}"),
new Route(POST, "_zentity/models/{entity_type}"),
new Route(PUT, "_zentity/models/{entity_type}"),
new Route(DELETE, "_zentity/models/{entity_type}")
);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,24 @@
import io.zentity.resolution.input.Input;
import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.BytesRestResponse;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.RestStatus;

import java.util.List;

import static org.elasticsearch.rest.RestRequest.Method.POST;


public class ResolutionAction extends BaseRestHandler {

@Inject
ResolutionAction(RestController controller) {
controller.registerHandler(POST, "_zentity/resolution", this);
controller.registerHandler(POST, "_zentity/resolution/{entity_type}", this);
@Override
public List<Route> routes() {
return List.of(
new Route(POST, "_zentity/resolution"),
new Route(POST, "_zentity/resolution/{entity_type}")
);
}

@Override
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/org/elasticsearch/plugin/zentity/SetupAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@

import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.BytesRestResponse;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.RestStatus;

import java.util.List;
import java.util.Properties;

import static org.elasticsearch.rest.RestRequest.Method;
Expand Down Expand Up @@ -47,9 +46,11 @@ public class SetupAction extends BaseRestHandler {
" \"doc\": " + INDEX_MAPPING + "\n" +
"}";

@Inject
public SetupAction(RestController controller) {
controller.registerHandler(POST, "_zentity/_setup", this);
@Override
public List<Route> routes() {
return List.of(
new Route(POST, "_zentity/_setup")
);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
import java.util.function.Supplier;
Expand Down Expand Up @@ -69,12 +69,11 @@ public List<RestHandler> getRestHandlers(
SettingsFilter settingsFilter,
IndexNameExpressionResolver indexNameExpressionResolver,
Supplier<DiscoveryNodes> nodesInCluster) {
List<RestHandler> handlers = new ArrayList<RestHandler>() {{
new HomeAction(restController);
new ModelsAction(restController);
new ResolutionAction(restController);
new SetupAction(restController);
}};
return handlers;
return Arrays.asList(
new HomeAction(),
new ModelsAction(),
new ResolutionAction(),
new SetupAction()
);
}
}
Loading

0 comments on commit 44b908c

Please sign in to comment.