Skip to content

Commit c2010a6

Browse files
committed
Merge branch 'develop' of github.com:secure-software-engineering/FlowDroid into develop
2 parents d8359b8 + bda5f26 commit c2010a6

3 files changed

Lines changed: 24 additions & 17 deletions

File tree

soot-infoflow-android/src/soot/jimple/infoflow/android/iccta/IccRedirectionCreator.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ protected SootMethod generateRedirectMethodForStartActivityForResult(SootClass o
181181
dummyMainClass.addMethod(newSM);
182182
final JimpleBody b = Jimple.v().newBody(newSM);
183183
newSM.setActiveBody(b);
184+
newSM.addTag(SimulatedCodeElementTag.TAG);
184185

185186
LocalGenerator lg = new LocalGenerator(b);
186187

@@ -228,13 +229,14 @@ protected SootMethod generateRedirectMethodForStartActivityForResult(SootClass o
228229
protected SootMethod generateRedirectMethod(SootClass wrapper) {
229230
SootMethod targetDummyMain = componentToEntryPoint.getEntryPoint(wrapper);
230231
if (targetDummyMain == null) {
231-
logger.warn(String.format("Destination component %s has no dummy main method", wrapper.getName()));
232+
logger.warn("Destination component {} has no dummy main method", wrapper.getName());
232233
return null;
233234
}
234235

235236
String newSM_name = "redirector" + num++;
236237
SootMethod newSM = Scene.v().makeSootMethod(newSM_name, Collections.<Type>singletonList(INTENT_TYPE),
237238
VoidType.v(), Modifier.STATIC | Modifier.PUBLIC);
239+
newSM.addTag(SimulatedCodeElementTag.TAG);
238240
dummyMainClass.addMethod(newSM);
239241
JimpleBody b = Jimple.v().newBody(newSM);
240242
newSM.setActiveBody(b);
@@ -260,12 +262,13 @@ protected SootMethod generateRedirectMethod(SootClass wrapper) {
260262
protected SootMethod generateRedirectMethodForStartActivity(SootClass wrapper) {
261263
SootMethod targetDummyMain = componentToEntryPoint.getEntryPoint(wrapper);
262264
if (targetDummyMain == null) {
263-
logger.warn(String.format("Destination component %s has no dummy main method", wrapper.getName()));
265+
logger.warn("Destination component {} has no dummy main method", wrapper.getName());
264266
return null;
265267
}
266268
String newSM_name = "redirector" + num++;
267269
SootMethod newSM = Scene.v().makeSootMethod(newSM_name, Collections.<Type>singletonList(INTENT_TYPE),
268270
VoidType.v(), Modifier.STATIC | Modifier.PUBLIC);
271+
newSM.addTag(SimulatedCodeElementTag.TAG);
269272
dummyMainClass.addMethod(newSM);
270273
JimpleBody b = Jimple.v().newBody(newSM);
271274
newSM.setActiveBody(b);
@@ -291,12 +294,12 @@ protected SootMethod generateRedirectMethodForStartActivity(SootClass wrapper) {
291294
protected SootMethod generateRedirectMethodForBindService(SootClass serviceConnection, SootClass destComp) {
292295
ServiceEntryPointInfo entryPointInfo = (ServiceEntryPointInfo) componentToEntryPoint.get(destComp);
293296
if (entryPointInfo == null) {
294-
logger.warn(String.format("Destination component %s has no dummy main method", destComp.getName()));
297+
logger.warn("Destination component {} has no dummy main method", destComp.getName());
295298
return null;
296299
}
297300
SootMethod targetDummyMain = entryPointInfo.getEntryPoint();
298301
if (targetDummyMain == null) {
299-
logger.warn(String.format("Destination component %s has no dummy main method", destComp.getName()));
302+
logger.warn("Destination component {} has no dummy main method", destComp.getName());
300303
return null;
301304
}
302305
String newSM_name = "redirector" + num++;
@@ -307,6 +310,7 @@ protected SootMethod generateRedirectMethodForBindService(SootClass serviceConne
307310

308311
SootMethod newSM = Scene.v().makeSootMethod(newSM_name, newSM_parameters, VoidType.v(),
309312
Modifier.STATIC | Modifier.PUBLIC);
313+
newSM.addTag(SimulatedCodeElementTag.TAG);
310314
dummyMainClass.addMethod(newSM);
311315
JimpleBody b = Jimple.v().newBody(newSM);
312316
newSM.setActiveBody(b);
@@ -342,7 +346,7 @@ protected SootMethod generateRedirectMethodForBindService(SootClass serviceConne
342346
Local iLocal1 = lg.generateLocal(RefType.v("android.content.ComponentName"));
343347
b.getUnits().add(Jimple.v().newAssignStmt(iLocal1, NullConstant.v()));
344348

345-
List<Value> args = new ArrayList<Value>();
349+
List<Value> args = new ArrayList<>();
346350
args.add(iLocal1);
347351
args.add(ibinderLocal);
348352
SootClass sc = Scene.v().getSootClass(originActivityParameterLocal.getType().toString());
@@ -363,6 +367,7 @@ protected SootMethod generateRedirectMethodForContentProvider(Stmt iccStmt, Soot
363367
String newSM_name = "redirector" + num++;
364368
SootMethod newSM = Scene.v().makeSootMethod(newSM_name, iccMethod.getParameterTypes(),
365369
iccMethod.getReturnType(), Modifier.STATIC | Modifier.PUBLIC);
370+
newSM.addTag(SimulatedCodeElementTag.TAG);
366371
dummyMainClass.addMethod(newSM);
367372
JimpleBody b = Jimple.v().newBody(newSM);
368373
newSM.setActiveBody(b);
@@ -419,7 +424,7 @@ protected void insertRedirectMethodCallAfterIccMethod(IccLink link, SootMethod r
419424

420425
// specially deal with startActivityForResult since they have two
421426
// parameters
422-
List<Value> args = new ArrayList<Value>();
427+
List<Value> args = new ArrayList<>();
423428
if (callee.getNumberedSubSignature().equals(subsigStartActivityForResult)) {
424429
InstanceInvokeExpr iiexpr = (InstanceInvokeExpr) fromStmt.getInvokeExpr();
425430
args.add(iiexpr.getBase());
@@ -451,8 +456,9 @@ protected void insertRedirectMethodCallAfterIccMethod(IccLink link, SootMethod r
451456
redirectCallU.addTag(SimulatedCodeElementTag.TAG);
452457
units.insertAfter(redirectCallU, link.getFromU());
453458
instrumentedUnits.put(body, redirectCallU);
454-
if (instrumentationCallback != null)
459+
if (instrumentationCallback != null) {
455460
instrumentationCallback.onRedirectorCallInserted(link, redirectCallU, redirectMethod);
461+
}
456462

457463
// remove the real ICC methods call stmt
458464
// link.getFromSM().retrieveActiveBody().getUnits().remove(link.getFromU());

soot-infoflow/src/soot/jimple/infoflow/codeOptimization/InterproceduralConstantValuePropagator.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
import soot.jimple.toolkits.scalar.UnconditionalBranchFolder;
7070
import soot.jimple.toolkits.scalar.UnreachableCodeEliminator;
7171
import soot.options.Options;
72-
import soot.tagkit.SyntheticTag;
7372
import soot.toolkits.exceptions.ThrowAnalysis;
7473
import soot.toolkits.exceptions.ThrowableSet;
7574
import soot.toolkits.exceptions.UnitThrowAnalysis;
@@ -481,7 +480,7 @@ private void propagateReturnValueIntoCallers(SootMethod sm) {
481480
}
482481

483482
private void fixExceptions(SootMethod caller, Unit callSite) {
484-
fixExceptions(caller, callSite, new HashSet<SootClass>());
483+
fixExceptions(caller, callSite, new HashSet<>());
485484
}
486485

487486
private void fixExceptions(SootMethod caller, Unit callSite, Set<SootClass> doneSet) {
@@ -496,6 +495,7 @@ private void fixExceptions(SootMethod caller, Unit callSite, Set<SootClass> done
496495
if (exceptionClass == null) {
497496
exceptionClass = Scene.v().makeSootClass("FLOWDROID_EXCEPTIONS", Modifier.PUBLIC);
498497
exceptionClass.setSuperclass(Scene.v().getSootClass("java.lang.Object"));
498+
exceptionClass.addTag(SimulatedCodeElementTag.TAG);
499499
Scene.v().addClass(exceptionClass);
500500
}
501501

@@ -544,9 +544,10 @@ protected SootMethod createDummyMainInternal() {
544544
protected void createEmptyMainMethod() {
545545
// Make sure that we don't end up with duplicate method names
546546
int methodIdx = exceptionThrowers.size();
547+
String baseName = "throw_" + t.getException().getName().replaceAll("\\W+", "_") + "_";
547548
String methodName;
548549
do {
549-
methodName = "throw" + methodIdx++;
550+
methodName = baseName + methodIdx++;
550551
} while (exceptionClass.declaresMethodByName(methodName));
551552

552553
// Create the new method
@@ -585,6 +586,7 @@ public Collection<SootField> getAdditionalFields() {
585586
Stmt throwCall = Jimple.v().newInvokeStmt(Jimple.v().newStaticInvokeExpr(thrower.makeRef()));
586587
throwCall.addTag(SimulatedCodeElementTag.TAG);
587588
caller.getActiveBody().getUnits().insertBefore(throwCall, callSite);
589+
588590
}
589591
}
590592

@@ -597,7 +599,7 @@ public Collection<SootField> getAdditionalFields() {
597599
* side-effects or calls a sink method, otherwise false.
598600
*/
599601
private boolean hasSideEffectsOrCallsSink(SootMethod method) {
600-
return hasSideEffectsOrCallsSink(method, new HashSet<SootMethod>());
602+
return hasSideEffectsOrCallsSink(method, new HashSet<>());
601603
}
602604

603605
/**
@@ -781,7 +783,7 @@ private boolean methodIsAndroidStub(SootMethod method) {
781783
// Check for super class constructor invocation
782784
if (!(method.getDeclaringClass().hasSuperclass()
783785
&& callee.getDeclaringClass() == method.getDeclaringClass().getSuperclass()
784-
&& callee.getName().equals("<init>")))
786+
&& callee.isConstructor()))
785787
return false;
786788
} else if (!(u instanceof ThrowStmt))
787789
return false;
@@ -817,7 +819,8 @@ private void propagateConstantsIntoCallee(SootMethod sm) {
817819
if (excludedMethods != null && icfg.isReachable(callSite)) {
818820
SootMethod caller = icfg.getMethodOf(callSite);
819821
// synthetic methods e.g. created by FlowDroid are excluded by default
820-
if (excludedMethods.contains(caller) || caller.hasTag(SyntheticTag.NAME)) {
822+
if (excludedMethods.contains(caller) || caller.hasTag(SimulatedCodeElementTag.TAG_NAME)) {
823+
logger.trace("Ignoring calls from {}", caller);
821824
continue;
822825
}
823826
}

soot-infoflow/src/soot/jimple/infoflow/data/pathBuilders/BatchPathBuilder.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ public void computeTaintPaths(Set<AbstractionAtSink> res) {
4040
// Build the next batch
4141
while (batch.size() < this.batchSize && resIt.hasNext())
4242
batch.add(resIt.next());
43-
logger.info(
44-
String.format("Running path reconstruction batch %d with %d elements", batchId++, batch.size()));
43+
logger.info("Running path reconstruction batch {} with {} elements", batchId++, batch.size());
4544

4645
// Run the next batch
4746
innerBuilder.reset();
@@ -120,8 +119,7 @@ public void addStatusListener(IMemoryBoundedSolverStatusNotification listener) {
120119
* Sets the number of paths that shall be part of one batch, i.e., that shall be
121120
* forwarded to the inner path builder at the same time
122121
*
123-
* @param batchSize
124-
* The number of paths in one batch
122+
* @param batchSize The number of paths in one batch
125123
*/
126124
public void setBatchSize(int batchSize) {
127125
this.batchSize = batchSize;

0 commit comments

Comments
 (0)