Skip to content

Commit 44b908c

Browse files
committed
Added support for Elasticsearch 7.7.0 to 7.10.1. Compatibility with older versions of Elasticsearch will not be maintained. Updated Jackson dependency to resolve security vulnerability CVE-2020-14062.
1 parent af1c681 commit 44b908c

19 files changed

+222
-214
lines changed

.travis.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@ jdk:
33
- oraclejdk11
44
env:
55
matrix:
6-
- ELASTICSEARCH_VERSION=7.6.2
7-
- ELASTICSEARCH_VERSION=7.6.1
8-
- ELASTICSEARCH_VERSION=7.6.0
9-
- ELASTICSEARCH_VERSION=7.5.2
10-
- ELASTICSEARCH_VERSION=7.5.1
11-
- ELASTICSEARCH_VERSION=7.5.0
12-
- ELASTICSEARCH_VERSION=7.4.2
13-
- ELASTICSEARCH_VERSION=7.4.1
14-
- ELASTICSEARCH_VERSION=7.4.0
6+
- ELASTICSEARCH_VERSION=7.10.1
7+
- ELASTICSEARCH_VERSION=7.10.0
8+
- ELASTICSEARCH_VERSION=7.9.3
9+
- ELASTICSEARCH_VERSION=7.9.2
10+
- ELASTICSEARCH_VERSION=7.9.1
11+
- ELASTICSEARCH_VERSION=7.9.0
12+
- ELASTICSEARCH_VERSION=7.8.1
13+
- ELASTICSEARCH_VERSION=7.8.0
14+
- ELASTICSEARCH_VERSION=7.7.1
15+
- ELASTICSEARCH_VERSION=7.7.0
1516

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

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Once you have installed Elasticsearch, you can install zentity from a remote URL
3131

3232
Example:
3333

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

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

pom.xml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@
1414
<zentity.author>Dave Moore</zentity.author>
1515
<zentity.classname>org.elasticsearch.plugin.zentity.ZentityPlugin</zentity.classname>
1616
<zentity.website>https://zentity.io</zentity.website>
17-
<zentity.version>1.6.0</zentity.version>
17+
<zentity.version>1.6.1</zentity.version>
1818
<!-- dependency versions -->
19-
<elasticsearch.version>7.6.2</elasticsearch.version>
20-
<jackson.core.version>2.9.10</jackson.core.version>
21-
<jackson.databind.version>2.9.10.3</jackson.databind.version>
19+
<elasticsearch.version>7.10.1</elasticsearch.version>
20+
<jackson.core.version>2.10.4</jackson.core.version>
21+
<jackson.databind.version>2.10.4</jackson.databind.version>
2222
<jdk.version>1.11</jdk.version>
23-
<log4j.version>2.9.1</log4j.version>
24-
<commons-io.version>2.6</commons-io.version>
23+
<log4j.version>2.11.1</log4j.version>
24+
<commons-io.version>2.8.0</commons-io.version>
2525
<!-- maven plugin versions -->
2626
<maven.assembly.version>2.6</maven.assembly.version>
27-
<maven.junit.version>2.5.3</maven.junit.version>
28-
<maven.surefire.version>2.20.1</maven.surefire.version>
27+
<maven.junit.version>2.7.8</maven.junit.version>
28+
<maven.surefire.version>2.22.2</maven.surefire.version>
2929
<!-- test properties -->
3030
<skipTests>false</skipTests>
3131
<skipUnitTests>${skipTests}</skipUnitTests>
@@ -80,8 +80,8 @@
8080
<groupId>org.apache.maven.plugins</groupId>
8181
<artifactId>maven-compiler-plugin</artifactId>
8282
<configuration>
83-
<source>1.8</source>
84-
<target>1.8</target>
83+
<source>9</source>
84+
<target>9</target>
8585
</configuration>
8686
</plugin>
8787
<plugin>

