-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Fix a number of CodeQL warnings #14882
Conversation
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
uses: actions/setup-go@v4 | ||
with: | ||
go-version: 1.21.5 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dee3d90
to
4f77d60
Compare
This addresses a number of CodeQL warnings. We have a concurrency field which is using inconsistent types across different fields, which means we end up casting and triggering warnings around overflows. We can use the smallest type here, namely int32 since that is for sure sufficient for real concurrency values. It avoids warnings like: https://github.com/vitessio/vitess/security/code-scanning/267 Also fixes the parsing bug identified in https://github.com/vitessio/vitess/security/code-scanning/266 where we parse with `ParseUint` instead of `ParseInt`. Last one is https://github.com/vitessio/vitess/security/code-scanning/268 which is fixed by making sure we parse it as the type MySQL sends down and to keep using that consistently. Signed-off-by: Dirkjan Bussink <[email protected]>
4f77d60
to
560496b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Thank you for fixing those @dbussink 🙏🏻
// name into a uint32 value. If the parameter is not set, the provided default | ||
// value is returned. | ||
func (r Request) ParseQueryParamAsInt32(name string, defaultVal int32) (int32, error) { | ||
if param := r.URL.Query().Get(name); param != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Styling-wise, I'd prefer to first handle the case where param == ""
and do an early return, then unindent the rest of the function. But it's insignificant and not worth the rebuild time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shlomi-noach Copy-pasted this mostly from another function for uint32
, so it's not "new" in that sense.
This addresses a number of CodeQL warnings. We have a concurrency field which is using inconsistent types across different fields, which means we end up casting and triggering warnings around overflows. We can use the smallest type here, namely int32 since that is for sure sufficient for real concurrency values. It avoids warnings like:
https://github.com/vitessio/vitess/security/code-scanning/267
Also fixes the parsing bug identified in
https://github.com/vitessio/vitess/security/code-scanning/266 where we parse with
ParseUint
instead ofParseInt
.Last one is
https://github.com/vitessio/vitess/security/code-scanning/268 which is fixed by making sure we parse it as the type MySQL sends down and to keep using that consistently.
Checklist