@@ -43,12 +43,14 @@ import semmle.code.java.dataflow.ExternalFlow
4343import semmle.code.java.dataflow.TaintTracking
4444import TestUtilities.InlineExpectationsTest
4545
46+ private predicate defaultSource ( DataFlow:: Node src ) {
47+ src .asExpr ( ) .( MethodAccess ) .getMethod ( ) .getName ( ) = [ "source" , "taint" ]
48+ }
49+
4650class DefaultValueFlowConf extends DataFlow:: Configuration {
4751 DefaultValueFlowConf ( ) { this = "qltest:defaultValueFlowConf" }
4852
49- override predicate isSource ( DataFlow:: Node n ) {
50- n .asExpr ( ) .( MethodAccess ) .getMethod ( ) .getName ( ) = [ "source" , "taint" ]
51- }
53+ override predicate isSource ( DataFlow:: Node n ) { defaultSource ( n ) }
5254
5355 override predicate isSink ( DataFlow:: Node n ) {
5456 exists ( MethodAccess ma | ma .getMethod ( ) .hasName ( "sink" ) | n .asExpr ( ) = ma .getAnArgument ( ) )
@@ -60,9 +62,7 @@ class DefaultValueFlowConf extends DataFlow::Configuration {
6062class DefaultTaintFlowConf extends TaintTracking:: Configuration {
6163 DefaultTaintFlowConf ( ) { this = "qltest:defaultTaintFlowConf" }
6264
63- override predicate isSource ( DataFlow:: Node n ) {
64- n .asExpr ( ) .( MethodAccess ) .getMethod ( ) .getName ( ) = [ "source" , "taint" ]
65- }
65+ override predicate isSource ( DataFlow:: Node n ) { defaultSource ( n ) }
6666
6767 override predicate isSink ( DataFlow:: Node n ) {
6868 exists ( MethodAccess ma | ma .getMethod ( ) .hasName ( "sink" ) | n .asExpr ( ) = ma .getAnArgument ( ) )
@@ -71,6 +71,11 @@ class DefaultTaintFlowConf extends TaintTracking::Configuration {
7171 override int fieldFlowBranchLimit ( ) { result = 1000 }
7272}
7373
74+ private string getSourceArgString ( DataFlow:: Node src ) {
75+ defaultSource ( src ) and
76+ src .asExpr ( ) .( MethodAccess ) .getAnArgument ( ) .( StringLiteral ) .getValue ( ) = result
77+ }
78+
7479class InlineFlowTest extends InlineExpectationsTest {
7580 InlineFlowTest ( ) { this = "HasFlowTest" }
7681
@@ -81,7 +86,7 @@ class InlineFlowTest extends InlineExpectationsTest {
8186 exists ( DataFlow:: Node src , DataFlow:: Node sink | getValueFlowConfig ( ) .hasFlow ( src , sink ) |
8287 sink .getLocation ( ) = location and
8388 element = sink .toString ( ) and
84- value = ""
89+ if exists ( getSourceArgString ( src ) ) then value = getSourceArgString ( src ) else value = ""
8590 )
8691 or
8792 tag = "hasTaintFlow" and
@@ -90,7 +95,7 @@ class InlineFlowTest extends InlineExpectationsTest {
9095 |
9196 sink .getLocation ( ) = location and
9297 element = sink .toString ( ) and
93- value = ""
98+ if exists ( getSourceArgString ( src ) ) then value = getSourceArgString ( src ) else value = ""
9499 )
95100 }
96101
0 commit comments