src/main/java/io/zentity/resolution/Job.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,7 @@
2424
import org.elasticsearch.common.Strings;
2525
import org.elasticsearch.common.settings.Settings;
2626
import org.elasticsearch.common.unit.TimeValue;
27-
import org.elasticsearch.common.xcontent.DeprecationHandler;
28-
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
29-
import org.elasticsearch.common.xcontent.ToXContent;
30-
import org.elasticsearch.common.xcontent.XContentFactory;
31-
import org.elasticsearch.common.xcontent.XContentParser;
32-
import org.elasticsearch.common.xcontent.XContentType;
27+
import org.elasticsearch.common.xcontent.*;
3328
import org.elasticsearch.index.IndexNotFoundException;
3429
import org.elasticsearch.search.SearchModule;
3530
import org.elasticsearch.search.builder.SearchSourceBuilder;
@@ -115,7 +110,7 @@ public Job(NodeClient client) {
115110

116111
public static String serializeException(Exception e, boolean includeErrorTrace) {
117112
List<String> errorParts = new ArrayList<>();
118-
if (e instanceof ElasticsearchException)
113+
if (e instanceof ElasticsearchException || e instanceof XContentParseException)
119114
errorParts.add("\"by\":\"elasticsearch\"");
120115
else
121116
errorParts.add("\"by\":\"zentity\"");
@@ -1241,9 +1236,15 @@ else if (!resolversClause.isEmpty())
12411236
}
12421237
responseString = responseDataCopyObj.toString();
12431238
} else {
1244-
ElasticsearchException e = (ElasticsearchException) responseError;
1245-
String cause = Strings.toString(e.toXContent(jsonBuilder().startObject(), ToXContent.EMPTY_PARAMS).endObject());
1246-
responseString = "{\"error\":{\"root_cause\":[" + cause + "],\"type\":\"" + ElasticsearchException.getExceptionName(e) + "\",\"reason\":\"" + e.getMessage() + "\"},\"status\":" + e.status().getStatus() + "}";
1239+
if (responseError instanceof XContentParseException) {
1240+
XContentParseException e = (XContentParseException) responseError;
1241+
String cause = "{\"type\":\"parsing_exception\",\"reason\":\"" + e.getMessage() + "\",\"line\":" + e.getLineNumber() + ",\"col\":" + e.getColumnNumber() + "}";
1242+
responseString = "{\"error\":{\"root_cause\":[" + cause + "],\"type\":\"parsing_exception\",\"reason\":\"" + e.getMessage() + "\",\"line\":" + e.getLineNumber() + ",\"col\":" + e.getColumnNumber() + "},\"status\":400}";
1243+
} else {
1244+
ElasticsearchException e = (ElasticsearchException) responseError;
1245+
String cause = Strings.toString(e.toXContent(jsonBuilder().startObject(), ToXContent.EMPTY_PARAMS).endObject());
1246+
responseString = "{\"error\":{\"root_cause\":[" + cause + "],\"type\":\"" + ElasticsearchException.getExceptionName(e) + "\",\"reason\":\"" + e.getMessage() + "\"},\"status\":" + e.status().getStatus() + "}";
1247+
}
12471248
}
12481249
String logged = serializeLoggedQuery(this.input, this.hop, _query, indexName, query, responseString, resolvers, resolversFilterTreeGrouped, termResolvers, termResolversFilterTree);
12491250
this.queries.add(logged);

src/main/java/org/elasticsearch/plugin/zentity/HomeAction.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
11
package org.elasticsearch.plugin.zentity;
22

33
import org.elasticsearch.client.node.NodeClient;
4-
import org.elasticsearch.common.inject.Inject;
54
import org.elasticsearch.common.xcontent.XContentBuilder;
65
import org.elasticsearch.common.xcontent.XContentFactory;
76
import org.elasticsearch.rest.BaseRestHandler;
87
import org.elasticsearch.rest.BytesRestResponse;
9-
import org.elasticsearch.rest.RestController;
108
import org.elasticsearch.rest.RestRequest;
119
import org.elasticsearch.rest.RestStatus;
1210

11+
import java.util.List;
1312
import java.util.Properties;
1413

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

