Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dnf] ensure packages are gpg-verified (#71537)
Change: - By default the dnf API does not gpg-verify packages. This is a feature that is executed in its CLI code. It never made it into Ansible's usage of the API, so packages were previously not verified. - This fixes CVE-2020-14365. Test Plan: - New integration tests Signed-off-by: Rick Elrod <rick@elrod.me>
- Loading branch information
Showing
6 changed files
with
107 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
security_fixes: | ||
- dnf - Previously, regardless of the ``disable_gpg_check`` option, packages were not GPG validated. They are now. (CVE-2020-14365) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# Set up a repo of unsigned rpms | ||
- block: | ||
- name: Ensure our test package isn't already installed | ||
dnf: | ||
name: | ||
- fpaste | ||
state: absent | ||
|
||
- name: Install rpm-sign | ||
dnf: | ||
name: | ||
- rpm-sign | ||
state: present | ||
|
||
- name: Create directory to use as local repo | ||
file: | ||
path: "{{ remote_tmp_dir }}/unsigned" | ||
state: directory | ||
|
||
- name: Download an RPM | ||
get_url: | ||
url: https://s3.amazonaws.com/ansible-ci-files/test/integration/targets/dnf/fpaste-0.3.9.1-1.fc27.noarch.rpm | ||
dest: "{{ remote_tmp_dir }}/unsigned/fpaste-0.3.9.1-1.fc27.noarch.rpm" | ||
mode: 0644 | ||
|
||
- name: Unsign the RPM | ||
command: rpmsign --delsign "{{ remote_tmp_dir }}/unsigned/fpaste-0.3.9.1-1.fc27.noarch.rpm" | ||
|
||
- name: createrepo | ||
command: createrepo . | ||
args: | ||
chdir: "{{ remote_tmp_dir }}/unsigned" | ||
|
||
- name: Add the repo | ||
yum_repository: | ||
name: unsigned | ||
description: unsigned rpms | ||
baseurl: "file://{{ remote_tmp_dir }}/unsigned/" | ||
# we want to ensure that signing is verified | ||
gpgcheck: true | ||
|
||
- name: Install fpaste from above | ||
dnf: | ||
name: | ||
- fpaste | ||
disablerepo: '*' | ||
enablerepo: unsigned | ||
register: res | ||
ignore_errors: yes | ||
|
||
- assert: | ||
that: | ||
- res is failed | ||
- "'Failed to validate GPG signature' in res.msg" | ||
|
||
always: | ||
- name: Remove rpm-sign (and fpaste if it got installed) | ||
dnf: | ||
name: | ||
- rpm-sign | ||
- fpaste | ||
state: absent | ||
|
||
- name: Remove test repo | ||
yum_repository: | ||
name: unsigned | ||
state: absent | ||
|
||
- name: Remove repo dir | ||
file: | ||
path: "{{ remote_tmp_dir }}/unsigned" | ||
state: absent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters