Skip to content

Commit f95deab

Browse files
authored
Merge pull request #2 from secure-software-engineering/boomerang-3.x-migration
Boomerang 3.x migration
2 parents e9061a4 + 6c12d2a commit f95deab

File tree

12 files changed

+448
-327
lines changed

12 files changed

+448
-327
lines changed

de.fraunhofer.iem.secucheck.analysis.releng/.attach_pid66076

Whitespace-only changes.

de.fraunhofer.iem.secucheck.analysis.sample/src/main/java/de/fraunhofer/iem/secucheck/analysis/sample/Main.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ private static void runDemoSet3(SecucheckAnalysis secucheckAnalysis,
143143
getTaintFlowQuery4()));
144144

145145
runAnalysisQuery(secucheckAnalysis, compositeOfFirst, 1, null);
146-
runAnalysisQuery(secucheckAnalysis, compositeOfFirstTwo, 2, null);
147-
runAnalysisQuery(secucheckAnalysis, compositeOfFirstThree, 3, null);
148-
runAnalysisQuery(secucheckAnalysis, compositeOfAll, 4, null);
146+
runAnalysisQuery(secucheckAnalysis, compositeOfFirstTwo, 12, null);
147+
runAnalysisQuery(secucheckAnalysis, compositeOfFirstThree, 13, null);
148+
runAnalysisQuery(secucheckAnalysis, compositeOfAll, 14, null);
149149
}
150150

