gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-schemafuzz] branch master updated: implemented a has


From: gnunet
Subject: [GNUnet-SVN] [taler-schemafuzz] branch master updated: implemented a hashing function for stacktrace strings. debugging the parsing.
Date: Fri, 27 Jul 2018 12:57:16 +0200

This is an automated email from the git hooks/post-receive script.

erwan-ulrich pushed a commit to branch master
in repository schemafuzz.

The following commit(s) were added to refs/heads/master by this push:
     new 9035742  implemented a hashing function for stacktrace strings. 
debugging the parsing.
9035742 is described below

commit 90357425a0ce84bbde4b8d4327bfe2556965e833
Author: Feideus <address@hidden>
AuthorDate: Fri Jul 27 12:57:10 2018 +0200

    implemented a hashing function for stacktrace strings. debugging the 
parsing.
---
 schemaspy.iml                                      |  94 ++++++++++++++++++
 src/main/java/org/schemaspy/DBFuzzer.java          |   4 +-
 .../java/org/schemaspy/model/ReportVector.java     |  53 +++++++++--
 src/main/java/org/schemaspy/model/Scorer.java      |   7 +-
 .../java/org/schemaspy/model/StackTraceLine.java   | 105 +++++++++++++++++++--
 5 files changed, 244 insertions(+), 19 deletions(-)

