Skip to content

Commit eb44dde

Browse files
committed
Address review comments
1 parent fa16728 commit eb44dde

10 files changed

Lines changed: 15 additions & 16 deletions

File tree

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); // $ MISSING: Alert // $ MISSING: Alert // BAD [NOT DETECTED]
22+
unsafe_put_user(123, &p); // $ MISSING: Alert // 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); // $ MISSING: Alert // $ MISSING: Alert // BAD [NOT DETECTED]
43+
unsafe_put_user(123, &v); // $ MISSING: Alert // 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)); // $ MISSING: Alert // $ MISSING: Alert // BAD [NOT DETECTED]
71+
unsafe_put_user(123, &(myData.x)); // $ MISSING: Alert // BAD [NOT DETECTED]
7272
}
7373

7474
void test6()

cpp/ql/test/experimental/query-tests/Security/CWE/CWE-190/AllocMultiplicationOverflow/test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ void test()
2424

2525
size_t size2 = x;
2626
size2 *= y;
27-
char *buffer6 = (char *)malloc(size2); // $ MISSING: Alert // $ MISSING: Alert // BAD [NOT DETECTED]
27+
char *buffer6 = (char *)malloc(size2); // $ MISSING: Alert // BAD [NOT DETECTED]
2828

2929
char *buffer7 = new char[x * 10]; // GOOD
3030
char *buffer8 = new char[x * y]; // $ Alert // BAD

cpp/ql/test/experimental/query-tests/Security/CWE/CWE-295/CurlSSL.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace std{
77
CURLOPT_URL,
88
CURLOPT_SSL_VERIFYHOST,
99
CURLOPT_SSL_VERIFYPEER
10-
};
10+
};
1111

1212
CURL *curl_easy_init();
1313
void curl_easy_cleanup(CURL *handle);
@@ -23,15 +23,15 @@ char host[] = "codeql.com";
2323
void bad(void) {
2424
std::unique_ptr<CURL> curl = std::unique_ptr<CURL>(curl_easy_init());
2525
curl_easy_setopt(curl.get(), CURLOPT_SSL_VERIFYPEER, 0); // $ Alert
26-
curl_easy_setopt(curl.get(), CURLOPT_SSL_VERIFYHOST, 0); // $ Alert
26+
curl_easy_setopt(curl.get(), CURLOPT_SSL_VERIFYHOST, 0); // $ Alert
2727
curl_easy_setopt(curl.get(), CURLOPT_URL, host);
2828
curl_easy_perform(curl.get());
2929
}
3030

3131
void good(void) {
3232
std::unique_ptr<CURL> curl = std::unique_ptr<CURL>(curl_easy_init());
3333
curl_easy_setopt(curl.get(), CURLOPT_SSL_VERIFYPEER, 2);
34-
curl_easy_setopt(curl.get(), CURLOPT_SSL_VERIFYHOST, 2);
34+
curl_easy_setopt(curl.get(), CURLOPT_SSL_VERIFYHOST, 2);
3535
curl_easy_setopt(curl.get(), CURLOPT_URL, host);
3636
curl_easy_perform(curl.get());
3737
}
@@ -40,4 +40,3 @@ int main(int c, char** argv){
4040
bad();
4141
good();
4242
}
43-

cpp/ql/test/query-tests/Best Practices/Likely Errors/CommaBeforeMisleadingIndentation/test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ int Foo::test(int (*baz)(int))
175175
return i++
176176
, i++ // GOOD(?) [FALSE POSITIVE] -- can't exclude w/o source code text :/
177177
? 1
178-
: 2; // $ Alert
178+
: 2; // $ SPURIOUS: Alert
179179

