Skip to content

Commit 899f35a

Browse files
authored
Merge pull request github#12185 from jketema/test-annotations
C++: Update test annotations for use-use dataflow
2 parents 1d4e974 + 9e46286 commit 899f35a

File tree

11 files changed

+25
-25
lines changed

11 files changed

+25
-25
lines changed

cpp/ql/test/experimental/query-tests/Security/CWE/CWE-020/NoCheckBeforeUnsafePutUser/test.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ void test1(int p)
1919
{
2020
sys_somesystemcall(&p);
2121

22-
unsafe_put_user(123, &p); // BAD
22+
unsafe_put_user(123, &p); // BAD [NOT DETECTED]
2323
}
2424

2525
void test2(int p)
@@ -40,7 +40,7 @@ void test3()
4040

4141
sys_somesystemcall(&v);
4242

43-
unsafe_put_user(123, &v); // BAD
43+
unsafe_put_user(123, &v); // BAD [NOT DETECTED]
4444
}
4545

4646
void test4()
@@ -68,7 +68,7 @@ void test5()
6868

6969
sys_somesystemcall(&myData);
7070

71-
unsafe_put_user(123, &(myData.x)); // BAD
71+
unsafe_put_user(123, &(myData.x)); // BAD [NOT DETECTED]
7272
}
7373

7474
void test6()