diff --git a/schemaspy.iml b/schemaspy.iml
new file mode 100644
index 0000000..c80c029
--- /dev/null
+++ b/schemaspy.iml
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module 
org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" 
version="4">
+  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
+    <output url="file://$MODULE_DIR$/target/classes" />
+    <output-test url="file://$MODULE_DIR$/target/test-classes" />
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$/src/main/java" 
isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/resources" 
type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/test/java" 
isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/test/resources" 
type="java-test-resource" />
+      <excludeFolder url="file://$MODULE_DIR$/target" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="library" name="Maven: 
com.github.spullara.mustache.java:compiler:0.9.1" level="project" />
+    <orderEntry type="library" name="Maven: 
org.apache.commons.math3:commons-math3:3.6.1" level="project" />
+    <orderEntry type="library" name="Maven: commons-io:commons-io:2.6" 
level="project" />
+    <orderEntry type="library" name="Maven: org.pegdown:pegdown:1.6.0" 
level="project" />
+    <orderEntry type="library" name="Maven: 
org.parboiled:parboiled-java:1.1.7" level="project" />
+    <orderEntry type="library" name="Maven: 
org.parboiled:parboiled-core:1.1.7" level="project" />
+    <orderEntry type="library" name="Maven: org.ow2.asm:asm:5.0.3" 
level="project" />
+    <orderEntry type="library" name="Maven: org.ow2.asm:asm-tree:5.0.3" 
level="project" />
+    <orderEntry type="library" name="Maven: org.ow2.asm:asm-analysis:5.0.3" 
level="project" />
+    <orderEntry type="library" name="Maven: org.ow2.asm:asm-util:5.0.3" 
level="project" />
+    <orderEntry type="library" name="Maven: org.jyaml:jyaml:1.3" 
level="project" />
+    <orderEntry type="library" name="Maven: 
org.springframework.boot:spring-boot-starter:1.5.9.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: 
org.springframework.boot:spring-boot-starter-logging:1.5.9.RELEASE" 
level="project" />
+    <orderEntry type="library" name="Maven: 
ch.qos.logback:logback-classic:1.1.11" level="project" />
+    <orderEntry type="library" name="Maven: 
ch.qos.logback:logback-core:1.1.11" level="project" />
+    <orderEntry type="library" name="Maven: org.slf4j:jcl-over-slf4j:1.7.25" 
level="project" />
+    <orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.7.25" 
level="project" />
+    <orderEntry type="library" name="Maven: org.slf4j:log4j-over-slf4j:1.7.25" 
level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: 
org.yaml:snakeyaml:1.17" level="project" />
+    <orderEntry type="library" name="Maven: 
org.springframework.boot:spring-boot:1.5.9.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: 
org.springframework.boot:spring-boot-autoconfigure:1.5.9.RELEASE" 
level="project" />
+    <orderEntry type="library" name="Maven: 
org.springframework:spring-core:4.3.13.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: 
commons-logging:commons-logging:1.2" level="project" />
+    <orderEntry type="library" name="Maven: 
org.springframework:spring-context:4.3.13.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: 
org.springframework:spring-aop:4.3.13.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: 
org.springframework:spring-expression:4.3.13.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: 
org.springframework:spring-beans:4.3.13.RELEASE" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: 
org.springframework.boot:spring-boot-starter-test:1.5.9.RELEASE" 
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: 
org.springframework.boot:spring-boot-test:1.5.9.RELEASE" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: 
org.springframework.boot:spring-boot-test-autoconfigure:1.5.9.RELEASE" 
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: 
com.jayway.jsonpath:json-path:2.2.0" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: 
net.minidev:json-smart:2.2.1" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: 
net.minidev:accessors-smart:1.1" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: 
org.hamcrest:hamcrest-library:1.3" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: 
org.skyscreamer:jsonassert:1.4.0" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: 
com.vaadin.external.google:android-json:0.0.20131108.vaadin1" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: 
org.springframework:spring-test:4.3.13.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" 
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: 
org.mockito:mockito-core:2.13.0" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: 
net.bytebuddy:byte-buddy:1.7.9" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: 
net.bytebuddy:byte-buddy-agent:1.7.9" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: 
org.objenesis:objenesis:2.6" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" 
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: 
org.assertj:assertj-core:3.8.0" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: 
com.h2database:h2:1.4.196" level="project" />
+    <orderEntry type="library" name="Maven: com.beust:jcommander:1.69" 
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: 
com.github.npetzall.testcontainers.junit:jdbc:0.1.0" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: 
org.testcontainers:jdbc:1.4.3" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: 
org.testcontainers:testcontainers:1.4.3" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: 
com.kohlschutter.junixsocket:junixsocket-common:2.0.4" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: 
com.kohlschutter.junixsocket:junixsocket-native-common:2.0.4" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: 
org.scijava:native-lib-loader:2.0.2" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: 
org.apache.commons:commons-compress:1.12" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: 
commons-codec:commons-codec:1.10" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: 
commons-lang:commons-lang:2.6" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: 
org.rnorth:tcp-unix-socket-proxy:1.0.1" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: 
org.zeroturnaround:zt-exec:1.8" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: 
org.rnorth.duct-tape:duct-tape:1.0.6" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: 
org.jetbrains:annotations:13.0" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: 
org.slf4j:slf4j-ext:1.7.25" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: 
org.rnorth.visible-assertions:visible-assertions:2.0.0" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: 
com.github.jnr:jnr-posix:3.0.41" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: 
com.github.jnr:jnr-ffi:2.1.4" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: 
com.github.jnr:jffi:1.2.15" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: 
com.github.jnr:jffi:native:1.2.15" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: 
org.ow2.asm:asm-commons:5.0.3" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: 
com.github.jnr:jnr-x86asm:1.0.2" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: 
com.github.jnr:jnr-constants:0.9.8" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: 
com.github.npetzall.testcontainers.junit:generic:0.1.0" level="project" />
+    <orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.25" 
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: 
org.testcontainers:oracle-xe:1.4.3" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: 
org.testcontainers:mysql:1.4.3" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: 
mysql:mysql-connector-java:6.0.6" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: 
com.microsoft.sqlserver:mssql-jdbc:6.2.2.jre8" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: 
org.testcontainers:mssqlserver:1.4.3" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: 
org.xmlunit:xmlunit-core:2.3.0" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: 
nl.jqno.equalsverifier:equalsverifier:2.4" level="project" />
+    <orderEntry type="library" name="Maven: 
org.apache.commons:commons-lang3:3.1" level="project" />
+  </component>
+</module>
\ No newline at end of file
diff --git a/src/main/java/org/schemaspy/DBFuzzer.java 
b/src/main/java/org/schemaspy/DBFuzzer.java
index 0218889..a73ddb9 100755
--- a/src/main/java/org/schemaspy/DBFuzzer.java
+++ b/src/main/java/org/schemaspy/DBFuzzer.java
@@ -74,6 +74,7 @@ public class DBFuzzer
                 evaluatorProcess.waitFor();
                 ReportVector mutationReport = new ReportVector(rootMutation);
                 mutationReport.parseFile("errorReports/parsedStackTrace_" + 
rootMutation.getId());
+                
mutationReport.setStackTraceHash(mutationReport.hashStackTrace(mutationTree));
                 rootMutation.setReportVector(mutationReport);
                 mark = new Scorer().score(rootMutation, mutationTree);
                 rootMutation.setInterest_mark(mark);
@@ -213,7 +214,8 @@ public class DBFuzzer
                     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());
+                    mutationReport.parseFile("errorReports/parsedStackTrace_" 
+ currentMutation.getId()); // initialises the reportVector stacktrace
+                    
mutationReport.setStackTraceHash(mutationReport.hashStackTrace(mutationTree));
                     currentMutation.setReportVector(mutationReport);
                     mark = new Scorer().score(currentMutation, mutationTree);
                     currentMutation.setInterest_mark(mark);
diff --git a/src/main/java/org/schemaspy/model/ReportVector.java 
b/src/main/java/org/schemaspy/model/ReportVector.java
index f2e0aef..b17b8b7 100755
--- a/src/main/java/org/schemaspy/model/ReportVector.java
+++ b/src/main/java/org/schemaspy/model/ReportVector.java
@@ -5,11 +5,10 @@ import java.io.FileReader;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Map;
-import java.util.Random;
 
 public class ReportVector {
     private ArrayList<StackTraceLine> stackTrace;
-    private double stackTraceHash;
+    private double[] stackTraceHash;
     private int codeCoverage; //unused right now
     GenericTreeNode parentMutation;
 
@@ -19,9 +18,9 @@ public class ReportVector {
         stackTrace = new ArrayList<StackTraceLine>();
     }
 
-    public double getStackTraceHash() { return stackTraceHash; }
+    public double[] getStackTraceHash() { return stackTraceHash; }
 
-    public void setStackTraceHash(double stackTraceHash) { this.stackTraceHash 
= stackTraceHash; }
+    public void setStackTraceHash(double[] stackTraceHash) { 
this.stackTraceHash = stackTraceHash; }
 
     public ArrayList<StackTraceLine> getStackTrace() {
         return stackTrace;
@@ -118,6 +117,7 @@ public class ReportVector {
 
             StackTraceLine stl = new 
StackTraceLine(functionName,fileName,lineNumber);
             stackTrace.add(stl);
+
         }
     }
 
@@ -145,9 +145,48 @@ public class ReportVector {
         return true;
     }
 
-    public double hashStackTrace(GenericTree mutationTree,GenericTreeNode 
currentNode)
+    public double[] hashStackTrace(GenericTree mutationTree)
     {
-        Random rand = new Random();
-        return rand.nextDouble();
+        ArrayList<double[]> stackTraceLinesHashes = new ArrayList<>();
+        double var1=500,var2=500,var3=500;
+
+        if(parentMutation.getId() == 1)
+        {
+            for(StackTraceLine stl :stackTrace)
+            {
+                stl.setFileNameHash(500);
+                stl.setFunctionNameHash(500);
+            }
+            double [] tmp = {500,500,500};
+            return tmp;
+        }
+
+        for(StackTraceLine stl : this.getStackTrace())
+        {
+            var1 = stl.consistentFunctionNameHash(mutationTree);
+            stl.setFunctionNameHash(var1);
+            var2 = stl.consistentFileNameHash(mutationTree);
+            stl.setFileNameHash(var2);
+            var3 = stl.getLineNumber();
+
+
+            double[] lineHash = {var1,var2,var3};
+            stackTraceLinesHashes.add(lineHash);
+        }
+
+        double 
functionNameHashTotal=0,fileNameHashTotal=0,lineNumberHashTotal=0;
+        for(double[] lineHash : stackTraceLinesHashes)
+        {
+            functionNameHashTotal = functionNameHashTotal + lineHash[0];
+            fileNameHashTotal= fileNameHashTotal+ lineHash[1];
+            lineNumberHashTotal= lineNumberHashTotal+ lineHash[2];
+        }
+
+        int denominator = stackTraceLinesHashes.size();
+        double[] stackTraceHash 
={functionNameHashTotal/denominator,fileNameHashTotal/denominator,lineNumberHashTotal/denominator};
+        return stackTraceHash;
+        
     }
+
+
 }
diff --git a/src/main/java/org/schemaspy/model/Scorer.java 
b/src/main/java/org/schemaspy/model/Scorer.java
index 95edea4..8591d1b 100755
--- a/src/main/java/org/schemaspy/model/Scorer.java
+++ b/src/main/java/org/schemaspy/model/Scorer.java
@@ -5,8 +5,6 @@ import org.apache.commons.math3.linear.RealMatrix;
 import org.apache.commons.math3.linear.RealVector;
 import org.apache.commons.math3.stat.StatUtils;
 
-
-import java.lang.reflect.Array;
 import java.util.*;
 
 /**
@@ -263,13 +261,12 @@ public class Scorer {
     {
         int i = 0;
         ReportVector rpv = gtn.getReportVector();
-        rpv.setStackTraceHash(rpv.hashStackTrace(mutationTree,gtn));
-        double[] tmp = {rpv.getStackTraceHash(),0,0};
+        double[] tmp = rpv.getStackTraceHash();
         predict = tmp;
         for(GenericTreeNode gtnLoop : mutationTree.toArray())
         {
 
-            double[] data = 
{gtnLoop.getReportVector().getStackTraceHash(),0,0};
+            double[] data = gtnLoop.getReportVector().getStackTraceHash();
             input[i] = data;
             i++;
         }
diff --git a/src/main/java/org/schemaspy/model/StackTraceLine.java 
b/src/main/java/org/schemaspy/model/StackTraceLine.java
index 328024a..155bb2b 100755
--- a/src/main/java/org/schemaspy/model/StackTraceLine.java
+++ b/src/main/java/org/schemaspy/model/StackTraceLine.java
@@ -3,7 +3,9 @@ package org.schemaspy.model;
 public class StackTraceLine {
 
     private String functionName;
+    private double functionNameHash;
     private String fileName;
+    private double fileNameHash;
     private int lineNumber;
 
     public StackTraceLine(String functionName, String fileName, int 
lineNumber) {
@@ -12,13 +14,17 @@ public class StackTraceLine {
         this.lineNumber = lineNumber;
     }
 
-    public String getfunctionName() {
-        return functionName;
-    }
+    public String getFunctionName() { return functionName; }
 
-    public void setfunctionName(String functionName) {
-        this.functionName = functionName;
-    }
+    public void setFunctionName(String functionName) { this.functionName = 
functionName; }
+
+    public double getFunctionNameHash() { return functionNameHash; }
+
+    public void setFunctionNameHash(double functionNameHash) { 
this.functionNameHash = functionNameHash; }
+
+    public double getFileNameHash() { return fileNameHash; }
+
+    public void setFileNameHash(double fileNameHash) { this.fileNameHash = 
fileNameHash; }
 
     public String getFileName() {
         return fileName;
@@ -51,4 +57,91 @@ public class StackTraceLine {
             return true;
         return false;
     }
+
+    public static double similarity(String s1, String s2) {
+        String longer = s1, shorter = s2;
+        if (s1.length() < s2.length()) { // longer should always have greater 
length
+            longer = s2; shorter = s1;
+        }
+        int longerLength = longer.length();
+        if (longerLength == 0) { return 1.0; /* both strings are zero length 
*/ }
+        return (longerLength - editDistance(longer, shorter)) / (double) 
longerLength;
+    }
+
+    public static int editDistance(String s1, String s2) {
+        s1 = s1.toLowerCase();
+        s2 = s2.toLowerCase();
+
+        int[] costs = new int[s2.length() + 1];
+        for (int i = 0; i <= s1.length(); i++) {
+            int lastValue = i;
+            for (int j = 0; j <= s2.length(); j++) {
+                if (i == 0)
+                    costs[j] = j;
+                else {
+                    if (j > 0) {
+                        int newValue = costs[j - 1];
+                        if (s1.charAt(i - 1) != s2.charAt(j - 1))
+                            newValue = Math.min(Math.min(newValue, lastValue),
+                                    costs[j]) + 1;
+                        costs[j - 1] = lastValue;
+                        lastValue = newValue;
+                    }
+                }
+            }
+            if (i > 0)
+                costs[s2.length()] = lastValue;
+        }
+        return costs[s2.length()];
+    }
+
+    public double consistentFunctionNameHash(GenericTree mutationTree)
+    {
+        double maxSimilarity = 0.0;
+        StackTraceLine closestStl = null;
+        for(GenericTreeNode gtn: mutationTree.toArray())
+        {
+            for(StackTraceLine stl : gtn.getReportVector().getStackTrace())
+            {
+                double currentSimilarity = 
similarity(functionName,stl.getFunctionName());
+                if(currentSimilarity > maxSimilarity)
+                {
+                    maxSimilarity = currentSimilarity;
+                    closestStl = stl;
+                }
+            }
+        }
+
+        if(maxSimilarity == 0.0 || closestStl == null)
+            return maxSimilarity;
+        else
+        {
+            return closestStl.getFunctionNameHash() / maxSimilarity;
+        }
+    }
+
+    public double consistentFileNameHash(GenericTree mutationTree)
+    {
+        double maxSimilarity = 0.0;
+        StackTraceLine closestStl = null;
+        for(GenericTreeNode gtn: mutationTree.toArray())
+        {
+            for(StackTraceLine stl : gtn.getReportVector().getStackTrace())
+            {
+                double currentSimilarity = 
similarity(fileName,stl.getFileName());
+                if(currentSimilarity > maxSimilarity)
+                {
+                    maxSimilarity = currentSimilarity;
+                    closestStl = stl;
+                }
+            }
+        }
+
+        if(maxSimilarity == 0.0 || closestStl == null)
+            return maxSimilarity;
+        else
+        {
+            return closestStl.getFunctionNameHash() / maxSimilarity;
+        }
+    }
 }

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]