brave / brave-variations

Resources to compile, publish and inspect the variations seed file
Mozilla Public License 2.0
17 stars 17 forks source link

Brave Variations (Griffin)

Griffin is Brave's version of Google's Finch - A backend for Chromium's variation service. This repository contains resources to compile, publish and inspect the so called seed file, which contains definitions for all variations.

See the Wiki to learn more about what variations are and how to use them for (1) staged rollouts, (2) parameter updates and (3) experiments.

Overview

A continuous integration server (CI) serializes and signs the updated seed file before publishing it to a CDN endpoint at https://variations.brave.com/seed. To browse the contents of the seed file a dashboard is hosted at https://griffin.brave.com. The repo is organized as follows:

Git flow

  1. Work in feature branch and when done create a PR to main branch (which will be picked up by CI for staging).
  2. Verify that everything works as intended via the staging endpoint --variations-server-url=https://variations.bravesoftware.com/seed.
  3. Cherry-pick the commit to production by creating another PR to production branch (which will be picked up by CI again).

Key Generation and Exchange

On initial deployment and subsequent key rotations a new key pair has to be generated. The public key is exchanged by patching the hard-coded public key bytes in variations_seed_store.cc#L37:

  1. Generate a key pair with $ go run ./crypto/crypto_util.go keygen.
  2. Update the patched public key in brave-core.
  3. Store the private key in a secure vault and ensure it is accessible by CI.

Seed Serialization, Signing and Serving

The following steps are performed by CI to publish the updated seed file:

  1. Run $ python seed/serialize.py seed/seed.json to compile the protobuf.
  2. Sign the seed file with $ go run /crypto/crypto_util.go sign.
  3. Update the X-Seed-Signature response header.
  4. Update the ETAG header with the contents of serialnumber.

Constraints:

Some Notes on using variations in the Browser

Dashboard

To build the dashboard:

  1. Install dependencies $ npm install
  2. Bundle resources $ npm run build