From ea490507cfbd153ae9410417d6c53419e953b96b Mon Sep 17 00:00:00 2001 From: Arthur Chan Date: Mon, 17 Oct 2022 17:30:33 +0100 Subject: [PATCH 1/7] Fix line number preservation Signed-off-by: Arthur Chan --- .../fuzz/introspector/soot/CallGraphGenerator.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/CallGraphGenerator.java b/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/CallGraphGenerator.java index 15d6f9cba..646b7c2f7 100644 --- a/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/CallGraphGenerator.java +++ b/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/CallGraphGenerator.java @@ -59,6 +59,7 @@ public static void main(String[] args) { Options.v().set_allow_phantom_refs(true); Options.v().set_whole_program(true); Options.v().set_app(true); + Options.v().set_keep_line_number(true); // Load and set main class Options.v().set_main_class(entryClass); @@ -102,10 +103,12 @@ protected void internalTransform(String phaseName, Map options) CallGraph callGraph = Scene.v().getCallGraph(); for(SootClass c : Scene.v().getApplicationClasses()) { for(SootMethod m : c.getMethods()){ - Iterator targets = new Targets(callGraph.edgesOutOf(m)); - for ( ; targets.hasNext(); numOfEdges++) { - SootMethod tgt = (SootMethod) targets.next(); - System.out.println(m + " may call " + tgt); + Iterator edges = callGraph.edgesOutOf(m); + for ( ; edges.hasNext(); numOfEdges++) { + Edge edge = edges.next(); + SootMethod tgt = (SootMethod) edge.getTgt(); + System.out.println(m + " calls " + tgt + " on Line " + + edge.srcStmt().getJavaSourceStartLineNumber()); } } } From 4c7025fe6819ed464c469d507c676c907fe5a147 Mon Sep 17 00:00:00 2001 From: Arthur Chan Date: Mon, 17 Oct 2022 17:57:47 +0100 Subject: [PATCH 2/7] Display more info Signed-off-by: Arthur Chan --- .../introspector/soot/CallGraphGenerator.java | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/CallGraphGenerator.java b/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/CallGraphGenerator.java index 646b7c2f7..028294d2c 100644 --- a/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/CallGraphGenerator.java +++ b/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/CallGraphGenerator.java @@ -23,7 +23,6 @@ import java.util.List; import java.util.Map; -import soot.MethodOrMethodContext; import soot.PackManager; import soot.Scene; import soot.SceneTransformer; @@ -31,7 +30,7 @@ import soot.SootMethod; import soot.Transform; import soot.jimple.toolkits.callgraph.CallGraph; -import soot.jimple.toolkits.callgraph.Targets; +import soot.jimple.toolkits.callgraph.Edge; import soot.options.Options; public class CallGraphGenerator { @@ -99,18 +98,37 @@ public CustomSenceTransformer() { @Override protected void internalTransform(String phaseName, Map options) { int numOfEdges = 0; + int numOfClasses = 0; + int numOfMethods = 0; CallGraph callGraph = Scene.v().getCallGraph(); + System.out.println("--------------------------------------------------"); for(SootClass c : Scene.v().getApplicationClasses()) { - for(SootMethod m : c.getMethods()){ + if (c.getName().startsWith("jdk")) { + continue; + } + numOfClasses++; + System.out.println("Class #" + numOfClasses + ": " + c.getName()); + for (SootMethod m : c.getMethods()) { + numOfMethods++; + int methodEdges = 0; Iterator edges = callGraph.edgesOutOf(m); - for ( ; edges.hasNext(); numOfEdges++) { + System.out.println("Class #" + numOfClasses + " Method #" + + numOfMethods + ": " + m); + if (!edges.hasNext()) { + System.out.println("\t > No external calls"); + } + + for ( ; edges.hasNext(); methodEdges++) { Edge edge = edges.next(); SootMethod tgt = (SootMethod) edge.getTgt(); - System.out.println(m + " calls " + tgt + " on Line " + - edge.srcStmt().getJavaSourceStartLineNumber()); + System.out.println("\t > calls " + tgt + " on Line " + + edge.srcStmt().getJavaSourceStartLineNumber()); } + System.out.println("\n\t Total: " + methodEdges + " external calls.\n"); + numOfEdges += methodEdges; } + System.out.println("--------------------------------------------------"); } System.out.println("Total Edges:" + numOfEdges); } From 27ab166ec1cbb876a5dcbbeb396df4f8832c49f5 Mon Sep 17 00:00:00 2001 From: Arthur Chan Date: Mon, 17 Oct 2022 18:25:20 +0100 Subject: [PATCH 3/7] Fix info digging logic Signed-off-by: Arthur Chan --- .../introspector/soot/CallGraphGenerator.java | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/CallGraphGenerator.java b/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/CallGraphGenerator.java index 028294d2c..ce8c82b00 100644 --- a/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/CallGraphGenerator.java +++ b/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/CallGraphGenerator.java @@ -112,15 +112,32 @@ protected void internalTransform(String phaseName, Map options) for (SootMethod m : c.getMethods()) { numOfMethods++; int methodEdges = 0; - Iterator edges = callGraph.edgesOutOf(m); - System.out.println("Class #" + numOfClasses + " Method #" + + Iterator outEdges = callGraph.edgesOutOf(m); + Iterator inEdges = callGraph.edgesInto(m); + System.out.println("Class #" + numOfClasses + " Method #" + numOfMethods + ": " + m); - if (!edges.hasNext()) { - System.out.println("\t > No external calls"); + + if (!inEdges.hasNext()) { + System.out.println("\t > No calls to this method."); + } + + for ( ; inEdges.hasNext(); methodEdges++) { + Edge edge = inEdges.next(); + SootMethod src = (SootMethod) edge.getSrc(); + System.out.println("\t > called by " + src + " on Line " + + edge.srcStmt().getJavaSourceStartLineNumber()); + } + + System.out.println("\n\t Total: " + methodEdges + " internal calls.\n"); + + methodEdges = 0; + + if (!outEdges.hasNext()) { + System.out.println("\t > No calls from this method."); } - for ( ; edges.hasNext(); methodEdges++) { - Edge edge = edges.next(); + for ( ; outEdges.hasNext(); methodEdges++) { + Edge edge = outEdges.next(); SootMethod tgt = (SootMethod) edge.getTgt(); System.out.println("\t > calls " + tgt + " on Line " + edge.srcStmt().getJavaSourceStartLineNumber()); From c07fbe1171fa9df0f9d6c4e7b064899a20973471 Mon Sep 17 00:00:00 2001 From: Arthur Chan Date: Tue, 18 Oct 2022 15:57:57 +0100 Subject: [PATCH 4/7] Add in yaml structure for java Signed-off-by: Arthur Chan --- .../introspector/soot/yaml/BranchProfile.java | 22 +++ .../introspector/soot/yaml/BranchSide.java | 56 ++++++ .../soot/yaml/FunctionConfig.java | 33 ++++ .../soot/yaml/FunctionElement.java | 183 ++++++++++++++++++ .../introspector/soot/yaml/FuzzerConfig.java | 22 +++ 5 files changed, 316 insertions(+) create mode 100644 frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/yaml/BranchProfile.java create mode 100644 frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/yaml/BranchSide.java create mode 100644 frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/yaml/FunctionConfig.java create mode 100644 frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/yaml/FunctionElement.java create mode 100644 frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/yaml/FuzzerConfig.java diff --git a/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/yaml/BranchProfile.java b/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/yaml/BranchProfile.java new file mode 100644 index 000000000..1682fffd8 --- /dev/null +++ b/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/yaml/BranchProfile.java @@ -0,0 +1,22 @@ +package ossf.fuzz.introspector.soot.yaml; + +public class BranchProfile { + private String branchString; + private BranchSide branchSides; + + public String getBranchString() { + return branchString; + } + + public void setBranchString(String branchString) { + this.branchString = branchString; + } + + public BranchSide getBranchSides() { + return branchSides; + } + + public void setBranchSides(BranchSide branchSides) { + this.branchSides = branchSides; + } +} diff --git a/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/yaml/BranchSide.java b/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/yaml/BranchSide.java new file mode 100644 index 000000000..647fb4b35 --- /dev/null +++ b/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/yaml/BranchSide.java @@ -0,0 +1,56 @@ +package ossf.fuzz.introspector.soot.yaml; + +import java.util.ArrayList; +import java.util.List; + +public class BranchSide { + private String trueSides; + private List trueSidesFuncs; + private String falseSides; + private List falseSidesFuncs; + + public BranchSide() { + this.trueSidesFuncs = new ArrayList(); + this.falseSidesFuncs = new ArrayList(); + } + + public String getTrueSides() { + return trueSides; + } + + public void setTrueSides(String trueSides) { + this.trueSides = trueSides; + } + + public List getTrueSidesFuncs() { + return trueSidesFuncs; + } + + public void addTrueSidesFuncs(String trueSidesFunc) { + this.trueSidesFuncs.add(trueSidesFunc); + } + + public void setTrueSidesFuncs(List trueSidesFuncs) { + this.trueSidesFuncs = trueSidesFuncs; + } + + public String getFalseSides() { + return falseSides; + } + + public void setFalseSides(String falseSides) { + this.falseSides = falseSides; + } + + public List getFalseSidesFuncs() { + return falseSidesFuncs; + } + + public void addFalseSidesFuncs(String falseSidesFunc) { + this.falseSidesFuncs.add(falseSidesFunc); + } + + public void setFalseSidesFuncs(List falseSidesFuncs) { + this.falseSidesFuncs = falseSidesFuncs; + } +} diff --git a/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/yaml/FunctionConfig.java b/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/yaml/FunctionConfig.java new file mode 100644 index 000000000..e870dde77 --- /dev/null +++ b/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/yaml/FunctionConfig.java @@ -0,0 +1,33 @@ +package ossf.fuzz.introspector.soot.yaml; + +import java.util.ArrayList; +import java.util.List; + +public class FunctionConfig { + private String listName; + private List functionElements; + + public FunctionConfig() { + this.functionElements = new ArrayList(); + } + + public String getListName() { + return listName; + } + + public void setListName(String listName) { + this.listName = listName; + } + + public List getFunctionElements() { + return functionElements; + } + + public void addFunctionElement(FunctionElement functionElement) { + this.functionElements.add(functionElement); + } + + public void setFunctionElements(List functionElements) { + this.functionElements = functionElements; + } +} diff --git a/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/yaml/FunctionElement.java b/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/yaml/FunctionElement.java new file mode 100644 index 000000000..b4038c66c --- /dev/null +++ b/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/yaml/FunctionElement.java @@ -0,0 +1,183 @@ +package ossf.fuzz.introspector.soot.yaml; + +import java.util.ArrayList; +import java.util.List; + +public class FunctionElement { + private String functionName; + private String functionSourceFile; + private String linkageType; + private Integer functionLinenumber; + private Integer functionDepth; + private String returnType; + private Integer argCount; + private List argTypes; + private List constantsTouched; + private List argNames; + private Integer BBCount; + private Integer iCount; + private Integer edgeCount; + private Integer CyclomaticComplexity; + private List functionReached; + private Integer functionUses; + private BranchProfile branchProfiles; + + public FunctionElement() { + this.argTypes = new ArrayList(); + this.constantsTouched = new ArrayList(); + this.argNames = new ArrayList(); + this.functionReached = new ArrayList(); + } + + public String getFunctionName() { + return functionName; + } + + public void setFunctionName(String functionName) { + this.functionName = functionName; + } + + public String getFunctionSourceFile() { + return functionSourceFile; + } + + public void setFunctionSourceFile(String functionSourceFile) { + this.functionSourceFile = functionSourceFile; + } + + public String getLinkageType() { + return linkageType; + } + + public void setLinkageType(String linkageType) { + this.linkageType = linkageType; + } + + public Integer getFunctionLinenumber() { + return functionLinenumber; + } + + public void setFunctionLinenumber(Integer functionLinenumber) { + this.functionLinenumber = functionLinenumber; + } + + public Integer getFunctionDepth() { + return functionDepth; + } + + public void setFunctionDepth(Integer functionDepth) { + this.functionDepth = functionDepth; + } + + public String getReturnType() { + return returnType; + } + + public void setReturnType(String type) { + this.returnType = type; + } + + public Integer getArgCount() { + return argCount; + } + + public void setArgCount(Integer argCount) { + this.argCount = argCount; + } + + public List getArgTypes() { + return argTypes; + } + + public void addArgType(String argType) { + this.argTypes.add(argType); + } + + public void setArgTypes(List list) { + this.argTypes = list; + } + + public List getConstantsTouched() { + return constantsTouched; + } + + public void addConstantsTouched(String constantsTouched) { + this.constantsTouched.add(constantsTouched); + } + + public void setConstantsTouched(List constantsTouched) { + this.constantsTouched = constantsTouched; + } + + public List getArgNames() { + return argNames; + } + + public void addArgName(String argNames) { + this.argNames.add(argNames); + } + + public void setArgNames(List argNames) { + this.argNames = argNames; + } + + public Integer getBBCount() { + return BBCount; + } + + public void setBBCount(Integer bBCount) { + BBCount = bBCount; + } + + public Integer getiCount() { + return iCount; + } + + public void setiCount(Integer iCount) { + this.iCount = iCount; + } + + public Integer getEdgeCount() { + return edgeCount; + } + + public void setEdgeCount(Integer edgeCount) { + this.edgeCount = edgeCount; + } + + public Integer getCyclomaticComplexity() { + return CyclomaticComplexity; + } + + public void setCyclomaticComplexity(Integer cyclomaticComplexity) { + CyclomaticComplexity = cyclomaticComplexity; + } + + public List getFunctionReached() { + return functionReached; + } + + public void addFunctionReached(String functionReached) { + this.functionReached.add(functionReached); + } + + public void setFunctionReached(List functionReached) { + this.functionReached = functionReached; + } + + public Integer getFunctionUses() { + return functionUses; + } + + public void setFunctionUses(Integer functionUses) { + this.functionUses = functionUses; + } + + public BranchProfile getBranchProfiles() { + return branchProfiles; + } + + public void setBranchProfiles(BranchProfile branchProfiles) { + this.branchProfiles = branchProfiles; + } +} diff --git a/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/yaml/FuzzerConfig.java b/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/yaml/FuzzerConfig.java new file mode 100644 index 000000000..e8b9cd2b2 --- /dev/null +++ b/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/yaml/FuzzerConfig.java @@ -0,0 +1,22 @@ +package ossf.fuzz.introspector.soot.yaml; + +public class FuzzerConfig { + private String filename; + private FunctionConfig functionConfig; + + public String getFilename() { + return filename; + } + + public void setFilename(String filename) { + this.filename = filename; + } + + public FunctionConfig getFunctionConfig() { + return functionConfig; + } + + public void setFunctionConfig(FunctionConfig functionConfig) { + this.functionConfig = functionConfig; + } +} From 55ff538e97813c7f9ab635560e1b61febb59a739 Mon Sep 17 00:00:00 2001 From: Arthur Chan Date: Tue, 18 Oct 2022 15:58:15 +0100 Subject: [PATCH 5/7] Fix and dig more properties for yaml return Signed-off-by: Arthur Chan --- .../introspector/soot/CallGraphGenerator.java | 54 ++++++++++++++++++- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/CallGraphGenerator.java b/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/CallGraphGenerator.java index ce8c82b00..d0036b210 100644 --- a/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/CallGraphGenerator.java +++ b/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/CallGraphGenerator.java @@ -13,7 +13,6 @@ // limitations under the License. /////////////////////////////////////////////////////////////////////////// - package ossf.fuzz.introspector.soot; import java.io.File; @@ -23,6 +22,13 @@ import java.util.List; import java.util.Map; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; + +import ossf.fuzz.introspector.soot.yaml.FunctionConfig; +import ossf.fuzz.introspector.soot.yaml.FunctionElement; +import ossf.fuzz.introspector.soot.yaml.FuzzerConfig; import soot.PackManager; import soot.Scene; import soot.SceneTransformer; @@ -33,7 +39,8 @@ import soot.jimple.toolkits.callgraph.Edge; import soot.options.Options; -public class CallGraphGenerator { +public class CallGraphGenerator + { public static void main(String[] args) { if (args.length != 2) { System.err.println("No entryClass or entryMethod."); @@ -85,6 +92,7 @@ class CustomSenceTransformer extends SceneTransformer { public CustomSenceTransformer() { excludeList = new LinkedList (); + excludeList.add("jdk."); excludeList.add("java."); excludeList.add("javax."); excludeList.add("sun."); @@ -100,6 +108,7 @@ protected void internalTransform(String phaseName, Map options) int numOfEdges = 0; int numOfClasses = 0; int numOfMethods = 0; + List classYaml = new ArrayList(); CallGraph callGraph = Scene.v().getCallGraph(); System.out.println("--------------------------------------------------"); @@ -107,9 +116,31 @@ protected void internalTransform(String phaseName, Map options) if (c.getName().startsWith("jdk")) { continue; } + + FuzzerConfig classConfig = new FuzzerConfig(); + FunctionConfig methodConfig = new FunctionConfig(); + classConfig.setFilename(c.getName()); + methodConfig.setListName("All functions"); + numOfClasses++; System.out.println("Class #" + numOfClasses + ": " + c.getName()); for (SootMethod m : c.getMethods()) { + FunctionElement element= new FunctionElement(); + element.setFunctionName(m.getName()); + element.setFunctionSourceFile(c.getFilePath()); + //element.setLinkageType("???"); + element.setFunctionLinenumber(m.getJavaSourceStartLineNumber()); + element.setReturnType(m.getReturnType().toString()); + element.setArgCount(m.getParameterCount()); + for (soot.Type type:m.getParameterTypes()) { + element.addArgType(type.toString()); + } + //element.setConstantsTouched([]); + //element.setArgNames(); + //element.setBBCount(0); + //element.setiCount(0); + //element.setCyclomaticComplexity(0); + numOfMethods++; int methodEdges = 0; Iterator outEdges = callGraph.edgesOutOf(m); @@ -130,6 +161,7 @@ protected void internalTransform(String phaseName, Map options) System.out.println("\n\t Total: " + methodEdges + " internal calls.\n"); + element.setFunctionUses(methodEdges); methodEdges = 0; if (!outEdges.hasNext()) { @@ -141,16 +173,34 @@ protected void internalTransform(String phaseName, Map options) SootMethod tgt = (SootMethod) edge.getTgt(); System.out.println("\t > calls " + tgt + " on Line " + edge.srcStmt().getJavaSourceStartLineNumber()); + element.addFunctionReached(tgt.toString() + "; Line: " + + edge.srcStmt().getJavaSourceStartLineNumber()); } System.out.println("\n\t Total: " + methodEdges + " external calls.\n"); numOfEdges += methodEdges; + + element.setEdgeCount(methodEdges); + //element.setBranchProfiles(new BranchProfile()); + methodConfig.addFunctionElement(element); } System.out.println("--------------------------------------------------"); + classConfig.setFunctionConfig(methodConfig); + classYaml.add(classConfig); } System.out.println("Total Edges:" + numOfEdges); + System.out.println("--------------------------------------------------"); + ObjectMapper om = new ObjectMapper(new YAMLFactory()); + for(FuzzerConfig config:classYaml) { + try { + System.out.println(om.writeValueAsString(config) + "\n"); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + } } public List getExcludeList() { return excludeList; } } + From fee51f004fd02286ca1d9cbc1ece3a6d17e14d32 Mon Sep 17 00:00:00 2001 From: Arthur Chan Date: Tue, 18 Oct 2022 17:34:13 +0100 Subject: [PATCH 6/7] Fix license Signed-off-by: Arthur Chan --- .../introspector/soot/CallGraphGenerator.java | 2 +- .../introspector/soot/yaml/BranchProfile.java | 15 +++++++++++++++ .../fuzz/introspector/soot/yaml/BranchSide.java | 15 +++++++++++++++ .../introspector/soot/yaml/FunctionConfig.java | 15 +++++++++++++++ .../introspector/soot/yaml/FunctionElement.java | 15 +++++++++++++++ .../fuzz/introspector/soot/yaml/FuzzerConfig.java | 15 +++++++++++++++ 6 files changed, 76 insertions(+), 1 deletion(-) diff --git a/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/CallGraphGenerator.java b/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/CallGraphGenerator.java index d0036b210..2dddfa038 100644 --- a/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/CallGraphGenerator.java +++ b/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/CallGraphGenerator.java @@ -173,7 +173,7 @@ protected void internalTransform(String phaseName, Map options) SootMethod tgt = (SootMethod) edge.getTgt(); System.out.println("\t > calls " + tgt + " on Line " + edge.srcStmt().getJavaSourceStartLineNumber()); - element.addFunctionReached(tgt.toString() + "; Line: " + + element.addFunctionReached(tgt.toString() + "; Line: " + edge.srcStmt().getJavaSourceStartLineNumber()); } System.out.println("\n\t Total: " + methodEdges + " external calls.\n"); diff --git a/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/yaml/BranchProfile.java b/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/yaml/BranchProfile.java index 1682fffd8..554c7e97a 100644 --- a/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/yaml/BranchProfile.java +++ b/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/yaml/BranchProfile.java @@ -1,3 +1,18 @@ +// Copyright 2022 Fuzz Introspector Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +/////////////////////////////////////////////////////////////////////////// + package ossf.fuzz.introspector.soot.yaml; public class BranchProfile { diff --git a/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/yaml/BranchSide.java b/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/yaml/BranchSide.java index 647fb4b35..8105b303c 100644 --- a/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/yaml/BranchSide.java +++ b/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/yaml/BranchSide.java @@ -1,3 +1,18 @@ +// Copyright 2022 Fuzz Introspector Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +/////////////////////////////////////////////////////////////////////////// + package ossf.fuzz.introspector.soot.yaml; import java.util.ArrayList; diff --git a/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/yaml/FunctionConfig.java b/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/yaml/FunctionConfig.java index e870dde77..59278c8d9 100644 --- a/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/yaml/FunctionConfig.java +++ b/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/yaml/FunctionConfig.java @@ -1,3 +1,18 @@ +// Copyright 2022 Fuzz Introspector Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +/////////////////////////////////////////////////////////////////////////// + package ossf.fuzz.introspector.soot.yaml; import java.util.ArrayList; diff --git a/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/yaml/FunctionElement.java b/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/yaml/FunctionElement.java index b4038c66c..565e68cbe 100644 --- a/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/yaml/FunctionElement.java +++ b/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/yaml/FunctionElement.java @@ -1,3 +1,18 @@ +// Copyright 2022 Fuzz Introspector Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +/////////////////////////////////////////////////////////////////////////// + package ossf.fuzz.introspector.soot.yaml; import java.util.ArrayList; diff --git a/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/yaml/FuzzerConfig.java b/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/yaml/FuzzerConfig.java index e8b9cd2b2..61b12d004 100644 --- a/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/yaml/FuzzerConfig.java +++ b/frontends/java/soot/src/main/java/ossf/fuzz/introspector/soot/yaml/FuzzerConfig.java @@ -1,3 +1,18 @@ +// Copyright 2022 Fuzz Introspector Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +/////////////////////////////////////////////////////////////////////////// + package ossf.fuzz.introspector.soot.yaml; public class FuzzerConfig { From 620f4b2f9556ee379d964c0b499c6340d0a2bb7e Mon Sep 17 00:00:00 2001 From: Arthur Chan Date: Tue, 18 Oct 2022 17:37:12 +0100 Subject: [PATCH 7/7] Fix readme Signed-off-by: Arthur Chan --- frontends/java/README.md | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/frontends/java/README.md b/frontends/java/README.md index 76609b53e..866e6f815 100644 --- a/frontends/java/README.md +++ b/frontends/java/README.md @@ -2,9 +2,15 @@ This is work in progress. +Download and install java / maven in ubuntu +----------------------------------------- +sudo apt-get install -y openjdk-8-jdk-headless maven + + Using java-callgraph ----------------------------------------- -Depends on OpenJDK+JRE 11.0 or later +Depends on OpenJDK+JRE 8 or later + Depends on https://github.com/gousiosg/java-callgraph, which has compiled and packed as a jar file (javacg-0.1-SNAPSHOT-static.jar) It requires the target source code compiled and packed into jar file. @@ -12,30 +18,30 @@ It requires the target source code compiled and packed into jar file. The resulting call tree are shown in stdout. Example of running: `java -jar javacg-0.1-SNAPSHOT-static.jar ` ------------------------------------------- Using IBM's WALA ------------------------------------------ -Depends on OpenJDK+JRE 11.0 or later +Depends on OpenJDK+JRE 8 or later + Depends on Maven 3.3 or later -Depends on IBM's WALA https://github.com/wala/WALA, the maven build process will automatically -download and pack the WALA jar libraries. + +Depends on IBM's WALA https://github.com/wala/WALA, the maven build process will automatically download and pack the WALA jar libraries. The resulting call tree are shown in stdout. Example of running: `./run.sh <-j | --jarFile> <-e | --entryclass> ` ------------------------------------------- Using Soot ------------------------------------------ -Depends on OpenJDK+JRE 11.0 or later +Depends on OpenJDK+JRE 8 or later + Depends on Maven 3.3 or later -Depends on IBM's WALA https://github.com/soot-oss/soot, the maven build process will automatically -download and pack the Soot jar libraries. + +Depends on IBM's WALA https://github.com/soot-oss/soot, the maven build process will automatically download and pack the Soot jar libraries. The resulting call tree are shown in stdout. -Example of running: `./run.sh <-j | --jarFile> <-c | --entryclass> ` <-m | --entrymethod ` +Example of running: `./run.sh <-j | --jarFile> <-c | --entryclass> <-m | --entrymethod `