180180
int quux =
181181
(tata->titi.tutu(),

cpp/ql/test/query-tests/Best Practices/Unused Entities/UnusedLocals/code2.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ int test_const_init()
66
int v2; // GOOD
77
int v3 = 0; // $ Alert // BAD: unused
88
int v4 = 0; // GOOD
9-
const int v5 = 0; // BAD: unused [NOT DETECTED]
9+
const int v5 = 0; // $ MISSING: Alert // BAD: unused [NOT DETECTED]
1010
const int v6 = 0; // GOOD
1111
constexpr int v7 = 0; // $ Alert // BAD: unused
1212
constexpr int v8 = 0; // GOOD
@@ -126,7 +126,7 @@ int test_lambdas1()
126126
int test_lambdas2()
127127
{
128128
int a, b; // $ Alert // BAD: b is not used
129-
auto myLambda = [=]() -> int // BAD: myLambda is not used [NOT DETECTED] (due to containing a Constructor)
129+
auto myLambda = [=]() -> int // $ MISSING: Alert // BAD: myLambda is not used [NOT DETECTED] (due to containing a Constructor)
130130
{
131131
return a;
132132
};

cpp/ql/test/query-tests/Likely Bugs/Format/WrongNumberOfFormatArguments/syntax_errors.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ void test_syntax_error() {
1212
(UNDEFINED_MACRO)2);
1313

1414
// GOOD [FALSE POSITIVE]
15-
printf("%d%d" // $ Alert[cpp/wrong-number-format-arguments]
15+
printf("%d%d" // $ SPURIOUS: Alert[cpp/wrong-number-format-arguments]
1616
UNDEFINED_MACRO,
1717
1, 2);
1818
}

cpp/ql/test/query-tests/Likely Bugs/Format/WrongTypeFormatArguments/Linux_signed_chars/pri_macros.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ void test_PRI_macros() {
1111

1212
printf("my_u64 = %" PRIu64 "\n", my_u64); // GOOD
1313
printf("my_u64 = %" PRIx64 "\n", my_u64); // GOOD
14-
printf("my_u64 = %" PRIi64 "\n", my_u64); // BAD: uint64_t read as int64_t [NOT DETECTED]
14+
printf("my_u64 = %" PRIi64 "\n", my_u64); // $ MISSING: Alert // BAD: uint64_t read as int64_t [NOT DETECTED]
1515
printf("my_u64 = %" PRIu32 "\n", my_u64); // $ Alert // BAD: uint64_t read as uint32_t
1616
}

cpp/ql/test/query-tests/Likely Bugs/Format/WrongTypeFormatArguments/Linux_unsigned_chars/pri_macros.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ void test_PRI_macros() {
1111

1212
printf("my_u64 = %" PRIu64 "\n", my_u64); // GOOD
1313
printf("my_u64 = %" PRIx64 "\n", my_u64); // GOOD
14-
printf("my_u64 = %" PRIi64 "\n", my_u64); // BAD: uint64_t read as int64_t [NOT DETECTED]
14+
printf("my_u64 = %" PRIi64 "\n", my_u64); // $ MISSING: Alert // BAD: uint64_t read as int64_t [NOT DETECTED]
1515
printf("my_u64 = %" PRIu32 "\n", my_u64); // $ Alert // BAD: uint64_t read as uint32_t
1616
}

cpp/ql/test/query-tests/Likely Bugs/Format/WrongTypeFormatArguments/Microsoft/pri_macros.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ void test_PRI_macros() {
1111

1212
printf("my_u64 = %" PRIu64 "\n", my_u64); // GOOD
1313
printf("my_u64 = %" PRIx64 "\n", my_u64); // GOOD
14-
printf("my_u64 = %" PRIi64 "\n", my_u64); // BAD: uint64_t read as int64_t [NOT DETECTED]
14+
printf("my_u64 = %" PRIi64 "\n", my_u64); // $ MISSING: Alert // BAD: uint64_t read as int64_t [NOT DETECTED]
1515
printf("my_u64 = %" PRIu32 "\n", my_u64); // $ Alert // BAD: uint64_t read as uint32_t
1616
}

cpp/ql/test/query-tests/Likely Bugs/Format/WrongTypeFormatArguments/Microsoft_no_wchar/pri_macros.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ void test_PRI_macros() {
1111

1212
printf("my_u64 = %" PRIu64 "\n", my_u64); // GOOD
1313
printf("my_u64 = %" PRIx64 "\n", my_u64); // GOOD
14-
printf("my_u64 = %" PRIi64 "\n", my_u64); // BAD: uint64_t read as int64_t [NOT DETECTED]
14+
printf("my_u64 = %" PRIi64 "\n", my_u64); // $ MISSING: Alert // BAD: uint64_t read as int64_t [NOT DETECTED]
1515
printf("my_u64 = %" PRIu32 "\n", my_u64); // $ Alert // BAD: uint64_t read as uint32_t
1616
}

0 commit comments

Comments
 (0)