Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't look at check run results in other repositories #807

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions server/handler/check_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func (h *CheckRun) Handle(ctx context.Context, eventType, deliveryID string, pay
}

repo := event.GetRepo()
repoID := repo.GetID()
ownerName := repo.GetOwner().GetLogin()
repoName := repo.GetName()
commitSHA := event.GetCheckRun().GetHeadSHA()
Expand All @@ -55,6 +56,19 @@ func (h *CheckRun) Handle(ctx context.Context, eventType, deliveryID string, pay
// of the event, but I can't find confirmation of that in the GitHub
// docs. The PR object is a minimal version that is missing the "state"
// field, so we can't check without loading the full object.

// The `check_run` event includes pull requests that contain the SHA
// which is being checked. These can be pull requests _from_ our
// repository _to_ another one, for example if it's been forked and
// there's a PR to merge changes from our repo into the fork. We don't
// want to try to evaluate the policy for such PRs as they're nothing to
// do with us.
prBaseRepo := pr.GetBase().GetRepo()
if prBaseRepo.GetID() != repoID {
logger.Debug().Msgf("Skipping pull request '%d' from different repository '%s'", pr.GetNumber(), prBaseRepo.GetURL())
continue
}

if err := h.Evaluate(ctx, installationID, common.TriggerStatus, pull.Locator{
Owner: ownerName,
Repo: repoName,
Expand Down