Skip to content

Commit ba0ba15

Browse files
committed
C++: Add CSimpleStringT model and accept tests.
1 parent b42bffc commit ba0ba15

File tree

5 files changed

+134
-23
lines changed

5 files changed

+134
-23
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
extensions:
2+
- addsTo:
3+
pack: codeql/cpp-all
4+
extensible: summaryModel
5+
data: # TODO this model can be improved a lot once we have MapKey content # namespace, type, subtypes, name, signature, ext, input, output, kind, provenance
6+
- ["", "CSimpleStringT", True, "CSimpleStringT", "(const XCHAR *,int,IAtlStringMgr *)", "", "Argument[*0]", "Argument[-1]", "value", "manual"]
7+
- ["", "CSimpleStringT", True, "CSimpleStringT", "(PCXSTR,IAtlStringMgr *)", "", "Argument[*0]", "Argument[-1]", "value", "manual"]
8+
- ["", "CSimpleStringT", True, "CSimpleStringT", "(const CSimpleStringT &)", "", "Argument[*0]", "Argument[-1]", "value", "manual"]
9+
- ["", "CSimpleStringT", True, "Append", "", "", "Argument[*0]", "Argument[-1]", "taint", "manual"]
10+
- ["", "CSimpleStringT", True, "AppendChar", "", "", "Argument[0]", "Argument[-1]", "taint", "manual"]
11+
- ["", "CSimpleStringT", True, "CopyChars", "(XCHAR *,const XCHAR *,int)", "", "Argument[*1]", "Argument[*0]", "value", "manual"]
12+
- ["", "CSimpleStringT", True, "CopyChars", "(XCHAR *,size_t,const XCHAR *,int)", "", "Argument[*2]", "Argument[*0]", "value", "manual"]
13+
- ["", "CSimpleStringT", True, "CopyCharsOverlapped", "(XCHAR *,const XCHAR *,int)", "", "Argument[*1]", "Argument[*0]", "value", "manual"]
14+
- ["", "CSimpleStringT", True, "GetString", "", "", "Argument[-1]", "ReturnValue[*]", "value", "manual"]
15+
- ["", "CSimpleStringT", True, "LockString", "", "", "Argument[-1]", "ReturnValue[*]", "value", "manual"]
16+
- ["", "CSimpleStringT", True, "SetAt", "", "", "Argument[1]", "Argument[-1]", "taint", "manual"]
17+
- ["", "CSimpleStringT", True, "SetString", "", "", "Argument[*0]", "Argument[-1]", "value", "manual"]
18+
- ["", "CSimpleStringT", True, "operator PCXSTR", "", "", "Argument[-1]", "ReturnValue[*]", "value", "manual"]
19+
- ["", "CSimpleStringT", True, "operator[]", "", "", "Argument[-1]", "ReturnValue", "taint", "manual"]
20+
- ["", "CSimpleStringT", True, "operator+=", "(PCXSTR)", "", "Argument[-1]", "ReturnValue[*]", "taint", "manual"]
21+
- ["", "CSimpleStringT", True, "operator+=", "(PCXSTR)", "", "Argument[*0]", "ReturnValue[*]", "taint", "manual"]
22+
- ["", "CSimpleStringT", True, "operator+=", "(PCXSTR)", "", "Argument[*0]", "Argument[-1]", "taint", "manual"]
23+
- ["", "CSimpleStringT", True, "operator+=", "(const CSimpleStringT &)", "", "Argument[-1]", "ReturnValue[*]", "taint", "manual"]
24+
- ["", "CSimpleStringT", True, "operator+=", "(const CSimpleStringT &)", "", "Argument[*0]", "ReturnValue[*]", "taint", "manual"]
25+
- ["", "CSimpleStringT", True, "operator+=", "(const CSimpleStringT &)", "", "Argument[*0]", "Argument[-1]", "taint", "manual"]
26+
- ["", "CSimpleStringT", True, "operator+=", "(const CStaticString &)", "", "Argument[-1]", "ReturnValue[*]", "taint", "manual"]
27+
- ["", "CSimpleStringT", True, "operator+=", "(const CStaticString &)", "", "Argument[*0]", "ReturnValue[*]", "taint", "manual"]
28+
- ["", "CSimpleStringT", True, "operator+=", "(const CStaticString &)", "", "Argument[*0]", "Argument[-1]", "taint", "manual"]
29+
- ["", "CSimpleStringT", True, "operator+=", "(char)", "", "Argument[-1]", "ReturnValue[*]", "taint", "manual"]
30+
- ["", "CSimpleStringT", True, "operator+=", "(char)", "", "Argument[0]", "ReturnValue[*]", "taint", "manual"]
31+
- ["", "CSimpleStringT", True, "operator+=", "(char)", "", "Argument[0]", "Argument[-1]", "taint", "manual"]
32+
- ["", "CSimpleStringT", True, "operator+=", "(unsigned char)", "", "Argument[-1]", "ReturnValue[*]", "taint", "manual"]
33+
- ["", "CSimpleStringT", True, "operator+=", "(unsigned char)", "", "Argument[0]", "ReturnValue[*]", "taint", "manual"]
34+
- ["", "CSimpleStringT", True, "operator+=", "(unsigned char)", "", "Argument[0]", "Argument[-1]", "taint", "manual"]
35+
- ["", "CSimpleStringT", True, "operator+=", "(wchar_t)", "", "Argument[-1]", "ReturnValue[*]", "taint", "manual"]
36+
- ["", "CSimpleStringT", True, "operator+=", "(wchar_t)", "", "Argument[0]", "ReturnValue[*]", "taint", "manual"]
37+
- ["", "CSimpleStringT", True, "operator+=", "(wchar_t)", "", "Argument[0]", "Argument[-1]", "taint", "manual"]
38+
- ["", "CSimpleStringT", True, "operator=", "", "", "Argument[*0]", "Argument[-1]", "value", "manual"]
39+
- ["", "CSimpleStringT", True, "GetAt", "", "", "Argument[-1]", "ReturnValue", "taint", "manual"]
40+
- ["", "CSimpleStringT", True, "GetBuffer", "", "", "Argument[-1]", "ReturnValue[*]", "value", "manual"]
41+
- ["", "CSimpleStringT", True, "GetBufferSetLength", "", "", "Argument[-1]", "ReturnValue[*]", "value", "manual"]

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ edges
1010
| asio_streams.cpp:100:44:100:62 | call to buffer | asio_streams.cpp:103:29:103:39 | *send_buffer | provenance | Sink:MaD:6 |
1111
| asio_streams.cpp:100:64:100:71 | *send_str | asio_streams.cpp:56:18:56:23 | [summary param] *0 in buffer | provenance | |
1212
| asio_streams.cpp:100:64:100:71 | *send_str | asio_streams.cpp:100:44:100:62 | call to buffer | provenance | MaD:10 |
13-
| test.cpp:4:5:4:11 | [summary param] 0 in ymlStep | test.cpp:4:5:4:11 | [summary] to write: ReturnValue in ymlStep | provenance | MaD:801 |
14-
| test.cpp:7:10:7:18 | call to ymlSource | test.cpp:7:10:7:18 | call to ymlSource | provenance | Src:MaD:799 |
15-
| test.cpp:7:10:7:18 | call to ymlSource | test.cpp:11:10:11:10 | x | provenance | Sink:MaD:800 |
13+
| test.cpp:4:5:4:11 | [summary param] 0 in ymlStep | test.cpp:4:5:4:11 | [summary] to write: ReturnValue in ymlStep | provenance | MaD:837 |
14+
| test.cpp:7:10:7:18 | call to ymlSource | test.cpp:7:10:7:18 | call to ymlSource | provenance | Src:MaD:835 |
15+
| test.cpp:7:10:7:18 | call to ymlSource | test.cpp:11:10:11:10 | x | provenance | Sink:MaD:836 |
1616
| test.cpp:7:10:7:18 | call to ymlSource | test.cpp:13:18:13:18 | x | provenance | |
1717
| test.cpp:13:10:13:16 | call to ymlStep | test.cpp:13:10:13:16 | call to ymlStep | provenance | |
18-
| test.cpp:13:10:13:16 | call to ymlStep | test.cpp:15:10:15:10 | y | provenance | Sink:MaD:800 |
18+
| test.cpp:13:10:13:16 | call to ymlStep | test.cpp:15:10:15:10 | y | provenance | Sink:MaD:836 |
1919
| test.cpp:13:18:13:18 | x | test.cpp:4:5:4:11 | [summary param] 0 in ymlStep | provenance | |
20-
| test.cpp:13:18:13:18 | x | test.cpp:13:10:13:16 | call to ymlStep | provenance | MaD:801 |
20+
| test.cpp:13:18:13:18 | x | test.cpp:13:10:13:16 | call to ymlStep | provenance | MaD:837 |
2121
nodes
2222
| asio_streams.cpp:56:18:56:23 | [summary param] *0 in buffer | semmle.label | [summary param] *0 in buffer |
2323
| asio_streams.cpp:56:18:56:23 | [summary] to write: ReturnValue in buffer | semmle.label | [summary] to write: ReturnValue in buffer |

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,17 @@
1818
| Dubious signature "(InputIterator,InputIterator,const Allocator &)" in summary model. |
1919
| Dubious signature "(LPCTSTR,DWORD *,void *,ULONG *)" in summary model. |
2020
| Dubious signature "(LPTSTR,LPCTSTR,DWORD *)" in summary model. |
21+
| Dubious signature "(PCXSTR,IAtlStringMgr *)" in summary model. |
22+
| Dubious signature "(XCHAR *,const XCHAR *,int)" in summary model. |
23+
| Dubious signature "(XCHAR *,size_t,const XCHAR *,int)" in summary model. |
2124
| Dubious signature "(const CComBSTR &)" in summary model. |
2225
| Dubious signature "(const CComSafeArray &)" in summary model. |
26+
| Dubious signature "(const CSimpleStringT &)" in summary model. |
27+
| Dubious signature "(const CStaticString &)" in summary model. |
2328
| Dubious signature "(const SAFEARRAY &)" in summary model. |
2429
| Dubious signature "(const SAFEARRAY *)" in summary model. |
2530
| Dubious signature "(const T &,BOOL)" in summary model. |
31+
| Dubious signature "(const XCHAR *,int,IAtlStringMgr *)" in summary model. |
2632
| Dubious signature "(const deque &)" in summary model. |
2733
| Dubious signature "(const deque &,const Allocator &)" in summary model. |
2834
| Dubious signature "(const forward_list &)" in summary model. |
@@ -43,5 +49,6 @@
4349
| Dubious signature "(list &&,const Allocator &)" in summary model. |
4450
| Dubious signature "(size_type,const T &)" in summary model. |
4551
| Dubious signature "(size_type,const T &,const Allocator &)" in summary model. |
52+
| Dubious signature "(unsigned char)" in summary model. |
4653
| Dubious signature "(vector &&)" in summary model. |
4754
| Dubious signature "(vector &&,const Allocator &)" in summary model. |

