From 876a4acf6f2e8264bb82e960e9aa886799c4bdb1 Mon Sep 17 00:00:00 2001 From: Denes Nemeth Date: Wed, 14 Mar 2018 09:51:50 +0100 Subject: Fix some security vulnerabilities Change-Id: Ib1c08c4f73df8cfe42b2857ee674f102ec09c253 Signed-off-by: Denes Nemeth Issue-ID: VFC-728 --- nokiav2/generatedapis/pom.xml | 100 +++++++++++++++------ .../src/test/java/TestInhertence.java | 97 +++++++------------- 2 files changed, 102 insertions(+), 95 deletions(-) (limited to 'nokiav2/generatedapis') diff --git a/nokiav2/generatedapis/pom.xml b/nokiav2/generatedapis/pom.xml index 1e2c7d98..21114bc3 100644 --- a/nokiav2/generatedapis/pom.xml +++ b/nokiav2/generatedapis/pom.xml @@ -26,6 +26,14 @@ 1.1.0-SNAPSHOT jar vfc/nfvo/driver/vnfm/svnfm/nokiav2/generatedapis + + 1.8.2 + 2.3.0 + 2.0.0 + 1.3.5 + 1.0.1 + 1.5.15 + @@ -41,6 +49,7 @@ ${basedir}/src/main/resources/nokia.vnfm.api.v3.lcm.json java + retrofit2 ${project.build.directory}/generated-sources/cbam com.nokia.cbam.lcm.v32.api com.nokia.cbam.lcm.v32.model @@ -60,12 +69,15 @@ ${basedir}/src/main/resources/nokia.vnfm.api.v3.lcn.subscription.json java + retrofit2 ${project.build.directory}/generated-sources/cbam com.nokia.cbam.lcn.v32.api com.nokia.cbam.lcn.v32.model false src/gen/java/main + true + true @@ -77,6 +89,7 @@ ${basedir}/src/main/resources/nokia.catalog.json java + retrofit2 ${project.build.directory}/generated-sources/cbam com.nokia.cbam.catalog.v1.api com.nokia.cbam.catalog.v1.model @@ -94,6 +107,7 @@ ${basedir}/src/main/resources/vfc.catalog.swagger.json java + retrofit2 ${project.build.directory}/generated-sources/vfccatalog org.onap.vfccatalog.api org.onap.vfccatalog.model @@ -111,6 +125,7 @@ ${basedir}/src/main/resources/vfc.vnfdriver.swagger.json java + retrofit2 ${project.build.directory}/generated-sources/vnfmdriver org.onap.vnfmdriver.api org.onap.vnfmdriver.model @@ -120,6 +135,26 @@ + @@ -156,37 +191,50 @@ - - com.google.code.gson - gson - 2.8.2 - io.swagger swagger-annotations - 1.5.16 + ${swagger-core-version} - joda-time - joda-time - 2.9.9 + com.squareup.retrofit2 + converter-gson + ${retrofit-version} - - com.fasterxml.jackson.datatype - jackson-datatype-joda - - 2.8.10 + com.squareup.retrofit2 + retrofit + ${retrofit-version} - com.squareup.okhttp - okhttp - 2.7.5 + com.squareup.retrofit2 + converter-scalars + ${retrofit-version} - com.squareup.okhttp - logging-interceptor - 2.7.5 + org.apache.oltu.oauth2 + org.apache.oltu.oauth2.client + ${oltu-version} + + + io.gsonfire + gson-fire + ${gson-fire-version} + + + org.threeten + threetenbp + ${threetenbp-version} + + + io.reactivex.rxjava2 + rxjava + ${rxjava-version} + + + com.squareup.retrofit2 + adapter-rxjava2 + ${retrofit-version} junit @@ -196,14 +244,10 @@ provided - io.gsonfire - gson-fire - 1.8.2 - - - org.threeten - threetenbp - 1.3.6 + com.google.guava + guava + 24.0-jre + test diff --git a/nokiav2/generatedapis/src/test/java/TestInhertence.java b/nokiav2/generatedapis/src/test/java/TestInhertence.java index 8e7d551e..f7e1108a 100644 --- a/nokiav2/generatedapis/src/test/java/TestInhertence.java +++ b/nokiav2/generatedapis/src/test/java/TestInhertence.java @@ -16,10 +16,19 @@ import com.nokia.cbam.lcm.v32.ApiClient; import com.nokia.cbam.lcm.v32.model.*; +import okhttp3.Headers; +import okhttp3.RequestBody; +import okhttp3.ResponseBody; +import okhttp3.internal.http.RealResponseBody; +import okio.Buffer; +import okio.BufferedSource; import org.junit.Test; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.lang.annotation.Annotation; + import static junit.framework.TestCase.assertEquals; -import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; public class TestInhertence { @@ -28,7 +37,7 @@ public class TestInhertence { * test OpenStack v2 inheritence handling in serialization and deserialization */ @Test - public void testOpenStackV2(){ + public void testOpenStackV2() throws IOException{ InstantiateVnfRequest req = new InstantiateVnfRequest(); OPENSTACKV2INFO vim = new OPENSTACKV2INFO(); req.getVims().add(vim); @@ -36,78 +45,32 @@ public class TestInhertence { OpenStackAccessInfoV2 accessInfo = new OpenStackAccessInfoV2(); accessInfo.setPassword("myPassword"); vim.setAccessInfo(accessInfo); - String serialize = new ApiClient().getJSON().serialize(req); - assertTrue(serialize.contains("myPassword")); - InstantiateVnfRequest deserialize = new ApiClient().getJSON().deserialize(serialize, InstantiateVnfRequest.class); + Annotation[] x = new Annotation[0]; + RequestBody requestBody = new ApiClient().getAdapterBuilder().build().requestBodyConverter(InstantiateVnfRequest.class, x, new Annotation[0]).convert(req); + assertTrue(getContent(requestBody).contains("myPassword")); + ResponseBody responseBody = toResponse(requestBody); + InstantiateVnfRequest deserialize = (InstantiateVnfRequest) new ApiClient().getAdapterBuilder().build().responseBodyConverter(InstantiateVnfRequest.class, new Annotation[0]).convert(responseBody); assertEquals(1, deserialize.getVims().size()); OPENSTACKV2INFO deserializedVim = (OPENSTACKV2INFO) deserialize.getVims().get(0); assertEquals("myPassword", deserializedVim.getAccessInfo().getPassword()); } - /** - * test OpenStack v3 inheritence handling in serialization and deserialization - */ - @Test - public void testOpenStackV3(){ - InstantiateVnfRequest req = new InstantiateVnfRequest(); - OPENSTACKV3INFO vim = new OPENSTACKV3INFO(); - req.getVims().add(vim); - vim.setVimInfoType(VimInfo.VimInfoTypeEnum.OPENSTACK_V3_INFO); - OpenStackAccessInfoV3 accessInfo = new OpenStackAccessInfoV3(); - accessInfo.setPassword("myPassword"); - vim.setAccessInfo(accessInfo); - String serialize = new ApiClient().getJSON().serialize(req); - assertTrue(serialize.contains("myPassword")); - InstantiateVnfRequest deserialize = new ApiClient().getJSON().deserialize(serialize, InstantiateVnfRequest.class); - assertEquals(1, deserialize.getVims().size()); - OPENSTACKV3INFO deserializedVim = (OPENSTACKV3INFO) deserialize.getVims().get(0); - assertEquals("myPassword", deserializedVim.getAccessInfo().getPassword()); - } - - /** - * test vCloud inheritence handling in serialization and deserialization - */ - @Test - public void testVCloud(){ - InstantiateVnfRequest req = new InstantiateVnfRequest(); - VMWAREVCLOUDINFO vim = new VMWAREVCLOUDINFO(); - req.getVims().add(vim); - vim.setVimInfoType(VimInfo.VimInfoTypeEnum.VMWARE_VCLOUD_INFO); - VCloudAccessInfo accessInfo = new VCloudAccessInfo(); - accessInfo.setPassword("myPassword"); - vim.setAccessInfo(accessInfo); - String serialize = new ApiClient().getJSON().serialize(req); - assertTrue(serialize.contains("myPassword")); - InstantiateVnfRequest deserialize = new ApiClient().getJSON().deserialize(serialize, InstantiateVnfRequest.class); - assertEquals(1, deserialize.getVims().size()); - VMWAREVCLOUDINFO deserializedVim = (VMWAREVCLOUDINFO) deserialize.getVims().get(0); - assertEquals("myPassword", deserializedVim.getAccessInfo().getPassword()); + private ResponseBody toResponse(RequestBody convert) throws IOException { + Headers headers = new Headers.Builder().build(); + Buffer buffer = new Buffer(); + convert.writeTo(buffer); + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + buffer.copyTo(byteArrayOutputStream); + BufferedSource response = buffer; + return new RealResponseBody(headers, response); } - /** - * test LCN serialization and deserialization - */ - @Test - public void testLcn() throws Exception{ - VnfLifecycleChangeNotification vnfLifecycleChangeNotification = new VnfLifecycleChangeNotification(); - vnfLifecycleChangeNotification.setNotificationType(VnfNotificationType.VNFLIFECYCLECHANGENOTIFICATION); - vnfLifecycleChangeNotification.setVnfInstanceId("myId"); - String serialize = new ApiClient().getJSON().serialize(vnfLifecycleChangeNotification); - VnfLifecycleChangeNotification deserialize = new ApiClient().getJSON().deserialize(serialize, VnfLifecycleChangeNotification.class); - assertEquals("myId", deserialize.getVnfInstanceId()); + private String getContent(RequestBody requestBody) throws IOException { + Buffer buffer = new Buffer(); + requestBody.writeTo(buffer); + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + buffer.copyTo(byteArrayOutputStream); + return new String(byteArrayOutputStream.toByteArray()); } - /** - * test arrays are not initialized to empty arrays - */ - @Test - public void testArrayBehaviour() throws Exception{ - VnfLifecycleChangeNotification vnfLifecycleChangeNotification = new VnfLifecycleChangeNotification(); - vnfLifecycleChangeNotification.setNotificationType(VnfNotificationType.VNFLIFECYCLECHANGENOTIFICATION); - vnfLifecycleChangeNotification.setVnfInstanceId("myId"); - String serialize = new ApiClient().getJSON().serialize(vnfLifecycleChangeNotification); - VnfLifecycleChangeNotification deserialize = new ApiClient().getJSON().deserialize(serialize, VnfLifecycleChangeNotification.class); - assertNull(deserialize.getAffectedVirtualLinks()); - } - } -- cgit 1.2.3-korg