cpp/ql/test/query-tests/Likely Bugs/Format/NonConstantFormat/test.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ int main(int argc, char **argv) {
4848
printf(choose_message(argc - 1), argc - 1); // GOOD
4949
printf(messages[1]); // GOOD
5050
printf(message); // GOOD
51-
printf(make_message(argc - 1)); // BAD
51+
printf(make_message(argc - 1)); // BAD [NOT DETECTED]
5252
printf("Hello, World\n"); // GOOD
5353
printf(_("Hello, World\n")); // GOOD
5454
{
@@ -97,7 +97,7 @@ int main(int argc, char **argv) {
9797
const char *hello = "Hello, World\n";
9898
const char **p = &hello;
9999
(*p)++;
100-
printf(hello); // BAD [NOT DETECTED]
100+
printf(hello); // BAD
101101
}
102102
{
103103
// Same as above block but through a C++ reference
@@ -112,7 +112,7 @@ int main(int argc, char **argv) {
112112
{
113113
const char *hello = "Hello, World\n";
114114
const char *const *p = &hello; // harmless reference to const pointer
115-
printf(hello); // GOOD
115+
printf(hello); // GOOD [FALSE POSITIVE]
116116
hello++; // modification comes after use and so does no harm
117117
}
118118
printf(argc > 2 ? "More than one\n" : _("Only one\n")); // GOOD

cpp/ql/test/query-tests/Likely Bugs/Protocols/test.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,37 +8,37 @@ void SetOptionsNoOldTls(boost::asio::ssl::context& ctx)
88

99
void TestProperConfiguration_inter_CorrectUsage01()
1010
{
11-
boost::asio::ssl::context ctx(boost::asio::ssl::context::tls_client);
11+
boost::asio::ssl::context ctx(boost::asio::ssl::context::tls_client); // GOOD [FALSE POSITIVE]
1212
SetOptionsNoOldTls(ctx);
1313
}
1414

1515
void TestProperConfiguration_inter_CorrectUsage02()
1616
{
17-
boost::asio::ssl::context ctx(boost::asio::ssl::context::sslv23);
17+
boost::asio::ssl::context ctx(boost::asio::ssl::context::sslv23); // GOOD [FALSE POSITIVE]
1818
ctx.set_options(boost::asio::ssl::context::no_tlsv1 |
1919
boost::asio::ssl::context::no_tlsv1_1 |
2020
boost::asio::ssl::context::no_sslv3);
2121
}
2222

2323
void TestProperConfiguration_inter_IncorrectUsage01()
2424
{
25-
boost::asio::ssl::context ctx(boost::asio::ssl::context::sslv23); // BUG - missing disable SSLv3
25+
boost::asio::ssl::context ctx(boost::asio::ssl::context::sslv23); // BAD - missing disable SSLv3
2626
SetOptionsNoOldTls(ctx);
2727
}
2828

2929
void TestProperConfiguration_IncorrectUsage01()
3030
{
31-
boost::asio::ssl::context ctx(boost::asio::ssl::context::sslv23); // BUG
31+
boost::asio::ssl::context ctx(boost::asio::ssl::context::sslv23); // BAD
3232
}
3333

3434
void TestProperConfiguration_IncorrectUsage02()
3535
{
36-
boost::asio::ssl::context ctx(boost::asio::ssl::context::tls); // BUG
36+
boost::asio::ssl::context ctx(boost::asio::ssl::context::tls); // BAD
3737
}
3838

3939
void TestProperConfiguration_IncorrectUsage03()
4040
{
41-
boost::asio::ssl::context ctx(boost::asio::ssl::context::tls); // BUG
41+
boost::asio::ssl::context ctx(boost::asio::ssl::context::tls); // BAD
4242
SetOptionsNoOldTls(ctx);
4343
ctx.set_options(boost::asio::ssl::context::no_tlsv1 |
4444
boost::asio::ssl::context::no_tlsv1_2 ); // BUG - disabling TLS 1.2

cpp/ql/test/query-tests/Likely Bugs/Protocols/test2.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
void good1()
44
{
5-
// GOOD
5+
// GOOD [FALSE POSITIVE]
66
boost::asio::ssl::context::method m = boost::asio::ssl::context::sslv23;
77
boost::asio::ssl::context ctx(m);
88
ctx.set_options(boost::asio::ssl::context::no_tlsv1 | boost::asio::ssl::context::no_tlsv1_1 | boost::asio::ssl::context::no_sslv3);
@@ -34,7 +34,7 @@ void bad2()
3434

3535
void good3()
3636
{
37-
// GOOD
37+
// GOOD [FALSE POSITIVE]
3838
boost::asio::ssl::context *ctx = new boost::asio::ssl::context(boost::asio::ssl::context::sslv23);
3939
ctx->set_options(boost::asio::ssl::context::no_tlsv1 | boost::asio::ssl::context::no_tlsv1_1 | boost::asio::ssl::context::no_sslv3);
4040
}

cpp/ql/test/query-tests/Likely Bugs/Protocols/test3.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ void useTLS_bad()
1313
void useTLS_good()
1414
{
1515
boost::asio::ssl::context ctx(boost::asio::ssl::context::tls);
16-
ctx.set_options(boost::asio::ssl::context::no_tlsv1 | boost::asio::ssl::context::no_tlsv1_1); // GOOD
16+
ctx.set_options(boost::asio::ssl::context::no_tlsv1 | boost::asio::ssl::context::no_tlsv1_1); // GOOD [FALSE POSITIVE]
1717

1818
// ...
1919
}

cpp/ql/test/query-tests/Security/CWE/CWE-119/semmle/tests/tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void test1()
2020
char bigbuffer[20];
2121

2222
memcpy(bigbuffer, smallbuffer, sizeof(smallbuffer)); // GOOD
23-
memcpy(bigbuffer, smallbuffer, sizeof(bigbuffer)); // BAD: over-read [NOT DETECTED]
23+
memcpy(bigbuffer, smallbuffer, sizeof(bigbuffer)); // BAD: over-read
2424
memcpy(smallbuffer, bigbuffer, sizeof(smallbuffer)); // GOOD
2525
memcpy(smallbuffer, bigbuffer, sizeof(bigbuffer)); // BAD: over-write
2626
}

cpp/ql/test/query-tests/Security/CWE/CWE-120/semmle/tests/unions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ void unions_test(MyUnion *mu)
2929
mu->ptr = buffer;
3030
strcpy(mu->ptr, "1234567890"); // GOOD
3131
strcpy(mu->ptr, "12345678901234567890"); // GOOD
32-
strcpy(mu->ptr, "123456789012345678901234567890"); // BAD
32+
strcpy(mu->ptr, "123456789012345678901234567890"); // BAD [NOT DETECTED]
3333
}

cpp/ql/test/query-tests/Security/CWE/CWE-134/semmle/argv/argvLocal.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,14 @@ int main(int argc, char **argv) {
150150
printf(i8);
151151
printWrapper(i8);
152152

153-
// BAD: i9 value comes from argv
153+
// BAD: i9 value comes from argv [NOT DETECTED]
154154
char i9buf[32];
155155
char *i9 = i9buf;
156156
memcpy(1 ? ++i9 : 0, argv[1], 1);
157157
printf(i9);
158158
printWrapper(i9);
159159

160-
// BAD: i91 value comes from argv
160+
// BAD: i91 value comes from argv [NOT DETECTED]
161161
char i91buf[64];
162162
char *i91 = &i91buf[0];
163163
memcpy(0 ? 0 : i91, argv[1] + 1, 1);

cpp/ql/test/query-tests/Security/CWE/CWE-319/UseOfHttp/test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ void doNothing(char *url)
2121
{
2222
}
2323

24-
const char *url_g = "http://example.com"; // BAD [NOT DETECTED]
24+
const char *url_g = "http://example.com"; // BAD
2525

2626
void test()
2727
{

cpp/ql/test/query-tests/Security/CWE/CWE-611/tests3.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class XMLReaderFactory
2222
void test3_1(InputSource &data) {
2323
SAX2XMLReader *p = XMLReaderFactory::createXMLReader();
2424

25-
p->parse(data); // BAD (parser not correctly configured) [NOT DETECTED]
25+
p->parse(data); // BAD (parser not correctly configured)
2626
}
2727

2828
void test3_2(InputSource &data) {
@@ -35,14 +35,14 @@ void test3_2(InputSource &data) {
3535
SAX2XMLReader *p_3_3 = XMLReaderFactory::createXMLReader();
3636

3737
void test3_3(InputSource &data) {
38-
p_3_3->parse(data); // BAD (parser not correctly configured)
38+
p_3_3->parse(data); // BAD (parser not correctly configured) [NOT DETECTED]
3939
}
4040

4141
SAX2XMLReader *p_3_4 = XMLReaderFactory::createXMLReader();
4242

4343
void test3_4(InputSource &data) {
4444
p_3_4->setFeature(XMLUni::fgXercesDisableDefaultEntityResolution, true);
45-
p_3_4->parse(data); // GOOD [FALSE POSITIVE]
45+
p_3_4->parse(data); // GOOD
4646
}
4747

4848
SAX2XMLReader *p_3_5 = XMLReaderFactory::createXMLReader();
@@ -53,7 +53,7 @@ void test3_5_init() {
5353

5454
void test3_5(InputSource &data) {
5555
test3_5_init();
56-
p_3_5->parse(data); // GOOD [FALSE POSITIVE]
56+
p_3_5->parse(data); // GOOD
5757
}
5858

5959
void test3_6(InputSource &data) {

0 commit comments

Comments
 (0)