Merge pull request #9811 from smowton/smowton/feature/kotlin-jvmoverloads-annotation

Kotlin: Implement JvmOverloads annotation
This commit is contained in:
Chris Smowton
2022-10-04 11:21:44 +01:00
committed by GitHub
25 changed files with 1427 additions and 226 deletions

View File

@@ -0,0 +1,39 @@
public class User {
public static String source() { return "taint"; }
public static void test(Test2 t2, GenericTest<Integer> gt) {
Test.taintSuppliedAsDefault(1, "no taint", 2);
Test.taintSuppliedAsDefault(1, 2);
Test.noTaintByDefault(1, source(), 2, 3);
Test.noTaintByDefault(1, source(), 2);
Test2.taintSuppliedAsDefaultStatic(1, "no taint", 2);
Test2.taintSuppliedAsDefaultStatic(1, 2);
Test2.noTaintByDefaultStatic(1, source(), 2, 3);
Test2.noTaintByDefaultStatic(1, source(), 2);
t2.taintSuppliedAsDefault(1, "no taint", 2);
t2.taintSuppliedAsDefault(1, 2);
t2.noTaintByDefault(1, source(), 2, 3);
t2.noTaintByDefault(1, source(), 2);
gt.taintSuppliedAsDefault(1, "no taint", 2);
gt.taintSuppliedAsDefault(1, 2);
gt.noTaintByDefault(1, source(), 2, 3);
gt.noTaintByDefault(1, source(), 2);
new ConstructorTaintsByDefault(1, "no taint", 2);
new ConstructorTaintsByDefault(1, 2);
new ConstructorDoesNotTaintByDefault(1, source(), 2, 3);
new ConstructorDoesNotTaintByDefault(1, source(), 2);
new GenericConstructorTaintsByDefault<Integer>(1, "no taint", 2);
new GenericConstructorTaintsByDefault<Integer>(1, 2);
new GenericConstructorDoesNotTaintByDefault<Integer>(1, source(), 2, 3);
new GenericConstructorDoesNotTaintByDefault<Integer>(1, source(), 2);
}
}

View File

@@ -0,0 +1,19 @@
| User.java:9:30:9:37 | source(...) | test.kt:13:97:13:97 | s |
| User.java:10:30:10:37 | source(...) | test.kt:13:97:13:97 | s |
| User.java:14:37:14:44 | source(...) | test.kt:25:105:25:105 | s |
| User.java:15:37:15:44 | source(...) | test.kt:25:105:25:105 | s |
| User.java:19:28:19:35 | source(...) | test.kt:33:97:33:97 | s |
| User.java:20:28:20:35 | source(...) | test.kt:33:97:33:97 | s |
| User.java:24:28:24:35 | source(...) | test.kt:43:93:43:93 | s |
| User.java:25:28:25:35 | source(...) | test.kt:43:93:43:93 | s |
| User.java:29:45:29:52 | source(...) | test.kt:58:10:58:10 | s |
| User.java:30:45:30:52 | source(...) | test.kt:58:10:58:10 | s |
| User.java:34:61:34:68 | source(...) | test.kt:74:10:74:10 | s |
| User.java:35:61:35:68 | source(...) | test.kt:74:10:74:10 | s |
| test.kt:10:55:10:62 | source(...) | test.kt:10:84:10:84 | s |
| test.kt:22:63:22:70 | source(...) | test.kt:22:92:22:92 | s |
| test.kt:22:63:22:70 | source(...) | test.kt:22:92:22:92 | s |
| test.kt:30:55:30:62 | source(...) | test.kt:30:84:30:84 | s |
| test.kt:40:53:40:60 | source(...) | test.kt:40:80:40:80 | s |
| test.kt:47:92:47:99 | source(...) | test.kt:50:10:50:10 | s |
| test.kt:63:100:63:107 | source(...) | test.kt:66:10:66:10 | s |

View File

@@ -0,0 +1,78 @@
fun getString() = "Hello world"
fun source() = "tainted"
fun sink(s: String) { }
object Test {
@JvmOverloads @JvmStatic
fun taintSuppliedAsDefault(before: Int, s: String = source(), after: Int) { sink(s) }
@JvmOverloads @JvmStatic
fun noTaintByDefault(before: Int, s: String = "no taint", after: Int, after2: Int = 1) { sink(s) }
}
public class Test2 {
companion object {
@JvmOverloads @JvmStatic
fun taintSuppliedAsDefaultStatic(before: Int, s: String = source(), after: Int) { sink(s) }
@JvmOverloads @JvmStatic
fun noTaintByDefaultStatic(before: Int, s: String = "no taint", after: Int, after2: Int = 1) { sink(s) }
}
@JvmOverloads
fun taintSuppliedAsDefault(before: Int, s: String = source(), after: Int) { sink(s) }
@JvmOverloads
fun noTaintByDefault(before: Int, s: String = "no taint", after: Int, after2: Int = 1) { sink(s) }
}
public class GenericTest<T> {
@JvmOverloads
fun taintSuppliedAsDefault(before: T, s: String = source(), after: T) { sink(s) }
@JvmOverloads
fun noTaintByDefault(before: T, s: String = "no taint", after: T, after2: Int = 1) { sink(s) }
}
public class ConstructorTaintsByDefault @JvmOverloads constructor(before: Int, s: String = source(), after: Int) {
init {
sink(s)
}
}
public class ConstructorDoesNotTaintByDefault @JvmOverloads constructor(before: Int, s: String = "no taint", after: Int, after2: Int = 1) {
init {
sink(s)
}
}
public class GenericConstructorTaintsByDefault<T> @JvmOverloads constructor(before: T, s: String = source(), after: T) {
init {
sink(s)
}
}
public class GenericConstructorDoesNotTaintByDefault<T> @JvmOverloads constructor(before: T, s: String = "no taint", after: T, after2: T? = null) {
init {
sink(s)
}
}

View File

@@ -0,0 +1,4 @@
from create_database_utils import *
os.mkdir('kbuild')
run_codeql_database_create(["kotlinc test.kt -d kbuild", "javac User.java -cp kbuild"], lang="java")

View File

@@ -0,0 +1,18 @@
import java
import semmle.code.java.dataflow.DataFlow
class Config extends DataFlow::Configuration {
Config() { this = "config" }
override predicate isSource(DataFlow::Node n) {
n.asExpr().(MethodAccess).getCallee().getName() = "source"
}
override predicate isSink(DataFlow::Node n) {
n.asExpr().(Argument).getCall().getCallee().getName() = "sink"
}
}
from Config c, DataFlow::Node source, DataFlow::Node sink
where c.hasFlow(source, sink)
select source, sink

View File

@@ -63,6 +63,8 @@ class Element extends @element, Top {
i = 7 and result = "Setter for a Kotlin delegated property"
or
i = 8 and result = "Proxy static method for a @JvmStatic-annotated function or property"
or
i = 9 and result = "Forwarder for a @JvmOverloads-annotated function"
)
}
}

View File

@@ -534,12 +534,17 @@ final class ClassInterfaceNode extends ElementNode {
or
childIndex >= 0 and
result.(ElementNode).getElement() =
rank[childIndex](Element e, string file, int line, int column, string childStr |
rank[childIndex](Element e, string file, int line, int column, string childStr, int argCount |
e = this.getADeclaration() and
locationSortKeys(e, file, line, column) and
childStr = e.toString()
childStr = e.toString() and
(
if e instanceof Callable
then argCount = e.(Callable).getNumberOfParameters()
else argCount = 0
)
|
e order by file, line, column, childStr
e order by file, line, column, childStr, argCount
)
}
}

View File

