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

Query and tests for sum without domain #12292

Merged
merged 3 commits into from Feb 27, 2023
Merged

Conversation

calumgrant
Copy link
Contributor

This produces 14 results on this repo, and they are mostly good results.

@calumgrant calumgrant marked this pull request as ready for review February 23, 2023 12:35
@calumgrant calumgrant requested a review from a team as a code owner February 23, 2023 12:35
@MathiasVP
Copy link
Contributor

This looks great! I guess uses of avg is also likely to be broken in the same way, right?

@calumgrant
Copy link
Contributor Author

I guess uses of avg is also likely to be broken in the same way, right?

Yes, that's true.

You could also think about count being broken, but I didn't think that case came up so much because you often count things that aren't numbers, so count(this.getChild(_)) is quite common and correct providing you're not counting numbers.

@erik-krogh
Copy link
Contributor

You could also think about count being broken, but I didn't think that case came up so much because you often count things that aren't numbers, so count(this.getChild(_)) is quite common and correct providing you're not counting numbers.

You could check whether the type of the inner expression to determine whether it's counting integers.

@calumgrant
Copy link
Contributor Author

You could check whether the type of the inner expression to determine whether it's counting integers.

I did think about this, but didn't do this initially as I wasn't sure how often people people counted integers, and whether it's legitimate. So I coded this up and it turns out that we do this a lot in CodeQL for many different reasons. e.g.

count(body.indexOf("(")) != count(body.indexOf(")"))

strictcount(e.getValue().toInt()) = 1

result = count(this.getFormat().indexOf("%"))

count(node.getStackSizeAfter()) != 1

actualArity = count(row.indexOf(";")) + 1

I couldn't see any additional true positives. For that reason, let's not try to cover count/strictcount as well.

Copy link
Contributor

@erik-krogh erik-krogh left a comment

Choose a reason for hiding this comment

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

:shipit:

@MathiasVP MathiasVP merged commit 1dd95a6 into main Feb 27, 2023
11 checks passed
@MathiasVP MathiasVP deleted the calumgrant/aggregate-domain branch February 27, 2023 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants