diff options
author | Feideus <erwan.ulrich@gmail.com> | 2018-07-13 19:08:00 +0200 |
---|---|---|
committer | Feideus <erwan.ulrich@gmail.com> | 2018-07-13 19:08:00 +0200 |
commit | 5866abefab72e2ea99f4bf3b23328937e2c0622a (patch) | |
tree | 0db99db376208a5bdc4e42d91af2d3c8956c50b8 /src | |
parent | ad6fb89f89c9fb064433bc4b704c1cf21ce04fe6 (diff) | |
download | schemafuzz-5866abefab72e2ea99f4bf3b23328937e2c0622a.tar.gz schemafuzz-5866abefab72e2ea99f4bf3b23328937e2c0622a.tar.bz2 schemafuzz-5866abefab72e2ea99f4bf3b23328937e2c0622a.zip |
m
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/schemaspy/DBFuzzer.java | 24 | ||||
-rw-r--r-- | src/main/java/org/schemaspy/model/ReportVector.java | 84 |
2 files changed, 96 insertions, 12 deletions
diff --git a/src/main/java/org/schemaspy/DBFuzzer.java b/src/main/java/org/schemaspy/DBFuzzer.java index a78b9db..f6bd878 100644 --- a/src/main/java/org/schemaspy/DBFuzzer.java +++ b/src/main/java/org/schemaspy/DBFuzzer.java @@ -5,6 +5,8 @@ import java.lang.invoke.MethodHandles; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.*; + +import org.parboiled.parserunners.ProfilingParseRunner; import org.schemaspy.model.*; import org.schemaspy.model.Table; import org.schemaspy.model.GenericTree; @@ -191,8 +193,11 @@ public class DBFuzzer System.out.println("Weight : "+currentMutation.getWeight()); LOGGER.info("Target is : "+analyzer.getCommandLineArguments().getTarget()); - Process evaluatorProcess = new ProcessBuilder("/bin/bash", "./stackTraceCParser.sh",analyzer.getCommandLineArguments().getTarget()).start(); - LOGGER.info(getEvaluatorResponse(evaluatorProcess)); + Process evaluatorProcess = new ProcessBuilder("/bin/bash", "./stackTraceCParser.sh",analyzer.getCommandLineArguments().getTarget(),Integer.toString(currentMutation.getId())).start(); + evaluatorProcess.waitFor(); + ReportVector mutationReport = new ReportVector(currentMutation); + mutationReport.parseFile("errorReports/parsedStackTrace_"+currentMutation.getId()); + } catch(Exception e) { @@ -204,13 +209,14 @@ public class DBFuzzer removeTemporaryCascade(); printMutationTree(); - if(analyzer.getCommandLineArguments().getReport().equals("y") || analyzer.getCommandLineArguments().getReport().equals("yes")) - { - LOGGER.info("CLEAN UP"); - try { - Process evaluatorProcess = new ProcessBuilder("/bin/bash", "./cleanup.sh").start(); - } catch (Exception e) { - e.printStackTrace(); + if(analyzer.getCommandLineArguments().getReport() != null) { + if (analyzer.getCommandLineArguments().getReport().equals("y") || analyzer.getCommandLineArguments().getReport().equals("yes")) { + LOGGER.info("CLEAN UP"); + try { + Process evaluatorProcess = new ProcessBuilder("/bin/bash", "./cleanup.sh").start(); + } catch (Exception e) { + e.printStackTrace(); + } } } System.out.println("ending process"); diff --git a/src/main/java/org/schemaspy/model/ReportVector.java b/src/main/java/org/schemaspy/model/ReportVector.java index 595c9a9..b4b3b31 100644 --- a/src/main/java/org/schemaspy/model/ReportVector.java +++ b/src/main/java/org/schemaspy/model/ReportVector.java @@ -1,15 +1,18 @@ package org.schemaspy.model; +import java.io.BufferedReader; +import java.io.FileReader; import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; public class ReportVector { private ArrayList<StackTraceLine> stackTrace; private int codeCoverage; //unused right now GenericTreeNode parentMutation; - public ReportVector(ArrayList<StackTraceLine> stackTrace, int codeCoverage, GenericTreeNode parentMutation) { - this.stackTrace = stackTrace; - this.codeCoverage = codeCoverage; + public ReportVector(GenericTreeNode parentMutation) + { this.parentMutation = parentMutation; } @@ -36,4 +39,79 @@ public class ReportVector { public void setParentMutation(GenericTreeNode parentMutation) { this.parentMutation = parentMutation; } + + public void addStackTraceLine(StackTraceLine stl) + { + stackTrace.add(stl); + } + + public void parseFile(String pathToFile) + { + HashMap<String,ArrayList<String>> allLists = new HashMap<>(); + + String data; + String key="uninitialized key.Should not be that way"; + ArrayList<String> currentArray = new ArrayList<>(); + + try { + BufferedReader infile = new BufferedReader(new FileReader(pathToFile)); + while ((data = infile.readLine()) != null) { + if (data.contains(":")) { + if (!currentArray.isEmpty()) { + allLists.put(key, currentArray); // putting in the map the "title" of the data and values before stepping into the next block + currentArray = new ArrayList<>(); + } + + key = data.replace(":", ""); + } else { + currentArray.add(data); + } + } + + storeLines(allLists); + } + catch(Exception e) + { + e.printStackTrace(); + } + } + + public void storeLines(HashMap<String,ArrayList<String>> allLists) + { + int maxSize=0; + + for(Map.Entry<String,ArrayList<String>> entry : allLists.entrySet()) + { + if(entry.getValue().size() > maxSize) + maxSize = entry.getValue().size(); + } + + for(int i = 0; i < maxSize ; i ++) + { + String functionName = "unknown.this is abnormal behavior"; + String fileName = "unknown.this is abnormal behavior"; + int lineNumber = -1; + + if(i < allLists.get("functionNames").size()) { + functionName = allLists.get("functionNames").get(i); + } + + if(i < allLists.get("fileNames").size()) { + fileName = allLists.get("fileNames").get(i); + } + + if(i < allLists.get("lineNumbers").size()) { + try + { + lineNumber = Integer.parseInt(allLists.get("lineNumbers").get(i)); + } + catch(Exception e) {e.printStackTrace();} + } + + StackTraceLine stl = new StackTraceLine(functionName,fileName,lineNumber); + stackTrace.add(stl); + } + + + } } |