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 --- .../main/java/org/openecomp/sdc/asdctool/App.java | 8 +- .../java/org/openecomp/sdc/asdctool/Utils.java | 2 +- .../sdc/asdctool/impl/GraphMLConverter.java | 31 +++--- .../sdc/asdctool/impl/GraphMLDataAnalyzer.java | 6 +- .../openecomp/sdc/asdctool/impl/ProductLogic.java | 2 +- .../sdc/asdctool/impl/UpdatePropertyOnVertex.java | 2 +- .../validator/config/ValidationConfigManager.java | 6 +- .../impl/validator/utils/ReportManager.java | 9 +- .../sdc/asdctool/main/DataSchemaMenu.java | 111 ++++++++++----------- .../main/EsToCassandraDataMigrationMenu.java | 2 +- .../servlets/ExportImportTitanServlet.java | 4 +- 11 files changed, 98 insertions(+), 85 deletions(-) (limited to 'asdctool/src') diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/App.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/App.java index b433357db3..7d1104005d 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/App.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/App.java @@ -23,12 +23,16 @@ package org.openecomp.sdc.asdctool; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletHolder; +import org.openecomp.sdc.asdctool.main.ArtifactUUIDFixMenu; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Hello world! * */ public class App { + private static Logger log = LoggerFactory.getLogger(App.class); public static void main(String[] args) { String asdcToolPort = "8087"; @@ -52,12 +56,12 @@ public class App { try { jettyServer.start(); - System.out.println("Server was started on port " + asdcToolPort); + log.info("Server was started on port {}", asdcToolPort); jettyServer.join(); } catch (Exception e) { - e.printStackTrace(); + log.info("Server failed to start - {}", e); System.exit(1); } finally { jettyServer.destroy(); diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/Utils.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/Utils.java index 23612a80f1..ce8b2c4ef7 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/Utils.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/Utils.java @@ -45,7 +45,7 @@ public class Utils { private static Logger log = LoggerFactory.getLogger(Utils.class.getName()); - public static String NEW_LINE = System.getProperty("line.separator"); + public final static String NEW_LINE = System.getProperty("line.separator"); public static Response buildOkResponse( /* diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/GraphMLConverter.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/GraphMLConverter.java index 2bcc8c05a8..f036c397f1 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/GraphMLConverter.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/GraphMLConverter.java @@ -94,7 +94,7 @@ public class GraphMLConverter { return result; } catch (Exception e) { - e.printStackTrace(); + log.info("import graph failed - {} " , e); return false; } finally { if (graph != null) { @@ -121,7 +121,7 @@ public class GraphMLConverter { System.out.println("Exported file=" + result); } catch (Exception e) { - e.printStackTrace(); + log.info("export graph failed -{}" , e); return false; } finally { if (graph != null) { @@ -146,7 +146,7 @@ public class GraphMLConverter { System.out.println("Exported file=" + result); } catch (Exception e) { - e.printStackTrace(); + log.info("export exportGraphMl failed - {}" , e); return null; } finally { if (graph != null) { @@ -173,7 +173,7 @@ public class GraphMLConverter { System.out.println("Exported file=" + result); } catch (Exception e) { - e.printStackTrace(); + log.info("find Error In Json Graph failed - {}" , e); return false; } finally { if (graph != null) { @@ -221,7 +221,7 @@ public class GraphMLConverter { result = outputFile; } catch (Exception e) { - e.printStackTrace(); + log.info("export Json Graph failed - {}" , e); graph.tx().rollback(); } finally { try { @@ -229,7 +229,7 @@ public class GraphMLConverter { out.close(); } } catch (IOException e) { - e.printStackTrace(); + log.info("close FileOutputStream failed - {}" , e); } } return result; @@ -247,7 +247,7 @@ public class GraphMLConverter { graph.tx().commit(); } catch (Exception e) { graph.tx().rollback(); - e.printStackTrace(); + log.info("export Graph Ml failed - {}" , e); } return result; @@ -305,7 +305,7 @@ public class GraphMLConverter { } catch (Exception e) { System.out.println("Failed to import graph " + e.getMessage()); - e.printStackTrace(); + log.info("Failed to import graph - {}" , e); // graph.rollback(); graph.tx().rollback(); } finally { @@ -314,7 +314,7 @@ public class GraphMLConverter { is.close(); } } catch (IOException e) { - e.printStackTrace(); + log.info("close FileOutputStream failed - {}" , e); } } @@ -396,7 +396,7 @@ public class GraphMLConverter { openGraph.tx().rollback(); } catch (Exception e) { - e.printStackTrace(); + log.info("run Edge Scan failed - {}" , e); log.error("fromVertex={}", Utils.getProperties(vertexFrom)); log.error("toVertex={}", Utils.getProperties(vertexTo)); @@ -450,6 +450,7 @@ public class GraphMLConverter { } catch (Exception e) { e.printStackTrace(); + log.info("run Vertex Scan failed - {}" , e); Object property1 = vertex.value(GraphPropertiesDictionary.HEALTH_CHECK.getProperty()); System.out.println(property1); @@ -508,7 +509,7 @@ public class GraphMLConverter { graph.tx().rollback(); } catch (Exception e) { - e.printStackTrace(); + log.info("find Error In Json Graph failed - {}" , e); // graph.rollback(); graph.tx().rollback(); } finally { @@ -517,7 +518,7 @@ public class GraphMLConverter { out.close(); } } catch (IOException e) { - e.printStackTrace(); + log.info("close FileOutputStream failed - {}" , e); } } return result; @@ -592,7 +593,7 @@ public class GraphMLConverter { result = outputFile; } catch (Exception e) { - e.printStackTrace(); + log.info("export Users failed - {}" , e); graph.tx().rollback(); } finally { try { @@ -600,7 +601,7 @@ public class GraphMLConverter { fileWriter.close(); } } catch (IOException e) { - e.printStackTrace(); + log.info("close FileOutputStream failed - {}" , e); } } return result; @@ -642,7 +643,7 @@ public class GraphMLConverter { System.out.println("Exported file=" + result); } catch (Exception e) { - e.printStackTrace(); + log.info("export Users failed - {}" , e); return false; } finally { if (graph != null) { diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/GraphMLDataAnalyzer.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/GraphMLDataAnalyzer.java index 77163b4cc5..f34feb0af6 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/GraphMLDataAnalyzer.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/GraphMLDataAnalyzer.java @@ -36,9 +36,13 @@ import org.jdom2.Element; import org.jdom2.filter.ElementFilter; import org.jdom2.input.SAXBuilder; import org.jdom2.util.IteratorIterable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class GraphMLDataAnalyzer { + private static Logger log = LoggerFactory.getLogger(GraphMLDataAnalyzer.class); + private static final String[] COMPONENT_SHEET_HEADER = { "uniqueId", "type", "name", "toscaResourceName", "resourceType", "version", "deleted", "hasNonCalculatedReqCap" }; private static final String[] COMPONENT_INSTANCES_SHEET_HEADER = { "uniqueId", "name", "originUid", "originType", @@ -51,7 +55,7 @@ public class GraphMLDataAnalyzer { result = _analyzeGraphMLData(mlFileLocation); System.out.println("Analyzed ML file=" + mlFileLocation + ", XLS result=" + result); } catch (Exception e) { - e.printStackTrace(); + log.info("analyze GraphML Data failed - {}" , e); return null; } return result; diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/ProductLogic.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/ProductLogic.java index 502ddd1981..a8674f8a1b 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/ProductLogic.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/ProductLogic.java @@ -77,7 +77,7 @@ public class ProductLogic { graph.tx().commit(); return productsToDelete; } catch (Exception e) { - e.printStackTrace(); + log.info("get All Products failed - {}" , e); graph.tx().rollback(); return null; diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/UpdatePropertyOnVertex.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/UpdatePropertyOnVertex.java index 0336701b2d..6f0136cba3 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/UpdatePropertyOnVertex.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/UpdatePropertyOnVertex.java @@ -102,7 +102,7 @@ public class UpdatePropertyOnVertex { return numberOfUpdatedVertexes; } catch (Exception e) { - e.printStackTrace(); + log.info("update Property On Service At Least Certified failed -{}" , e); // graph.rollback(); graph.tx().rollback(); diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationConfigManager.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationConfigManager.java index 90d850686b..01b92f7ae7 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationConfigManager.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationConfigManager.java @@ -4,12 +4,16 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.Properties; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Created by chaya on 7/4/2017. */ public class ValidationConfigManager { + private static Logger log = LoggerFactory.getLogger(ValidationConfigManager.class); + private static Properties prop = new Properties(); private static String outputFullFilePath; private static String outputFilePath; @@ -44,7 +48,7 @@ public class ValidationConfigManager { input = new FileInputStream(path); prop.load(input); } catch (IOException ex) { - ex.printStackTrace(); + log.info("FileInputStream failed - " , ex); } return prop; } diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManager.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManager.java index a19a98ed27..ebedf0a568 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManager.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManager.java @@ -13,12 +13,15 @@ import java.util.Set; import org.apache.commons.lang.text.StrBuilder; import org.openecomp.sdc.asdctool.impl.validator.config.ValidationConfigManager; import org.openecomp.sdc.be.dao.jsongraph.GraphVertex; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Created by chaya on 7/5/2017. */ public class ReportManager { + private static Logger log = LoggerFactory.getLogger(ReportManager.class); private static String reportOutputFilePath; private static String csvReportFilePath; private static Map> failedVerticesPerTask = new HashMap<>(); @@ -29,7 +32,7 @@ public class ReportManager { initCsvFile(); initReportFile(); } catch (IOException e) { - e.printStackTrace(); + log.info("Init file failed - {}" , e); } } @@ -79,7 +82,7 @@ public class ReportManager { Files.write(Paths.get(reportOutputFilePath), new StrBuilder().appendNewLine().toString().getBytes(), StandardOpenOption.APPEND); Files.write(Paths.get(reportOutputFilePath), message.getBytes(), StandardOpenOption.APPEND); } catch (IOException e) { - e.printStackTrace(); + log.info("write to file failed - {}" , e); } } @@ -128,7 +131,7 @@ public class ReportManager { Files.write(Paths.get(csvReportFilePath), resultLine.getBytes(), StandardOpenOption.APPEND); Files.write(Paths.get(csvReportFilePath), new StrBuilder().appendNewLine().toString().getBytes(), StandardOpenOption.APPEND); } catch (IOException e) { - e.printStackTrace(); + log.info("write to file failed - {}" , e); } }); }); diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/DataSchemaMenu.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/DataSchemaMenu.java index b0e3dbea6d..665a9b75d1 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/DataSchemaMenu.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/DataSchemaMenu.java @@ -31,69 +31,66 @@ import org.slf4j.LoggerFactory; public class DataSchemaMenu { - private static Logger log = LoggerFactory.getLogger(DataSchemaMenu.class.getName()); + private static Logger log = LoggerFactory.getLogger(DataSchemaMenu.class.getName()); - public static void main(String[] args) { + public static void main(String[] args) { - String operation = args[0]; + String operation = args[0]; - String appConfigDir = args[1]; + String appConfigDir = args[1]; - if (args == null || args.length < 2) { - usageAndExit(); - } + if (args == null || args.length < 2) { + usageAndExit(); + } - ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir); - ConfigurationManager configurationManager = new ConfigurationManager(configurationSource); - - try { + ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir); + ConfigurationManager configurationManager = new ConfigurationManager(configurationSource); - switch (operation.toLowerCase()) { - case "create-cassandra-structures": - log.debug("Start create cassandra keyspace, tables and indexes"); - if (SdcSchemaBuilder.createSchema()) { - log.debug("create cassandra keyspace, tables and indexes successfull"); - System.exit(0); - } else { - log.debug("create cassandra keyspace, tables and indexes failed"); - System.exit(2); - } - case "create-titan-structures": - log.debug("Start create titan keyspace"); - String titanCfg = 2 == args.length? configurationManager.getConfiguration().getTitanCfgFile(): args[2]; - if (TitanGraphInitializer.createGraph(titanCfg)) { - log.debug("create titan keyspace successfull"); - System.exit(0); - } else { - log.debug("create titan keyspace failed"); - System.exit(2); - } - case "clean-cassndra": - log.debug("Start clean keyspace, tables"); - if (SdcSchemaBuilder.deleteSchema()) { - log.debug(" successfull"); - System.exit(0); - } else { - log.debug(" failed"); - System.exit(2); - } - default: - usageAndExit(); - } - } catch (Throwable t) { - t.printStackTrace(); - log.debug("create cassandra keyspace, tables and indexes failed"); - System.exit(3); - } - } + switch (operation.toLowerCase()) { + case "create-cassandra-structures": + log.debug("Start create cassandra keyspace, tables and indexes"); + if (SdcSchemaBuilder.createSchema()) { + log.debug("create cassandra keyspace, tables and indexes successfull"); + System.exit(0); + } else { + log.debug("create cassandra keyspace, tables and indexes failed"); + System.exit(2); + } + break; + case "create-titan-structures": + log.debug("Start create titan keyspace"); + String titanCfg = 2 == args.length ? configurationManager.getConfiguration().getTitanCfgFile() : args[2]; + if (TitanGraphInitializer.createGraph(titanCfg)) { + log.debug("create titan keyspace successfull"); + System.exit(0); + } else { + log.debug("create titan keyspace failed"); + System.exit(2); + } + break; + case "clean-cassndra": + log.debug("Start clean keyspace, tables"); + if (SdcSchemaBuilder.deleteSchema()) { + log.debug(" successfull"); + System.exit(0); + } else { + log.debug(" failed"); + System.exit(2); + } + break; + default: + usageAndExit(); + break; + } + } - private static void usageAndExit() { - DataSchemeUsage(); - System.exit(1); - } + private static void usageAndExit() { + DataSchemeUsage(); + System.exit(1); + } - private static void DataSchemeUsage() { - System.out.println("Usage: create-cassandra-structures "); - System.out.println("Usage: create-titan-structures "); - } + private static void DataSchemeUsage() { + System.out.println("Usage: create-cassandra-structures "); + System.out.println("Usage: create-titan-structures "); + } } diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/EsToCassandraDataMigrationMenu.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/EsToCassandraDataMigrationMenu.java index f791098493..873bdb1496 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/EsToCassandraDataMigrationMenu.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/EsToCassandraDataMigrationMenu.java @@ -89,7 +89,7 @@ public class EsToCassandraDataMigrationMenu { usageAndExit(); } } catch (Throwable t) { - t.printStackTrace(); + log.info("data migration failed - {}", t); System.exit(3); } } diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/servlets/ExportImportTitanServlet.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/servlets/ExportImportTitanServlet.java index 9d40354651..62b59f13f3 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/servlets/ExportImportTitanServlet.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/servlets/ExportImportTitanServlet.java @@ -164,7 +164,7 @@ public class ExportImportTitanServlet { result = outputFile; } catch (Exception e) { - e.printStackTrace(); + log.info("export Graph failed - {}" , e); // graph.rollback(); graph.tx().rollback(); } finally { @@ -173,7 +173,7 @@ public class ExportImportTitanServlet { out.close(); } } catch (IOException e) { - e.printStackTrace(); + log.info("close FileOutputStream failed - {}" , e); } } return result; -- cgit 1.2.3-korg