@@ -3846,58 +3846,6 @@ funcExprs.kt:
# 36| 5: [BlockStmt] { ... }
# 36| 0: [SuperConstructorInvocationStmt] super(...)
# 36| 2: [Method] invoke
# 36| 3: [TypeAccess] String
#-----| 4: (Parameters)
# 36| 0: [Parameter] a0
# 36| 0: [TypeAccess] int
# 36| 1: [Parameter] a1
# 36| 0: [TypeAccess] int
# 36| 2: [Parameter] a2
# 36| 0: [TypeAccess] int
# 36| 3: [Parameter] a3
# 36| 0: [TypeAccess] int
# 36| 4: [Parameter] a4
# 36| 0: [TypeAccess] int
# 36| 5: [Parameter] a5
# 36| 0: [TypeAccess] int
# 36| 6: [Parameter] a6
# 36| 0: [TypeAccess] int
# 36| 7: [Parameter] a7
# 36| 0: [TypeAccess] int
# 36| 8: [Parameter] a8
# 36| 0: [TypeAccess] int
# 36| 9: [Parameter] a9
# 36| 0: [TypeAccess] int
# 36| 10: [Parameter] a10
# 36| 0: [TypeAccess] int
# 36| 11: [Parameter] a11
# 36| 0: [TypeAccess] int
# 36| 12: [Parameter] a12
# 36| 0: [TypeAccess] int
# 36| 13: [Parameter] a13
# 36| 0: [TypeAccess] int
# 36| 14: [Parameter] a14
# 36| 0: [TypeAccess] int
# 36| 15: [Parameter] a15
# 36| 0: [TypeAccess] int
# 36| 16: [Parameter] a16
# 36| 0: [TypeAccess] int
# 36| 17: [Parameter] a17
# 36| 0: [TypeAccess] int
# 36| 18: [Parameter] a18
# 36| 0: [TypeAccess] int
# 36| 19: [Parameter] a19
# 36| 0: [TypeAccess] int
# 36| 20: [Parameter] a20
# 36| 0: [TypeAccess] int
# 36| 21: [Parameter] a21
# 36| 0: [TypeAccess] int
# 36| 22: [Parameter] a22
# 36| 0: [TypeAccess] int
# 36| 5: [BlockStmt] { ... }
# 36| 0: [ReturnStmt] return ...
# 36| 0: [StringLiteral]
# 36| 2: [Method] invoke
#-----| 4: (Parameters)
# 36| 0: [Parameter] a0
# 36| 5: [BlockStmt] { ... }
@@ -4019,6 +3967,58 @@ funcExprs.kt:
# 36| 1: [ArrayAccess] ...[...]
# 36| 0: [VarAccess] a0
# 36| 1: [IntegerLiteral] 22
# 36| 3: [Method] invoke
# 36| 3: [TypeAccess] String
#-----| 4: (Parameters)
# 36| 0: [Parameter] a0
# 36| 0: [TypeAccess] int
# 36| 1: [Parameter] a1
# 36| 0: [TypeAccess] int
# 36| 2: [Parameter] a2
# 36| 0: [TypeAccess] int
# 36| 3: [Parameter] a3
# 36| 0: [TypeAccess] int
# 36| 4: [Parameter] a4
# 36| 0: [TypeAccess] int
# 36| 5: [Parameter] a5
# 36| 0: [TypeAccess] int
# 36| 6: [Parameter] a6
# 36| 0: [TypeAccess] int
# 36| 7: [Parameter] a7
# 36| 0: [TypeAccess] int
# 36| 8: [Parameter] a8
# 36| 0: [TypeAccess] int
# 36| 9: [Parameter] a9
# 36| 0: [TypeAccess] int
# 36| 10: [Parameter] a10
# 36| 0: [TypeAccess] int
# 36| 11: [Parameter] a11
# 36| 0: [TypeAccess] int
# 36| 12: [Parameter] a12
# 36| 0: [TypeAccess] int
# 36| 13: [Parameter] a13
# 36| 0: [TypeAccess] int
# 36| 14: [Parameter] a14
# 36| 0: [TypeAccess] int
# 36| 15: [Parameter] a15
# 36| 0: [TypeAccess] int
# 36| 16: [Parameter] a16
# 36| 0: [TypeAccess] int
# 36| 17: [Parameter] a17
# 36| 0: [TypeAccess] int
# 36| 18: [Parameter] a18
# 36| 0: [TypeAccess] int
# 36| 19: [Parameter] a19
# 36| 0: [TypeAccess] int
# 36| 20: [Parameter] a20
# 36| 0: [TypeAccess] int
# 36| 21: [Parameter] a21
# 36| 0: [TypeAccess] int
# 36| 22: [Parameter] a22
# 36| 0: [TypeAccess] int
# 36| 5: [BlockStmt] { ... }
# 36| 0: [ReturnStmt] return ...
# 36| 0: [StringLiteral]
# 36| -3: [TypeAccess] FunctionN<String>
# 36| 0: [TypeAccess] String
# 38| 14: [ExprStmt] <Expr>;
@@ -4683,58 +4683,6 @@ funcExprs.kt:
# 90| 5: [BlockStmt] { ... }
# 90| 0: [SuperConstructorInvocationStmt] super(...)
# 90| 2: [Method] invoke
# 90| 3: [TypeAccess] String
#-----| 4: (Parameters)
# 90| 0: [Parameter] p0
# 90| 0: [TypeAccess] int
# 90| 1: [Parameter] p1
# 90| 0: [TypeAccess] int
# 90| 2: [Parameter] p2
# 90| 0: [TypeAccess] int
# 90| 3: [Parameter] p3
# 90| 0: [TypeAccess] int
# 90| 4: [Parameter] p4
# 90| 0: [TypeAccess] int
# 90| 5: [Parameter] p5
# 90| 0: [TypeAccess] int
# 90| 6: [Parameter] p6
# 90| 0: [TypeAccess] int
# 90| 7: [Parameter] p7
# 90| 0: [TypeAccess] int
# 90| 8: [Parameter] p8
# 90| 0: [TypeAccess] int
# 90| 9: [Parameter] p9
# 90| 0: [TypeAccess] int
# 90| 10: [Parameter] p10
# 90| 0: [TypeAccess] int
# 90| 11: [Parameter] p11
# 90| 0: [TypeAccess] int
# 90| 12: [Parameter] p12
# 90| 0: [TypeAccess] int
# 90| 13: [Parameter] p13
# 90| 0: [TypeAccess] int
# 90| 14: [Parameter] p14
# 90| 0: [TypeAccess] int
# 90| 15: [Parameter] p15
# 90| 0: [TypeAccess] int
# 90| 16: [Parameter] p16
# 90| 0: [TypeAccess] int
# 90| 17: [Parameter] p17
# 90| 0: [TypeAccess] int
# 90| 18: [Parameter] p18
# 90| 0: [TypeAccess] int
# 90| 19: [Parameter] p19
# 90| 0: [TypeAccess] int
# 90| 20: [Parameter] p20
# 90| 0: [TypeAccess] int
# 90| 21: [Parameter] p21
# 90| 0: [TypeAccess] int
# 90| 22: [Parameter] p22
# 90| 0: [TypeAccess] int
# 90| 5: [BlockStmt] { ... }
# 90| 0: [ReturnStmt] return ...
# 90| 0: [StringLiteral]
# 90| 2: [Method] invoke
#-----| 4: (Parameters)
# 90| 0: [Parameter] a0
# 90| 5: [BlockStmt] { ... }
@@ -4856,6 +4804,58 @@ funcExprs.kt:
# 90| 1: [ArrayAccess] ...[...]
# 90| 0: [VarAccess] a0
# 90| 1: [IntegerLiteral] 22
# 90| 3: [Method] invoke
# 90| 3: [TypeAccess] String
#-----| 4: (Parameters)
# 90| 0: [Parameter] p0
# 90| 0: [TypeAccess] int
# 90| 1: [Parameter] p1
# 90| 0: [TypeAccess] int
# 90| 2: [Parameter] p2
# 90| 0: [TypeAccess] int
# 90| 3: [Parameter] p3
# 90| 0: [TypeAccess] int
# 90| 4: [Parameter] p4
# 90| 0: [TypeAccess] int
# 90| 5: [Parameter] p5
# 90| 0: [TypeAccess] int
# 90| 6: [Parameter] p6
# 90| 0: [TypeAccess] int
# 90| 7: [Parameter] p7
# 90| 0: [TypeAccess] int
# 90| 8: [Parameter] p8
# 90| 0: [TypeAccess] int
# 90| 9: [Parameter] p9
# 90| 0: [TypeAccess] int
# 90| 10: [Parameter] p10
# 90| 0: [TypeAccess] int
# 90| 11: [Parameter] p11
# 90| 0: [TypeAccess] int
# 90| 12: [Parameter] p12
# 90| 0: [TypeAccess] int
# 90| 13: [Parameter] p13
# 90| 0: [TypeAccess] int
# 90| 14: [Parameter] p14
# 90| 0: [TypeAccess] int
# 90| 15: [Parameter] p15
# 90| 0: [TypeAccess] int
# 90| 16: [Parameter] p16
# 90| 0: [TypeAccess] int
# 90| 17: [Parameter] p17
# 90| 0: [TypeAccess] int
# 90| 18: [Parameter] p18
# 90| 0: [TypeAccess] int
# 90| 19: [Parameter] p19
# 90| 0: [TypeAccess] int
# 90| 20: [Parameter] p20
# 90| 0: [TypeAccess] int
# 90| 21: [Parameter] p21
# 90| 0: [TypeAccess] int
# 90| 22: [Parameter] p22
# 90| 0: [TypeAccess] int
# 90| 5: [BlockStmt] { ... }
# 90| 0: [ReturnStmt] return ...
# 90| 0: [StringLiteral]
# 90| -3: [TypeAccess] FunctionN<String>
# 90| 0: [TypeAccess] String
# 91| 5: [ExprStmt] <Expr>;
@@ -6038,58 +6038,6 @@ samConversion.kt:
# 43| 5: [BlockStmt] { ... }
# 43| 0: [SuperConstructorInvocationStmt] super(...)
# 43| 2: [Method] invoke
# 43| 3: [TypeAccess] boolean
#-----| 4: (Parameters)
# 43| 0: [Parameter] i0
# 43| 0: [TypeAccess] int
# 43| 1: [Parameter] i1
# 43| 0: [TypeAccess] int
# 43| 2: [Parameter] i2
# 43| 0: [TypeAccess] int
# 43| 3: [Parameter] i3
# 43| 0: [TypeAccess] int
# 43| 4: [Parameter] i4
# 43| 0: [TypeAccess] int
# 43| 5: [Parameter] i5
# 43| 0: [TypeAccess] int
# 43| 6: [Parameter] i6
# 43| 0: [TypeAccess] int
# 43| 7: [Parameter] i7
# 43| 0: [TypeAccess] int
# 43| 8: [Parameter] i8
# 43| 0: [TypeAccess] int
# 43| 9: [Parameter] i9
# 43| 0: [TypeAccess] int
# 44| 10: [Parameter] i10
# 44| 0: [TypeAccess] int
# 44| 11: [Parameter] i11
# 44| 0: [TypeAccess] int
# 44| 12: [Parameter] i12
# 44| 0: [TypeAccess] int
# 44| 13: [Parameter] i13
# 44| 0: [TypeAccess] int
# 44| 14: [Parameter] i14
# 44| 0: [TypeAccess] int
# 44| 15: [Parameter] i15
# 44| 0: [TypeAccess] int
# 44| 16: [Parameter] i16
# 44| 0: [TypeAccess] int
# 44| 17: [Parameter] i17
# 44| 0: [TypeAccess] int
# 44| 18: [Parameter] i18
# 44| 0: [TypeAccess] int
# 44| 19: [Parameter] i19
# 44| 0: [TypeAccess] int
# 45| 20: [Parameter] i20
# 45| 0: [TypeAccess] int
# 45| 21: [Parameter] i21
# 45| 0: [TypeAccess] int
# 45| 22: [Parameter] i22
# 45| 0: [TypeAccess] int
# 45| 5: [BlockStmt] { ... }
# 45| 0: [ReturnStmt] return ...
# 45| 0: [BooleanLiteral] true
# 43| 2: [Method] invoke
#-----| 4: (Parameters)
# 43| 0: [Parameter] a0
# 43| 5: [BlockStmt] { ... }
@@ -6211,6 +6159,58 @@ samConversion.kt:
# 43| 1: [ArrayAccess] ...[...]
# 43| 0: [VarAccess] a0
# 43| 1: [IntegerLiteral] 22
# 43| 3: [Method] invoke
# 43| 3: [TypeAccess] boolean
#-----| 4: (Parameters)
# 43| 0: [Parameter] i0
# 43| 0: [TypeAccess] int
# 43| 1: [Parameter] i1
# 43| 0: [TypeAccess] int
# 43| 2: [Parameter] i2
# 43| 0: [TypeAccess] int
# 43| 3: [Parameter] i3
# 43| 0: [TypeAccess] int
# 43| 4: [Parameter] i4
# 43| 0: [TypeAccess] int
# 43| 5: [Parameter] i5
# 43| 0: [TypeAccess] int
# 43| 6: [Parameter] i6
# 43| 0: [TypeAccess] int
# 43| 7: [Parameter] i7
# 43| 0: [TypeAccess] int
# 43| 8: [Parameter] i8
# 43| 0: [TypeAccess] int
# 43| 9: [Parameter] i9
# 43| 0: [TypeAccess] int
# 44| 10: [Parameter] i10
# 44| 0: [TypeAccess] int
# 44| 11: [Parameter] i11
# 44| 0: [TypeAccess] int
# 44| 12: [Parameter] i12
# 44| 0: [TypeAccess] int
# 44| 13: [Parameter] i13
# 44| 0: [TypeAccess] int
# 44| 14: [Parameter] i14
# 44| 0: [TypeAccess] int
# 44| 15: [Parameter] i15
# 44| 0: [TypeAccess] int
# 44| 16: [Parameter] i16
# 44| 0: [TypeAccess] int
# 44| 17: [Parameter] i17
# 44| 0: [TypeAccess] int
# 44| 18: [Parameter] i18
# 44| 0: [TypeAccess] int
# 44| 19: [Parameter] i19
# 44| 0: [TypeAccess] int
# 45| 20: [Parameter] i20
# 45| 0: [TypeAccess] int
# 45| 21: [Parameter] i21
# 45| 0: [TypeAccess] int
# 45| 22: [Parameter] i22
# 45| 0: [TypeAccess] int
# 45| 5: [BlockStmt] { ... }
# 45| 0: [ReturnStmt] return ...
# 45| 0: [BooleanLiteral] true
# 43| -3: [TypeAccess] FunctionN<Boolean>
# 43| 0: [TypeAccess] Boolean
# 46| 3: [LocalVariableDeclStmt] var ...;

