Fix vulnerable issue in vim proxy 71/41171/1
authorKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Thu, 5 Apr 2018 06:18:30 +0000 (11:48 +0530)
committerKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Thu, 5 Apr 2018 06:19:51 +0000 (11:49 +0530)
Issue-ID: VFC-644

Change-Id: Ia1912f0e693ac3a6f9a48ac6203cccd18306e93b
Signed-off-by: Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
service/src/main/java/org/onap/vfc/nfvo/multivimproxy/common/util/restclient/HttpBaseRest.java
service/src/test/java/org/onap/vfc/nfvo/multivimproxy/common/util/RestfulUtilTest.java

index 89a5dd6..100f799 100644 (file)
@@ -19,6 +19,7 @@ package org.onap.vfc.nfvo.multivimproxy.common.util.restclient;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
+import java.net.Inet4Address;
 import java.net.URLEncoder;
 import java.text.SimpleDateFormat;
 import java.util.Calendar;
@@ -37,7 +38,7 @@ import org.slf4j.LoggerFactory;
  * <br/>
  * <p>
  * </p>
- * 
+ *
  * @author
  * @version Aug 9, 2016
  */
@@ -49,7 +50,7 @@ public abstract class HttpBaseRest implements Restful {
 
     protected HttpClient client = null;
 
-    private static final String LOCAL_HOST = "127.0.0.1";
+    private static final String LOCAL_HOST = Inet4Address.getLoopbackAddress().getHostAddress();
 
     static final String HTTP_PATCH = "PATCH";
 
@@ -65,7 +66,7 @@ public abstract class HttpBaseRest implements Restful {
      * Constructor<br/>
      * <p>
      * </p>
-     * 
+     *
      * @since
      */
     public HttpBaseRest() {
@@ -135,7 +136,7 @@ public abstract class HttpBaseRest implements Restful {
 
     /**
      * <br/>
-     * 
+     *
      * @param method
      * @param servicePath
      * @param restParametes
index 2f9c00d..15b908b 100644 (file)
@@ -19,6 +19,8 @@ package org.onap.vfc.nfvo.multivimproxy.common.util;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
+import java.net.Inet4Address;
+
 import org.junit.Test;
 import org.onap.vfc.nfvo.multivimproxy.common.util.restclient.RestfulOptions;
 import org.onap.vfc.nfvo.multivimproxy.common.util.restclient.RestfulParametes;
@@ -52,6 +54,12 @@ public class RestfulUtilTest {
         };
     }
 
+
+    @Test
+    public void findLocalAddress() {
+        assertEquals("127.0.0.1", Inet4Address.getLoopbackAddress().getHostAddress());
+    }
+
     private void mockGetResponseContentReturnNull() {
         new MockUp<RestfulUtil>() {