13
13
*/
14
14
15
15
import java
16
- import DataFlow:: PathGraph
17
16
import MyBatisCommonLib
18
17
import MyBatisAnnotationSqlInjectionLib
19
18
import semmle.code.java.dataflow.FlowSources
19
+ import semmle.code.java.dataflow.TaintTracking
20
+ import MyBatisAnnotationSqlInjectionFlow:: PathGraph
20
21
21
- private class MyBatisAnnotationSqlInjectionConfiguration extends TaintTracking :: Configuration {
22
- MyBatisAnnotationSqlInjectionConfiguration ( ) { this = "MyBatis annotation sql injection" }
22
+ private module MyBatisAnnotationSqlInjectionConfig implements DataFlow :: ConfigSig {
23
+ predicate isSource ( DataFlow :: Node source ) { source instanceof RemoteFlowSource }
23
24
24
- override predicate isSource ( DataFlow:: Node source ) { source instanceof RemoteFlowSource }
25
+ predicate isSink ( DataFlow:: Node sink ) { sink instanceof MyBatisAnnotatedMethodCallArgument }
25
26
26
- override predicate isSink ( DataFlow:: Node sink ) {
27
- sink instanceof MyBatisAnnotatedMethodCallArgument
28
- }
29
-
30
- override predicate isSanitizer ( DataFlow:: Node node ) {
27
+ predicate isBarrier ( DataFlow:: Node node ) {
31
28
node .getType ( ) instanceof PrimitiveType or
32
29
node .getType ( ) instanceof BoxedType or
33
30
node .getType ( ) instanceof NumberType
34
31
}
35
32
36
- override predicate isAdditionalTaintStep ( DataFlow:: Node node1 , DataFlow:: Node node2 ) {
33
+ predicate isAdditionalFlowStep ( DataFlow:: Node node1 , DataFlow:: Node node2 ) {
37
34
exists ( MethodAccess ma |
38
35
ma .getMethod ( ) .getDeclaringType ( ) instanceof TypeObject and
39
36
ma .getMethod ( ) .getName ( ) = "toString" and
@@ -43,12 +40,15 @@ private class MyBatisAnnotationSqlInjectionConfiguration extends TaintTracking::
43
40
}
44
41
}
45
42
43
+ private module MyBatisAnnotationSqlInjectionFlow =
44
+ TaintTracking:: Global< MyBatisAnnotationSqlInjectionConfig > ;
45
+
46
46
from
47
- MyBatisAnnotationSqlInjectionConfiguration cfg , DataFlow :: PathNode source ,
48
- DataFlow :: PathNode sink , IbatisSqlOperationAnnotation isoa , MethodAccess ma ,
49
- string unsafeExpression
47
+ MyBatisAnnotationSqlInjectionFlow :: PathNode source ,
48
+ MyBatisAnnotationSqlInjectionFlow :: PathNode sink , IbatisSqlOperationAnnotation isoa ,
49
+ MethodAccess ma , string unsafeExpression
50
50
where
51
- cfg . hasFlowPath ( source , sink ) and
51
+ MyBatisAnnotationSqlInjectionFlow :: flowPath ( source , sink ) and
52
52
ma .getAnArgument ( ) = sink .getNode ( ) .asExpr ( ) and
53
53
myBatisSqlOperationAnnotationFromMethod ( ma .getMethod ( ) , isoa ) and
54
54
unsafeExpression = getAMybatisAnnotationSqlValue ( isoa ) and
0 commit comments