File tree Expand file tree Collapse file tree
java/ql/test-kotlin2/library-tests/name-based-destructuring Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ selectedProperty
2+ | test.kt:10:10:10:17 | currency | test.kt:10:10:10:17 | getCurrency(...) | test.kt:3:36:3:55 | getCurrency |
3+ #select
4+ | test.kt:14:28:14:35 | source(...) | test.kt:11:10:11:17 | currency |
Original file line number Diff line number Diff line change 1+ // codeql-extractor-kotlin-options: -XXLanguage:+FullValueClasses -XXLanguage:+NameBasedDestructuring -XXLanguage:+EnableNameBasedDestructuringShortForm
2+
3+ value class Money (val amount : Int , val currency : String )
4+
5+ fun source (): String = " "
6+
7+ fun sink (value : String ) {}
8+
9+ fun test (money : Money ) {
10+ val (currency) = money
11+ sink(currency)
12+ }
13+
14+ fun flow () = test(Money (0 , source()))
Original file line number Diff line number Diff line change 1+ import java
2+ import semmle.code.java.dataflow.TaintTracking
3+
4+ query predicate selectedProperty (
5+ LocalVariableDeclExpr variable , MethodCall initializer , Method getter
6+ ) {
7+ variable .getVariable ( ) .hasName ( "currency" ) and
8+ initializer = variable .getInit ( ) and
9+ getter = initializer .getMethod ( )
10+ }
11+
12+ module Config implements DataFlow:: ConfigSig {
13+ predicate isSource ( DataFlow:: Node n ) { n .asExpr ( ) .( MethodCall ) .getMethod ( ) .hasName ( "source" ) }
14+
15+ predicate isSink ( DataFlow:: Node n ) { n .asExpr ( ) .( Argument ) .getCall ( ) .getCallee ( ) .hasName ( "sink" ) }
16+ }
17+
18+ module Flow = TaintTracking:: Global< Config > ;
19+
20+ from DataFlow:: Node source , DataFlow:: Node sink
21+ where Flow:: flow ( source , sink )
22+ select source , sink
Original file line number Diff line number Diff line change 1+ test.ql
You can’t perform that action at this time.
0 commit comments