Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix UBTU-20-010013 OVAL and simplify ansible remediation #11085

Closed

Conversation

dexterle
Copy link
Contributor

@dexterle dexterle commented Sep 8, 2023

Description:

  • Fix UBTU-20-010013
  • Fix remediations and OVAL definitions for Ubuntu

Rationale:

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-010013"

To test changes with bash, run the remediation sections: xccdf_org.ssgproject.content_rule_accounts_tmout

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 not be tested with the latest Ubuntu 2004 Benchmark SCAP. Please perform a manual check given the check text. For reference, please review the latest artifacts: https://public.cyber.mil/stigs/downloads/

This commit will fix the tmout remediation for UBTU-20-010013 which only expects TMOUT=600. Additionally, the remediation variable has been simplified to tmout_line, which can be used for OS's that may have different expected TMOUT lines.
@openshift-ci openshift-ci bot added do-not-merge/work-in-progress Used by openshift-ci bot. needs-ok-to-test Used by openshift-ci bot. labels Sep 8, 2023
@openshift-ci
Copy link

openshift-ci bot commented Sep 8, 2023

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.

@Mab879 Mab879 added Ubuntu Ubuntu product related. STIG STIG Benchmark related. labels Sep 8, 2023
@github-actions
Copy link

github-actions bot commented Sep 8, 2023

Start a new ephemeral environment with changes proposed in this pull request:

rhel8 (from CTF) Environment (using Fedora as testing environment)
Open in Gitpod

Fedora Testing Environment
Open in Gitpod

Oracle Linux 8 Environment
Open in Gitpod

@github-actions
Copy link

github-actions bot commented Sep 8, 2023

This datastream diff is auto generated by the check Compare DS/Generate Diff

Click here to see the full diff
ansible remediation for rule 'xccdf_org.ssgproject.content_rule_accounts_tmout' differs.
--- xccdf_org.ssgproject.content_rule_accounts_tmout
+++ xccdf_org.ssgproject.content_rule_accounts_tmout
@@ -4,11 +4,30 @@
   tags:
     - always
 
-- name: Correct any occurrence of TMOUT in /etc/profile
-  replace:
+- name: Set Interactive Session Timeout - Set TMOUT Line Fact
+  ansible.builtin.set_fact:
+    tmout_line: declare -xr TMOUT={{ var_accounts_tmout }}
+  when: ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
+  tags:
+  - CCE-80673-7
+  - NIST-800-171-3.1.11
+  - NIST-800-53-AC-12
+  - NIST-800-53-AC-2(5)
+  - NIST-800-53-CM-6(a)
+  - NIST-800-53-SC-10
+  - PCI-DSSv4-8.6.1
+  - accounts_tmout
+  - low_complexity
+  - low_disruption
+  - medium_severity
+  - no_reboot_needed
+  - restrict_strategy
+
+- name: Set Interactive Session Timeout - Correct Any Occurrence of TMOUT in /etc/profile
+  ansible.builtin.replace:
     path: /etc/profile
     regexp: ^[^#].*TMOUT=.*
-    replace: declare -xr TMOUT={{ var_accounts_tmout }}
+    replace: '{{ tmout_line }}'
   register: profile_replaced
   when: ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
   tags:
@@ -31,7 +50,7 @@
     path: /etc/profile.d/tmout.sh
     create: true
     regexp: TMOUT=
-    line: declare -xr TMOUT={{ var_accounts_tmout }}
+    line: '{{ tmout_line }}'
     state: present
   when: ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
   tags:

@codeclimate
Copy link

codeclimate bot commented Sep 8, 2023

Code Climate has analyzed commit e488724 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 dexterle marked this pull request as ready for review September 11, 2023 16:25
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Used by openshift-ci bot. label Sep 11, 2023
@dodys dodys requested a review from a team September 13, 2023 15:32
@dodys dodys self-assigned this Sep 13, 2023
@dodys dodys added ok-to-test Used by openshift-ci bot. and removed needs-ok-to-test Used by openshift-ci bot. labels Sep 13, 2023
Copy link
Contributor

@dodys dodys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should do the remediation as proposed by DISA but instead follow CIS on this.

@@ -37,8 +37,10 @@
{{% if filepath %}}
<ind:filepath>{{{ filepath }}}</ind:filepath>
{{% endif %}}
{{% if product in ['sle12', 'sle15'] or "ubuntu" in product %}}
{{% if product in ['sle12', 'sle15'] or product in ['ubuntu1804', 'ubuntu2204'] %}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should not split this rule
I belive the solution as is now is way better than what is in DISA's stig document.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you recommend to drop the PR if we follow CIS? The original remediation seems to work well so not sure if this PR is even needed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you will still want to add a ubuntu specific ansible, as the shared ansible does not cover our case, see bash remediation. But for the oval you could drop the changes.

@elsoa-invitech
Copy link

On ubuntu 22.04 ansible create wrong tmout file: cat /etc/profile.d/tmout.sh

typeset -xr TMOUT=900

Bash fix is good.

Copy link

openshift-ci bot commented Jul 30, 2024

@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/4.14-images e488724 link true /test 4.14-images
ci/prow/4.13-images e488724 link true /test 4.13-images
ci/prow/4.15-images e488724 link true /test 4.15-images
ci/prow/4.16-images e488724 link true /test 4.16-images
ci/prow/4.12-images e488724 link true /test 4.12-images
ci/prow/4.17-images e488724 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.

@jan-cerny
Copy link
Collaborator

ping

@dodys
Copy link
Contributor

dodys commented Aug 2, 2024

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.

@dodys dodys closed this Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test Used by openshift-ci bot. STIG STIG Benchmark related. Ubuntu Ubuntu product related.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants