File tree Expand file tree Collapse file tree 6 files changed +43
-10
lines changed
lib/semmle/code/java/frameworks/android
test/library-tests/frameworks/android/widget Expand file tree Collapse file tree 6 files changed +43
-10
lines changed Original file line number Diff line number Diff line change @@ -18,12 +18,20 @@ private class DefaultAndroidWidgetSources extends RemoteFlowSource {
1818
1919private class EditableToStringStep extends AdditionalTaintStep {
2020 override predicate step ( DataFlow:: Node n1 , DataFlow:: Node n2 ) {
21- exists ( MethodAccess toString |
22- toString .getMethod ( ) .hasName ( "toString" ) and
23- toString .getReceiverType ( ) .hasQualifiedName ( "android.text" , "Editable" )
24- |
25- n1 .asExpr ( ) = toString .getQualifier ( ) and
26- n2 .asExpr ( ) = toString
21+ exists ( MethodAccess ma |
22+ ma .getMethod ( ) .hasName ( "toString" ) and
23+ ma .getReceiverType ( ) .getASourceSupertype * ( ) .hasQualifiedName ( "android.text" , "Editable" ) and
24+ n1 .asExpr ( ) = ma .getQualifier ( ) and
25+ n2 .asExpr ( ) = ma
26+ or
27+ ma .getMethod ( ) .hasQualifiedName ( "java.lang" , "String" , "valueOf" ) and
28+ ma .getArgument ( 0 )
29+ .getType ( )
30+ .( RefType )
31+ .getASourceSupertype * ( )
32+ .hasQualifiedName ( "android.text" , "Editable" ) and
33+ n1 .asExpr ( ) = ma .getArgument ( 0 ) and
34+ n2 .asExpr ( ) = ma
2735 )
2836 }
2937}
Original file line number Diff line number Diff line change 22
33public class TestWidget {
44
5+ private EditText source () {
6+ return null ;
7+ }
8+
59 private void sink (Object sink ) {}
610
7- public void test (EditText t ) {
8- sink (t .getText ().toString ()); // $ hasTaintFlow
11+ public void test () {
12+ sink (source () .getText ().toString ()); // $ hasTaintFlow
913 }
1014}
1115
Original file line number Diff line number Diff line change 1+ import android.text.Editable
2+
3+ class TestWidget {
4+
5+ fun source () : Editable ? { return null }
6+ fun sink (sink : String ) {}
7+
8+ fun test () {
9+ val t = source()
10+ sink(t.toString()); // $ hasTaintFlow
11+
12+ val t2 : Any? = source()
13+ sink(t2.toString()); // $ MISSING: hasTaintFlow
14+ }
15+ }
16+
Original file line number Diff line number Diff line change 11//semmle-extractor-options: --javac-args -cp ${testdir}/../../../../stubs/google-android-9.0.0
2+ //codeql-extractor-kotlin-options: ${testdir}/../../../../stubs/google-android-9.0.0
Original file line number Diff line number Diff line change 1+ +failures
2+ +valueOf
3+ +| TestWidgetKt.kt:10:16:10:25 | valueOf(...) |
4+ +| TestWidgetKt.kt:13:17:13:26 | valueOf(...) |
Original file line number Diff line number Diff line change @@ -2,6 +2,6 @@ import java
22import semmle.code.java.dataflow.FlowSources
33import TestUtilities.InlineFlowTest
44
5- class SourceTaintFlowConf extends DefaultTaintFlowConf {
6- override predicate isSource ( DataFlow :: Node src ) { src instanceof RemoteFlowSource }
5+ query predicate valueOf ( MethodAccess ma ) {
6+ ma . getMethod ( ) . hasQualifiedName ( "java.lang" , "String" , "valueOf" )
77}
You can’t perform that action at this time.
0 commit comments