Skip to content

Commit 3108817

Browse files
committed
C++: Add additional functions to the SQL models
1 parent d62f76a commit 3108817

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed
Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,32 @@
1+
/**
2+
* Provides implementation classes modeling the MySql C API.
3+
* See `semmle.code.cpp.models.Models` for usage information.
4+
*/
5+
16
private import semmle.code.cpp.models.interfaces.Sql
27
private import semmle.code.cpp.models.interfaces.FunctionInputsAndOutputs
38

9+
/**
10+
* The `mysql_query` family of functions from the MySQL C API.
11+
*/
412
private class MySqlExecutionFunction extends SqlExecutionFunction {
5-
MySqlExecutionFunction() { this.hasName(["mysql_query", "mysql_real_query"]) }
13+
MySqlExecutionFunction() {
14+
this.hasName(["mysql_query", "mysql_real_query", "mysql_real_query_nonblocking"])
15+
}
616

717
override predicate hasSqlArgument(FunctionInput input) { input.isParameterDeref(1) }
818
}
19+
20+
/**
21+
* The `mysql_real_escape_string` family of functions from the MySQL C API.
22+
*/
23+
private class MySqlBarrierFunction extends SqlBarrierFunction {
24+
MySqlBarrierFunction() {
25+
this.hasName(["mysql_real_escape_string", "mysql_real_escape_string_quote"])
26+
}
27+
28+
override predicate barrierSqlArgument(FunctionInput input, FunctionOutput output) {
29+
input.isParameterDeref(2) and
30+
output.isParameterDeref(1)
31+
}
32+
}
Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
1+
/**
2+
* Provides implementation classes modeling the SQLite C API.
3+
* See `semmle.code.cpp.models.Models` for usage information.
4+
*/
5+
16
private import semmle.code.cpp.models.interfaces.Sql
27
private import semmle.code.cpp.models.interfaces.FunctionInputsAndOutputs
38

9+
/**
10+
* The `sqlite3_exec` and `sqlite3_prepare` families of functions from the SQLite C API.
11+
*/
412
private class SqLite3ExecutionFunction extends SqlExecutionFunction {
5-
SqLite3ExecutionFunction() { this.hasName("sqlite3_exec") }
13+
SqLite3ExecutionFunction() {
14+
this.hasName([
15+
"sqlite3_exec", "sqlite3_prepare", "sqlite3_prepare_v2", "sqlite3_prepare_v3",
16+
"sqlite3_prepare16", "sqlite3_prepare16_v2", "sqlite3_prepare16_v3"
17+
])
18+
}
619

720
override predicate hasSqlArgument(FunctionInput input) { input.isParameterDeref(1) }
821
}

0 commit comments

Comments
 (0)