cpp/ql/test/library-tests/dataflow/taint-tests/atl.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -954,58 +954,58 @@ void test_CSimpleStringT() {
954954
char* x = indirect_source<char>();
955955

956956
CSimpleStringT<char> s1(x, 10, nullptr);
957-
sink(s1.GetString()); // $ MISSING: ir
957+
sink(s1.GetString()); // $ ir
958958

959959
CSimpleStringT<char> s2(x, nullptr);
960-
sink(s2.GetString()); // $ MISSING: ir
960+
sink(s2.GetString()); // $ ir
961961

962962
CSimpleStringT<char> s3(s2);
963-
sink(s3.GetString()); // $ MISSING: ir
963+
sink(s3.GetString()); // $ ir
964964

965965
CSimpleStringT<char> s4;
966966
s4.Append(indirect_source<char>());
967-
sink(s4.GetString()); // $ MISSING: ir
967+
sink(s4.GetString()); // $ ir
968968

969969
CSimpleStringT<char> s5;
970970
s5.Append(s4);
971-
sink(s5.GetString()); // $ MISSING: ir
971+
sink(s5.GetString()); // $ ir
972972

973973
CSimpleStringT<char> s6;
974974
s6.Append(indirect_source<char>(), 42);
975-
sink(s6.GetString()); // $ MISSING: ir
975+
sink(s6.GetString()); // $ ir
976976

977977
char buffer1[128];
978978
CSimpleStringT<char>::CopyChars(buffer1, x, 10);
979-
sink(buffer1); // $ ast MISSING: ir
979+
sink(buffer1); // $ ast ir
980980

981981
char buffer2[128];
982982
CSimpleStringT<char>::CopyChars(buffer2, 128, x, 10);
983-
sink(buffer2); // $ ast MISSING: ir
983+
sink(buffer2); // $ ast ir
984984

985985
char buffer3[128];
986986
CSimpleStringT<char>::CopyCharsOverlapped(buffer3, x, 10);
987-
sink(buffer3); // $ ast MISSING: ir
987+
sink(buffer3); // $ ast ir
988988

989-
sink(s4.GetAt(0)); // $ MISSING: ir
990-
sink(s4.GetBuffer(10)); // $ MISSING: ir
991-
sink(s4.GetBuffer()); // $ MISSING: ir
992-
sink(s4.GetBufferSetLength(10)); // $ MISSING: ir
989+
sink(s4.GetAt(0)); // $ ir
990+
sink(s4.GetBuffer(10)); // $ ir
991+
sink(s4.GetBuffer()); // $ ir
992+
sink(s4.GetBufferSetLength(10)); // $ ir
993993

994994
sink(s4.LockBuffer());
995995

996996
CSimpleStringT<char> s7;
997997
s7.SetAt(0, source<char>());
998-
sink(s7.GetAt(0)); // $ MISSING: ir
998+
sink(s7.GetAt(0)); // $ ir
999999

10001000
CSimpleStringT<char> s8;
10011001
s8.SetString(indirect_source<char>());
1002-
sink(s8.GetAt(0)); // $ MISSING: ir
1002+
sink(s8.GetAt(0)); // $ ir
10031003

10041004
CSimpleStringT<char> s9;
10051005
s9.SetString(indirect_source<char>(), 1024);
1006-
sink(s9.GetAt(0)); // $ MISSING: ir
1006+
sink(s9.GetAt(0)); // $ ir
10071007

1008-
sink(static_cast<CSimpleStringT<char>::PCXSTR>(s1)); // $ MISSING: ir
1008+
sink(static_cast<CSimpleStringT<char>::PCXSTR>(s1)); // $ ir
10091009

1010-
sink(s1[0]); // $ MISSING: ir
1010+
sink(s1[0]); // $ ir
10111011
}

0 commit comments

Comments
 (0)