C++: Increase precision of cpp/arithmetic-uncontrolled to high
#7459
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.


Fixes github/codeql-c-team#553.
This PR does two things:
The first commit removes a bunch of false positives by restricting the sinks to be signed integers in the case of potentially overflowing expressions. This removes a ton of results, and I think this is overall a good thing since (unlike signed-integer overflow) unsigned integer overflow is well-defined.
Here's a list of 70 random projects that produce alerts on this query, and here is a difference query that shows how many results we remove with this PR.
A note on Samate:
On
mainthis query raises22798TPs on Samate and after this PR it raises18012TPs.So we lose
4786results. Out of those results, 1920 are related to CWE-680 (which we have a seperate query for), and the remaining 2866 results are CWE-190 related that look like:which I'm not convinced is an issue that we want to highlight in real code.
The second commit raises the query's precision to high, meaning it'll be part of the code-scanning suite and be displayed by default on LGTM.
Here's the results on our usual list of test projects: https://lgtm.com/query/7783254823209558200/.
I'm leaving this PR as a draft while I run the query on a larger set of LGTM projects.
The text was updated successfully, but these errors were encountered: