Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

vole
Site
Clone

Read only, no credentials:

https://rodent.software/vole.git

Write over SSH with a registered key:

git clone ssh://git@rodent.software/vole.git

Self-hosted forge that lives in your Git repo.

Replace the runner allowlist with a runner role

648cd81bde97042f682a528ebb9ce6353b95bf3f · Keenan Nemetz · 1d ago · parent ea92d754

server/ssh/runner.go +11−11

@@ -89,9 +89,9 @@ type runnerRequest struct {
89 89 Run string `json:"run"`
90 90 // Repos narrows this session's leases to the repositories the runner was started
91 91 // for (--repos). It is applied as an intersection with what the account's runner
92 // allowlists grant, so it can only subtract: a runner cannot ask its way into a
93 // repository no allowlist names. Empty means "no narrowing", which keeps the list
94 // following allowlist edits instead of freezing it at connect time.
92 // role grants, so it can only subtract: a runner cannot ask its way into a
93 // repository no role names. Empty means "no narrowing", which keeps the list
94 // following role edits instead of freezing it at connect time.
95 95 Repos []string `json:"repos,omitempty"`
96 96 // Labels are what this machine is (--label), and a job is only leased to a runner
97 97 // carrying every label the job asked for with runs-on. They describe a machine, not
@@ -287,7 +287,7 @@ func (s *Server) serveRunner(ch Session, user string) {
287 287 defer cfg.Runs.DropSession(sessionID)
288 288 // repos is this session's eligibility list, reused for one poll window. Reading
289 289 // every repository's rules on every lease request is O(repos) per idle runner, and
290 // the answer changes only when an admin edits an allowlist — so it is refreshed on
290 // the answer changes only when an admin edits a role — so it is refreshed on
291 291 // the same five-second beat the roster is, and not once per request.
292 292 var repos []string
293 293 var reposAt time.Time
@@ -306,9 +306,9 @@ func (s *Server) serveRunner(ch Session, user string) {
306 306 switch req.Op {
307 307 case "lease":
308 308 now := time.Now().UTC()
309 // A runner may only run jobs for repositories whose runner allowlist it is
310 // on: running a job executes that repository's code, which is a bigger
311 // power than writing to it.
309 // A runner may only run jobs for repositories where its account holds the
310 // runner role: running a job executes that repository's code, which is a
311 // bigger power than writing to it.
312 312 if reposAt.IsZero() || now.Sub(reposAt) > eligibleFor {
313 313 list, err := s.runnableRepos(user)
314 314 if err != nil {
@@ -319,7 +319,7 @@ func (s *Server) serveRunner(ch Session, user string) {
319 319 }
320 320 // --repos narrows the grant. The intersection is computed here rather than
321 321 // trusted from the runner, so the worst a hostile client can do is ask for
322 // nothing — never for a repository no allowlist gave it.
322 // nothing — never for a repository no role gave it.
323 323 want := narrow(repos, req.Repos)
324 324 // Take the wake-up before asking, so a run queued between the lease and the
325 325 // wait closes a channel somebody is holding. Asking first and waiting second
@@ -667,13 +667,13 @@ func (s *Server) runnableRepos(name string) ([]string, error) {
667 667 }
668 668
669 669 // narrow keeps only the repositories a runner asked for, and is the whole of what
670 // --repos is allowed to do. The granted list is what the account's runner allowlists
671 // produce; the asked list comes from the client. Intersecting them means the worst a
670 // --repos is allowed to do. The granted list is what the account's runner role
671 // produces; the asked list comes from the client. Intersecting them means the worst a
672 672 // client can do is run less than it was allowed to — the alternative, honouring the
673 673 // client's list, would make an SSH flag an access-control decision.
674 674 //
675 675 // An empty asked list means "no narrowing" rather than "nothing": that is what a runner
676 // without --repos sends, and it keeps such a runner following allowlist edits instead
676 // without --repos sends, and it keeps such a runner following role edits instead
677 677 // of freezing its list at connect time. Asked names that were never granted simply
678 678 // disappear, which the runner reports on startup because it can see both lists.
679 679 func narrow(granted, asked []string) []string {