151151
private static void runAnalysisQuery(SecucheckAnalysis secucheckAnalysis,

de.fraunhofer.iem.secucheck.analysis/pom.xml

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,31 +21,47 @@
2121
</properties>
2222

2323
<dependencies>
24+
25+
<!--
26+
2427
<dependency>
2528
<groupId>de.fraunhofer.iem</groupId>
2629
<artifactId>boomerangPDS</artifactId>
2730
<version>2.2</version>
2831
</dependency>
32+
33+
-->
34+
2935
<dependency>
3036
<groupId>ca.mcgill.sable</groupId>
3137
<artifactId>soot</artifactId>
3238
<version>3.2.0</version>
3339
</dependency>
40+
41+
<!--
42+
3443
<dependency>
3544
<groupId>heros</groupId>
3645
<artifactId>heros</artifactId>
3746
<version>1.1.0</version>
3847
</dependency>
48+
49+
-->
50+
3951
<dependency>
4052
<groupId>org.apache.logging.log4j</groupId>
4153
<version>2.11.0</version>
4254
<artifactId>log4j-api</artifactId>
4355
</dependency>
56+
4457
<dependency>
4558
<groupId>org.apache.logging.log4j</groupId>
4659
<version>2.11.0</version>
4760
<artifactId>log4j-core</artifactId>
4861
</dependency>
62+
63+
<!--
64+
4965
<dependency>
5066
<groupId>de.fraunhofer.iem</groupId>
5167
<artifactId>synchronizedPDS</artifactId>
@@ -66,6 +82,23 @@
6682
<groupId>org.slf4j</groupId>
6783
<artifactId>slf4j-api</artifactId>
6884
</dependency>
85+
86+
-->
87+
88+
<!-- New tags for migration -->
89+
90+
<dependency>
91+
<groupId>de.fraunhofer.iem</groupId>
92+
<artifactId>boomerangScope</artifactId>
93+
<version>3.1.1</version>
94+
</dependency>
95+
96+
<dependency>
97+
<groupId>de.fraunhofer.iem</groupId>
98+
<artifactId>boomerangPDS</artifactId>
99+
<version>3.1.1</version>
100+
</dependency>
101+
69102
</dependencies>
70103

71104
<repositories>
@@ -85,10 +118,18 @@
85118
<enabled>false</enabled>
86119
</snapshots>
87120
</repository>
121+
122+
<!-- New tags for migration -->
123+
<repository>
124+
<id>github</id>
125+
<name>CodeShield-Security</name>
126+
<url>https://maven.pkg.github.com/CodeShield-Security/SPDS/</url>
127+
</repository>
128+
88129
</repositories>
89130

90131
<build>
91-
<sourceDirectory>../de.fraunhofer.iem.secucheck.analysis/src</sourceDirectory>
132+
<!-- <sourceDirectory>../de.fraunhofer.iem.secucheck.analysis/src</sourceDirectory> -->
92133
<plugins>
93134
<plugin>
94135
<artifactId>maven-compiler-plugin</artifactId>

de.fraunhofer.iem.secucheck.analysis/src/main/java/de/fraunhofer/iem/secucheck/analysis/SecucheckTaintAnalysisBase.java

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
11
package de.fraunhofer.iem.secucheck.analysis;
22

33
import java.util.ArrayList;
4+
import java.util.Collection;
5+
import java.util.Collections;
46
import java.util.HashMap;
57
import java.util.Iterator;
68
import java.util.LinkedList;
79
import java.util.List;
810
import java.util.Map;
911
import java.util.concurrent.locks.ReentrantLock;
1012

11-
import boomerang.preanalysis.BoomerangPretransformer;
13+
import boomerang.BackwardQuery;
14+
import boomerang.Boomerang;
15+
import boomerang.DefaultBoomerangOptions;
16+
import boomerang.Query;
17+
import boomerang.results.BackwardBoomerangResults;
18+
import boomerang.scene.AnalysisScope;
19+
import boomerang.scene.SootDataFlowScope;
20+
import boomerang.scene.Statement;
21+
import boomerang.scene.Val;
22+
import boomerang.scene.jimple.BoomerangPretransformer;
23+
import boomerang.scene.jimple.SootCallGraph;
1224
import de.fraunhofer.iem.secucheck.analysis.internal.CompositeTaintFlowAnalysis;
1325
import de.fraunhofer.iem.secucheck.analysis.query.CompositeTaintFlowQueryImpl;
1426
import de.fraunhofer.iem.secucheck.analysis.query.EntryPoint;
@@ -32,13 +44,13 @@
3244
import soot.util.cfgcmd.CFGToDotGraph;
3345
import soot.util.dot.DotGraph;
3446
import test.core.selfrunning.ImprecisionException;
47+
import wpds.impl.Weight;
3548

3649
public abstract class SecucheckTaintAnalysisBase implements SecucheckAnalysis {
3750

3851
protected final ReentrantLock lock;
3952

4053
protected long analysisTime;
41-
protected BiDiInterproceduralCFG<Unit, SootMethod> icfg;
4254

4355
private OS os;
4456
private String appClassPath;
@@ -180,6 +192,8 @@ private SecucheckTaintAnalysisResult analyze() {
180192
Transform transform = new Transform("wjtp.ifds", createAnalysisTransformer());
181193
PackManager.v().getPack("wjtp").add(transform);
182194
PackManager.v().getPack("cg").apply();
195+
196+
BoomerangPretransformer.v().apply();
183197
PackManager.v().getPack("wjtp").apply();
184198
if (resultListener != null) {
185199
resultListener.reportCompleteResult(this.result);
@@ -189,18 +203,17 @@ private SecucheckTaintAnalysisResult analyze() {
189203

190204
private SceneTransformer createAnalysisTransformer() throws ImprecisionException {
191205
return new SceneTransformer() {
192-
protected void internalTransform(String phaseName, Map options) {
193-
BoomerangPretransformer.v().apply();
194-
icfg = new JimpleBasedInterproceduralCFG(true);
206+
protected void internalTransform(String phaseName,
207+
@SuppressWarnings("rawtypes") Map options) {
208+
195209
try {
196210
executeAnalysis();
197211
} catch (Exception ex) {
198212
ex.printStackTrace();
199213
}
200214
}
201215
};
202-
}
203-
216+
}
204217

205218
private static void drawCallGraph(CallGraph callGraph){
206219
DotGraph dot = new DotGraph("callgraph");
@@ -218,16 +231,24 @@ private static void drawCallGraph(CallGraph callGraph){
218231

219232
private void executeAnalysis() throws Exception {
220233

234+
SootCallGraph sootCallGraph = new SootCallGraph();
235+
221236
// For dumping the call graph for debugging purposes.
222237
//drawCallGraph(Scene.v().getCallGraph());
223238

224239
for (CompositeTaintFlowQueryImpl flowQuery : this.flowQueries) {
240+
225241
if (resultListener != null && resultListener.isCancelled()) {
226242
break;
227243
}
228-
Analysis analysis = new CompositeTaintFlowAnalysis(icfg, flowQuery, resultListener);
244+
245+
Analysis analysis = new CompositeTaintFlowAnalysis(sootCallGraph, flowQuery, resultListener);
229246
CompositeTaintFlowQueryResult singleResult = (CompositeTaintFlowQueryResult) analysis.run();
230-
this.result.addResult(flowQuery, singleResult);
247+
248+
if (singleResult.size() != 0) {
249+
this.result.addResult(flowQuery, singleResult);
250+
}
251+
231252
if (resultListener != null) {
232253
resultListener.reportCompositeFlowResult((CompositeTaintFlowQueryResult) singleResult);
233254
}

de.fraunhofer.iem.secucheck.analysis/src/main/java/de/fraunhofer/iem/secucheck/analysis/internal/CompositeTaintFlowAnalysis.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import boomerang.callgraph.ObservableICFG;
66
import boomerang.callgraph.ObservableStaticICFG;
7+
import boomerang.scene.jimple.SootCallGraph;
78
import de.fraunhofer.iem.secucheck.analysis.Analysis;
89
import de.fraunhofer.iem.secucheck.analysis.query.CompositeTaintFlowQuery;
910
import de.fraunhofer.iem.secucheck.analysis.query.Method;
@@ -20,14 +21,14 @@
2021
public class CompositeTaintFlowAnalysis implements Analysis {
2122

2223
private final CompositeTaintFlowQuery flowQuery;
23-
private final ObservableICFG<Unit, SootMethod> icfg;
24+
private final SootCallGraph sootCallGraph;
2425
private final AnalysisResultListener resultListener;
2526

26-
public CompositeTaintFlowAnalysis(BiDiInterproceduralCFG<Unit, SootMethod> icfg,
27+
public CompositeTaintFlowAnalysis(SootCallGraph sootCallGraph,
2728
CompositeTaintFlowQuery flowQuery, AnalysisResultListener resultListener)
2829
throws Exception {
2930
this.flowQuery = flowQuery;
30-
this.icfg = new ObservableStaticICFG(icfg);
31+
this.sootCallGraph = sootCallGraph;
3132
this.resultListener = resultListener;
3233
// Resolve all methods. This is necessary if a flow participant is not part of
3334
// the user code...
@@ -45,7 +46,7 @@ public AnalysisResult run() {
4546
if (this.resultListener != null && this.resultListener.isCancelled()) {
4647
break;
4748
}
48-
Analysis analysis = new SingleFlowAnalysis(originalFlow, icfg, this.resultListener);
49+
Analysis analysis = new SingleFlowAnalysis(originalFlow, sootCallGraph, this.resultListener);
4950
TaintFlowQueryResult retResult = (TaintFlowQueryResult) analysis.run();
5051
if (retResult.size() == 0) {
5152
result.clear();

0 commit comments

Comments
 (0)