C++: Convert qlref tests to inline expectations#22127
Conversation
24aac89 to
e1753ae
Compare
Rerun has been triggered: 2 restarted 🚀 |
1 similar comment
Rerun has been triggered: 2 restarted 🚀 |
|
Since I was looking at this already: I see quite some |
e1753ae to
76d8ae8
Compare
jketema
left a comment
There was a problem hiding this comment.
Got up to query-tests/Security, but need a break 😅
| sys_somesystemcall(&p); | ||
|
|
||
| unsafe_put_user(123, &p); // BAD [NOT DETECTED] | ||
| unsafe_put_user(123, &p); // $ MISSING: Alert // $ MISSING: Alert // BAD [NOT DETECTED] |
There was a problem hiding this comment.
| unsafe_put_user(123, &p); // $ MISSING: Alert // $ MISSING: Alert // BAD [NOT DETECTED] | |
| unsafe_put_user(123, &p); // $ MISSING: Alert // BAD [NOT DETECTED] |
| sys_somesystemcall(&v); | ||
|
|
||
| unsafe_put_user(123, &v); // BAD [NOT DETECTED] | ||
| unsafe_put_user(123, &v); // $ MISSING: Alert // $ MISSING: Alert // BAD [NOT DETECTED] |
There was a problem hiding this comment.
| unsafe_put_user(123, &v); // $ MISSING: Alert // $ MISSING: Alert // BAD [NOT DETECTED] | |
| unsafe_put_user(123, &v); // $ MISSING: Alert // BAD [NOT DETECTED] |
| sys_somesystemcall(&myData); | ||
|
|
||
| unsafe_put_user(123, &(myData.x)); // BAD [NOT DETECTED] | ||
| unsafe_put_user(123, &(myData.x)); // $ MISSING: Alert // $ MISSING: Alert // BAD [NOT DETECTED] |
There was a problem hiding this comment.
| unsafe_put_user(123, &(myData.x)); // $ MISSING: Alert // $ MISSING: Alert // BAD [NOT DETECTED] | |
| unsafe_put_user(123, &(myData.x)); // $ MISSING: Alert // BAD [NOT DETECTED] |
| size_t size2 = x; | ||
| size2 *= y; | ||
| char *buffer6 = (char *)malloc(size2); // BAD [NOT DETECTED] | ||
| char *buffer6 = (char *)malloc(size2); // $ MISSING: Alert // $ MISSING: Alert // BAD [NOT DETECTED] |
There was a problem hiding this comment.
| char *buffer6 = (char *)malloc(size2); // $ MISSING: Alert // $ MISSING: Alert // BAD [NOT DETECTED] | |
| char *buffer6 = (char *)malloc(size2); // $ MISSING: Alert // BAD [NOT DETECTED] |
| curl_easy_setopt(curl.get(), CURLOPT_SSL_VERIFYPEER, 0); // $ Alert | ||
| curl_easy_setopt(curl.get(), CURLOPT_SSL_VERIFYHOST, 0); // $ Alert |
There was a problem hiding this comment.
| curl_easy_setopt(curl.get(), CURLOPT_SSL_VERIFYPEER, 0); // $ Alert | |
| curl_easy_setopt(curl.get(), CURLOPT_SSL_VERIFYHOST, 0); // $ Alert | |
| curl_easy_setopt(curl.get(), CURLOPT_SSL_VERIFYPEER, 0); // $ Alert | |
| curl_easy_setopt(curl.get(), CURLOPT_SSL_VERIFYHOST, 0); // $ Alert |
|
|
||
| // GOOD [FALSE POSITIVE] | ||
| printf("%d%d" | ||
| printf("%d%d" // $ Alert[cpp/wrong-number-format-arguments] |
There was a problem hiding this comment.
| printf("%d%d" // $ Alert[cpp/wrong-number-format-arguments] | |
| printf("%d%d" // $ SPURIOUS: Alert[cpp/wrong-number-format-arguments] |
| @@ -12,5 +12,5 @@ void test_PRI_macros() { | |||
| printf("my_u64 = %" PRIu64 "\n", my_u64); // GOOD | |||
| printf("my_u64 = %" PRIx64 "\n", my_u64); // GOOD | |||
| printf("my_u64 = %" PRIi64 "\n", my_u64); // BAD: uint64_t read as int64_t [NOT DETECTED] | |||
There was a problem hiding this comment.
| printf("my_u64 = %" PRIi64 "\n", my_u64); // BAD: uint64_t read as int64_t [NOT DETECTED] | |
| printf("my_u64 = %" PRIi64 "\n", my_u64); // $ MISSING: Alert // BAD: uint64_t read as int64_t [NOT DETECTED] |
There was a problem hiding this comment.
There might be more of these, but this is clearly best-effort, so no need to go looking for more.
| @@ -12,5 +12,5 @@ void test_PRI_macros() { | |||
| printf("my_u64 = %" PRIu64 "\n", my_u64); // GOOD | |||
| printf("my_u64 = %" PRIx64 "\n", my_u64); // GOOD | |||
| printf("my_u64 = %" PRIi64 "\n", my_u64); // BAD: uint64_t read as int64_t [NOT DETECTED] | |||
There was a problem hiding this comment.
| printf("my_u64 = %" PRIi64 "\n", my_u64); // BAD: uint64_t read as int64_t [NOT DETECTED] | |
| printf("my_u64 = %" PRIi64 "\n", my_u64); // $ MISSING: Alert // BAD: uint64_t read as int64_t [NOT DETECTED] |
| @@ -12,5 +12,5 @@ void test_PRI_macros() { | |||
| printf("my_u64 = %" PRIu64 "\n", my_u64); // GOOD | |||
| printf("my_u64 = %" PRIx64 "\n", my_u64); // GOOD | |||
| printf("my_u64 = %" PRIi64 "\n", my_u64); // BAD: uint64_t read as int64_t [NOT DETECTED] | |||
There was a problem hiding this comment.
| printf("my_u64 = %" PRIi64 "\n", my_u64); // BAD: uint64_t read as int64_t [NOT DETECTED] | |
| printf("my_u64 = %" PRIi64 "\n", my_u64); // $ MISSING: Alert // BAD: uint64_t read as int64_t [NOT DETECTED] |
| @@ -12,5 +12,5 @@ void test_PRI_macros() { | |||
| printf("my_u64 = %" PRIu64 "\n", my_u64); // GOOD | |||
| printf("my_u64 = %" PRIx64 "\n", my_u64); // GOOD | |||
| printf("my_u64 = %" PRIi64 "\n", my_u64); // BAD: uint64_t read as int64_t [NOT DETECTED] | |||
There was a problem hiding this comment.
| printf("my_u64 = %" PRIi64 "\n", my_u64); // BAD: uint64_t read as int64_t [NOT DETECTED] | |
| printf("my_u64 = %" PRIi64 "\n", my_u64); // $ MISSING: Alert // BAD: uint64_t read as int64_t [NOT DETECTED] |
There was a problem hiding this comment.
Final few comments.
I also came across a few lines that now look like:
... // $ ... // $ ...
So two inline expectations. Those probably need to be fixed up too, nut it seems more effective to find those through a grep on the codebase than me flagging them up here.
| // $ MISSING: Alert // BAD -- Not allocating space for '\0' terminator [NOT DETECTED] | ||
| char *buffer = (char *)malloc(strlen(str)); |
There was a problem hiding this comment.
| // $ MISSING: Alert // BAD -- Not allocating space for '\0' terminator [NOT DETECTED] | |
| char *buffer = (char *)malloc(strlen(str)); | |
| // BAD -- Not allocating space for '\0' terminator [NOT DETECTED] | |
| char *buffer = (char *)malloc(strlen(str)); // $ MISSING: Alert |
| // $ MISSING: Alert // BAD -- Not allocating space for '\0' terminator [NOT DETECTED] | ||
| wchar_t *buffer = (wchar_t *)calloc(wcslen(str), sizeof(wchar_t)); |
There was a problem hiding this comment.
| // $ MISSING: Alert // BAD -- Not allocating space for '\0' terminator [NOT DETECTED] | |
| wchar_t *buffer = (wchar_t *)calloc(wcslen(str), sizeof(wchar_t)); | |
| // BAD -- Not allocating space for '\0' terminator [NOT DETECTED] | |
| wchar_t *buffer = (wchar_t *)calloc(wcslen(str), sizeof(wchar_t)); // $ MISSING: Alert |
| // $ MISSING: Alert // BAD (requires pointer analysis to catch) [NOT DETECTED] | ||
| const char** userp = ¤tUser; | ||
| *userp = userName; | ||
| if (!strcmp(currentUser, "admin")) { |
There was a problem hiding this comment.
| // $ MISSING: Alert // BAD (requires pointer analysis to catch) [NOT DETECTED] | |
| const char** userp = ¤tUser; | |
| *userp = userName; | |
| if (!strcmp(currentUser, "admin")) { | |
| // BAD (requires pointer analysis to catch) [NOT DETECTED] | |
| const char** userp = ¤tUser; | |
| *userp = userName; | |
| if (!strcmp(currentUser, "admin")) { // $ MISSING: Alert |
Oops, there are still some things to fix. Sorry for taking it out of draft too early.