Skip to content

Commit

Permalink
sootUp:boomerang:progress on custom entrypoint
Browse files Browse the repository at this point in the history
  • Loading branch information
swissiety committed Nov 26, 2024
1 parent 6ec3dc3 commit fdae53c
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 32 deletions.
62 changes: 37 additions & 25 deletions boomerangPDS/src/test/java/test/FrameworkScopeFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import soot.jimple.JimpleBody;
import soot.options.Options;
import sootup.ScopedAnalysisInputLocation;
import sootup.callgraph.CallGraphAlgorithm;
import sootup.callgraph.ClassHierarchyAnalysisAlgorithm;
import sootup.core.inputlocation.AnalysisInputLocation;
import sootup.core.model.SootClassMember;
Expand Down Expand Up @@ -239,26 +240,25 @@ private static String getTargetClass(SootMethod sootTestMethod, String testCaseC
return sootClass.toString();
}


/** SootUp Framework setup TODO: [ms] refactor me! */
private static FrameworkScope getSootUpFrameworkScope(
String pathStr,
String className,
String methodName,
String applicationDir,
String customEntrypointMethodName,
List<String> includedPackages,
List<String> excludedPackages) {

// configure interceptors
// TODO: check if the interceptor needs a reset in between runs
List<BodyInterceptor> bodyInterceptors =
new ArrayList<>(BytecodeBodyInterceptors.Default.getBodyInterceptors());
bodyInterceptors.add(
new BoomerangPreInterceptor()); // TODO: check if the interceptor needs a reset in between
// runs?
bodyInterceptors.add(new BoomerangPreInterceptor());

// configure AnalysisInputLocations
List<AnalysisInputLocation> inputLocations = new ArrayList<>();

if (applicationDir != null) {
if (customEntrypointMethodName != null) {
JavaClassPathAnalysisInputLocation processDirInputLocation =
new JavaClassPathAnalysisInputLocation(pathStr, SourceType.Application, bodyInterceptors);
}
Expand All @@ -279,30 +279,42 @@ private static FrameworkScope getSootUpFrameworkScope(
List<MethodSignature> entypointSignatures;
List<JavaSootMethod> eps = Lists.newArrayList();

if (methodName != null) {
// build entrypoint

/*
String targetClassAsJimpleStr = ""; print jimple via soot and adapt to a template
new JimpleStringAnalysisInputLocation() // currently in sootup:develop branch
*/
throw new UnsupportedOperationException("implement me!");

} else {
// collect entrypoints
for (JavaSootClass sootClass : javaView.getClasses()) {
String scStr = sootClass.toString();
if (scStr.equals(className) || (scStr.contains(className + "$"))) {
eps.addAll(sootClass.getMethods());
if (customEntrypointMethodName == null) {
// collect entrypoints
for (JavaSootClass sootClass : javaView.getClasses()) {
String scStr = sootClass.toString();
if (scStr.equals(className) || (scStr.contains(className + "$"))) {
eps.addAll(sootClass.getMethods());
}
}

} else {
// build entrypoint
String jimpleClassStr = "class dummyClass\n" +
"{\n" +
" public static void main(java.lang.String[])\n" +
" {\n" +
" "+ className +" dummyObj;\n" +
" java.lang.String[] l0;\n" +
" l0 := @parameter0: java.lang.String[];\n" +
" dummyObj = new "+ className +";\n" +
" virtualinvoke dummyObj.<"+ className +": void "+customEntrypointMethodName+"()>();\n" +
" return;\n" +
" }\n" +
"}";

// new JimpleStringAnalysisInputLocation(jimpleClassStr) // currently in sootup:develop branch

throw new UnsupportedOperationException("implement me!");
}
}

// initialize CallGraphAlgorithm
// initialize CallGraphAlgorithm
entypointSignatures =
eps.stream().map(SootClassMember::getSignature).collect(Collectors.toList());
ClassHierarchyAnalysisAlgorithm cha = new ClassHierarchyAnalysisAlgorithm(javaView);
cg = cha.initialize(entypointSignatures);

// TODO: adapt if: --> use spark when available
CallGraphAlgorithm cga = customEntrypointMethodName == null? new ClassHierarchyAnalysisAlgorithm(javaView) : new ClassHierarchyAnalysisAlgorithm(javaView);
cg = cga.initialize(entypointSignatures);

return new SootUpFrameworkScope(javaView, cg, entypointSignatures);
}
Expand Down
14 changes: 7 additions & 7 deletions idealPDS/src/test/java/test/IDEALTestingFramework.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,20 @@
import typestate.TransitionFunction;
import typestate.finiteautomata.TypeStateMachineWeightFunctions;

public class IDEALTestingFramework extends AbstractTestingFramework {
public class IDEALTestingFramework extends AbstractTestingFramework {
private static final boolean FAIL_ON_IMPRECISE = false;
protected StoreIDEALResultHandler<TransitionFunction> resultHandler =
new StoreIDEALResultHandler<>();
protected CallGraph callGraph;
protected DataFlowScope dataFlowScope;

@Override
protected void initializeWithEntryPoint() {
scopeFactory =
FrameworkScopeFactory.init(buildClassPath(), getIncludedList(), getExludedPackageList());
}
@Override
protected void initializeWithEntryPoint() {
scopeFactory =
FrameworkScopeFactory.init(buildClassPath(), getIncludedList(), getExludedPackageList());
}

@Override
@Override
protected void analyze() {
// FIXME: [ms] implement me
throw new UnsupportedOperationException("Not supported yet.");
Expand Down

0 comments on commit fdae53c

Please sign in to comment.