Skip to content

Commit

Permalink
webhook: Don't process events from repositories that are not registered
Browse files Browse the repository at this point in the history
This returns an error if the repository does not belong to a group. This way we won't
have funky issues when trying to evaluate a policy for a non-existent group.
  • Loading branch information
JAORMX committed Sep 11, 2023
1 parent faaf012 commit 653f687
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/controlplane/handlers_githubwebhooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,12 @@ func getRepoInformationFromPayload(
}
return db.Repository{}, fmt.Errorf("error getting repository: %w", err)
}

if dbrepo.GroupID == 0 {
return db.Repository{}, fmt.Errorf("no group found for repository %s/%s: %w",
dbrepo.RepoOwner, dbrepo.RepoName, ErrRepoNotFound)
}

return dbrepo, nil
}

Expand Down

0 comments on commit 653f687

Please sign in to comment.