Skip to content

Commit ec7a657

Browse files
authored
Merge pull request #3855 from JLLeitschuh/feat/JLL/jOOQ_SQL_injection
Add jOOQ methods as SQL Injection Sinks
2 parents 6adedac + 341ab2e commit ec7a657

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* Provides classes and predicates for working with the jOOQ framework.
3+
*/
4+
5+
import java
6+
7+
/**
8+
* Methods annotated with this allow for generation of "plain SQL"
9+
* and is prone to SQL injection.
10+
* https://www.jooq.org/doc/current/manual/sql-building/plain-sql/
11+
*/
12+
private class PlainSQLType extends Annotation {
13+
PlainSQLType() { this.getType().hasQualifiedName("org.jooq", "PlainSQL") }
14+
}
15+
16+
/**
17+
* Holds if `m` is a jOOQ SQL method taking an SQL string as its
18+
* first argument.
19+
*/
20+
predicate jOOQSqlMethod(Method m) {
21+
m.getAnAnnotation() instanceof PlainSQLType and
22+
m.getParameterType(0) instanceof TypeString
23+
}

java/ql/src/semmle/code/java/security/QueryInjection.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java
44
import semmle.code.java.dataflow.DataFlow
55
import semmle.code.java.frameworks.Jdbc
6+
import semmle.code.java.frameworks.jOOQ
67
import semmle.code.java.frameworks.android.SQLite
78
import semmle.code.java.frameworks.javaee.Persistence
89
import semmle.code.java.frameworks.SpringJdbc
@@ -30,6 +31,8 @@ private class SqlInjectionSink extends QueryInjectionSink {
3031
index = 0 and mybatisSqlMethod(m)
3132
or
3233
index = 0 and hibernateSqlMethod(m)
34+
or
35+
index = 0 and jOOQSqlMethod(m)
3336
)
3437
}
3538
}

0 commit comments

Comments
 (0)