Skip to content

Commit

Permalink
Demo 1.3, done!
Browse files Browse the repository at this point in the history
+several features
  • Loading branch information
chaos-warzh authored and zhangt2333 committed May 28, 2024
1 parent 6e0104f commit 1548d49
Show file tree
Hide file tree
Showing 12 changed files with 252 additions and 249 deletions.
5 changes: 1 addition & 4 deletions src/main/java/pascal/taie/analysis/pta/PointerAnalysis.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,13 @@
import pascal.taie.analysis.pta.plugin.EntryPointHandler;
import pascal.taie.analysis.pta.plugin.Plugin;
import pascal.taie.analysis.pta.plugin.ReferenceHandler;
import pascal.taie.analysis.pta.plugin.ResultProcessor;
import pascal.taie.analysis.pta.plugin.ThreadHandler;
import pascal.taie.analysis.pta.plugin.exception.ExceptionAnalysis;
import pascal.taie.analysis.pta.plugin.invokedynamic.InvokeDynamicAnalysis;
import pascal.taie.analysis.pta.plugin.invokedynamic.Java9StringConcatHandler;
import pascal.taie.analysis.pta.plugin.invokedynamic.LambdaAnalysis;
import pascal.taie.analysis.pta.plugin.natives.NativeModeller;
import pascal.taie.analysis.pta.plugin.reflection.ReflectionAnalysis;
import pascal.taie.analysis.pta.plugin.taint.DCTaintAnalysis;
import pascal.taie.analysis.pta.plugin.taint.TaintAnalysis;
import pascal.taie.analysis.pta.toolkit.CollectionMethods;
import pascal.taie.analysis.pta.toolkit.mahjong.Mahjong;
Expand Down Expand Up @@ -153,8 +151,7 @@ private static void setPlugin(Solver solver, AnalysisOptions options) {
plugin.addPlugin(new InvokeDynamicAnalysis());
}
if (options.getString("taint-config") != null) {
// plugin.addPlugin(new TaintAnalysis());
plugin.addPlugin(new DCTaintAnalysis());
plugin.addPlugin(new TaintAnalysis());
}
// plugin.addPlugin(new ResultProcessor());
// add plugins specified in options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,7 @@ public Set<Obj> getPointsToSet(Var var) {
if (!propTypes.isAllowed(var)) {
return Set.of();
}
// return varPointsTo.computeIfAbsent(var, v ->
return varPointsTo.compute(var, (__, v) ->
return varPointsTo.computeIfAbsent(var, v ->
removeContexts(csManager.getCSVarsOf(var)
.stream()
.flatMap(Pointer::objects)));
Expand All @@ -207,8 +206,7 @@ public Set<Obj> getPointsToSet(Var base, JField field) {
return Set.of();
}
// TODO - properly handle non-exist base.field
// return ifieldPointsTo.computeIfAbsent(new Pair<>(base, field), p ->
return ifieldPointsTo.compute(new Pair<>(base, field), (k, v) ->
return ifieldPointsTo.computeIfAbsent(new Pair<>(base, field), p ->
removeContexts(csManager.getCSVarsOf(base)
.stream()
.flatMap(Pointer::objects)
Expand Down Expand Up @@ -272,8 +270,7 @@ public Set<Obj> getPointsToSet(Var base, Var index) {
logger.warn("{} is not an array", base);
return Set.of();
}
// return arrayPointsTo.computeIfAbsent(base, b ->
return arrayPointsTo.compute(base, (b, __) ->
return arrayPointsTo.computeIfAbsent(base, b ->
removeContexts(csManager.getCSVarsOf(b)
.stream()
.flatMap(Pointer::objects)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,20 @@ public void setPointsToSet(PointsToSet pointsToSet) {
this.pointsToSet = pointsToSet;
}

@Override
public void rmFromPointsToIf(Predicate<CSObj> predicate) {
if (pointsToSet != null) {
pointsToSet.removeIf(predicate);
}
}

@Override
public void rmFromOutEdgesIf(Predicate<PointerFlowEdge> predicate) {
if (! outEdges.isEmpty()) {
outEdges.removeIf(predicate);
}
}

@Override
public void addFilter(Predicate<CSObj> filter) {
if (filters.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ public interface Pointer extends Indexable {
@Nullable
PointsToSet getPointsToSet();

void rmFromPointsToIf(Predicate<CSObj> predicate);

void rmFromOutEdgesIf(Predicate<PointerFlowEdge> predicate);

/**
* Sets the associated points-to set of this pointer.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ private void stop() {
/**
* Processes work list entries until the work list is empty.
*/
public void analyze() {
private void analyze() {
while (!workList.isEmpty() && !isTimeout) {
// phase starts
while (!workList.isEmpty() && !isTimeout) {
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/pascal/taie/analysis/pta/plugin/CompositePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ private void addPlugin(Plugin plugin, List<Plugin> plugins,
}
}

public void clearAllPlugins() {
allPlugins.clear();
onNewPointsToSetPlugins.clear();
onNewCallEdgePlugins.clear();
onNewMethodPlugins.clear();
onNewStmtPlugins.clear();
onNewCSMethodPlugins.clear();
onUnresolvedCallPlugins.clear();
}

@Override
public void setSolver(Solver solver) {
allPlugins.forEach(p -> p.setSolver(solver));
Expand Down

This file was deleted.

123 changes: 0 additions & 123 deletions src/main/java/pascal/taie/analysis/pta/plugin/taint/DynamicConfig.java

This file was deleted.

Loading

0 comments on commit 1548d49

Please sign in to comment.