View File

@@ -0,0 +1,591 @@
test.kt:
# 0| [CompilationUnit] test
# 0| 1: [Class] TestKt
# 1| 1: [Method] getString
# 1| 3: [TypeAccess] String
# 1| 5: [BlockStmt] { ... }
# 1| 0: [ReturnStmt] return ...
# 1| 0: [StringLiteral] Hello world
# 45| 2: [ExtensionMethod] testExtensionFunction
# 45| 3: [TypeAccess] int
#-----| 4: (Parameters)
# 45| 0: [Parameter] <this>
# 45| 0: [TypeAccess] Test
# 45| 1: [Parameter] a
# 45| 0: [TypeAccess] int
# 45| 2: [Parameter] c
# 45| 0: [TypeAccess] double
# 45| 3: [Parameter] e
# 45| 0: [TypeAccess] boolean
# 45| 5: [BlockStmt] { ... }
# 45| 0: [ReturnStmt] return ...
# 45| 0: [MethodAccess] testExtensionFunction(...)
# 45| -1: [TypeAccess] TestKt
# 45| 0: [ExtensionReceiverAccess] this
# 45| 1: [VarAccess] a
# 45| 2: [MethodAccess] getString(...)
# 45| -1: [TypeAccess] TestKt
# 45| 3: [VarAccess] c
# 45| 4: [FloatLiteral] 1.0
# 45| 5: [VarAccess] e
# 45| 3: [ExtensionMethod] testExtensionFunction
# 45| 3: [TypeAccess] int
#-----| 4: (Parameters)
# 45| 0: [Parameter] <this>
# 45| 0: [TypeAccess] Test
# 45| 1: [Parameter] a
# 45| 0: [TypeAccess] int
# 45| 2: [Parameter] b
# 45| 0: [TypeAccess] String
# 45| 3: [Parameter] c
# 45| 0: [TypeAccess] double
# 45| 4: [Parameter] e
# 45| 0: [TypeAccess] boolean
# 45| 5: [BlockStmt] { ... }
# 45| 0: [ReturnStmt] return ...
# 45| 0: [MethodAccess] testExtensionFunction(...)
# 45| -1: [TypeAccess] TestKt
# 45| 0: [ExtensionReceiverAccess] this
# 45| 1: [VarAccess] a
# 45| 2: [VarAccess] b
# 45| 3: [VarAccess] c
# 45| 4: [FloatLiteral] 1.0
# 45| 5: [VarAccess] e
# 45| 4: [ExtensionMethod] testExtensionFunction
# 45| 3: [TypeAccess] int
#-----| 4: (Parameters)
# 45| 0: [Parameter] <this>
# 45| 0: [TypeAccess] Test
# 45| 1: [Parameter] a
# 45| 0: [TypeAccess] int
# 45| 2: [Parameter] b
# 45| 0: [TypeAccess] String
# 45| 3: [Parameter] c
# 45| 0: [TypeAccess] double
# 45| 4: [Parameter] d
# 45| 0: [TypeAccess] float
# 45| 5: [Parameter] e
# 45| 0: [TypeAccess] boolean
# 45| 5: [BlockStmt] { ... }
# 45| 0: [ReturnStmt] return ...
# 45| 0: [VarAccess] a
# 3| 2: [Class] Test
# 3| 1: [Constructor] Test
# 3| 5: [BlockStmt] { ... }
# 3| 0: [SuperConstructorInvocationStmt] super(...)
# 3| 1: [BlockStmt] { ... }
# 6| 2: [Method] testStaticFunction
# 6| 3: [TypeAccess] int
#-----| 4: (Parameters)
# 6| 0: [Parameter] a
# 6| 0: [TypeAccess] int
# 6| 1: [Parameter] c
# 6| 0: [TypeAccess] double
# 6| 2: [Parameter] e
# 6| 0: [TypeAccess] boolean
# 6| 5: [BlockStmt] { ... }
# 6| 0: [ReturnStmt] return ...
# 6| 0: [MethodAccess] testStaticFunction(...)
# 6| -1: [TypeAccess] Test
# 6| 0: [VarAccess] a
# 6| 1: [MethodAccess] getString(...)
# 6| -1: [TypeAccess] TestKt
# 6| 2: [VarAccess] c
# 6| 3: [FloatLiteral] 1.0
# 6| 4: [VarAccess] e
# 6| 3: [Method] testStaticFunction
# 6| 3: [TypeAccess] int
#-----| 4: (Parameters)
# 6| 0: [Parameter] a
# 6| 0: [TypeAccess] int
# 6| 1: [Parameter] b
# 6| 0: [TypeAccess] String
# 6| 2: [Parameter] c
# 6| 0: [TypeAccess] double
# 6| 3: [Parameter] e
# 6| 0: [TypeAccess] boolean
# 6| 5: [BlockStmt] { ... }
# 6| 0: [ReturnStmt] return ...
# 6| 0: [MethodAccess] testStaticFunction(...)
# 6| -1: [TypeAccess] Test
# 6| 0: [VarAccess] a
# 6| 1: [VarAccess] b
# 6| 2: [VarAccess] c
# 6| 3: [FloatLiteral] 1.0
# 6| 4: [VarAccess] e
# 6| 4: [Method] testStaticFunction
# 6| 3: [TypeAccess] int
#-----| 4: (Parameters)
# 6| 0: [Parameter] a
# 6| 0: [TypeAccess] int
# 6| 1: [Parameter] b
# 6| 0: [TypeAccess] String
# 6| 2: [Parameter] c
# 6| 0: [TypeAccess] double
# 6| 3: [Parameter] d
# 6| 0: [TypeAccess] float
# 6| 4: [Parameter] e
# 6| 0: [TypeAccess] boolean
# 6| 5: [BlockStmt] { ... }
# 6| 0: [ReturnStmt] return ...
# 6| 0: [VarAccess] a
# 9| 5: [Method] testMemberFunction
# 9| 3: [TypeAccess] int
#-----| 4: (Parameters)
# 9| 0: [Parameter] a
# 9| 0: [TypeAccess] int
# 9| 1: [Parameter] c
# 9| 0: [TypeAccess] double
# 9| 2: [Parameter] e
# 9| 0: [TypeAccess] boolean
# 9| 5: [BlockStmt] { ... }
# 9| 0: [ReturnStmt] return ...
# 9| 0: [MethodAccess] testMemberFunction(...)
# 9| -1: [ThisAccess] this
# 9| 0: [VarAccess] a
# 9| 1: [MethodAccess] getString(...)
# 9| -1: [TypeAccess] TestKt
# 9| 2: [VarAccess] c
# 9| 3: [FloatLiteral] 1.0
# 9| 4: [VarAccess] e
# 9| 6: [Method] testMemberFunction
# 9| 3: [TypeAccess] int
#-----| 4: (Parameters)
# 9| 0: [Parameter] a
# 9| 0: [TypeAccess] int
# 9| 1: [Parameter] b
# 9| 0: [TypeAccess] String
# 9| 2: [Parameter] c
# 9| 0: [TypeAccess] double
# 9| 3: [Parameter] e
# 9| 0: [TypeAccess] boolean
# 9| 5: [BlockStmt] { ... }
# 9| 0: [ReturnStmt] return ...
# 9| 0: [MethodAccess] testMemberFunction(...)
# 9| -1: [ThisAccess] this
# 9| 0: [VarAccess] a
# 9| 1: [VarAccess] b
# 9| 2: [VarAccess] c
# 9| 3: [FloatLiteral] 1.0
# 9| 4: [VarAccess] e
# 9| 7: [Method] testMemberFunction
# 9| 3: [TypeAccess] int
#-----| 4: (Parameters)
# 9| 0: [Parameter] a
# 9| 0: [TypeAccess] int
# 9| 1: [Parameter] b
# 9| 0: [TypeAccess] String
# 9| 2: [Parameter] c
# 9| 0: [TypeAccess] double
# 9| 3: [Parameter] d
# 9| 0: [TypeAccess] float
# 9| 4: [Parameter] e
# 9| 0: [TypeAccess] boolean
# 9| 5: [BlockStmt] { ... }
# 9| 0: [ReturnStmt] return ...
# 9| 0: [VarAccess] a
# 12| 8: [ExtensionMethod] testMemberExtensionFunction
# 12| 3: [TypeAccess] int
#-----| 4: (Parameters)
# 12| 0: [Parameter] <this>
# 12| 0: [TypeAccess] Test2
# 12| 1: [Parameter] a
# 12| 0: [TypeAccess] int
# 12| 2: [Parameter] c
# 12| 0: [TypeAccess] double
# 12| 3: [Parameter] e
# 12| 0: [TypeAccess] boolean
# 12| 5: [BlockStmt] { ... }
# 12| 0: [ReturnStmt] return ...
# 12| 0: [MethodAccess] testMemberExtensionFunction(...)
# 12| -1: [ThisAccess] this
# 12| 0: [ExtensionReceiverAccess] this
# 12| 1: [VarAccess] a
# 12| 2: [MethodAccess] getString(...)
# 12| -1: [TypeAccess] TestKt
# 12| 3: [VarAccess] c
# 12| 4: [FloatLiteral] 1.0
# 12| 5: [VarAccess] e
# 12| 9: [ExtensionMethod] testMemberExtensionFunction
# 12| 3: [TypeAccess] int
#-----| 4: (Parameters)
# 12| 0: [Parameter] <this>
# 12| 0: [TypeAccess] Test2
# 12| 1: [Parameter] a
# 12| 0: [TypeAccess] int
# 12| 2: [Parameter] b
# 12| 0: [TypeAccess] String
# 12| 3: [Parameter] c
# 12| 0: [TypeAccess] double
# 12| 4: [Parameter] e
# 12| 0: [TypeAccess] boolean
# 12| 5: [BlockStmt] { ... }
# 12| 0: [ReturnStmt] return ...
# 12| 0: [MethodAccess] testMemberExtensionFunction(...)
# 12| -1: [ThisAccess] this
# 12| 0: [ExtensionReceiverAccess] this
# 12| 1: [VarAccess] a
# 12| 2: [VarAccess] b
# 12| 3: [VarAccess] c
# 12| 4: [FloatLiteral] 1.0
# 12| 5: [VarAccess] e
# 12| 10: [ExtensionMethod] testMemberExtensionFunction
# 12| 3: [TypeAccess] int
#-----| 4: (Parameters)
# 12| 0: [Parameter] <this>
# 12| 0: [TypeAccess] Test2
# 12| 1: [Parameter] a
# 12| 0: [TypeAccess] int
# 12| 2: [Parameter] b
# 12| 0: [TypeAccess] String
# 12| 3: [Parameter] c
# 12| 0: [TypeAccess] double
# 12| 4: [Parameter] d
# 12| 0: [TypeAccess] float
# 12| 5: [Parameter] e
# 12| 0: [TypeAccess] boolean
# 12| 5: [BlockStmt] { ... }
# 12| 0: [ReturnStmt] return ...
# 12| 0: [VarAccess] a
# 16| 3: [Class] Test2
# 16| 1: [Constructor] Test2
#-----| 4: (Parameters)
# 16| 0: [Parameter] a
# 16| 0: [TypeAccess] int
# 16| 1: [Parameter] c
# 16| 0: [TypeAccess] double
# 16| 2: [Parameter] e
# 16| 0: [TypeAccess] boolean
# 16| 5: [BlockStmt] { ... }
# 16| 0: [ThisConstructorInvocationStmt] this(...)
# 16| 0: [VarAccess] a
# 16| 1: [MethodAccess] getString(...)
# 16| -1: [TypeAccess] TestKt
# 16| 2: [VarAccess] c
# 16| 3: [FloatLiteral] 1.0
# 16| 4: [VarAccess] e
# 16| 2: [Constructor] Test2
#-----| 4: (Parameters)
# 16| 0: [Parameter] a
# 16| 0: [TypeAccess] int
# 16| 1: [Parameter] b
# 16| 0: [TypeAccess] String
# 16| 2: [Parameter] c
# 16| 0: [TypeAccess] double
# 16| 3: [Parameter] e
# 16| 0: [TypeAccess] boolean
# 16| 5: [BlockStmt] { ... }
# 16| 0: [ThisConstructorInvocationStmt] this(...)
# 16| 0: [VarAccess] a
# 16| 1: [VarAccess] b
# 16| 2: [VarAccess] c
# 16| 3: [FloatLiteral] 1.0
# 16| 4: [VarAccess] e
# 16| 3: [Constructor] Test2
#-----| 4: (Parameters)
# 16| 0: [Parameter] a
# 16| 0: [TypeAccess] int
# 16| 1: [Parameter] b
# 16| 0: [TypeAccess] String
# 16| 2: [Parameter] c
# 16| 0: [TypeAccess] double
# 16| 3: [Parameter] d
# 16| 0: [TypeAccess] float
# 16| 4: [Parameter] e
# 16| 0: [TypeAccess] boolean
# 16| 5: [BlockStmt] { ... }
# 16| 0: [SuperConstructorInvocationStmt] super(...)
# 16| 1: [BlockStmt] { ... }
# 18| 4: [Class] Companion
# 18| 1: [Constructor] Companion
# 18| 5: [BlockStmt] { ... }
# 18| 0: [SuperConstructorInvocationStmt] super(...)
# 18| 1: [BlockStmt] { ... }
# 21| 2: [Method] testCompanionFunction
# 21| 3: [TypeAccess] int
#-----| 4: (Parameters)
# 21| 0: [Parameter] a
# 21| 0: [TypeAccess] int
# 21| 1: [Parameter] c
# 21| 0: [TypeAccess] double
# 21| 2: [Parameter] e
# 21| 0: [TypeAccess] boolean
# 21| 5: [BlockStmt] { ... }
# 21| 0: [ReturnStmt] return ...
# 21| 0: [MethodAccess] testCompanionFunction(...)
# 21| -1: [ThisAccess] this
# 21| 0: [VarAccess] a
# 21| 1: [MethodAccess] getString(...)
# 21| -1: [TypeAccess] TestKt
# 21| 2: [VarAccess] c
# 21| 3: [FloatLiteral] 1.0
# 21| 4: [VarAccess] e
# 21| 3: [Method] testCompanionFunction
# 21| 3: [TypeAccess] int
#-----| 4: (Parameters)
# 21| 0: [Parameter] a
# 21| 0: [TypeAccess] int
# 21| 1: [Parameter] b
# 21| 0: [TypeAccess] String
# 21| 2: [Parameter] c
# 21| 0: [TypeAccess] double
# 21| 3: [Parameter] e
# 21| 0: [TypeAccess] boolean
# 21| 5: [BlockStmt] { ... }
# 21| 0: [ReturnStmt] return ...
# 21| 0: [MethodAccess] testCompanionFunction(...)
# 21| -1: [ThisAccess] this
# 21| 0: [VarAccess] a
# 21| 1: [VarAccess] b
# 21| 2: [VarAccess] c
# 21| 3: [FloatLiteral] 1.0
# 21| 4: [VarAccess] e
# 21| 4: [Method] testCompanionFunction
# 21| 3: [TypeAccess] int
#-----| 4: (Parameters)
# 21| 0: [Parameter] a
# 21| 0: [TypeAccess] int
# 21| 1: [Parameter] b
# 21| 0: [TypeAccess] String
# 21| 2: [Parameter] c
# 21| 0: [TypeAccess] double
# 21| 3: [Parameter] d
# 21| 0: [TypeAccess] float
# 21| 4: [Parameter] e
# 21| 0: [TypeAccess] boolean
# 21| 5: [BlockStmt] { ... }
# 21| 0: [ReturnStmt] return ...
# 21| 0: [VarAccess] a
# 24| 5: [Method] testStaticCompanionFunction
# 24| 3: [TypeAccess] int
#-----| 4: (Parameters)
# 24| 0: [Parameter] a
# 24| 0: [TypeAccess] int
# 24| 1: [Parameter] c
# 24| 0: [TypeAccess] double
# 24| 2: [Parameter] e
# 24| 0: [TypeAccess] boolean
# 24| 5: [BlockStmt] { ... }
# 24| 0: [ReturnStmt] return ...
# 24| 0: [MethodAccess] testStaticCompanionFunction(...)
# 24| -1: [ThisAccess] this
# 24| 0: [VarAccess] a
# 24| 1: [MethodAccess] getString(...)
# 24| -1: [TypeAccess] TestKt
# 24| 2: [VarAccess] c
# 24| 3: [FloatLiteral] 1.0
# 24| 4: [VarAccess] e
# 24| 6: [Method] testStaticCompanionFunction
# 24| 3: [TypeAccess] int
#-----| 4: (Parameters)
# 24| 0: [Parameter] a
# 24| 0: [TypeAccess] int
# 24| 1: [Parameter] b
# 24| 0: [TypeAccess] String
# 24| 2: [Parameter] c
# 24| 0: [TypeAccess] double
# 24| 3: [Parameter] e
# 24| 0: [TypeAccess] boolean
# 24| 5: [BlockStmt] { ... }
# 24| 0: [ReturnStmt] return ...
# 24| 0: [MethodAccess] testStaticCompanionFunction(...)
# 24| -1: [ThisAccess] this
# 24| 0: [VarAccess] a
# 24| 1: [VarAccess] b
# 24| 2: [VarAccess] c
# 24| 3: [FloatLiteral] 1.0
# 24| 4: [VarAccess] e
# 24| 7: [Method] testStaticCompanionFunction
# 24| 3: [TypeAccess] int
#-----| 4: (Parameters)
# 24| 0: [Parameter] a
# 24| 0: [TypeAccess] int
# 24| 1: [Parameter] b
# 24| 0: [TypeAccess] String
# 24| 2: [Parameter] c
# 24| 0: [TypeAccess] double
# 24| 3: [Parameter] d
# 24| 0: [TypeAccess] float
# 24| 4: [Parameter] e
# 24| 0: [TypeAccess] boolean
# 24| 5: [BlockStmt] { ... }
# 24| 0: [ReturnStmt] return ...
# 24| 0: [VarAccess] a
# 24| 5: [Method] testStaticCompanionFunction
# 24| 3: [TypeAccess] int
#-----| 4: (Parameters)
# 24| 0: [Parameter] a
# 24| 0: [TypeAccess] int
# 24| 1: [Parameter] c
# 24| 0: [TypeAccess] double
# 24| 2: [Parameter] e
# 24| 0: [TypeAccess] boolean
# 24| 5: [BlockStmt] { ... }
# 24| 0: [ReturnStmt] return ...
# 24| 0: [MethodAccess] testStaticCompanionFunction(...)
# 24| -1: [ThisAccess] this
# 24| 0: [VarAccess] a
# 24| 1: [MethodAccess] getString(...)
# 24| -1: [TypeAccess] TestKt
# 24| 2: [VarAccess] c
# 24| 3: [FloatLiteral] 1.0
# 24| 4: [VarAccess] e
# 24| 6: [Method] testStaticCompanionFunction
# 24| 3: [TypeAccess] int
#-----| 4: (Parameters)
# 24| 0: [Parameter] a
# 24| 0: [TypeAccess] int
# 24| 1: [Parameter] b
# 24| 0: [TypeAccess] String
# 24| 2: [Parameter] c
# 24| 0: [TypeAccess] double
# 24| 3: [Parameter] e
# 24| 0: [TypeAccess] boolean
# 24| 5: [BlockStmt] { ... }
# 24| 0: [ReturnStmt] return ...
# 24| 0: [MethodAccess] testStaticCompanionFunction(...)
# 24| -1: [ThisAccess] this
# 24| 0: [VarAccess] a
# 24| 1: [VarAccess] b
# 24| 2: [VarAccess] c
# 24| 3: [FloatLiteral] 1.0
# 24| 4: [VarAccess] e
# 24| 7: [Method] testStaticCompanionFunction
# 24| 3: [TypeAccess] int
#-----| 4: (Parameters)
# 24| 0: [Parameter] a
# 24| 0: [TypeAccess] int
# 24| 1: [Parameter] b
# 24| 0: [TypeAccess] String
# 24| 2: [Parameter] c
# 24| 0: [TypeAccess] double
# 24| 3: [Parameter] d
# 24| 0: [TypeAccess] float
# 24| 4: [Parameter] e
# 24| 0: [TypeAccess] boolean
# 24| 5: [BlockStmt] { ... }
# 24| 0: [ReturnStmt] return ...
# 24| 0: [MethodAccess] testStaticCompanionFunction(...)
# 24| -1: [VarAccess] Test2.Companion
# 24| -1: [TypeAccess] Test2
# 24| 0: [VarAccess] a
# 24| 1: [VarAccess] b
# 24| 2: [VarAccess] c
# 24| 3: [VarAccess] d
# 24| 4: [VarAccess] e
# 30| 4: [Class,GenericType,ParameterizedType] GenericTest
#-----| -2: (Generic Parameters)
# 30| 0: [TypeVariable] T
# 30| 1: [Constructor] GenericTest
#-----| 4: (Parameters)
# 30| 0: [Parameter] b
# 30| 0: [TypeAccess] T
# 30| 1: [Parameter] d
# 30| 0: [TypeAccess] T
# 30| 5: [BlockStmt] { ... }
# 30| 0: [ThisConstructorInvocationStmt] this(...)
# 30| 0: [IntegerLiteral] 1
# 30| 1: [VarAccess] b
# 30| 2: [StringLiteral] Hello world
# 30| 3: [VarAccess] d
# 30| 2: [Constructor] GenericTest
#-----| 4: (Parameters)
# 30| 0: [Parameter] a
# 30| 0: [TypeAccess] int
# 30| 1: [Parameter] b
# 30| 0: [TypeAccess] T
# 30| 2: [Parameter] d
# 30| 0: [TypeAccess] T
# 30| 5: [BlockStmt] { ... }
# 30| 0: [ThisConstructorInvocationStmt] this(...)
# 30| 0: [VarAccess] a
# 30| 1: [VarAccess] b
# 30| 2: [StringLiteral] Hello world
# 30| 3: [VarAccess] d
# 30| 3: [Constructor] GenericTest
#-----| 4: (Parameters)
# 30| 0: [Parameter] a
# 30| 0: [TypeAccess] int
# 30| 1: [Parameter] b
# 30| 0: [TypeAccess] T
# 30| 2: [Parameter] c
# 30| 0: [TypeAccess] String
# 30| 3: [Parameter] d
# 30| 0: [TypeAccess] T
# 30| 5: [BlockStmt] { ... }
# 30| 0: [SuperConstructorInvocationStmt] super(...)
# 30| 1: [BlockStmt] { ... }
# 33| 4: [Method] testMemberFunction
# 33| 3: [TypeAccess] int
#-----| 4: (Parameters)
# 33| 0: [Parameter] b
# 33| 0: [TypeAccess] T
# 33| 1: [Parameter] d
# 33| 0: [TypeAccess] T
# 33| 5: [BlockStmt] { ... }
# 33| 0: [ReturnStmt] return ...
# 33| 0: [MethodAccess] testMemberFunction(...)
# 33| -1: [ThisAccess] this
# 33| 0: [IntegerLiteral] 1
# 33| 1: [VarAccess] b
# 33| 2: [StringLiteral] Hello world
# 33| 3: [VarAccess] d
# 33| 5: [Method] testMemberFunction
# 33| 3: [TypeAccess] int
#-----| 4: (Parameters)
# 33| 0: [Parameter] a
# 33| 0: [TypeAccess] int
# 33| 1: [Parameter] b
# 33| 0: [TypeAccess] T
# 33| 2: [Parameter] d
# 33| 0: [TypeAccess] T
# 33| 5: [BlockStmt] { ... }
# 33| 0: [ReturnStmt] return ...
# 33| 0: [MethodAccess] testMemberFunction(...)
# 33| -1: [ThisAccess] this
# 33| 0: [VarAccess] a
# 33| 1: [VarAccess] b
# 33| 2: [StringLiteral] Hello world
# 33| 3: [VarAccess] d
# 33| 6: [Method] testMemberFunction
# 33| 3: [TypeAccess] int
#-----| 4: (Parameters)
# 33| 0: [Parameter] a
# 33| 0: [TypeAccess] int
# 33| 1: [Parameter] b
# 33| 0: [TypeAccess] T
# 33| 2: [Parameter] c
# 33| 0: [TypeAccess] String
# 33| 3: [Parameter] d
# 33| 0: [TypeAccess] T
# 33| 5: [BlockStmt] { ... }
# 33| 0: [ReturnStmt] return ...
# 33| 0: [VarAccess] a
# 35| 7: [Method] useSpecialised
# 35| 3: [TypeAccess] Unit
#-----| 4: (Parameters)
# 35| 0: [Parameter] spec1
# 35| 0: [TypeAccess] GenericTest<Float>
# 35| 0: [TypeAccess] Float
# 35| 1: [Parameter] spec2
# 35| 0: [TypeAccess] GenericTest<Double>
# 35| 0: [TypeAccess] Double
# 35| 5: [BlockStmt] { ... }
# 37| 0: [ExprStmt] <Expr>;
# 37| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
# 37| 0: [TypeAccess] Unit
# 37| 1: [MethodAccess] testMemberFunction(...)
# 37| -1: [VarAccess] spec1
# 37| 0: [IntegerLiteral] 1
# 37| 1: [FloatLiteral] 1.0
# 37| 2: [StringLiteral] Hello world
# 37| 3: [FloatLiteral] 2.0
# 38| 1: [ExprStmt] <Expr>;
# 38| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
# 38| 0: [TypeAccess] Unit
# 38| 1: [MethodAccess] testMemberFunction(...)
# 38| -1: [VarAccess] spec2
# 38| 0: [IntegerLiteral] 1
# 38| 1: [DoubleLiteral] 1.0
# 38| 2: [StringLiteral] Hello world
# 38| 3: [DoubleLiteral] 2.0