16+
1717
public class HomeAction extends BaseRestHandler {
1818

19-
@Inject
20-
public HomeAction(RestController controller) {
21-
controller.registerHandler(GET, "_zentity", this);
19+
@Override
20+
public List<Route> routes() {
21+
return List.of(
22+
new Route(GET, "_zentity")
23+
);
2224
}
2325

2426
@Override

src/main/java/org/elasticsearch/plugin/zentity/ModelsAction.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@
1414
import org.elasticsearch.action.search.SearchRequestBuilder;
1515
import org.elasticsearch.action.search.SearchResponse;
1616
import org.elasticsearch.client.node.NodeClient;
17-
import org.elasticsearch.common.inject.Inject;
1817
import org.elasticsearch.common.xcontent.ToXContent;
1918
import org.elasticsearch.common.xcontent.XContentBuilder;
2019
import org.elasticsearch.common.xcontent.XContentFactory;
2120
import org.elasticsearch.common.xcontent.XContentType;
2221
import org.elasticsearch.index.IndexNotFoundException;
2322
import org.elasticsearch.rest.BaseRestHandler;
2423
import org.elasticsearch.rest.BytesRestResponse;
25-
import org.elasticsearch.rest.RestController;
2624
import org.elasticsearch.rest.RestRequest;
2725
import org.elasticsearch.rest.RestStatus;
2826

27+
import java.util.List;
28+
2929
import static org.elasticsearch.rest.RestRequest.Method;
3030
import static org.elasticsearch.rest.RestRequest.Method.DELETE;
3131
import static org.elasticsearch.rest.RestRequest.Method.GET;
@@ -36,13 +36,15 @@ public class ModelsAction extends BaseRestHandler {
3636

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

39-
@Inject
40-
public ModelsAction(RestController controller) {
41-
controller.registerHandler(GET, "_zentity/models", this);
42-
controller.registerHandler(GET, "_zentity/models/{entity_type}", this);
43-
controller.registerHandler(POST, "_zentity/models/{entity_type}", this);
44-
controller.registerHandler(PUT, "_zentity/models/{entity_type}", this);
45-
controller.registerHandler(DELETE, "_zentity/models/{entity_type}", this);
39+
@Override
40+
public List<Route> routes() {
41+
return List.of(
42+
new Route(GET, "_zentity/models"),
43+
new Route(GET, "_zentity/models/{entity_type}"),
44+
new Route(POST, "_zentity/models/{entity_type}"),
45+
new Route(PUT, "_zentity/models/{entity_type}"),
46+
new Route(DELETE, "_zentity/models/{entity_type}")
47+
);
4648
}
4749

4850
/**

src/main/java/org/elasticsearch/plugin/zentity/ResolutionAction.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,24 @@
66
import io.zentity.resolution.input.Input;
77
import org.elasticsearch.action.get.GetResponse;
88
import org.elasticsearch.client.node.NodeClient;
9-
import org.elasticsearch.common.inject.Inject;
109
import org.elasticsearch.rest.BaseRestHandler;
1110
import org.elasticsearch.rest.BytesRestResponse;
12-
import org.elasticsearch.rest.RestController;
1311
import org.elasticsearch.rest.RestRequest;
1412
import org.elasticsearch.rest.RestStatus;
1513

14+
import java.util.List;
15+
1616
import static org.elasticsearch.rest.RestRequest.Method.POST;
1717

18+
1819
public class ResolutionAction extends BaseRestHandler {
1920

20-
@Inject
21-
ResolutionAction(RestController controller) {
22-
controller.registerHandler(POST, "_zentity/resolution", this);
23-
controller.registerHandler(POST, "_zentity/resolution/{entity_type}", this);
21+
@Override
22+
public List<Route> routes() {
23+
return List.of(
24+
new Route(POST, "_zentity/resolution"),
25+
new Route(POST, "_zentity/resolution/{entity_type}")
26+
);
2427
}
2528

2629
@Override

src/main/java/org/elasticsearch/plugin/zentity/SetupAction.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@
22

33
import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
44
import org.elasticsearch.client.node.NodeClient;
5-
import org.elasticsearch.common.inject.Inject;
65
import org.elasticsearch.common.settings.Settings;
76
import org.elasticsearch.common.xcontent.XContentBuilder;
87
import org.elasticsearch.common.xcontent.XContentFactory;
98
import org.elasticsearch.common.xcontent.XContentType;
109
import org.elasticsearch.rest.BaseRestHandler;
1110
import org.elasticsearch.rest.BytesRestResponse;
12-
import org.elasticsearch.rest.RestController;
1311
import org.elasticsearch.rest.RestRequest;
1412
import org.elasticsearch.rest.RestStatus;
1513

14+
import java.util.List;
1615
import java.util.Properties;
1716

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

50-
@Inject
51-
public SetupAction(RestController controller) {
52-
controller.registerHandler(POST, "_zentity/_setup", this);
49+
@Override
50+
public List<Route> routes() {
51+
return List.of(
52+
new Route(POST, "_zentity/_setup")
53+
);
5354
}
5455

5556
/**

src/main/java/org/elasticsearch/plugin/zentity/ZentityPlugin.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import java.io.IOException;
1616
import java.io.InputStream;
17-
import java.util.ArrayList;
17+
import java.util.Arrays;
1818
import java.util.List;
1919
import java.util.Properties;
2020
import java.util.function.Supplier;
@@ -69,12 +69,11 @@ public List<RestHandler> getRestHandlers(
6969
SettingsFilter settingsFilter,
7070
IndexNameExpressionResolver indexNameExpressionResolver,
7171
Supplier<DiscoveryNodes> nodesInCluster) {
72-
List<RestHandler> handlers = new ArrayList<RestHandler>() {{
73-
new HomeAction(restController);
74-
new ModelsAction(restController);
75-
new ResolutionAction(restController);
76-
new SetupAction(restController);
77-
}};
78-
return handlers;
72+
return Arrays.asList(
73+
new HomeAction(),
74+
new ModelsAction(),
75+
new ResolutionAction(),
76+
new SetupAction()
77+
);
7978
}
8079
}

0 commit comments

Comments
 (0)