Skip to content

Chocolatey Package Caching and Checksums for Performance and Security #397

@CMCDragonkai

Description

@CMCDragonkai

Specification

The build:windows and subsequently integration:windows jobs involve using chocolatey to download packages to be usable on Windows. In particular nodejs and python.

The current configuration in .gitlab-ci.yml will redownload packages and reinstall each time. This is slow, error prone and results in our CI/CD getting rate limited from chocolatey (#394 (comment)).

On top of that the chocolatey community software packages on https://community.chocolatey.org/packages, which is the default source of packages is not entirely secure, or at least not recommended for organisational usage https://docs.chocolatey.org/en-us/community-repository/community-packages-disclaimer.

Furthermore when downloading and installing chocolatey packages, we are simply relying on the checksum specified by the package maintainer. This is the case with nixpkgs, but with nixpkgs we can pin our package set from nixpkgs-overlay, with chocolatey, this is not the case. We can get halfway there by doing TOFU, and acquiring the checksum for a trusted version of the package, and then enforce that installing the package again must also have the same checksum.

This is particularly important because some packages download things over the internet during installation (this is due to chocolatey lacking distribution rights, thus the "package" is just an instruction set on how to download & install, but not the actual software runtime being installed). Having a checksum specified at our CI/CD level just ensures some level of end-to-end trust of immutability.

Additional context

Tasks

  1. Iterate on this using our matrix-win-1 computer first before applying to gitlab cicd
  2. Setup to host chocolatey packages privately, probably over a directory that is cached by gitlab - https://docs.chocolatey.org/en-us/features/host-packages#local-folder-unc-share-cifs
  3. Follow this guide https://docs.chocolatey.org/en-us/guides/create/recompile-packages to internalise community packages that we are using nodejs and python into that directory
  4. Acquire the checksum of the trusted packages using choco info <packageName> and specify these checksums when performing a installation
  5. Ensure that choco install is installing from the our local directory source by using --source option, and not from the upstream community source, this should remove any 429 too many request rate limiting

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions