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:
sam committed 2026-10-28 23:57:44 +11:00
1 parent b60ec06839
commit ebec2f3081
6 files changed
+106 -67

No files matched your search

+11 -1
View File
@@ -311,7 +311,7 @@ func (d *Daemon) sweepAccess(ctx context.Context) {
log := d.Log.With("identity", source.Identity)
ctx, cancel := context.WithTimeout(ctx, sweepTimeout)
defer cancel()
if err := source.Forge.AcceptInvitations(ctx); err != nil {
if err := source.Forge.AcceptInvitations(ctx, repoRefs(source.Repos)); err != nil {
log.WarnContext(ctx, "invitation sweep failed", "err", err)
}
for _, r := range source.Repos {
@@ -338,6 +338,16 @@ func (d *Daemon) sweepAccess(ctx context.Context) {
wg.Wait()
}
// repoRefs is a source's configured repositories as the allowlist the forge
// accepts invitations against.
func repoRefs(repos []config.Repo) []forge.RepoRef {
out := make([]forge.RepoRef, 0, len(repos))
for _, r := range repos {
out = append(out, forge.RepoRef{Owner: r.Owner, Repo: r.Name})
}
return out
}
// Run polls until the context ends.
func (d *Daemon) Run(ctx context.Context) error {
// A pass no longer waits for the tasks it submitted, so the run does, once