View File

@@ -0,0 +1 @@
semmle/code/java/PrintAst.ql

View File

@@ -0,0 +1,48 @@
| file:///!unknown-binary-location/GenericTest.class:0:0:0:0 | GenericTest<Double> | file:///!unknown-binary-location/GenericTest.class:0:0:0:0 | GenericTest<Double> | GenericTest<Double>(int,java.lang.Double,java.lang.Double) |
| file:///!unknown-binary-location/GenericTest.class:0:0:0:0 | GenericTest<Double> | file:///!unknown-binary-location/GenericTest.class:0:0:0:0 | GenericTest<Double> | GenericTest<Double>(int,java.lang.Double,java.lang.String,java.lang.Double) |
| file:///!unknown-binary-location/GenericTest.class:0:0:0:0 | GenericTest<Double> | file:///!unknown-binary-location/GenericTest.class:0:0:0:0 | GenericTest<Double> | GenericTest<Double>(java.lang.Double,java.lang.Double) |
| file:///!unknown-binary-location/GenericTest.class:0:0:0:0 | GenericTest<Double> | file:///!unknown-binary-location/GenericTest.class:0:0:0:0 | testMemberFunction | testMemberFunction(int,java.lang.Double,java.lang.Double) |
| file:///!unknown-binary-location/GenericTest.class:0:0:0:0 | GenericTest<Double> | file:///!unknown-binary-location/GenericTest.class:0:0:0:0 | testMemberFunction | testMemberFunction(int,java.lang.Double,java.lang.String,java.lang.Double) |
| file:///!unknown-binary-location/GenericTest.class:0:0:0:0 | GenericTest<Double> | file:///!unknown-binary-location/GenericTest.class:0:0:0:0 | testMemberFunction | testMemberFunction(java.lang.Double,java.lang.Double) |
| file:///!unknown-binary-location/GenericTest.class:0:0:0:0 | GenericTest<Double> | file:///!unknown-binary-location/GenericTest.class:0:0:0:0 | useSpecialised | useSpecialised(GenericTest,GenericTest) |
| file:///!unknown-binary-location/GenericTest.class:0:0:0:0 | GenericTest<Float> | file:///!unknown-binary-location/GenericTest.class:0:0:0:0 | GenericTest<Float> | GenericTest<Float>(int,java.lang.Float,java.lang.Float) |
| file:///!unknown-binary-location/GenericTest.class:0:0:0:0 | GenericTest<Float> | file:///!unknown-binary-location/GenericTest.class:0:0:0:0 | GenericTest<Float> | GenericTest<Float>(int,java.lang.Float,java.lang.String,java.lang.Float) |
| file:///!unknown-binary-location/GenericTest.class:0:0:0:0 | GenericTest<Float> | file:///!unknown-binary-location/GenericTest.class:0:0:0:0 | GenericTest<Float> | GenericTest<Float>(java.lang.Float,java.lang.Float) |
| file:///!unknown-binary-location/GenericTest.class:0:0:0:0 | GenericTest<Float> | file:///!unknown-binary-location/GenericTest.class:0:0:0:0 | testMemberFunction | testMemberFunction(int,java.lang.Float,java.lang.Float) |
| file:///!unknown-binary-location/GenericTest.class:0:0:0:0 | GenericTest<Float> | file:///!unknown-binary-location/GenericTest.class:0:0:0:0 | testMemberFunction | testMemberFunction(int,java.lang.Float,java.lang.String,java.lang.Float) |
| file:///!unknown-binary-location/GenericTest.class:0:0:0:0 | GenericTest<Float> | file:///!unknown-binary-location/GenericTest.class:0:0:0:0 | testMemberFunction | testMemberFunction(java.lang.Float,java.lang.Float) |
| file:///!unknown-binary-location/GenericTest.class:0:0:0:0 | GenericTest<Float> | file:///!unknown-binary-location/GenericTest.class:0:0:0:0 | useSpecialised | useSpecialised(GenericTest,GenericTest) |
| test.kt:0:0:0:0 | TestKt | test.kt:1:1:1:31 | getString | getString() |
| test.kt:0:0:0:0 | TestKt | test.kt:45:1:45:112 | testExtensionFunction | testExtensionFunction(Test,int,double,boolean) |
| test.kt:0:0:0:0 | TestKt | test.kt:45:1:45:112 | testExtensionFunction | testExtensionFunction(Test,int,java.lang.String,double,boolean) |
| test.kt:0:0:0:0 | TestKt | test.kt:45:1:45:112 | testExtensionFunction | testExtensionFunction(Test,int,java.lang.String,double,float,boolean) |
| test.kt:3:1:14:1 | Test | test.kt:3:1:14:1 | Test | Test() |
| test.kt:3:1:14:1 | Test | test.kt:6:3:6:106 | testStaticFunction | testStaticFunction(int,double,boolean) |
| test.kt:3:1:14:1 | Test | test.kt:6:3:6:106 | testStaticFunction | testStaticFunction(int,java.lang.String,double,boolean) |
| test.kt:3:1:14:1 | Test | test.kt:6:3:6:106 | testStaticFunction | testStaticFunction(int,java.lang.String,double,float,boolean) |
| test.kt:3:1:14:1 | Test | test.kt:9:3:9:106 | testMemberFunction | testMemberFunction(int,double,boolean) |
| test.kt:3:1:14:1 | Test | test.kt:9:3:9:106 | testMemberFunction | testMemberFunction(int,java.lang.String,double,boolean) |
| test.kt:3:1:14:1 | Test | test.kt:9:3:9:106 | testMemberFunction | testMemberFunction(int,java.lang.String,double,float,boolean) |
| test.kt:3:1:14:1 | Test | test.kt:12:3:12:121 | testMemberExtensionFunction | testMemberExtensionFunction(Test2,int,double,boolean) |
| test.kt:3:1:14:1 | Test | test.kt:12:3:12:121 | testMemberExtensionFunction | testMemberExtensionFunction(Test2,int,java.lang.String,double,boolean) |
| test.kt:3:1:14:1 | Test | test.kt:12:3:12:121 | testMemberExtensionFunction | testMemberExtensionFunction(Test2,int,java.lang.String,double,float,boolean) |
| test.kt:16:1:28:1 | Test2 | test.kt:16:34:28:1 | Test2 | Test2(int,double,boolean) |
| test.kt:16:1:28:1 | Test2 | test.kt:16:34:28:1 | Test2 | Test2(int,java.lang.String,double,boolean) |
| test.kt:16:1:28:1 | Test2 | test.kt:16:34:28:1 | Test2 | Test2(int,java.lang.String,double,float,boolean) |
| test.kt:16:1:28:1 | Test2 | test.kt:24:5:24:117 | testStaticCompanionFunction | testStaticCompanionFunction(int,double,boolean) |
| test.kt:16:1:28:1 | Test2 | test.kt:24:5:24:117 | testStaticCompanionFunction | testStaticCompanionFunction(int,java.lang.String,double,boolean) |
| test.kt:16:1:28:1 | Test2 | test.kt:24:5:24:117 | testStaticCompanionFunction | testStaticCompanionFunction(int,java.lang.String,double,float,boolean) |
| test.kt:18:3:26:3 | Companion | test.kt:18:3:26:3 | Companion | Companion() |
| test.kt:18:3:26:3 | Companion | test.kt:21:5:21:111 | testCompanionFunction | testCompanionFunction(int,double,boolean) |
| test.kt:18:3:26:3 | Companion | test.kt:21:5:21:111 | testCompanionFunction | testCompanionFunction(int,java.lang.String,double,boolean) |
| test.kt:18:3:26:3 | Companion | test.kt:21:5:21:111 | testCompanionFunction | testCompanionFunction(int,java.lang.String,double,float,boolean) |
| test.kt:18:3:26:3 | Companion | test.kt:24:5:24:117 | testStaticCompanionFunction | testStaticCompanionFunction(int,double,boolean) |
| test.kt:18:3:26:3 | Companion | test.kt:24:5:24:117 | testStaticCompanionFunction | testStaticCompanionFunction(int,java.lang.String,double,boolean) |
| test.kt:18:3:26:3 | Companion | test.kt:24:5:24:117 | testStaticCompanionFunction | testStaticCompanionFunction(int,java.lang.String,double,float,boolean) |
| test.kt:30:1:42:1 | GenericTest | test.kt:30:43:42:1 | GenericTest | GenericTest(int,java.lang.Object,java.lang.Object) |
| test.kt:30:1:42:1 | GenericTest | test.kt:30:43:42:1 | GenericTest | GenericTest(int,java.lang.Object,java.lang.String,java.lang.Object) |
| test.kt:30:1:42:1 | GenericTest | test.kt:30:43:42:1 | GenericTest | GenericTest(java.lang.Object,java.lang.Object) |
| test.kt:30:1:42:1 | GenericTest | test.kt:33:3:33:84 | testMemberFunction | testMemberFunction(int,java.lang.Object,java.lang.Object) |
| test.kt:30:1:42:1 | GenericTest | test.kt:33:3:33:84 | testMemberFunction | testMemberFunction(int,java.lang.Object,java.lang.String,java.lang.Object) |
| test.kt:30:1:42:1 | GenericTest | test.kt:33:3:33:84 | testMemberFunction | testMemberFunction(java.lang.Object,java.lang.Object) |
| test.kt:30:1:42:1 | GenericTest | test.kt:35:3:40:3 | useSpecialised | useSpecialised(GenericTest,GenericTest) |

