content
content copied to clipboard
Fix remediation ubtu 20 010065
Description:
- Fix UBTU-20-010065
- Fix Ansible remediation
smartcard_configure_cert_checking
and use proper styling
Rationale:
- Part of Ubuntu 20.04 DISA STIG v1r9 profile upgrade
- https://github.com/ComplianceAsCode/content/pull/10738
Review Hints:
Build the product:
./build_product ubuntu2004
To test these changes with Ansible:
ansible-playbook build/ansible/ubuntu2004-playbook-stig.yml --tags "DISA-STIG-UBTU-20-010065"
Checkout Manual STIG OVAL definitions, and use software like DISA STIG Viewer to view definitions.
git checkout dexterle:add-manual-stig-ubtu-20-v1r9
This STIG can be tested with the latest Ubuntu 2004 Benchmark SCAP. For reference, please review the latest artifacts: https://public.cyber.mil/stigs/downloads/
Hi @dexterle. Thanks for your PR.
I'm waiting for a ComplianceAsCode member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test
on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.
Once the patch is verified, the new status will be reflected by the ok-to-test
label.
I understand the commands that are listed here.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.
Start a new ephemeral environment with changes proposed in this pull request:
rhel7 (from CTF) Environment (using Fedora as testing environment)
This datastream diff is auto generated by the check Compare DS/Generate Diff
Click here to see the full diff
bash remediation for rule 'xccdf_org.ssgproject.content_rule_smartcard_configure_cert_checking' differs.
--- xccdf_org.ssgproject.content_rule_smartcard_configure_cert_checking
+++ xccdf_org.ssgproject.content_rule_smartcard_configure_cert_checking
@@ -4,6 +4,7 @@
if ! rpm -q --quiet "pam_pkcs11" ; then
yum install -y "pam_pkcs11"
fi
+
if grep "^\s*cert_policy" /etc/pam_pkcs11/pam_pkcs11.conf | grep -qv "ocsp_on"; then
sed -i "/^\s*#/! s/cert_policy.*/cert_policy = ca, ocsp_on, signature;/g" /etc/pam_pkcs11/pam_pkcs11.conf
ansible remediation for rule 'xccdf_org.ssgproject.content_rule_smartcard_configure_cert_checking' differs.
--- xccdf_org.ssgproject.content_rule_smartcard_configure_cert_checking
+++ xccdf_org.ssgproject.content_rule_smartcard_configure_cert_checking
@@ -1,5 +1,18 @@
-- name: Package facts
- package_facts: null
+- name: Gather the package facts
+ package_facts:
+ manager: auto
+ tags:
+ - CCE-80520-0
+ - DISA-STIG-RHEL-07-041003
+ - low_complexity
+ - low_disruption
+ - medium_severity
+ - no_reboot_needed
+ - restrict_strategy
+ - smartcard_configure_cert_checking
+
+- name: Configure Smart Card Certificate Status Checking - Gather Package Facts
+ ansible.builtin.package_facts: null
when:
- ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
- ansible_architecture != "s390x"
@@ -13,15 +26,19 @@
- restrict_strategy
- smartcard_configure_cert_checking
-- name: Replace 'none' from cert_policy
- replace:
+- name: Configure Smart Card Certificate Status Checking - Check if cert_policy in
+ /etc/pam_pkcs11/pam_pkcs11.conf Is Already Set
+ ansible.builtin.lineinfile:
path: /etc/pam_pkcs11/pam_pkcs11.conf
- regexp: (^\s*cert_policy\s*=\s*)none\s*;(\s*$)
- replace: \g<1>ocsp_on,ca,signature;\g<2>
+ regexp: ^(\s*)cert_policy\s+.*
+ state: absent
+ check_mode: true
+ changed_when: false
+ register: cert_policy_replace
when:
- ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
- ansible_architecture != "s390x"
- - '''pam_pkcs11'' in ansible_facts.packages'
+ - '"libpam-pkcs11" in ansible_facts.packages'
tags:
- CCE-80520-0
- DISA-STIG-RHEL-07-041003
@@ -32,15 +49,17 @@
- restrict_strategy
- smartcard_configure_cert_checking
-- name: Add 'ocsp_on' parameter for cert_policy in /etc/pam_pkcs11/pam_pkcs11.conf
- replace:
+- name: Configure Smart Card Certificate Status Checking - Ensure 'none' Parameter
+ for cert_policy in /etc/pam_pkcs11/pam_pkcs11.conf Is Removed
+ ansible.builtin.replace:
path: /etc/pam_pkcs11/pam_pkcs11.conf
- regexp: (^\s*cert_policy\s*=\s*)(?!.*ocsp_on)(.*)
- replace: \g<1>ocsp_on,\g<2>
+ regexp: (^\s*cert_policy\s*=\s*)none\s*;(\s*$)
+ replace: \g<1>ocsp_on,ca,signature;\g<2>
when:
- ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
- ansible_architecture != "s390x"
- - '''pam_pkcs11'' in ansible_facts.packages'
+ - cert_policy_replace.found > 0
+ - '"libpam-pkcs11" in ansible_facts.packages'
tags:
- CCE-80520-0
- DISA-STIG-RHEL-07-041003
@@ -50,3 +69,46 @@
- no_reboot_needed
- restrict_strategy
- smartcard_configure_cert_checking
+
+- name: Configure Smart Card Certificate Status Checking - Add 'ocsp_on' Parameter
+ for cert_policy in /etc/pam_pkcs11/pam_pkcs11.conf
+ ansible.builtin.replace:
+ path: /etc/pam_pkcs11/pam_pkcs11.conf
+ regexp: (^\s*cert_policy\s*=\s*)(?!.*ocsp_on)(.*)
+ replace: \g<1>ocsp_on,\g<2>
+ when:
+ - ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
+ - ansible_architecture != "s390x"
+ - cert_policy_replace.found > 0
+ - '"libpam-pkcs11" in ansible_facts.packages'
+ tags:
+ - CCE-80520-0
+ - DISA-STIG-RHEL-07-041003
+ - low_complexity
+ - low_disruption
+ - medium_severity
+ - no_reboot_needed
+ - restrict_strategy
+ - smartcard_configure_cert_checking
+
+- name: Configure Smart Card Certificate Status Checking - Add cert_policy if It Does
+ Not Exist
+ ansible.builtin.lineinfile:
+ path: /etc/pam_pkcs11/pam_pkcs11.conf
+ line: cert_policy = ocsp_on,ca,signature;
+ state: present
+ create: true
+ when:
+ - ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
+ - ansible_architecture != "s390x"
+ - cert_policy_replace.found == 0
+ - '"libpam-pkcs11" in ansible_facts.packages'
+ tags:
+ - CCE-80520-0
+ - DISA-STIG-RHEL-07-041003
+ - low_complexity
+ - low_disruption
+ - medium_severity
+ - no_reboot_needed
+ - restrict_strategy
+ - smartcard_configure_cert_checking
Code Climate has analyzed commit 7cd441ee and detected 0 issues on this pull request.
The test coverage on the diff in this pull request is 100.0% (50% is the threshold).
This pull request will bring the total coverage in the repository to 53.8% (0.0% change).
View more on Code Climate.
@dexterle: The following tests failed, say /retest
to rerun all failed tests or /retest-required
to rerun all mandatory failed tests:
Test name | Commit | Details | Required | Rerun command |
---|---|---|---|---|
ci/prow/images | 7cd441ee8b938bd28586cdb1fe8d8a7ffc823062 | link | true | /test images |
ci/prow/4.12-images | 7cd441ee8b938bd28586cdb1fe8d8a7ffc823062 | link | true | /test 4.12-images |
ci/prow/4.17-images | 7cd441ee8b938bd28586cdb1fe8d8a7ffc823062 | link | true | /test 4.17-images |
Full PR test history. Your PR dashboard.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.
dexterle reached out last week about continuing work on this PRs, and I've asked to open new ones for a clean state. Therefore closing this one.