Skip to content

Have an external builder build an artifact and host the result #888

Backlog

Description

@simonchrz

The proxy can scan an artifact with an external service before it serves it. This issue asks whether it should also be able to have an artifact built by an external service and host the result.

#887 is a draft that implements the core of it, so there is something concrete to look at. This issue is for the question of whether it fits the project, and how far it should go.

The case I have. A build needs ffmpeg for linux/arm64, built from a pinned upstream commit with a few configure flags. Today a script builds it in Docker on a workstation and pushes the archive as a hosted generic file:

PUT /api/hosted/generic/ffmpeg/<commit>/ffmpeg-<commit12>-linux-arm64.tar.xz

Image builds then download it from /generic/hosted/… and check a pinned sha256. That works well: the file is immutable, scanned, and never evicted. What is left outside the proxy is everything around it:

  • The machine that builds holds hosted.token. That token can push any hosted package, including an npm version that replaces the upstream one, so it shouldn't sit on a build machine.
  • Nothing records where a hosted file came from: which source, which builder, when.
  • Nobody can see that a file is being built, or that its build failed.

The idea. The proxy doesn't build and doesn't know how to build. It asks a builder for one file and accepts exactly that file, the way it asks a scanner for a verdict.

  1. A build is requested: POST /api/builds with the hosted name, version and filename, plus parameters the proxy passes on untouched. It needs the hosted token and returns a job.
  2. The proxy POSTs the request to the configured builder (building.builders[].url, with headers, like scanning.scanners). The request carries an upload URL and a failure URL, signed for that one build and short-lived.
  3. The builder builds and PUTs the result to the upload URL. The proxy stores it as a hosted file through the same path as a push, so it is scanned and immutable.
  4. The job's status (requested, building, done, failed) is at GET /api/builds/{id} and on the package page.

A build at the first client request is not part of this: builds take minutes, and a client would time out. A request for a file that isn't built yet answers 404 as today.

What #887 covers. Steps 1 to 4 for generic files, a Builder interface with one HTTP implementation laid out like internal/scanner, builds kept in the database, and an optional body template per builder so that a CI system (a GitHub workflow_dispatch, a GitLab pipeline trigger) can be the builder without an adapter in between.

What it leaves out

  • A signed upload URL on its own (POST /api/hosted/…/upload-url), for a CI job that delivers a file without a build request. It would be a smaller first step if the rest is too much.
  • Provenance kept with the file and shown on the version page.
  • Schedules, like mirror.schedules: build again when the source has a new tag.
  • Ecosystems other than generic.

Open questions

  • Is this in scope at all, or should the proxy stay with what clients and operators push?
  • Body templates go further than scanning does, which has one fixed format and leaves other systems to adapters. Keep them, or drop them and keep the fixed format only?
  • A template can read the proxy's environment (env), which a token in the body needs. Is that acceptable, given only whoever writes the configuration can use it?
  • Generic files only, or also the ecosystems hosted packages support (npm, Composer)?
  • Is there a format for the provenance worth storing as it is (an in-toto or SLSA statement the builder uploads next to the file), instead of fields of our own?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions