Skip to content

Commit ee14745

Browse files
committed
fixed some bugs, improved performance, and added a test case
1 parent d427148 commit ee14745

6 files changed

Lines changed: 46 additions & 17 deletions

File tree

soot-infoflow-android/src/soot/jimple/infoflow/android/callbacks/AbstractCallbackAnalyzer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ protected void analyzeMethodForViewPagers(SootClass clazz, SootMethod method) {
528528
SootMethod getItem = rt.getSootClass().getMethodUnsafe("android.support.v4.app.Fragment getItem(int)");
529529
if (getItem == null)
530530
getItem = rt.getSootClass().getMethodUnsafe("androidx.fragment.app.Fragment getItem(int)");
531-
if (getItem == null)
531+
if (getItem == null || !getItem.isConcrete())
532532
continue;
533533

534534
Body b = getItem.retrieveActiveBody();

soot-infoflow-android/src/soot/jimple/infoflow/android/callbacks/DefaultCallbackAnalyzer.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,13 @@ private void analyzeRechableMethods(SootClass lifecycleElement, List<MethodOrMet
230230
filter.setReachableMethods(rm);
231231

232232
SootMethod method = reachableMethods.next().method();
233-
analyzeMethodForCallbackRegistrations(lifecycleElement, method);
234-
analyzeMethodForDynamicBroadcastReceiver(method);
235-
analyzeMethodForServiceConnection(method);
236-
analyzeMethodForFragmentTransaction(lifecycleElement, method);
237-
analyzeMethodForViewPagers(lifecycleElement, method);
233+
if (method.isConcrete()) {
234+
analyzeMethodForCallbackRegistrations(lifecycleElement, method);
235+
analyzeMethodForDynamicBroadcastReceiver(method);
236+
analyzeMethodForServiceConnection(method);
237+
analyzeMethodForFragmentTransaction(lifecycleElement, method);
238+
analyzeMethodForViewPagers(lifecycleElement, method);
239+
}
238240
}
239241
}
240242

soot-infoflow-android/src/soot/jimple/infoflow/android/entryPointCreators/components/AbstractComponentEntryPointCreator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ public void assignIntent(SootClass hostComponent, SootMethod method, int indexOf
274274
* RuntimeException: couldn't find method getIntent(*) in
275275
* com.google.android.gcm.GCMBroadcastReceiver
276276
*/
277-
SootMethod m = hostComponent.getMethodByName("getIntent");
277+
SootMethod m = hostComponent.getMethod("android.content.Intent getIntent()");
278278
if (stmt.getTag(SimulatedCodeElementTag.TAG_NAME) != null) {
279279
if (stmt.getInvokeExpr().getMethod().equals(m))
280280
break;

soot-infoflow-android/src/soot/jimple/infoflow/android/resources/LayoutFileParser.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,8 @@ private void parseIncludeAttributes(String layoutFile, AXmlNode rootNode) {
306306
return;
307307
}
308308
if (!(targetRes instanceof StringResource)) {
309-
logger.warn("Invalid target node for include tag in layout XML, was %s",
310-
targetRes.getClass().getName());
309+
logger.warn(String.format("Invalid target node for include tag in layout XML, was %s",
310+
targetRes.getClass().getName()));
311311
return;
312312
}
313313
String targetFile = ((StringResource) targetRes).getValue();

soot-infoflow-android/src/soot/jimple/infoflow/android/source/AndroidSourceSinkManager.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@
2626
import soot.SootField;
2727
import soot.SootMethod;
2828
import soot.Unit;
29+
import soot.Value;
2930
import soot.jimple.AssignStmt;
3031
import soot.jimple.FieldRef;
3132
import soot.jimple.IntConstant;
3233
import soot.jimple.InvokeExpr;
34+
import soot.jimple.NullConstant;
3335
import soot.jimple.Stmt;
3436
import soot.jimple.StringConstant;
3537
import soot.jimple.infoflow.InfoflowConfiguration.LayoutMatchingMode;
@@ -204,7 +206,7 @@ else if (assign.getRightOp() instanceof FieldRef) {
204206
if (tag instanceof IntegerConstantValueTag)
205207
return ((IntegerConstantValueTag) tag).getIntValue();
206208
else
207-
logger.error("Constant %s was of unexpected type", field.toString());
209+
logger.error(String.format("Constant %s was of unexpected type", field.toString()));
208210
} else if (assign.getRightOp() instanceof InvokeExpr) {
209211
InvokeExpr inv = (InvokeExpr) assign.getRightOp();
210212
if (inv.getMethod().getName().equals("getIdentifier")
@@ -214,7 +216,8 @@ else if (assign.getRightOp() instanceof FieldRef) {
214216
// well-known
215217
// Android API method for resource handling
216218
if (inv.getArgCount() != 3) {
217-
logger.error("Invalid parameter count (%d) for call to getIdentifier", inv.getArgCount());
219+
logger.error(String.format("Invalid parameter count (%d) for call to getIdentifier",
220+
inv.getArgCount()));
218221
return null;
219222
}
220223

@@ -228,13 +231,17 @@ else if (assign.getRightOp() instanceof FieldRef) {
228231
resName = ((StringConstant) inv.getArg(0)).value;
229232
if (inv.getArg(1) instanceof StringConstant)
230233
resID = ((StringConstant) inv.getArg(1)).value;
231-
if (inv.getArg(2) instanceof StringConstant)
232-
packageName = ((StringConstant) inv.getArg(2)).value;
233-
else if (inv.getArg(2) instanceof Local)
234-
packageName = findLastStringAssignment(stmt, (Local) inv.getArg(2), cfg);
234+
235+
Value thirdArg = inv.getArg(2);
236+
if (thirdArg instanceof StringConstant)
237+
packageName = ((StringConstant) thirdArg).value;
238+
else if (thirdArg instanceof Local)
239+
packageName = findLastStringAssignment(stmt, (Local) thirdArg, cfg);
240+
else if (thirdArg instanceof NullConstant)
241+
return null;
235242
else {
236-
logger.error("Unknown parameter type %s in call to getIdentifier",
237-
inv.getArg(2).getClass().getName());
243+
logger.error(String.format("Unknown parameter type %s in call to getIdentifier",
244+
inv.getArg(2).getClass().getName()));
238245
return null;
239246
}
240247

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package soot.jimple.infoflow.test.collect;
2+
3+
import static org.junit.Assert.assertEquals;
4+
5+
import org.junit.Test;
6+
7+
import soot.jimple.infoflow.collect.ConcurrentCountingMap;
8+
9+
public class ConcurrentCountingMapTest {
10+
11+
@Test
12+
public void keySetTest() {
13+
ConcurrentCountingMap<String> map = new ConcurrentCountingMap<>();
14+
map.increment("Hello");
15+
map.increment("World");
16+
for (String k : map.keySet())
17+
assertEquals(new Integer(1), map.get(k));
18+
}
19+
20+
}

0 commit comments

Comments
 (0)