mirror of
https://github.com/github/codeql.git
synced 2026-04-28 02:05:14 +02:00
Add taint step for String.valueOf(Editable)
Kotlin inlines expr.toString() as String.valueOf(expr) when expr is nullable
This commit is contained in:
@@ -2,10 +2,14 @@ import android.widget.EditText;
|
||||
|
||||
public class TestWidget {
|
||||
|
||||
private EditText source() {
|
||||
return null;
|
||||
}
|
||||
|
||||
private void sink(Object sink) {}
|
||||
|
||||
public void test(EditText t) {
|
||||
sink(t.getText().toString()); // $ hasTaintFlow
|
||||
public void test() {
|
||||
sink(source().getText().toString()); // $ hasTaintFlow
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import android.text.Editable
|
||||
|
||||
class TestWidget {
|
||||
|
||||
fun source() : Editable? { return null }
|
||||
fun sink(sink : String) {}
|
||||
|
||||
fun test() {
|
||||
val t = source()
|
||||
sink(t.toString()); // $ hasTaintFlow
|
||||
|
||||
val t2 : Any? = source()
|
||||
sink(t2.toString()); // $ MISSING: hasTaintFlow
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
//semmle-extractor-options: --javac-args -cp ${testdir}/../../../../stubs/google-android-9.0.0
|
||||
//codeql-extractor-kotlin-options: ${testdir}/../../../../stubs/google-android-9.0.0
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
+failures
|
||||
+valueOf
|
||||
+| TestWidgetKt.kt:10:16:10:25 | valueOf(...) |
|
||||
+| TestWidgetKt.kt:13:17:13:26 | valueOf(...) |
|
||||
@@ -2,6 +2,6 @@ import java
|
||||
import semmle.code.java.dataflow.FlowSources
|
||||
import TestUtilities.InlineFlowTest
|
||||
|
||||
class SourceTaintFlowConf extends DefaultTaintFlowConf {
|
||||
override predicate isSource(DataFlow::Node src) { src instanceof RemoteFlowSource }
|
||||
query predicate valueOf(MethodAccess ma) {
|
||||
ma.getMethod().hasQualifiedName("java.lang", "String", "valueOf")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user