|
5 | 5 | "encoding/json"
|
6 | 6 | "fmt"
|
7 | 7 | "io"
|
| 8 | + "math" |
8 | 9 | "net/http"
|
9 | 10 | "strings"
|
10 | 11 | "time"
|
@@ -1558,19 +1559,35 @@ func queryClosingPRsForIssueEnhanced(ctx context.Context, client *githubv4.Clien
|
1558 | 1559 | } `graphql:"repository(owner: $owner, name: $repo)"`
|
1559 | 1560 | }
|
1560 | 1561 |
|
1561 |
| - // Build variables map with conditional inclusion |
| 1562 | + // Validate issue number |
| 1563 | + if issueNumber < 0 || issueNumber > math.MaxInt32 { |
| 1564 | + return nil, fmt.Errorf("issue number %d is out of valid range", issueNumber) |
| 1565 | + } |
| 1566 | + issueNumber32 := int32(issueNumber) // safe: range-checked above |
| 1567 | + |
| 1568 | + // Validate pagination |
| 1569 | + if params.Last != 0 && (params.Last < 0 || params.Last > math.MaxInt32) { |
| 1570 | + return nil, fmt.Errorf("last parameter %d is out of valid range", params.Last) |
| 1571 | + } |
| 1572 | + if params.First < 0 || params.First > math.MaxInt32 { |
| 1573 | + return nil, fmt.Errorf("first parameter %d is out of valid range", params.First) |
| 1574 | + } |
| 1575 | + |
| 1576 | + first32 := int32(params.First) |
| 1577 | + last32 := int32(params.Last) |
| 1578 | + |
| 1579 | + // Build variables map |
1562 | 1580 | variables := map[string]any{
|
1563 | 1581 | "owner": githubv4.String(owner),
|
1564 | 1582 | "repo": githubv4.String(repo),
|
1565 |
| - "number": githubv4.Int(issueNumber), |
| 1583 | + "number": githubv4.Int(issueNumber32), |
1566 | 1584 | }
|
1567 | 1585 |
|
1568 |
| - // Add pagination parameters conditionally |
1569 |
| - if params.Last != 0 { |
1570 |
| - variables["last"] = githubv4.Int(params.Last) |
| 1586 | + if last32 != 0 { |
| 1587 | + variables["last"] = githubv4.Int(last32) |
1571 | 1588 | variables["first"] = (*githubv4.Int)(nil)
|
1572 | 1589 | } else {
|
1573 |
| - variables["first"] = githubv4.Int(params.First) |
| 1590 | + variables["first"] = githubv4.Int(first32) |
1574 | 1591 | variables["last"] = (*githubv4.Int)(nil)
|
1575 | 1592 | }
|
1576 | 1593 |
|
|
0 commit comments