mozilla-releng / mozilla-releng/scriptworker

Chain of Trust: Restrict git/hg branches

Open
#273 11 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
5
Forks
39
Avg merge
4h 18m
Merged PRs (30d)
6

Description

Today, @rpappalax came to me with an interesting case: he has some big changes to make on the focus-android taskgraph and he's willing to use a github branch (living the focus-android repo). This branch needs some taskcluster scopes.
He asked @imbstack to expand the following role: https://tools.taskcluster.net/auth/roles/repo%3Agithub.com%2Fmozilla-mobile%2Ffocus-android%3Abranch%3A*. Without too much context, all the scopes needed to sign and publish a Focus build ended up in the role (I actually wonder if these scopes were on the master role).

Immediate fix

I updated to role to strip all the signing/publishing scopes out. As of now, no one can publish Focus from a random branch on the main repo.

What scriptworker can do

In hg.mozilla.org, this is safeguarded by cot_restricted_scopes. Sadly, scriptworker doesn't allow to restrict branches within an existing repo. This case has never popped up on hg.mozilla.org, but we now have a case on github.

To me, scriptworker can enforce that. scriptworker knows what's the commit under checks. We can let it know what's the branch it's on. scriptworker will then verify against:

This way scriptworker knows the branch against which the graph was triggered, and it knows the branch isn't a lie. Therefore, scriptworker can restrict by git/hg branches.

@escapewindow @tomprince, how does this look to you?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with scriptworker/constants.py, especially cot_restricted_scopes, and trace where the worker identifies the checked commit and repository. Compare GitHub's branch_commits endpoint with hg.mozilla.org's json-pushes response; done means branch restrictions are verified for both systems before restricted scopes are granted.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, github, python
Domain
authorization, backend, security
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.