33 */
44
55import semmle.code.java.Type
6+ import semmle.code.java.dataflow.ExternalFlow
67
78/*--- Types ---*/
89/** The interface `java.sql.Connection`. */
@@ -26,62 +27,6 @@ class TypeStatement extends Interface {
2627}
2728
2829/*--- Methods ---*/
29- /** A method with the name `prepareStatement` declared in `java.sql.Connection`. */
30- class ConnectionPrepareStatement extends Method {
31- ConnectionPrepareStatement ( ) {
32- getDeclaringType ( ) instanceof TypeConnection and
33- hasName ( "prepareStatement" )
34- }
35- }
36-
37- /** A method with the name `prepareCall` declared in `java.sql.Connection`. */
38- class ConnectionPrepareCall extends Method {
39- ConnectionPrepareCall ( ) {
40- getDeclaringType ( ) instanceof TypeConnection and
41- hasName ( "prepareCall" )
42- }
43- }
44-
45- /** A method with the name `executeQuery` declared in `java.sql.Statement`. */
46- class StatementExecuteQuery extends Method {
47- StatementExecuteQuery ( ) {
48- getDeclaringType ( ) instanceof TypeStatement and
49- hasName ( "executeQuery" )
50- }
51- }
52-
53- /** A method with the name `execute` declared in `java.sql.Statement`. */
54- class MethodStatementExecute extends Method {
55- MethodStatementExecute ( ) {
56- getDeclaringType ( ) instanceof TypeStatement and
57- hasName ( "execute" )
58- }
59- }
60-
61- /** A method with the name `executeUpdate` declared in `java.sql.Statement`. */
62- class MethodStatementExecuteUpdate extends Method {
63- MethodStatementExecuteUpdate ( ) {
64- getDeclaringType ( ) instanceof TypeStatement and
65- hasName ( "executeUpdate" )
66- }
67- }
68-
69- /** A method with the name `executeLargeUpdate` declared in `java.sql.Statement`. */
70- class MethodStatementExecuteLargeUpdate extends Method {
71- MethodStatementExecuteLargeUpdate ( ) {
72- getDeclaringType ( ) instanceof TypeStatement and
73- hasName ( "executeLargeUpdate" )
74- }
75- }
76-
77- /** A method with the name `addBatch` declared in `java.sql.Statement`. */
78- class MethodStatementAddBatch extends Method {
79- MethodStatementAddBatch ( ) {
80- getDeclaringType ( ) instanceof TypeStatement and
81- hasName ( "addBatch" )
82- }
83- }
84-
8530/** A method with the name `getString` declared in `java.sql.ResultSet`. */
8631class ResultSetGetStringMethod extends Method {
8732 ResultSetGetStringMethod ( ) {
@@ -92,24 +37,18 @@ class ResultSetGetStringMethod extends Method {
9237}
9338
9439/*--- Other definitions ---*/
95- /**
96- * An expression representing SQL code that occurs as an argument of
97- * a method in `java.sql.Connection` or `java.sql.Statement`.
98- */
99- class SqlExpr extends Expr {
100- SqlExpr ( ) {
101- exists ( MethodAccess call , Method method |
102- call .getArgument ( 0 ) = this and
103- method = call .getMethod ( ) and
104- (
105- method instanceof ConnectionPrepareStatement or
106- method instanceof ConnectionPrepareCall or
107- method instanceof StatementExecuteQuery or
108- method instanceof MethodStatementExecute or
109- method instanceof MethodStatementExecuteUpdate or
110- method instanceof MethodStatementExecuteLargeUpdate or
111- method instanceof MethodStatementAddBatch
112- )
113- )
40+ private class SqlSinkCsv extends SinkModelCsv {
41+ override predicate row ( string row ) {
42+ row =
43+ [
44+ //"package;type;overrides;name;signature;ext;spec;kind"
45+ "java.sql;Connection;true;prepareStatement;;;Argument[0];sql" ,
46+ "java.sql;Connection;true;prepareCall;;;Argument[0];sql" ,
47+ "java.sql;Statement;true;execute;;;Argument[0];sql" ,
48+ "java.sql;Statement;true;executeQuery;;;Argument[0];sql" ,
49+ "java.sql;Statement;true;executeUpdate;;;Argument[0];sql" ,
50+ "java.sql;Statement;true;executeLargeUpdate;;;Argument[0];sql" ,
51+ "java.sql;Statement;true;addBatch;;;Argument[0];sql"
52+ ]
11453 }
11554}
0 commit comments