View File

@@ -0,0 +1,45 @@
fun getString() = "Hello world"
object Test {
@JvmOverloads @JvmStatic
fun testStaticFunction(a: Int, b: String = getString(), c: Double, d: Float = 1.0f, e: Boolean): Int = a
@JvmOverloads
fun testMemberFunction(a: Int, b: String = getString(), c: Double, d: Float = 1.0f, e: Boolean): Int = a
@JvmOverloads
fun Test2.testMemberExtensionFunction(a: Int, b: String = getString(), c: Double, d: Float = 1.0f, e: Boolean): Int = a
}
public class Test2 @JvmOverloads constructor(a: Int, b: String = getString(), c: Double, d: Float = 1.0f, e: Boolean) {
companion object {
@JvmOverloads
fun testCompanionFunction(a: Int, b: String = getString(), c: Double, d: Float = 1.0f, e: Boolean): Int = a
@JvmOverloads @JvmStatic
fun testStaticCompanionFunction(a: Int, b: String = getString(), c: Double, d: Float = 1.0f, e: Boolean): Int = a
}
}
public class GenericTest<T> @JvmOverloads constructor(a: Int = 1, b: T, c: String = "Hello world", d: T) {
@JvmOverloads
fun testMemberFunction(a: Int = 1, b: T, c: String = "Hello world", d: T): Int = a
fun useSpecialised(spec1: GenericTest<Float>, spec2: GenericTest<Double>) {
spec1.testMemberFunction(1, 1.0f, "Hello world", 2.0f)
spec2.testMemberFunction(1, 1.0, "Hello world", 2.0)
}
}
@JvmOverloads
fun Test.testExtensionFunction(a: Int, b: String = getString(), c: Double, d: Float = 1.0f, e: Boolean): Int = a

