fix(forge): accept invitations only to configured repositories
The GitHub forge extension accepted every pending repository invitation, so any GitHub user could add archie's account to a repository by sending an invitation. AcceptInvitations now carries the connection's configured repositories and the extension leaves an invitation to anything else pending.
This commit is contained in:
1 parent
b60ec06839
commit
ebec2f3081
6 files changed
+106
-67
No files matched your search
+11
-2
@@ -103,10 +103,19 @@ type RepoArchiveReader interface {
|
||||
GetRepoArchive(ctx context.Context, owner, repo, ref string) (io.ReadCloser, error)
|
||||
}
|
||||
|
||||
// RepoRef identifies one repository on a forge.
|
||||
type RepoRef struct {
|
||||
Owner string
|
||||
Repo string
|
||||
}
|
||||
|
||||
// RepoForge is repository-level operations.
|
||||
type RepoForge interface {
|
||||
// AcceptInvitations auto-accepts pending repository invitations.
|
||||
AcceptInvitations(ctx context.Context) error
|
||||
// AcceptInvitations accepts pending repository invitations, but only
|
||||
// to the given repositories: an invitation to anything else is left
|
||||
// pending, so a stranger cannot add archie's account to a repository
|
||||
// the operator never configured.
|
||||
AcceptInvitations(ctx context.Context, repos []RepoRef) error
|
||||
|
||||
// VerifyPush confirms the token can push to the repo.
|
||||
VerifyPush(ctx context.Context, owner, repo string) error
|
||||
|
||||
@@ -57,7 +57,7 @@ func (n *NoopForge) PRState(ctx context.Context, owner, repo string, number int)
|
||||
return "closed", nil
|
||||
}
|
||||
|
||||
func (n *NoopForge) AcceptInvitations(ctx context.Context) error {
|
||||
func (n *NoopForge) AcceptInvitations(ctx context.Context, repos []RepoRef) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user