Skip to content

Potential fix for code scanning alert no. 2: Incorrect conversion between integer types - #284

Draft
MichaelSp wants to merge 1 commit into
mainfrom
alert-autofix-2
Draft

MichaelSp wants to merge 1 commit into
mainfrom
alert-autofix-2

Conversation

@MichaelSp

Copy link
Copy Markdown

Potential fix for https://github.com/openmcp-project/controller-utils/security/code-scanning/2

Use fixed-width parsing at the source so the parsed value is guaranteed to fit the downstream narrower type.
Best fix here: replace strconv.Atoi with strconv.ParseInt(s, 10, 32) for webhooks-service-port, then convert to int for the existing WithWebhookServicePort call. This preserves behavior (still accepts decimal text input) while preventing out-of-range values from being accepted. ParseInt with bit size 32 returns an error for values outside signed 32-bit range, which addresses the CodeQL concern without requiring assumptions about WithWebhookServicePort.

Edits are confined to pkg/init/webhooks/flags.go, inside the webhooks-service-port flag handler (lines 41–45 region). No new imports are required since strconv is already imported.

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

…ween integer types

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: Michael <MichaelSp@users.noreply.github.com>
@MichaelSp
MichaelSp requested a review from moelsayed September 10, 2026 06:51
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