Commit graph

21 commits

Author SHA1 Message Date
Alexis Métaireau
e9ddf8b375
Add a way to cancel an ongoing container upgrade
This might happen if people in a hurry want to do a conversion without
having to wait for the new container to be ready.
2025-04-30 19:32:30 +02:00
Alexis Métaireau
27aa2b05a1
Check for new container image releases when checking for updates
There is now a new setting that is updated when a container upgrade
needs to be applied.

The `UpdaterReport` has been extended to support this scenario, and is
now a python `dataclass`.
2025-04-30 15:43:00 +02:00
Alexis Métaireau
e5d091d268
Fix types and use pathlib.Path for files 2025-04-29 15:00:53 +02:00
Alexis Métaireau
e9b399baf5
Use a share/image-name.txt file which defines what image name we should expect
This is especially useful when running the tests against some
non-production version of the image. Note that the signature for this
image will need to match the key at `share/freedomofpress-dangerzone-pub.key`
2025-04-29 15:00:21 +02:00
Alexis Métaireau
be1704ce4f
Use str for DEFAULT_PUBKEY_LOCATION 2025-04-29 14:59:38 +02:00
Alexis Métaireau
8d95c1f0e9
Use a specific error if no signatures files are found 2025-04-29 14:58:54 +02:00
Alexis Métaireau
c26bfc409b
Skip container signature verification during the tests
This is not required, and skipping them allows to make the whole
test-suite run faster.
2025-04-29 14:58:54 +02:00
Alexis Métaireau
b78fd237e1
Provide a simple function to install the shipped tarball.
It leaves in `dangerzone.updater.install_local_container_tar()`
2025-04-29 14:58:53 +02:00
Alexis Métaireau
1187cf27fc
dangerzone.updater exposes a few funtions, constants and exceptions
This is done to avoid looking at the internal logic of
`dangerzone.updater`. Only the features that actually are part of
the exposed API are exposed, and do not require deep knowledge of the
updater's logic to be used.
2025-04-29 14:58:53 +02:00
Alexis Métaireau
9c95c9d627
Make the upgrade_container_image() callback argument optional 2025-04-29 14:58:53 +02:00
Alexis Métaireau
7f5bc451e0
Allow a different runtime on dangerzone-image commands.
This can be done with the newly added `--runtime` flag, which needs to
be passed to the first group, e.g:

```bash
dangerzone-cli --runtime docker COMMAND
```
2025-04-29 14:58:53 +02:00
Alexis Métaireau
647f551989
Display the {podman,docker} pull progress when installing a new image
The progressbars we see when using this same commands on the
command line doesn't seem to be passed to the python process here,
unfortunately.
2025-04-29 14:58:53 +02:00
Alexis Métaireau
f35787d2ef
Add a dangerzone-image store-signature CLI command
This can be useful when signatures are missing from the system, for an
already present image, and can be used as a way to fix user issues.
2025-04-29 14:58:53 +02:00
Alexis Métaireau
2485a719a1
Replace the updater_check setting by updater_check_all
This new setting triggers the same user prompts, but the actual meaning of
it differs, since users will now be accepting to upgrade the container image
rather than just checking for new releases.

Changing the name of the setting will trigger this prompt for all users, effectively
ensuring they want their image to be automatically upgraded.
2025-04-29 14:58:53 +02:00
Alexis Métaireau
1dc0ac5f5e
Split updater GUI code from the code checking for release updates
The code making the actual requests and checks now lives in the
`updater.releases` module. The code should be easier to read and to
reason about.

Tests have been updated to reflect this.
2025-04-29 14:58:53 +02:00
Alexis Métaireau
9191fb9264
Provide an is_update_available function
This function does all the needed checks before returning `True`, making it a good external API.

Under the hood, the registry now has an `is_new_remote_image_available`
which is just for checking the presence of a new image, but doesn't do
any verirications on it, and there is also a new `check_signatures_and_logindex` that ensures that these two are valid.
2025-04-29 14:58:52 +02:00
Alexis Métaireau
8a536c37d2
Add signatures tests 2025-04-29 14:58:52 +02:00
Alex Pyrgiotis
01ad141f33
Publish and attest multi-architecture container images
A new `dangerzone-image attest-provenance` script is now available,
making it possible to verify the attestations of an image published on
the github container registry.

Container images are now build nightly and uploaded to the container
registry.
2025-04-29 14:58:52 +02:00
Alexis Métaireau
196823d67d
Introduce a subprocess_run utility function
This is done to avoid forgetting windows specific arguments when calling `subprocess.run`.
2025-04-29 14:58:52 +02:00
Alexis Métaireau
f04afde8fd
Download and verify cosign signatures
Signatures are stored in the OCI Manifest v2 registry [0], and are
expected to follow the Cosign Signature Specification [0]

The following CLI utilities are provided with `dangerzone-image`:

For checking new container images, upgrading them and downloading them:

- `upgrade` allows to upgrade the current installed image to the
  last one available on the OCI registry, downloading and storing the
  signatures in the process.
- `verify-local` allows the verify the currently installed image against
  downloaded signatures and public key.

To prepare and install archives on air-gapped environments:

- `prepare-archive` helps to prepare an archive to install on another
  machine
- `load-archive` helps upgrade the local image to the archive given
  in argument.

Signatures are stored locally using the format provided by `cosign
download signature`, and the Rekor log index is used to ensure the
requested-to-install container image is fresher than the one already
present on the system.

[0] https://github.com/sigstore/cosign/blob/main/specs/SIGNATURE_SPEC.md
2025-04-29 14:58:52 +02:00
Alexis Métaireau
83a8f85226
Add a dangerzone-image CLI script
It contains utilities to interact with OCI registries, like getting the list of
published tags and getting the content of a manifest. It does so
via the use of the Docker Registry API v2 [0].

The script has been added to the `dev_scripts`, and is also installed on
the system under `dangerzone-image`.

[0]  https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry
2025-04-29 14:58:51 +02:00