View File

@@ -0,0 +1,5 @@
import java
from Callable c
where c.getSourceDeclaration().fromSource()
select c.getDeclaringType(), c, c.getSignature()

View File

@@ -0,0 +1,43 @@
public class User {
public static String source() { return "taint"; }
public static void test(Test2 t2, GenericTest<Integer> gt, TestDefaultParameterReference paramRefTest) {
Test.taintSuppliedAsDefault(1, "no taint", 2);
Test.taintSuppliedAsDefault(1, 2);
Test.noTaintByDefault(1, source(), 2, 3);
Test.noTaintByDefault(1, source(), 2);
Test2.taintSuppliedAsDefaultStatic(1, "no taint", 2);
Test2.taintSuppliedAsDefaultStatic(1, 2);
Test2.noTaintByDefaultStatic(1, source(), 2, 3);
Test2.noTaintByDefaultStatic(1, source(), 2);
t2.taintSuppliedAsDefault(1, "no taint", 2);
t2.taintSuppliedAsDefault(1, 2);
t2.noTaintByDefault(1, source(), 2, 3);
t2.noTaintByDefault(1, source(), 2);
gt.taintSuppliedAsDefault(1, "no taint", 2);
gt.taintSuppliedAsDefault(1, 2);
gt.noTaintByDefault(1, source(), 2, 3);
gt.noTaintByDefault(1, source(), 2);
new ConstructorTaintsByDefault(1, "no taint", 2);
new ConstructorTaintsByDefault(1, 2);
new ConstructorDoesNotTaintByDefault(1, source(), 2, 3);
new ConstructorDoesNotTaintByDefault(1, source(), 2);
new GenericConstructorTaintsByDefault<Integer>(1, "no taint", 2);
new GenericConstructorTaintsByDefault<Integer>(1, 2);
new GenericConstructorDoesNotTaintByDefault<Integer>(1, source(), 2, 3);
new GenericConstructorDoesNotTaintByDefault<Integer>(1, source(), 2);
paramRefTest.f(source(), "no flow");
paramRefTest.f("flow", source());
paramRefTest.f(source()); // Should also have flow due to the default for the second parameter being the value of the first
}
}

