Skip to content

fix(pilotctl): bounds-check --net before uint16 truncation (CodeQL #21,#23,#24,#25,#32)#218

Merged
TeoSlayer merged 1 commit into
mainfrom
fix/codeql-truncation-and-workflow-permissions
Jun 6, 2026
Merged

fix(pilotctl): bounds-check --net before uint16 truncation (CodeQL #21,#23,#24,#25,#32)#218
TeoSlayer merged 1 commit into
mainfrom
fix/codeql-truncation-and-workflow-permissions

Conversation

@TeoSlayer

Copy link
Copy Markdown
Collaborator

Summary

Closes 5 CodeQL "Incorrect conversion between integer types" alerts by introducing flagNetID — a helper that validates --net N is in 0..65535 before casting int → uint16, rather than silently truncating.

Before: --net 70000uint16(70000 & 0xFFFF) = 4464 — command runs against the wrong network with no warning.
After: --net 70000 → fatal invalid_argument: --net must be in 0..65535, got 70000.

Closes

Not addressed in this PR

Test plan

  • go build ./cmd/pilotctl/... succeeds
  • pilotctl network info --net 70000 now aborts instead of silently picking net 4464
  • Existing --net 1 / --net 100 flows unchanged

…#23,#24,#25,#32)

flagInt returns an int; `uint16(flagInt(...))` silently truncates
when the user passes a value > 65535. `--net 70000` becomes
uint16(70000 & 0xFFFF)=4464, so the command operates on the wrong
network without warning.

Introduce flagNetID helper that bounds-checks and aborts on out-of-range
input, then replace all 5 truncation call sites.
@TeoSlayer TeoSlayer requested a review from Alexgodoroja as a code owner June 6, 2026 09:57
@TeoSlayer TeoSlayer merged commit 53fc33a into main Jun 6, 2026
8 checks passed
@TeoSlayer TeoSlayer deleted the fix/codeql-truncation-and-workflow-permissions branch June 6, 2026 09:59
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