@@ -742,6 +742,10 @@ private AccessPath createAccessPathInMethod(Taint t, SootMethod sm) {
742
742
743
743
@ Override
744
744
public Set <Abstraction > getTaintsForMethod (Stmt stmt , Abstraction d1 , Abstraction taintedAbs ) {
745
+
746
+ if (stmt .toString ().contains ("toByteArray" ))
747
+ System .out .println ("x" );
748
+
745
749
// We only care about method invocations
746
750
if (!stmt .containsInvokeExpr ())
747
751
return Collections .singleton (taintedAbs );
@@ -751,8 +755,8 @@ public Set<Abstraction> getTaintsForMethod(Stmt stmt, Abstraction d1, Abstractio
751
755
ByReferenceBoolean classSupported = new ByReferenceBoolean (false );
752
756
753
757
// Compute the wrapper taints for the current method
754
- Set < AccessPath > res = computeTaintsForMethod ( stmt , d1 , taintedAbs , stmt .getInvokeExpr ().getMethod (),
755
- killIncomingTaint , classSupported );
758
+ final SootMethod callee = stmt .getInvokeExpr ().getMethod ();
759
+ Set < AccessPath > res = computeTaintsForMethod ( stmt , d1 , taintedAbs , callee , killIncomingTaint , classSupported );
756
760
757
761
// Create abstractions from the access paths
758
762
if (res != null && !res .isEmpty ()) {
@@ -765,10 +769,9 @@ public Set<Abstraction> getTaintsForMethod(Stmt stmt, Abstraction d1, Abstractio
765
769
// If we have no data flows, we can abort early
766
770
if (!killIncomingTaint .value && (resAbs == null || resAbs .isEmpty ())) {
767
771
wrapperMisses .incrementAndGet ();
768
- SootMethod method = stmt .getInvokeExpr ().getMethod ();
769
772
770
773
if (!classSupported .value )
771
- reportMissingMethod (method );
774
+ reportMissingMethod (callee );
772
775
773
776
if (classSupported .value )
774
777
return Collections .singleton (taintedAbs );
@@ -897,19 +900,21 @@ private Set<AccessPath> applyFlowsIterative(MethodSummaries flowsInCallee, List<
897
900
// implementations in the application code
898
901
if ((flowsInTarget == null || flowsInTarget .isEmpty ()) && curGap != null ) {
899
902
SootMethod callee = Scene .v ().grabMethod (curGap .getSignature ());
900
- if (callee != null )
901
- for (SootMethod implementor : getAllImplementors (callee ))
903
+ if (callee != null ) {
904
+ for (SootMethod implementor : getAllImplementors (callee )) {
902
905
if (implementor .getDeclaringClass ().isConcrete () && !implementor .getDeclaringClass ().isPhantom ()
903
906
&& implementor .isConcrete ()) {
904
907
Set <AccessPathPropagator > implementorPropagators = spawnAnalysisIntoClientCode (implementor ,
905
908
curPropagator );
906
909
if (implementorPropagators != null )
907
910
workList .addAll (implementorPropagators );
908
911
}
912
+ }
913
+ }
909
914
}
910
915
911
916
// Apply the flow summaries for other libraries
912
- if (flowsInTarget != null && !flowsInTarget .isEmpty ())
917
+ if (flowsInTarget != null && !flowsInTarget .isEmpty ()) {
913
918
for (MethodFlow flow : flowsInTarget ) {
914
919
// Apply the flow summary
915
920
AccessPathPropagator newPropagator = applyFlow (flow , curPropagator );
@@ -947,6 +952,7 @@ private Set<AccessPath> applyFlowsIterative(MethodSummaries flowsInCallee, List<
947
952
workList .add (backwardsPropagator );
948
953
}
949
954
}
955
+ }
950
956
}
951
957
return res ;
952
958
}
@@ -1610,7 +1616,7 @@ private Taint addSinkTaint(MethodFlow flow, Taint taint, GapDefinition gap) {
1610
1616
final AbstractFlowSinkSource flowSource = flow .source ();
1611
1617
final AbstractFlowSinkSource flowSink = flow .sink ();
1612
1618
final boolean taintSubFields = flow .sink ().taintSubFields ();
1613
- final boolean checkTypes = flow .getTypeChecking ();
1619
+ final Boolean checkTypes = flow .getTypeChecking ();
1614
1620
1615
1621
AccessPathFragment remainingFields = cutSubFields (flow , getRemainingFields (flowSource , taint ));
1616
1622
AccessPathFragment appendedFields = AccessPathFragment .append (flowSink .getAccessPath (), remainingFields );
@@ -1620,16 +1626,13 @@ private Taint addSinkTaint(MethodFlow flow, Taint taint, GapDefinition gap) {
1620
1626
Type sinkType = TypeUtils .getTypeFromString (getAssignmentType (flowSink ));
1621
1627
Type taintType = TypeUtils .getTypeFromString (getAssignmentType (taint , lastCommonAPIdx - 1 ));
1622
1628
1623
- if (checkTypes ) {
1624
- // For type checking, we need types
1625
- if (sinkType == null || taintType == null )
1626
- return null ;
1627
-
1629
+ // For type checking, we need types
1630
+ if ((checkTypes == null || checkTypes .booleanValue ()) && sinkType != null && taintType != null ) {
1628
1631
// If we taint something in the base object, its type must match. We
1629
1632
// might have a taint for "a" in o.add(a) and need to check whether
1630
1633
// "o" matches the expected type in our summary.
1631
1634
if (!(sinkType instanceof PrimType ) && !isCastCompatible (taintType , sinkType )
1632
- && flowSink .getType () == SourceSinkType .Field && ! checkTypes ) {
1635
+ && flowSink .getType () == SourceSinkType .Field ) {
1633
1636
// If the target is an array, the value might also flow into an
1634
1637
// element
1635
1638
boolean found = false ;
@@ -1703,8 +1706,12 @@ protected AccessPathFragment cutSubFields(MethodFlow flow, AccessPathFragment ac
1703
1706
*/
1704
1707
protected boolean isCutSubFields (MethodFlow flow ) {
1705
1708
Boolean cut = flow .getCutSubFields ();
1706
- if (cut == null )
1707
- return !flow .getTypeChecking ();
1709
+ Boolean typeChecking = flow .getTypeChecking ();
1710
+ if (cut == null ) {
1711
+ if (typeChecking != null )
1712
+ return !typeChecking .booleanValue ();
1713
+ return false ;
1714
+ }
1708
1715
return cut .booleanValue ();
1709
1716
}
1710
1717
0 commit comments