C++: Accept test changes after github/codeql#21313.#1036
C++: Accept test changes after github/codeql#21313.#1036jketema merged 2 commits intogithub:nextfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the INT34-C C/CERT test expectations to account for the reduced precision behavior introduced by the SimpleRangeAnalysis performance fix (github/codeql#21313), ensuring the test suite continues to pass under the new analysis limits.
Changes:
- Mark two previously-
COMPLIANTshift cases as expected false positives inINT34-C/test.c. - Update the
.expectedbaseline to reflect less precise (higher) inferred upper bounds from range analysis.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| c/cert/test/rules/INT34-C/test.c | Adjusts compliance annotations for two shift cases that now trigger alerts due to reduced range-analysis precision. |
| c/cert/test/rules/INT34-C/ExprShiftedbyNegativeOrGreaterPrecisionOperand.expected | Updates expected query results/upper-bound values (and adds any newly-triggered results) to match current analysis output. |
Comments suppressed due to low confidence (1)
c/cert/test/rules/INT34-C/test.c:361
- Test markers elsewhere in this repo predominantly use underscore-separated tags like
COMPLIANT[FALSE_POSITIVE]/NON_COMPLIANT[FALSE_NEGATIVE]. To keep consistency (and avoid any tooling that might treat spaces inside the tag unexpectedly), consider changingCOMPLIANT[FALSE POSITIVE]toCOMPLIANT[FALSE_POSITIVE]here.
lhs12 << rhs13; // COMPLIANT[FALSE POSITIVE]: lhs12's precision is strictly greater than rhs13 (FP because range analysis reduced precision for performance reasons)
lhs12 << rhs14; // COMPLIANT[FALSE POSITIVE]: lhs12's precision is strictly greater than rhs14 (FP because range analysis reduced precision for performance reasons)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
paldepind
left a comment
There was a problem hiding this comment.
Changes looks good to me.
Note that the actual simple range analysis produces a small number of bounds in this file. So there's a discrepancy between our estimate on the number of bounds and the actual numbers of bounds. I have an idea that might fix that and allow us to revert these changes later.
If that does not work out, another fix would be to split this up into several functions/introduce more variables such that the same variable is not used in as many if statements.
Description
In github/codeql#21313 we fixed a performance problem in
SimpleRangeAnalysis. As part of that we reduced the limit for when range analysis decides to bail out and reduces precision because it expects too many bounds prior to the main range analysis recursion.Because this test function produces so many bounds (because it's thousands of lines of code with lots of sequential
ìfs) we now hit this limit.I suggest you rewrite this test in the future to better reflect real-world code. This will make range analysis perform just like it did before.
Change request type
.ql,.qll,.qlsor unit tests)Rules with added or modified queries
Release change checklist
A change note (development_handbook.md#change-notes) is required for any pull request which modifies:
If you are only adding new rule queries, a change note is not required.
Author: Is a change note required?
🚨🚨🚨
Reviewer: Confirm that format of shared queries (not the .qll file, the
.ql file that imports it) is valid by running them within VS Code.
Reviewer: Confirm that either a change note is not required or the change note is required and has been added.
Query development review checklist
For PRs that add new queries or modify existing queries, the following checklist should be completed by both the author and reviewer:
Author
As a rule of thumb, predicates specific to the query should take no more than 1 minute, and for simple queries be under 10 seconds. If this is not the case, this should be highlighted and agreed in the code review process.
Reviewer
As a rule of thumb, predicates specific to the query should take no more than 1 minute, and for simple queries be under 10 seconds. If this is not the case, this should be highlighted and agreed in the code review process.