-
Notifications
You must be signed in to change notification settings - Fork 1
Potential fix for code scanning alert no. 231: Incorrect conversion between integer types #41
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
Changes from all commits
fa7e9be
cdae0b7
feacdec
4b396bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | |||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -90,15 +90,13 @@ func (t systemSetType) Convert(v interface{}) (interface{}, error) { | ||||||||||||||||||||||
| case float64: | |||||||||||||||||||||||
| // Float values aren't truly accepted, but the engine will give them when it should give ints. | |||||||||||||||||||||||
| // Therefore, if the float doesn't have a fractional portion, we treat it as an int. | |||||||||||||||||||||||
| if value >= float64(math.MinInt64) && value <= float64(math.MaxInt64) { | |||||||||||||||||||||||
| if math.Trunc(value) == value { // Ensure no fractional part exists | |||||||||||||||||||||||
| // Additional bounds check for out-of-range values | |||||||||||||||||||||||
| if value < float64(math.MinInt64) || value > float64(math.MaxInt64) { | |||||||||||||||||||||||
| return nil, ErrInvalidSystemVariableValue.New(t.varName, v) // Reject out-of-range values | |||||||||||||||||||||||
| } | |||||||||||||||||||||||
| intValue := int64(value) | |||||||||||||||||||||||
| return t.SetType.Convert(intValue) | |||||||||||||||||||||||
| if math.Trunc(value) == value { // Ensure no fractional part exists | |||||||||||||||||||||||
| // Explicit bounds check for int64 range | |||||||||||||||||||||||
| if value < float64(math.MinInt64) || value > float64(math.MaxInt64) { | |||||||||||||||||||||||
| return nil, ErrInvalidSystemVariableValue.New(t.varName, v) // Reject out-of-range values | |||||||||||||||||||||||
| } | |||||||||||||||||||||||
| intValue := int64(value) | |||||||||||||||||||||||
Check failureCode scanning / CodeQL Incorrect conversion between integer types High
Incorrect conversion of an unsigned 64-bit integer from strconv.ParseUint to a lower bit size type int64 without an upper bound check.
Incorrect conversion of an unsigned 64-bit integer from strconv.ParseUint to a lower bit size type int64 without an upper bound check. Incorrect conversion of an unsigned 64-bit integer from strconv.ParseUint to a lower bit size type int64 without an upper bound check.
Copilot AutofixAI 4 months ago To fix this issue, we need to ensure that when converting a Additionally, if the value originated as a Summary of changes:
Suggested changeset
1
sql/system_settype.go
Copilot is powered by AI and may make mistakes. Always verify output.
Positive FeedbackNegative Feedback
Refresh and try again.
|
|||||||||||||||||||||||
| return t.SetType.Convert(intValue) | |||||||||||||||||||||||
| } | |||||||||||||||||||||||
| return nil, ErrInvalidSystemVariableValue.New(t.varName, v) // Reject out-of-range values | |||||||||||||||||||||||
| case decimal.Decimal: | |||||||||||||||||||||||
|
|
|||||||||||||||||||||||
Check failure
Code scanning / CodeQL
Clear-text logging of sensitive information High
Copilot Autofix
AI 4 months ago
The best way to fix this problem is to ensure that sensitive information, such as passwords, is never logged, even in debug mode. This can be achieved by strengthening the
sanitizeArgumentsandcontainsSensitiveDatafunctions to more reliably detect and redact sensitive fields, especially for known node types likeplan.CreateUserand any structure that may contain password fields. Specifically, we should:sanitizeArgumentsto explicitly handleplan.CreateUserand similar types, redacting any password fields within them.sql/analyzer/analyzer.go, within thesanitizeArgumentsandsanitizeStructfunctions.No changes are needed in
engine.goorsql/parse/parse.go, as the fix is best localized to the logging/sanitization logic.