View File

@@ -0,0 +1,21 @@
| User.java:9:30:9:37 | source(...) | test.kt:13:97:13:97 | s |
| User.java:10:30:10:37 | source(...) | test.kt:13:97:13:97 | s |
| User.java:14:37:14:44 | source(...) | test.kt:25:105:25:105 | s |
| User.java:15:37:15:44 | source(...) | test.kt:25:105:25:105 | s |
| User.java:19:28:19:35 | source(...) | test.kt:33:97:33:97 | s |
| User.java:20:28:20:35 | source(...) | test.kt:33:97:33:97 | s |
| User.java:24:28:24:35 | source(...) | test.kt:43:93:43:93 | s |
| User.java:25:28:25:35 | source(...) | test.kt:43:93:43:93 | s |
| User.java:29:45:29:52 | source(...) | test.kt:58:10:58:10 | s |
| User.java:30:45:30:52 | source(...) | test.kt:58:10:58:10 | s |
| User.java:34:61:34:68 | source(...) | test.kt:74:10:74:10 | s |
| User.java:35:61:35:68 | source(...) | test.kt:74:10:74:10 | s |
| User.java:38:28:38:35 | source(...) | test.kt:84:10:84:10 | y |
| User.java:39:20:39:27 | source(...) | test.kt:84:10:84:10 | y |
| test.kt:10:55:10:62 | source(...) | test.kt:10:84:10:84 | s |
| test.kt:22:63:22:70 | source(...) | test.kt:22:92:22:92 | s |
| test.kt:22:63:22:70 | source(...) | test.kt:22:92:22:92 | s |
| test.kt:30:55:30:62 | source(...) | test.kt:30:84:30:84 | s |
| test.kt:40:53:40:60 | source(...) | test.kt:40:80:40:80 | s |
| test.kt:47:92:47:99 | source(...) | test.kt:50:10:50:10 | s |
| test.kt:63:100:63:107 | source(...) | test.kt:66:10:66:10 | s |

