Skip to content
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

Revert 'Added jackson dependency to server" and change extension reading #5768

Merged
merged 7 commits into from
Jan 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Add support for discovered cluster manager and remove local weights ([#5680](https://github.com/opensearch-project/OpenSearch/pull/5680))
- Added support for feature flags in opensearch.yml ([#4959](https://github.com/opensearch-project/OpenSearch/pull/4959))
- Add query for initialized extensions ([#5658](https://github.com/opensearch-project/OpenSearch/pull/5658))
- Revert 'Added jackson dependency to server' and change extension reading ([#5768](https://github.com/opensearch-project/OpenSearch/pull/5768))

### Dependencies
- Bumps `log4j-core` from 2.18.0 to 2.19.0
Expand Down
2 changes: 2 additions & 0 deletions modules/ingest-geoip/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ dependencies {
api('com.maxmind.geoip2:geoip2:4.0.0')
// geoip2 dependencies:
api('com.maxmind.db:maxmind-db:3.0.0')
api("com.fasterxml.jackson.core:jackson-annotations:${versions.jackson}")
api("com.fasterxml.jackson.core:jackson-databind:${versions.jackson_databind}")

testImplementation 'org.elasticsearch:geolite2-databases:20191119'
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2a6ad504d591a7903ffdec76b5b7252819a2d162
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
268524b9056cae1211b9f1f52560ef19347f4d17
8 changes: 8 additions & 0 deletions modules/ingest-geoip/licenses/jackson-databind-LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
This copy of Jackson JSON processor streaming parser/generator is licensed under the
Apache (Software) License, version 2.0 ("the License").
See the License for details about distribution rights, and the
specific rights regarding derivate works.

You may obtain a copy of the License at:

http://www.apache.org/licenses/LICENSE-2.0
20 changes: 20 additions & 0 deletions modules/ingest-geoip/licenses/jackson-databind-NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Jackson JSON processor

Jackson is a high-performance, Free/Open Source JSON processing library.
It was originally written by Tatu Saloranta (tatu.saloranta@iki.fi), and has
been in development since 2007.
It is currently developed by a community of developers, as well as supported
commercially by FasterXML.com.

## Licensing

Jackson core and extension components may licensed under different licenses.
To find the details that apply to this artifact see the accompanying LICENSE file.
For more information, including possible other licensing options, contact
FasterXML.com (http://fasterxml.com).

## Credits

A list of contributors may be found from CREDITS file, which is included
in some artifacts (usually source distributions); but is always available
from the source code management (SCM) system project uses.
2 changes: 2 additions & 0 deletions plugins/discovery-ec2/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ dependencies {
api "commons-logging:commons-logging:${versions.commonslogging}"
api "org.apache.logging.log4j:log4j-1.2-api:${versions.log4j}"
api "commons-codec:commons-codec:${versions.commonscodec}"
api "com.fasterxml.jackson.core:jackson-databind:${versions.jackson_databind}"
api "com.fasterxml.jackson.core:jackson-annotations:${versions.jackson}"
}

restResources {
Expand Down
8 changes: 8 additions & 0 deletions plugins/discovery-ec2/licenses/jackson-LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
This copy of Jackson JSON processor streaming parser/generator is licensed under the
Apache (Software) License, version 2.0 ("the License").
See the License for details about distribution rights, and the
specific rights regarding derivate works.

You may obtain a copy of the License at:

http://www.apache.org/licenses/LICENSE-2.0
20 changes: 20 additions & 0 deletions plugins/discovery-ec2/licenses/jackson-NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Jackson JSON processor

Jackson is a high-performance, Free/Open Source JSON processing library.
It was originally written by Tatu Saloranta (tatu.saloranta@iki.fi), and has
been in development since 2007.
It is currently developed by a community of developers, as well as supported
commercially by FasterXML.com.

## Licensing

Jackson core and extension components may licensed under different licenses.
To find the details that apply to this artifact see the accompanying LICENSE file.
For more information, including possible other licensing options, contact
FasterXML.com (http://fasterxml.com).

## Credits

A list of contributors may be found from CREDITS file, which is included
in some artifacts (usually source distributions); but is always available
from the source code management (SCM) system project uses.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2a6ad504d591a7903ffdec76b5b7252819a2d162
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
268524b9056cae1211b9f1f52560ef19347f4d17
2 changes: 2 additions & 0 deletions plugins/repository-azure/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ dependencies {
api 'io.projectreactor.netty:reactor-netty-core:1.0.24'
api 'io.projectreactor.netty:reactor-netty-http:1.0.24'
api "org.slf4j:slf4j-api:${versions.slf4j}"
api "com.fasterxml.jackson.core:jackson-annotations:${versions.jackson}"
api "com.fasterxml.jackson.core:jackson-databind:${versions.jackson_databind}"
api "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:${versions.jackson}"
api "com.fasterxml.jackson.dataformat:jackson-dataformat-xml:${versions.jackson}"
api "com.fasterxml.jackson.module:jackson-module-jaxb-annotations:${versions.jackson}"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2a6ad504d591a7903ffdec76b5b7252819a2d162
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
268524b9056cae1211b9f1f52560ef19347f4d17
3 changes: 3 additions & 0 deletions plugins/repository-s3/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ dependencies {
api "commons-logging:commons-logging:${versions.commonslogging}"
api "org.apache.logging.log4j:log4j-1.2-api:${versions.log4j}"
api "commons-codec:commons-codec:${versions.commonscodec}"
api "com.fasterxml.jackson.core:jackson-core:${versions.jackson}"
api "com.fasterxml.jackson.core:jackson-databind:${versions.jackson_databind}"
api "com.fasterxml.jackson.core:jackson-annotations:${versions.jackson}"
api "com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:${versions.jackson}"
api "joda-time:joda-time:${versions.joda}"

Expand Down
8 changes: 8 additions & 0 deletions plugins/repository-s3/licenses/jackson-LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
This copy of Jackson JSON processor streaming parser/generator is licensed under the
Apache (Software) License, version 2.0 ("the License").
See the License for details about distribution rights, and the
specific rights regarding derivate works.

You may obtain a copy of the License at:

http://www.apache.org/licenses/LICENSE-2.0
20 changes: 20 additions & 0 deletions plugins/repository-s3/licenses/jackson-NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Jackson JSON processor

Jackson is a high-performance, Free/Open Source JSON processing library.
It was originally written by Tatu Saloranta (tatu.saloranta@iki.fi), and has
been in development since 2007.
It is currently developed by a community of developers, as well as supported
commercially by FasterXML.com.

## Licensing

Jackson core and extension components may licensed under different licenses.
To find the details that apply to this artifact see the accompanying LICENSE file.
For more information, including possible other licensing options, contact
FasterXML.com (http://fasterxml.com).

## Credits

A list of contributors may be found from CREDITS file, which is included
in some artifacts (usually source distributions); but is always available
from the source code management (SCM) system project uses.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2a6ad504d591a7903ffdec76b5b7252819a2d162
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
268524b9056cae1211b9f1f52560ef19347f4d17
26 changes: 22 additions & 4 deletions server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,6 @@ dependencies {
// jna
api "net.java.dev.jna:jna:${versions.jna}"

// jackson
api "com.fasterxml.jackson.core:jackson-databind:${versions.jackson_databind}"
api "com.fasterxml.jackson.core:jackson-annotations:${versions.jackson}"

testImplementation(project(":test:framework")) {
// tests use the locally compiled version of server
exclude group: 'org.opensearch', module: 'server'
Expand Down Expand Up @@ -212,12 +208,31 @@ tasks.named("processResources").configure {

tasks.named("thirdPartyAudit").configure {
ignoreMissingClasses(
// from com.fasterxml.jackson.dataformat.yaml.YAMLMapper (jackson-dataformat-yaml)
'com.fasterxml.jackson.databind.ObjectMapper',

// from log4j
'com.conversantmedia.util.concurrent.SpinPolicy',
'com.fasterxml.jackson.annotation.JsonInclude$Include',
'com.fasterxml.jackson.databind.DeserializationContext',
'com.fasterxml.jackson.databind.DeserializationFeature',
'com.fasterxml.jackson.databind.JsonMappingException',
'com.fasterxml.jackson.databind.JsonNode',
'com.fasterxml.jackson.databind.Module$SetupContext',
'com.fasterxml.jackson.databind.ObjectReader',
'com.fasterxml.jackson.databind.ObjectWriter',
'com.fasterxml.jackson.databind.SerializerProvider',
'com.fasterxml.jackson.databind.deser.std.StdDeserializer',
'com.fasterxml.jackson.databind.deser.std.StdScalarDeserializer',
'com.fasterxml.jackson.databind.module.SimpleModule',
'com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter',
'com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider',
'com.fasterxml.jackson.databind.ser.std.StdScalarSerializer',
'com.fasterxml.jackson.databind.ser.std.StdSerializer',
'com.fasterxml.jackson.dataformat.xml.JacksonXmlModule',
'com.fasterxml.jackson.dataformat.xml.XmlMapper',
'com.fasterxml.jackson.dataformat.xml.util.DefaultXmlPrettyPrinter',
'com.fasterxml.jackson.databind.node.ObjectNode',
'org.fusesource.jansi.Ansi',
'org.fusesource.jansi.AnsiRenderer$Code',
'com.lmax.disruptor.EventFactory',
Expand Down Expand Up @@ -277,6 +292,9 @@ tasks.named("thirdPartyAudit").configure {
'org.noggit.JSONParser',

// from lucene-spatial
'com.fasterxml.jackson.databind.JsonSerializer',
'com.fasterxml.jackson.databind.JsonDeserializer',
'com.fasterxml.jackson.databind.node.ArrayNode',
'com.google.common.geometry.S2Cell',
'com.google.common.geometry.S2CellId',
'com.google.common.geometry.S2Projections',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -61,11 +62,9 @@
import org.opensearch.transport.TransportResponse;
import org.opensearch.transport.TransportResponseHandler;
import org.opensearch.transport.TransportService;
import org.yaml.snakeyaml.Yaml;
import org.opensearch.env.EnvironmentSettingsResponse;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;

/**
* The main class for managing Extension communication with the OpenSearch Node.
*
Expand Down Expand Up @@ -556,10 +555,36 @@ public String executor() {
}

private ExtensionsSettings readFromExtensionsYml(Path filePath) throws IOException {
ObjectMapper objectMapper = new ObjectMapper(new YAMLFactory());
InputStream input = Files.newInputStream(filePath);
ExtensionsSettings extensionSettings = objectMapper.readValue(input, ExtensionsSettings.class);
return extensionSettings;
Yaml yaml = new Yaml();
try (InputStream inputStream = Files.newInputStream(filePath)) {
Map<String, Object> obj = yaml.load(inputStream);
if (obj == null) {
inputStream.close();
throw new IOException("extensions.yml is empty");
}
List<HashMap<String, ?>> unreadExtensions = new ArrayList<>((Collection<HashMap<String, ?>>) obj.get("extensions"));
List<Extension> readExtensions = new ArrayList<Extension>();
for (HashMap<String, ?> extensionMap : unreadExtensions) {
readExtensions.add(
new Extension(
extensionMap.get("name").toString(),
extensionMap.get("uniqueId").toString(),
extensionMap.get("hostName").toString(),
extensionMap.get("hostAddress").toString(),
extensionMap.get("port").toString(),
extensionMap.get("version").toString(),
extensionMap.get("description").toString(),
extensionMap.get("opensearchVersion").toString(),
extensionMap.get("javaVersion").toString(),
extensionMap.get("className").toString(),
extensionMap.get("customFolderName").toString(),
extensionMap.get("hasNativeController").toString()
)
);
}
inputStream.close();
return new ExtensionsSettings(readExtensions);
}
}

public static String getRequestExtensionActionName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ public class ExtensionsSettings {

private List<Extension> extensions;

public ExtensionsSettings(List<Extension> extensions) {
this.extensions = extensions;
}

public ExtensionsSettings() {
extensions = new ArrayList<Extension>();
}
Expand All @@ -46,6 +50,34 @@ public static class Extension {
private String hasNativeController;
private List<ExtensionDependency> dependencies = Collections.emptyList();

public Extension(
String name,
String uniqueId,
String hostName,
String hostAddress,
String port,
String version,
String description,
String opensearchVersion,
String jvmVersion,
String className,
String customFolderName,
String hasNativeController
) {
this.name = name;
this.uniqueId = uniqueId;
this.hostName = hostName;
this.hostAddress = hostAddress;
this.port = port;
this.version = version;
this.description = description;
this.opensearchVersion = opensearchVersion;
this.jvmVersion = jvmVersion;
this.className = className;
this.customFolderName = customFolderName;
this.hasNativeController = hasNativeController;
}

public Extension() {
name = "";
uniqueId = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,6 @@ grant {
permission jdk.net.NetworkPermission "getOption.TCP_KEEPCOUNT";
permission jdk.net.NetworkPermission "setOption.TCP_KEEPCOUNT";

permission java.lang.RuntimePermission "accessDeclaredMembers";
permission java.lang.reflect.ReflectPermission "suppressAccessChecks";

// Allow read access to all system properties
permission java.util.PropertyPermission "*", "read";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import org.junit.Before;
import org.opensearch.Version;
import org.opensearch.common.SuppressForbidden;
import org.opensearch.common.bytes.BytesReference;
import org.opensearch.common.io.stream.BytesStreamInput;
import org.opensearch.common.io.stream.BytesStreamOutput;
Expand All @@ -20,12 +19,10 @@
import org.opensearch.test.OpenSearchTestCase;

import java.io.IOException;
import java.lang.reflect.Field;
import java.util.EnumMap;
import java.util.EnumSet;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;

import static org.opensearch.common.settings.Setting.Property;
import static org.opensearch.common.settings.WriteableSetting.SettingType;
Expand Down Expand Up @@ -461,22 +458,4 @@ public void testVersionSetting() throws IOException {
}
}
}

@SuppressForbidden(reason = "The only way to test these is via reflection")
public void testExceptionHandling() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
// abuse reflection to change default value, no way to do this with given Setting class
Setting<String> setting = Setting.simpleString("");
Field dv = setting.getClass().getDeclaredField("defaultValue");
dv.setAccessible(true);
Field p = setting.getClass().getDeclaredField("parser");
p.setAccessible(true);

// test default value type not in enum
Function<Settings, String> dvfi = s -> "";
dv.set(setting, dvfi);
Function<String, WriteableSettingTests> pfi = s -> new WriteableSettingTests();
p.set(setting, pfi);
IllegalArgumentException iae = expectThrows(IllegalArgumentException.class, () -> new WriteableSetting(setting));
assertTrue(iae.getMessage().contains("generic type: WriteableSettingTests"));
}
}