Integer parameters equal to 2^63 pass the range check in toInt and wrap to a negative number
メンテナーはふだん 4 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 82/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- go
調査の方向性
pkg/github/params.go の toInt から始め、pkg/github にある既存の toInt テストを確認してください。現在のカバレッジを確認するために go test ./pkg/github を実行し、その後、2^63 付近の境界ケースを追加してください。それらが文書化された範囲エラーを返し、有効範囲内の値は引き続き変換されることを確認してください。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
toInt in pkg/github/params.go is documented to reject "values outside the int range", but its upper bound check compares against math.MaxInt as a float:
if f > math.MaxInt || f < math.MinInt {
return 0, fmt.Errorf("numeric value out of int range: %v", f)
}
return int(f), nil
math.MaxInt (2^63 - 1) cannot be represented as a float64 and rounds up to exactly 2^63. A value of 2^63 is therefore not greater than the bound, passes the check, and int(f) on an out-of-range float is implementation-defined in Go. On amd64 it produces math.MinInt (-9223372036854775808).
Any value that parses to 2^63, including the integer 9223372036854775807 itself, is accepted without an error and becomes a large negative number. This affects every tool that reads integers through RequiredInt, OptionalIntParam, OptionalIntParamWithDefault and OptionalPaginationParams (for example issue_number, pull_number, page, perPage). toInt64 is not affected because it uses a round-trip check.
Affected version
main at 07e2466, built from source (Go toolchain from go.mod, linux/amd64).
Steps to reproduce the behavior
-
Add this test to
pkg/github:package github import "testing" func TestToIntUpperBound(t *testing.T) { for _, v := range []any{"9223372036854775807", float64(9223372036854775807), "9223372036854775808", "1e19"} { n, err := OptionalIntParam(map[string]any{"pull_number": v}, "pull_number") t.Logf("%v -> %d, err=%v", v, n, err) } } -
Run
go test ./pkg/github -run TestToIntUpperBound -v.
Expected vs actual behavior
Expected: every value at or above 2^63 is rejected with numeric value out of int range, as 1e19 already is.
Actual:
9223372036854775807 -> -9223372036854775808, err=<nil>
9.223372036854776e+18 -> -9223372036854775808, err=<nil>
9223372036854775808 -> -9223372036854775808, err=<nil>
1e19 -> 0, err=parameter pull_number is not a valid number: numeric value out of int range: 1e+19
The negative value is then sent on to the GitHub API (for example as a pull request number or page) instead of being rejected locally with a clear parameter error.
Logs
Not applicable; the output above is from the test.
Possible Solution
- Make the upper bound exclusive at 2^63 (
f >= -float64(math.MinInt)), or reuse the round-trip check thattoInt64already performs. - Add the boundary values above to the existing
toInttests.
if f >= -float64(math.MinInt) || f < float64(math.MinInt) {
return 0, fmt.Errorf("numeric value out of int range: %v", f)
}
return int(f), nil
I'm happy to send a PR.
- 主要言語
- Go
- スター
- 33.4k
- フォーク
- 5.1k
- 平均マージ
- 2日 10時間
- マージ済み PR(30日)
- 35
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
github/github-mcp-server のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
github/github-mcp-server#3475 ·
メンテナーはふだん 4 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
github/github-mcp-server#3450 ·
メンテナーはふだん 4 日以内に返信
-
request ai review
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
github/github-mcp-server#3439 ·
メンテナーはふだん 4 日以内に返信
-
get_job_logs with failed_only misses failed jobs after the first 30 jobs of a run対応中かも @jayhemnani9910 が 7 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
github/github-mcp-server#3428 ·
メンテナーはふだん 4 日以内に返信
-
create_or_update_file writes to the wrong file when the path contains # or ?対応中かも @jayhemnani9910 が 7 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
github/github-mcp-server#3427 ·
メンテナーはふだん 4 日以内に返信
github/github-mcp-server の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
-
agent-review-finding bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
jordansmall/spindrift#5281 ·
メンテナーはふだん 1 日以内に返信
-
L: java:gradle L: java:maven L: ruby:bundler T: bug 🐞
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
dependabot/dependabot-core#16547 ·
メンテナーはふだん 1 日以内に返信
-
Docs/examples still create key ranges in ascending order, which fails in 3.1.0 (follow-up to #1754)オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
pg-sharding/spqr#3083 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
メンテナーはふだん 1 日以内に返信