Skip to content

Commit b8d1c5e

Browse files
chmouelclaude
andcommitted
fix(github): guard nil response and cap comment pagination in ACL checks
Guard against nil HTTP response dereference in CheckPolicyAllowing when the API call fails at the transport level (fixes #2661). Cap GetStringPullRequestComment pagination to 10 pages (1000 comments) to prevent rate-limit exhaustion from comment flooding on PRs when RememberOKToTest is enabled (fixes #2662). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 421f96c commit b8d1c5e

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

pkg/provider/github/acl.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func (v *Provider) CheckPolicyAllowing(ctx context.Context, event *info.Event, a
2525
members, resp, err := wrapAPI(v, "list_team_members_by_slug", func() ([]*github.User, *github.Response, error) {
2626
return v.Client().Teams.ListTeamMembersBySlug(ctx, event.Organization, team, &github.TeamListTeamMembersOptions{ListOptions: opt})
2727
})
28-
if resp.StatusCode == http.StatusNotFound {
28+
if resp != nil && resp.StatusCode == http.StatusNotFound {
2929
// we explicitly disallow the policy when the team is not found
3030
// maybe we should ignore it instead? i'd rather keep this explicit
3131
// and conservative since being security related.
@@ -321,7 +321,7 @@ func (v *Provider) GetStringPullRequestComment(ctx context.Context, runevent *in
321321

322322
gitOpsCommentPrefix := provider.GetGitOpsCommentPrefix(v.repo)
323323

324-
for {
324+
for page := 0; page < maxCommentPages; page++ {
325325
comments, resp, err := wrapAPI(v, "list_issue_comments", func() ([]*github.IssueComment, *github.Response, error) {
326326
return v.Client().Issues.ListComments(ctx, runevent.Organization, runevent.Repository,
327327
prNumber, opt)

pkg/provider/github/github.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ const (
4141
publicRawURLHost = "raw.githubusercontent.com"
4242

4343
defaultPaginedNumber = 100
44+
// maxCommentPages caps the number of pages fetched when scanning PR
45+
// comments (e.g. for /ok-to-test). With defaultPaginedNumber=100 this
46+
// allows up to 1000 comments, which is generous for legitimate use while
47+
// preventing rate-limit exhaustion from comment flooding.
48+
maxCommentPages = 10
4449
)
4550

4651
var _ provider.Interface = (*Provider)(nil)

0 commit comments

Comments
 (0)