Skip to content

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

Merged
MichaelSp merged 1 commit into
mainfrom
alert-autofix-2
Sep 17, 2026
Merged

MichaelSp merged 1 commit into
mainfrom
alert-autofix-2

Conversation

@MichaelSp

Copy link
Copy Markdown
Contributor

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.

@MichaelSp
MichaelSp requested a review from moelsayed September 10, 2026 06:51

@Diaphteiros Diaphteiros left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm

…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 marked this pull request as ready for review September 17, 2026 13:20
@MichaelSp
MichaelSp merged commit f1d603c into main Sep 17, 2026
7 checks passed
@MichaelSp
MichaelSp deleted the alert-autofix-2 branch September 17, 2026 13:20
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.

2 participants