Skip to content

Commit f479649

Browse files
committed
C++: Add Boost::Asio models.
1 parent 7e5b734 commit f479649

File tree

7 files changed

+39
-6
lines changed

7 files changed

+39
-6
lines changed

cpp/ql/lib/ext/Boost.Asio.model.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
extensions:
2+
# partial model of the Boost::Asio network library
3+
extensions:
4+
- addsTo:
5+
pack: codeql/cpp-all
6+
extensible: sourceModel
7+
data: # namespace, type, subtypes, name, signature, ext, output, kind, provenance
8+
- ["boost::asio", "", False, "read", "", "", "Argument[1*]", "remote", "manual"]
9+
- ["boost::asio", "", False, "read_at", "", "", "Argument[*2]", "remote", "manual"]
10+
- ["boost::asio", "", False, "read_until", "", "", "Argument[*1]", "remote", "manual"]
11+
- ["boost::asio", "", False, "async_read", "", "", "Argument[1*]", "remote", "manual"]
12+
- ["boost::asio", "", False, "async_read_at", "", "", "Argument[*2]", "remote", "manual"]
13+
- ["boost::asio", "", False, "async_read_until", "", "", "Argument[*1]", "remote", "manual"]
14+
- addsTo:
15+
pack: codeql/cpp-all
16+
extensible: sinkModel
17+
data: # namespace, type, subtypes, name, signature, ext, input, kind, provenance
18+
- ["boost::asio", "", False, "write", "", "", "Argument[*1]", "remote-sink", "manual"]
19+
- ["boost::asio", "", False, "write_at", "", "", "Argument[*2]", "remote-sink", "manual"]
20+
- ["boost::asio", "", False, "async_write", "", "", "Argument[*1]", "remote-sink", "manual"]
21+
- ["boost::asio", "", False, "async_write_at", "", "", "Argument[*2]", "remote-sink", "manual"]
22+
- addsTo:
23+
pack: codeql/cpp-all
24+
extensible: summaryModel
25+
data: # namespace, type, subtypes, name, signature, ext, input, output, kind, provenance
26+
- ["boost::asio", "", False, "buffer", "", "", "Argument[*0]", "ReturnValue", "taint", "manual"]

cpp/ql/test/library-tests/dataflow/external-models/asio_streams.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,19 +88,19 @@ void test(boost::asio::ip::tcp::socket &socket) {
8888
if (error) {
8989
// ...
9090
}
91-
sink(recv_buffer); // $ MISSING: ir
91+
sink(recv_buffer); // $ ir
9292

93-
boost::asio::write(socket, recv_buffer, error); // $ MISSING: ir
93+
boost::asio::write(socket, recv_buffer, error); // $ ir
9494

9595
// ---
9696

9797
std::string send_str = std::string(source());
9898
sink(send_str); // $ ir
9999

100100
boost::asio::mutable_buffer send_buffer = boost::asio::buffer(send_str);
101-
sink(send_buffer); // $ MISSING: ir
101+
sink(send_buffer); // $ ir
102102

103-
boost::asio::write(socket, send_buffer, error); // $ MISSING: ir
103+
boost::asio::write(socket, send_buffer, error); // $ ir
104104
if (error) {
105105
// ...
106106
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
| asio_streams.cpp:93:29:93:39 | *recv_buffer | remote-sink |
2+
| asio_streams.cpp:103:29:103:39 | *send_buffer | remote-sink |
13
| test.cpp:9:10:9:10 | 0 | test-sink |
24
| test.cpp:11:10:11:10 | x | test-sink |
35
| test.cpp:15:10:15:10 | y | test-sink |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
| asio_streams.cpp:87:34:87:44 | read_until output argument | remote |
12
| test.cpp:7:10:7:18 | call to ymlSource | local |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
| asio_streams.cpp:100:64:100:71 | *send_str | asio_streams.cpp:100:44:100:62 | call to buffer |
12
| test.cpp:13:18:13:18 | x | test.cpp:13:10:13:16 | call to ymlStep |

cpp/ql/test/library-tests/dataflow/external-models/validatemodels.expected

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
| Dubious namespace "" in sink model. |
22
| Dubious namespace "" in source model. |
33
| Dubious namespace "" in summary model. |
4+
| Dubious namespace "boost::asio" in sink model. |
5+
| Dubious namespace "boost::asio" in source model. |
6+
| Dubious namespace "boost::asio" in summary model. |
47
| Dubious type "" in sink model. |
58
| Dubious type "" in source model. |
69
| Dubious type "" in summary model. |

cpp/ql/test/library-tests/dataflow/source-sink-tests/asio_streams.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,14 @@ void test(boost::asio::ip::tcp::socket &socket) {
7575
boost::asio::streambuf recv_buffer;
7676
boost::system::error_code error;
7777

78-
boost::asio::read_until(socket, recv_buffer, '\0', error); // $ MISSING: remote_source
78+
boost::asio::read_until(socket, recv_buffer, '\0', error); // $ remote_source
7979
if (error) {
8080
// ...
8181
}
8282

8383
std::string send_str = std::string("message");
8484
boost::asio::mutable_buffer send_buffer = boost::asio::buffer(send_str);
85-
boost::asio::write(socket, send_buffer, error); // $ MISSING: remote_sink
85+
boost::asio::write(socket, send_buffer, error); // $ remote_sink
8686
if (error) {
8787
// ...
8888
}

0 commit comments

Comments
 (0)