Skip to content

Commit 1083570

Browse files
authored
Merge pull request #806 from MarcMil/improve-tests
Improve tests for regression
2 parents 735737a + a5a4b3e commit 1083570

File tree

6 files changed

+45
-14
lines changed

6 files changed

+45
-14
lines changed

soot-infoflow-android/src/soot/jimple/infoflow/android/SetupApplication.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1317,7 +1317,7 @@ protected void configureCallgraph() {
13171317
* @author Steven Arzt
13181318
*
13191319
*/
1320-
protected static interface IInPlaceInfoflow extends IInfoflow {
1320+
public static interface IInPlaceInfoflow extends IInfoflow {
13211321

13221322
public void runAnalysis(final ISourceSinkManager sourcesSinks, SootMethod entryPoint);
13231323

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<java.net.URL: void <init>(java.lang.String)> -> _SINK_
2+
<android.location.Location: double getLatitude()> -> _SOURCE_
3+
<android.location.Location: double getLongitude()> -> _SOURCE_

soot-infoflow-integration/test/soot/jimple/infoflow/collections/test/junit/AndroidTests.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,28 @@ protected void setConfiguration(InfoflowConfiguration config) {
2121

2222
}
2323

24+
@Test
25+
public void testGeoLocation() throws IOException {
26+
File rootDir = getIntegrationRoot();
27+
SetupApplication app = initApplication(new File(rootDir, "testAPKs/CoordinatesToURLParameter.apk"));
28+
app.getConfig().getPathConfiguration()
29+
.setPathReconstructionMode(InfoflowConfiguration.PathReconstructionMode.Fast);
30+
InfoflowResults results = app.runInfoflow(new File(rootDir, "SourcesAndSinks_GeoLocationNetworkOnly.txt"));
31+
Assert.assertEquals(1, results.size());
32+
33+
DataFlowResult res = results.getResultSet().stream().findFirst().get();
34+
boolean found = false;
35+
for (Stmt stmt : res.getSource().getPath()) {
36+
if (stmt.containsInvokeExpr()) {
37+
String sig = stmt.getInvokeExpr().getMethod().getSignature();
38+
if (sig.contains("android.location.Location: double")) {
39+
found = true;
40+
}
41+
}
42+
}
43+
Assert.assertTrue(found);
44+
}
45+
2446
@Test
2547
public void testResourceResolving() throws IOException {
2648
File rootDir = getIntegrationRoot();
1.57 MB
Binary file not shown.

soot-infoflow/src/soot/jimple/infoflow/AbstractInfoflow.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1670,7 +1670,7 @@ protected static class SourceOrSink {
16701670
private final SinkInfo sinkInfo;
16711671
private final SourceSinkState state;
16721672

1673-
protected SourceOrSink(SourceInfo sourceInfo, SinkInfo sinkInfo) {
1673+
public SourceOrSink(SourceInfo sourceInfo, SinkInfo sinkInfo) {
16741674
this.sourceInfo = sourceInfo;
16751675
this.sinkInfo = sinkInfo;
16761676
if (sourceInfo != null && sinkInfo == null)
@@ -1683,15 +1683,15 @@ else if (sourceInfo != null && sinkInfo != null)
16831683
this.state = SourceSinkState.NEITHER;
16841684
}
16851685

1686-
protected SourceSinkState getState() {
1686+
public SourceSinkState getState() {
16871687
return state;
16881688
}
16891689

1690-
protected SourceInfo getSourceInfo() {
1690+
public SourceInfo getSourceInfo() {
16911691
return sourceInfo;
16921692
}
16931693

1694-
protected SinkInfo getSinkInfo() {
1694+
public SinkInfo getSinkInfo() {
16951695
return sinkInfo;
16961696
}
16971697

soot-infoflow/src/soot/jimple/infoflow/data/AccessPath.java

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@
1313
import java.util.Arrays;
1414

1515
import com.google.common.base.Joiner;
16-
import soot.*;
16+
17+
import soot.Local;
18+
import soot.NullType;
19+
import soot.SootField;
20+
import soot.Type;
21+
import soot.Value;
1722
import soot.jimple.ArrayRef;
1823
import soot.jimple.InstanceFieldRef;
1924
import soot.jimple.Jimple;
@@ -66,18 +71,18 @@ private AccessPath() {
6671

6772
AccessPath(Local val, SootField[] appendingFields, Type valType, Type[] appendingFieldTypes, boolean taintSubFields,
6873
boolean isCutOffApproximation, ArrayTaintType arrayTaintType, boolean canHaveImmutableAliases) {
69-
this(val, valType, null,
70-
AccessPathFragment.createFragmentArray(appendingFields, appendingFieldTypes, null),
71-
taintSubFields, isCutOffApproximation, arrayTaintType, canHaveImmutableAliases);
74+
this(val, valType, null, AccessPathFragment.createFragmentArray(appendingFields, appendingFieldTypes, null),
75+
taintSubFields, isCutOffApproximation, arrayTaintType, canHaveImmutableAliases);
7276
}
7377

7478
AccessPath(Local val, Type valType, AccessPathFragment[] fragments, boolean taintSubFields,
7579
boolean isCutOffApproximation, ArrayTaintType arrayTaintType, boolean canHaveImmutableAliases) {
76-
this(val, valType, null, fragments, taintSubFields, isCutOffApproximation, arrayTaintType, canHaveImmutableAliases);
80+
this(val, valType, null, fragments, taintSubFields, isCutOffApproximation, arrayTaintType,
81+
canHaveImmutableAliases);
7782
}
7883

7984
AccessPath(Local val, Type valType, ContainerContext[] ctxt, AccessPathFragment[] fragments, boolean taintSubFields,
80-
boolean isCutOffApproximation, ArrayTaintType arrayTaintType, boolean canHaveImmutableAliases) {
85+
boolean isCutOffApproximation, ArrayTaintType arrayTaintType, boolean canHaveImmutableAliases) {
8186
this.value = val;
8287
this.baseType = valType;
8388
this.baseContext = ctxt;
@@ -238,6 +243,7 @@ public int hashCode() {
238243
}
239244

240245
private int hashCodeWOContext = 0;
246+
241247
public int hashCodeWithoutContext() {
242248
if (hashCodeWOContext != 0)
243249
return hashCodeWOContext;
@@ -311,7 +317,8 @@ public boolean equalsWithoutContext(Object obj) {
311317

312318
AccessPath other = (AccessPath) obj;
313319

314-
if (this.hashCodeWOContext != 0 && other.hashCodeWOContext != 0 && this.hashCodeWOContext != other.hashCodeWOContext)
320+
if (this.hashCodeWOContext != 0 && other.hashCodeWOContext != 0
321+
&& this.hashCodeWOContext != other.hashCodeWOContext)
315322
return false;
316323

317324
if (value == null) {
@@ -500,7 +507,6 @@ public ContainerContext[] getBaseContext() {
500507
return this.baseContext;
501508
}
502509

503-
504510
/**
505511
* Gets whether sub-fields shall be tainted. If this access path is e.g. a.b.*,
506512
* the result is true, whereas it is false for a.b.
@@ -573,7 +579,7 @@ public boolean getCanHaveImmutableAliases() {
573579
*
574580
* @return The access path that is used in the zero abstraction
575581
*/
576-
static AccessPath getZeroAccessPath() {
582+
public static AccessPath getZeroAccessPath() {
577583
if (zeroAccessPath == null)
578584
zeroAccessPath = new AccessPath(Jimple.v().newLocal("zero", NullType.v()), null, NullType.v(), null, false,
579585
false, ArrayTaintType.ContentsAndLength, false);

0 commit comments

Comments
 (0)