Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Go: Improve incorrect integer conversion #13949

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

owen-mc
Copy link
Contributor

@owen-mc owen-mc commented Aug 11, 2023

All tests pass, including some that we weren't able to spot before (parse uint32 and then assign to int32, for example). Things left to do:

  • fix treatment of architecture-dependent types. New idea: have two flow states at an architecture-dependent source and encode in the flow state that the int-size has been assumed to be 32 or 64 bit, then try to refer to that when doing calculations later. This will make the two flow state branches more similar and hopefully make it clearer what's going on in various places.
  • Add more qldoc, make variable names more consistent.
  • check if we recover any of the results lost when we switched the backend of the data flow library to the new API.
  • Consider whether to do lower bounds as well as upper bounds. Separate query? Could the logic be shared somehow, e.g. making it into a parameterized module?

This has one problem: we aren't able to properly set sinks to be
barriers, to avoid the issue that we get flows from a source A to sink1,
and also from A to sink1 and then on to sink2, and
so on. These are
seen in SPURIOUS results in:
go/ql/test/query-tests/Security/CWE-681/IncorrectIntegerConversion.go
@github-actions github-actions bot added the Go label Aug 11, 2023
@@ -17,11 +17,12 @@
* Get the size of `int` or `uint` in `file`, or 0 if it is
* architecture-specific.
*/
int getIntTypeBitSize(File file) {
bindingset[architectureSpecificBitSize]
int getIntTypeBitSize(File file, int architectureSpecificBitSize) {

Check warning

Code scanning / CodeQL

Missing QLDoc for parameter Warning

The QLDoc has no documentation for architectureSpecificBitSize, but the QLDoc mentions int, and uint
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.

None yet

1 participant