Skip to content

Commit ed57b69

Browse files
committed
Fix integer overflow warning in MarkPullRequestReadyForReview
- Add bounds checking when converting int to int32 for pullNumber - Use int32 variable in githubv4.Int() conversion to avoid gosec G115 warning - Resolves linting issue while maintaining type safety
1 parent 8bbf01e commit ed57b69

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pkg/github/pullrequests.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1643,6 +1643,12 @@ func MarkPullRequestReadyForReview(getGQLClient GetGQLClientFn, t translations.T
16431643
return mcp.NewToolResultError(err.Error()), nil
16441644
}
16451645

1646+
// Convert int to int32 with bounds checking to avoid integer overflow
1647+
if pullNumber < 0 || pullNumber > 2147483647 {
1648+
return mcp.NewToolResultError("pullNumber out of range for int32"), nil
1649+
}
1650+
pullNumber32 := int32(pullNumber)
1651+
16461652
// Get the GraphQL client
16471653
client, err := getGQLClient(ctx)
16481654
if err != nil {
@@ -1662,7 +1668,7 @@ func MarkPullRequestReadyForReview(getGQLClient GetGQLClientFn, t translations.T
16621668
variables := map[string]any{
16631669
"owner": githubv4.String(owner),
16641670
"repo": githubv4.String(repo),
1665-
"prNum": githubv4.Int(pullNumber),
1671+
"prNum": githubv4.Int(pullNumber32),
16661672
}
16671673

16681674
if err := client.Query(ctx, &getPullRequestQuery, variables); err != nil {

0 commit comments

Comments
 (0)