Skip to content

C++: Convert qlref tests to inline expectations#22127

Open
owen-mc wants to merge 4 commits into
github:mainfrom
owen-mc:cpp/convert-qlref-inline-expectations
Open

C++: Convert qlref tests to inline expectations#22127
owen-mc wants to merge 4 commits into
github:mainfrom
owen-mc:cpp/convert-qlref-inline-expectations

Conversation

@owen-mc

@owen-mc owen-mc commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Oops, there are still some things to fix. Sorry for taking it out of draft too early.

@github-actions github-actions Bot added the C++ label Jul 5, 2026
@owen-mc owen-mc force-pushed the cpp/convert-qlref-inline-expectations branch 2 times, most recently from 24aac89 to e1753ae Compare July 6, 2026 11:34
@owen-mc

owen-mc commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author
Rerun has been triggered: 2 restarted 🚀

1 similar comment
@owen-mc

owen-mc commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author
Rerun has been triggered: 2 restarted 🚀

@owen-mc owen-mc marked this pull request as ready for review July 7, 2026 08:16
@owen-mc owen-mc requested a review from a team as a code owner July 7, 2026 08:16
Copilot AI review requested due to automatic review settings July 7, 2026 08:16
@owen-mc owen-mc marked this pull request as draft July 7, 2026 08:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review this pull request because it exceeds the maximum number of files (300). Try reducing the number of changed files and requesting a review from Copilot again.

@jketema

jketema commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Since I was looking at this already: I see quite some $ Alert // GOOD ... [FALSE POSITIVE] those need a "spurious". Bonus point for also updating // BAD ... [NOT DETECTED] with a missing alert annotation.

@owen-mc owen-mc force-pushed the cpp/convert-qlref-inline-expectations branch from e1753ae to 76d8ae8 Compare July 7, 2026 09:59
@owen-mc owen-mc marked this pull request as ready for review July 7, 2026 12:31
@owen-mc owen-mc requested a review from jketema July 7, 2026 12:32

@jketema jketema left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
char *buffer6 = (char *)malloc(size2); // $ MISSING: Alert // $ MISSING: Alert // BAD [NOT DETECTED]
char *buffer6 = (char *)malloc(size2); // $ MISSING: Alert // BAD [NOT DETECTED]

Comment on lines +25 to +26
curl_easy_setopt(curl.get(), CURLOPT_SSL_VERIFYPEER, 0); // $ Alert
curl_easy_setopt(curl.get(), CURLOPT_SSL_VERIFYHOST, 0); // $ Alert

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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]

@jketema jketema left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +42 to 43
// $ MISSING: Alert // BAD -- Not allocating space for '\0' terminator [NOT DETECTED]
char *buffer = (char *)malloc(strlen(str));

@jketema jketema Jul 7, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// $ 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

Comment on lines +56 to 57
// $ MISSING: Alert // BAD -- Not allocating space for '\0' terminator [NOT DETECTED]
wchar_t *buffer = (wchar_t *)calloc(wcslen(str), sizeof(wchar_t));

@jketema jketema Jul 7, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// $ 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

Comment on lines +38 to 41
// $ MISSING: Alert // BAD (requires pointer analysis to catch) [NOT DETECTED]
const char** userp = &currentUser;
*userp = userName;
if (!strcmp(currentUser, "admin")) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// $ MISSING: Alert // BAD (requires pointer analysis to catch) [NOT DETECTED]
const char** userp = &currentUser;
*userp = userName;
if (!strcmp(currentUser, "admin")) {
// BAD (requires pointer analysis to catch) [NOT DETECTED]
const char** userp = &currentUser;
*userp = userName;
if (!strcmp(currentUser, "admin")) { // $ MISSING: Alert

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants