Skip to content

[FEATURE REQUEST] Simple gpg signature verification of file downloads #63143

Closed
@lkubb

Description

Is your feature request related to a problem? Please describe.
Sometimes I write formulae to install builds from Github releases (or similar). If they offer cryptographic signatures, I would like to be able to securely and easily verify them. This includes verifying the signature has been made by a particular (set of) key(s), not everything imported in my keyring (ref apt-key deprecation). (This has been split into a separate FR: #63166)

Describe the solution you'd like

# [...] use gpg.present to receive keys

Verify release:
  gpg.verified:
    - name: /my/file.tar.gz
    - signature: /my/file.tar.gz.asc
    - signed_by_any:  # or signed_by_all
      - deadbeef
      - cafebabe
      - d00d1337

Edit:
More semantical sense, with the caveat that an implementation needs to be properly validated because of how much those states already handle, would make to add signature andsource_hash_sig (+supporting) parameters to file.managed and archive.extracted:

Install latest release:
  file.managed:
    - name: /opt/awesome/software
    - source: https://github.com/awesome/software/releases/42/awesome-software-42-x84_64
    - source_hash: https://github.com/awesome/software/releases/42/awesome-software-42-x84_64.SHA256
    - source_hash_sig: True  # verifies an embedded signature in the source hash file
    - mode: '0755'
Install latest release:
  file.managed:
    - name: /opt/awesome/software
    - source: https://github.com/awesome/software/releases/42/awesome-software-42-x84_64
    - source_hash: https://github.com/awesome/software/releases/42/awesome-software-42-x84_64.SHA256
    - signature: https://github.com/awesome/software/releases/42/awesome-software-42-x84_64.asc
    - mode: '0755'

Describe alternatives you've considered
This monster [does not contain the limitation to a particular (set of) key(s)]:

# [...] some lvl4 incantation to make sure the following
# does not run without the key actually being present

Vaultwarden web vault signature is verified:
  test.configurable_test_state:
    - name: Check if the downloaded web vault archive has been signed by the author.
    - changes: False
    - result: >
        __slot__:salt:gpg.verify(filename=/tmp/web-vault-{{ warden.version_web_vault }}.tar.gz,
        signature=/tmp/web-vault-{{ warden.version_web_vault }}.tar.gz.asc).res
    - require:
      - Vaultwarden key is actually present
      - Vaultwarden web vault is downloaded

Additional context
Already wrote the implementation, PR pending me writing tests for it and fixing another related, quite aggravating issue with gpg.receive_keys / gpg.present.

Metadata

Assignees

No one assigned

    Labels

    Featurenew functionality including changes to functionality and code refactors, etc.needs-triage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions