From 82fa3004cc68ef367e4f210900619743eb9abc95 Mon Sep 17 00:00:00 2001 From: Yuli Shlosberg Date: Mon, 2 Jul 2018 11:10:17 +0300 Subject: first attempt to fix vulnerabilities Change-Id: Iaf5f7db54511f730e09a8af8921d52ebf7f6c078 Issue-ID: SDC-1457 Signed-off-by: Yuli Shlosberg --- .../src/main/java/org/openecomp/sdc/common/api/ResponseInfo.java | 8 ++++++-- .../sdc/common/config/generation/GenerateEcompErrorsCsv.java | 9 +++++++-- .../org/openecomp/sdc/common/listener/AppContextListener.java | 2 +- .../main/java/org/openecomp/sdc/common/util/ValidationUtils.java | 2 +- .../org/openecomp/sdc/common/util/YamlToObjectConverter.java | 6 ++---- .../src/main/java/org/openecomp/sdc/common/util/ZipUtil.java | 5 +++-- 6 files changed, 20 insertions(+), 12 deletions(-) (limited to 'common-app-api/src/main/java') diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/api/ResponseInfo.java b/common-app-api/src/main/java/org/openecomp/sdc/common/api/ResponseInfo.java index 2a6b7e7055..3e8968a481 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/api/ResponseInfo.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/api/ResponseInfo.java @@ -25,14 +25,18 @@ import com.fasterxml.jackson.databind.ObjectMapper; public class ResponseInfo { - public static enum ResponseStatusEnum { + public enum ResponseStatusEnum { SUCCESS("success"), LOGIN_FAILED("loginFailed"), INTERNAL_ERROR("internalError"), MISSING_HEADERS("required headers are missing"), TIMEOUT("timeout"), PARSING_ERROR("parsingFailed"); + private String statusDescription; + ResponseStatusEnum(String status) { this.statusDescription = status; } - public String statusDescription; + public String getStatusDescription() { + return statusDescription; + } } private ResponseStatusEnum applicativeStatus; diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/config/generation/GenerateEcompErrorsCsv.java b/common-app-api/src/main/java/org/openecomp/sdc/common/config/generation/GenerateEcompErrorsCsv.java index 87453dedc4..6b7afc439f 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/config/generation/GenerateEcompErrorsCsv.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/config/generation/GenerateEcompErrorsCsv.java @@ -28,6 +28,8 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.openecomp.sdc.common.config.EcompErrorEnum; import org.openecomp.sdc.common.config.EcompErrorEnum.AlarmSeverity; @@ -36,6 +38,8 @@ import org.openecomp.sdc.common.config.EcompErrorLogUtil; public class GenerateEcompErrorsCsv { + private static Logger log = LoggerFactory.getLogger(GenerateEcompErrorsCsv.class); + private static String DATE_FORMAT = "dd-M-yyyy-hh-mm-ss"; private static String NEW_LINE = System.getProperty("line.separator"); @@ -195,14 +199,15 @@ public class GenerateEcompErrorsCsv { result = true; } catch (Exception e) { - e.printStackTrace(); + log.info("generate Ecomp Errors Csv File failed - {}" , e); + } finally { if (writer != null) { try { writer.flush(); writer.close(); } catch (IOException e) { - e.printStackTrace(); + log.info("close FileOutputStream failed - {}" , e); } } diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/listener/AppContextListener.java b/common-app-api/src/main/java/org/openecomp/sdc/common/listener/AppContextListener.java index a6965a75ac..75449529d6 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/listener/AppContextListener.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/listener/AppContextListener.java @@ -117,7 +117,7 @@ public class AppContextListener implements ServletContextListener { try { inputStream.close(); } catch (IOException e) { - e.printStackTrace(); + log.info("close FileOutputStream failed - {}" , e); } } } diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java index 004c2d0a67..864d79eb39 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java @@ -92,7 +92,7 @@ public class ValidationUtils { public final static Pattern COLON_PATTERN = Pattern.compile("[:]+"); public final static Pattern AT_PATTERN = Pattern.compile("[@]+"); public final static Pattern AND_PATTERN = Pattern.compile(" [aA][Nn][Dd] "); - public final static Set CATEGORY_CONJUNCTIONS = new HashSet( + protected final static Set CATEGORY_CONJUNCTIONS = new HashSet( Arrays.asList("of", "to", "for", "as", "a", "an", "the")); public final static Pattern COST_PATTERN = Pattern.compile("^[0-9]{1,5}\\.[0-9]{1,3}$"); diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/YamlToObjectConverter.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/YamlToObjectConverter.java index 322725b032..e8feb1b8e0 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/util/YamlToObjectConverter.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/YamlToObjectConverter.java @@ -220,8 +220,7 @@ public class YamlToObjectConverter { try { in.close(); } catch (IOException e) { - log.debug("Failed to close input stream {} ", e.getMessage(), e); - e.printStackTrace(); + log.debug("Failed to close input stream", e); } } } @@ -249,8 +248,7 @@ public class YamlToObjectConverter { try { in.close(); } catch (IOException e) { - log.debug("Failed to close input stream {} ", e.getMessage(), e); - e.printStackTrace(); + log.debug("Failed to close input stream", e); } } } diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/ZipUtil.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/ZipUtil.java index c9207b2f42..f60cc16abe 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/util/ZipUtil.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/ZipUtil.java @@ -88,7 +88,8 @@ public class ZipUtil { zis.close(); } catch (IOException ex) { - ex.printStackTrace(); + + log.info("close Byte stream failed - {}" , ex); return null; } finally { if (zis != null) { @@ -121,7 +122,7 @@ public class ZipUtil { ZipUtil.readZip(zipAsBytes); } catch (IOException e) { - e.printStackTrace(); + log.info("close Byte stream failed - {}" , e); } } -- cgit 1.2.3-korg