View File

@@ -0,0 +1,87 @@
fun getString() = "Hello world"
fun source() = "tainted"
fun sink(s: String) { }
object Test {
@JvmOverloads @JvmStatic
fun taintSuppliedAsDefault(before: Int, s: String = source(), after: Int) { sink(s) }
@JvmOverloads @JvmStatic
fun noTaintByDefault(before: Int, s: String = "no taint", after: Int, after2: Int = 1) { sink(s) }
}
public class Test2 {
companion object {
@JvmOverloads @JvmStatic
fun taintSuppliedAsDefaultStatic(before: Int, s: String = source(), after: Int) { sink(s) }
@JvmOverloads @JvmStatic
fun noTaintByDefaultStatic(before: Int, s: String = "no taint", after: Int, after2: Int = 1) { sink(s) }
}
@JvmOverloads
fun taintSuppliedAsDefault(before: Int, s: String = source(), after: Int) { sink(s) }
@JvmOverloads
fun noTaintByDefault(before: Int, s: String = "no taint", after: Int, after2: Int = 1) { sink(s) }
}
public class GenericTest<T> {
@JvmOverloads
fun taintSuppliedAsDefault(before: T, s: String = source(), after: T) { sink(s) }
@JvmOverloads
fun noTaintByDefault(before: T, s: String = "no taint", after: T, after2: Int = 1) { sink(s) }
}
public class ConstructorTaintsByDefault @JvmOverloads constructor(before: Int, s: String = source(), after: Int) {
init {
sink(s)
}
}
public class ConstructorDoesNotTaintByDefault @JvmOverloads constructor(before: Int, s: String = "no taint", after: Int, after2: Int = 1) {
init {
sink(s)
}
}
public class GenericConstructorTaintsByDefault<T> @JvmOverloads constructor(before: T, s: String = source(), after: T) {
init {
sink(s)
}
}
public class GenericConstructorDoesNotTaintByDefault<T> @JvmOverloads constructor(before: T, s: String = "no taint", after: T, after2: T? = null) {
init {
sink(s)
}
}
fun ident(s: String) = s
public class TestDefaultParameterReference {
@JvmOverloads fun f(x: String, y: String = ident(x)) {
sink(y)
}
}

View File

@@ -0,0 +1,18 @@
import java
import semmle.code.java.dataflow.DataFlow
class Config extends DataFlow::Configuration {
Config() { this = "config" }
override predicate isSource(DataFlow::Node n) {
n.asExpr().(MethodAccess).getCallee().getName() = "source"
}
override predicate isSink(DataFlow::Node n) {
n.asExpr().(Argument).getCall().getCallee().getName() = "sink"
}
}
from Config c, DataFlow::Node source, DataFlow::Node sink
where c.hasFlow(source, sink)
select source, sink

View File

@@ -0,0 +1,9 @@
public class User {
public static void test(A a) {
a.genericFunctionWithOverloads(null, null);
}
}

View File

@@ -0,0 +1,9 @@
| test.kt:4:3:4:94 | genericFunctionWithOverloads | genericFunctionWithOverloads() | return | T | genericFunctionWithOverloads() |
| test.kt:4:3:4:94 | genericFunctionWithOverloads | genericFunctionWithOverloads(java.lang.Object) | param | T | genericFunctionWithOverloads(java.lang.Object) |
| test.kt:4:3:4:94 | genericFunctionWithOverloads | genericFunctionWithOverloads(java.lang.Object) | return | T | genericFunctionWithOverloads(java.lang.Object) |
| test.kt:4:3:4:94 | genericFunctionWithOverloads | genericFunctionWithOverloads(java.lang.Object,java.util.List) | param | List<? extends T> | genericFunctionWithOverloads(java.lang.Object,java.util.List) |
| test.kt:4:3:4:94 | genericFunctionWithOverloads | genericFunctionWithOverloads(java.lang.Object,java.util.List) | param | T | genericFunctionWithOverloads(java.lang.Object,java.util.List) |
| test.kt:4:3:4:94 | genericFunctionWithOverloads | genericFunctionWithOverloads(java.lang.Object,java.util.List) | return | T | genericFunctionWithOverloads(java.lang.Object,java.util.List) |
| test.kt:4:3:4:94 | genericFunctionWithOverloads | genericFunctionWithOverloads(java.lang.Object,java.util.List,java.lang.Object) | param | List<? extends T> | genericFunctionWithOverloads(java.lang.Object,java.util.List,java.lang.Object) |
| test.kt:4:3:4:94 | genericFunctionWithOverloads | genericFunctionWithOverloads(java.lang.Object,java.util.List,java.lang.Object) | param | T | genericFunctionWithOverloads(java.lang.Object,java.util.List,java.lang.Object) |
| test.kt:4:3:4:94 | genericFunctionWithOverloads | genericFunctionWithOverloads(java.lang.Object,java.util.List,java.lang.Object) | return | T | genericFunctionWithOverloads(java.lang.Object,java.util.List,java.lang.Object) |

View File

@@ -0,0 +1,6 @@
public class A {
@JvmOverloads
fun <T> genericFunctionWithOverloads(x: T? = null, y: List<T>? = null, z: T? = null): T? = z
}

View File

@@ -0,0 +1,16 @@
import java
from Method m, string kind, Type t
where
m.fromSource() and
(
kind = "param" and t = m.getAParamType()
or
kind = "return" and t = m.getReturnType()
)
// 't.(ParameterizedType).getATypeArgument().(Wildcard).getUpperBound().getType()' is pulling the 'T' out of 'List<? extends T>'
select m, m.getSignature(), kind, t.toString(),
[t, t.(ParameterizedType).getATypeArgument().(Wildcard).getUpperBound().getType()]
.(TypeVariable)
.getGenericCallable()
.getSignature()