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

fix: code scanning alert no. 1: Incorrect conversion between integer types #133

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

flemzord
Copy link
Member

Fixes https://github.com/formancehq/go-libs/security/code-scanning/1

To fix the problem, we need to ensure that the conversion from a 64-bit integer to a smaller integer type is safe. This can be done by specifying the correct bit size when parsing the integer and adding bounds checking to ensure the value fits within the target type's range.

  1. Use strconv.ParseInt with a bit size of 32 to directly parse the integer as a 32-bit value.
  2. Add bounds checking to ensure the parsed value fits within the range of the int type.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

…ypes

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@flemzord flemzord changed the title Fix code scanning alert no. 1: Incorrect conversion between integer types fix: code scanning alert no. 1: Incorrect conversion between integer types Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant