@@ -102,3 +102,40 @@ class MyBatisSqlOperationAnnotationMethod extends Method {
102102class TypeParam extends Interface {
103103 TypeParam ( ) { this .hasQualifiedName ( "org.apache.ibatis.annotations" , "Param" ) }
104104}
105+
106+ module ProviderInjection {
107+ private import semmle.code.java.dataflow.DataFlow
108+
109+ class MyBatisInjectionSink extends DataFlow:: Node {
110+ MyBatisInjectionSink ( ) {
111+ exists ( Annotation a , Method m , TypeLiteral type , Class c |
112+ a .getType ( )
113+ .hasQualifiedName ( "org.apache.ibatis.annotations" ,
114+ [ "Select" , "Delete" , "Insert" , "Update" ] + "Provider" ) and
115+ type = a .getValue ( [ "type" , "value" ] ) and
116+ c .hasMethod ( m , type .getTypeName ( ) .getType ( ) ) and
117+ m .hasName ( a .getTarget ( ) .getName ( ) ) and
118+ this .asExpr ( ) = m .getBody ( ) .getAStmt ( ) .( ReturnStmt ) .getResult ( )
119+ )
120+ }
121+ }
122+
123+ class MyBatisAbstractSQLStep extends Unit {
124+ predicate step ( DataFlow:: Node node1 , DataFlow:: Node node2 ) {
125+ exists ( MethodAccess ma |
126+ ma .getMethod ( )
127+ .getDeclaringType ( )
128+ .hasQualifiedName ( "org.apache.ibatis.jdbc" , [ "AbstractSQL" , "AbstractSQL<SQL>" ] ) and
129+ ma .getMethod ( )
130+ .hasName ( [
131+ "SELECT" , "OFFSET_ROWS" , "FETCH_FIRST_ROWS_ONLY" , "OFFSET" , "LIMIT" , "ORDER_BY" ,
132+ "HAVING" , "GROUP_BY" , "WHERE" , "OUTER_JOIN" , "RIGHT_OUTER_JOIN" , "LEFT_OUTER_JOIN" ,
133+ "INNER_JOIN" , "JOIN" , "FROM" , "DELETE_FROM" , "SELECT_DISTINCT" , "SELECT" ,
134+ "INTO_VALUES" , "INTO_COLUMNS" , "VALUES" , "INSERT_INTO" , "SET" , "UPDATE"
135+ ] ) and
136+ ma .getArgument ( [ 0 , 1 ] ) = node1 .asExpr ( ) and
137+ ma = node2 .asExpr ( )
138+ )
139+ }
140+ }
141+ }
0 commit comments