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

ANSSI BP 028 profile for debian12 #11368

Merged
merged 36 commits into from
Dec 13, 2023

Conversation

a-skr
Copy link
Contributor

@a-skr a-skr commented Dec 10, 2023

Description:

  • Add ANSSI-BP-028 profile for Debian 12 (including remediation).

@openshift-ci openshift-ci bot added the needs-ok-to-test Used by openshift-ci bot. label Dec 10, 2023
Copy link

openshift-ci bot commented Dec 10, 2023

Hi @a-skr. 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.

Copy link

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

@marcusburghardt marcusburghardt added Debian Debian product related. ANSSI ANSSI Benchmark related. labels Dec 11, 2023
@@ -1,6 +1,6 @@
documentation_complete: true

prodtype: ubuntu2004,ubuntu2204
prodtype: ubuntu2004,ubuntu2204,debian12
Copy link
Collaborator

Choose a reason for hiding this comment

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

The prodtypes need to be alphabetically sorted. You have multiple occurrences of unsorting the prodtype key in this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't know that. I will fix them.

@@ -0,0 +1,20 @@
# platform = multi_platform_debian

Copy link
Collaborator

Choose a reason for hiding this comment

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

The OVAL checks and Ansible and Bash remediations for Debian 12 that you introduce are quite different from the existing ones that are there for other products. Consequently, the description and other texts in the rule.yml file of this rule aren't properly aligned with the actual check and remediation. Please update the linux_os/guide/system/software/integrity/software-integrity/aide/aide_build_database/rule.yml in a way so that it better describes the actual situation on Debian 12.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The debian description explains an interactive aide database update (through the aideinit wrapper) which, I think, is fitting.

The remedation (non interactive) uses options -y -f to automatically create then deploy the new database.

As per aideinit manpage, the user should ideally check the database content before deploying it, so I prefer a description that doesn't automatically force the deployment of the new DB.

@@ -51,7 +51,7 @@

- name: '{{{ rule_title }}} - Extract log files new format'
ansible.builtin.shell: |
set -o pipefail
{{% if not 'debian' in product %}}set -o pipefail{{% endif -%}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the reason for this change? I think that Ansible lint will require having the pipefail here.

Copy link
Contributor Author

@a-skr a-skr Dec 11, 2023

Choose a reason for hiding this comment

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

The default shell in Debian for scripts is dash. dash doesn't have the pipefail option. Some operating systems (such as those based on open-embedded) may not have bash compiled in (they usually use busybox).

Alternatively, I can force bash usage in the playbook fragment.

What do you prefer?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for a great explanation.

I have found that at this moment we have in our CI relaxed this Ansible lint check to a warning, due to some other existing ules that don't have the pipefail set in their Ansible code.

warn_list:
- name[missing] # Rule for checking task and play names.
- template-instead-of-copy # Templated files should use template instead of copy
- yaml[empty-lines] # Violations reported by yamllint.
- yaml[line-length] # Violations reported by yamllint.
- name[casing] # Rule for checking task and play names.
- no-handler # Style choice, skipping for now
- risky-shell-pipe # Skipping for now due to authselect rules

Also, there is a complex discussion about it on the Ansible lint GitHub ansible/ansible-lint#497 and there is no specific outcome.

So after finding these information I would prefer to keep this if condition here as you proposed. It would be nice to add an explanatory comment to the code there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will add an explanation ASAP.

@jan-cerny jan-cerny self-assigned this Dec 11, 2023
@jan-cerny jan-cerny added this to the 0.1.72 milestone Dec 11, 2023
Change default value from system.administrator@mail.mil to
change_me@localhost in case mail.mil suddenly becomes valid.
- enable remediation
- fix description
- add OVAL test
related macros

shared/macros/10-ansible.jinja fixes:

- fix name of task adding grub2 arguments
- fix kernel arguments matching regexp: kernel command line arguments may be words separated by commas. The \w metacharacter doesn't match the comma, so rules like grub2_l1tf_argument fail if the ansible remediation playbook is executed a second time.
@jan-cerny
Copy link
Collaborator

/packit retest-failed

- name: '{{{ rule_title }}} - Get include files directives'
ansible.builtin.shell: |
set -o pipefail
{{% if not 'debian' in product %}}set -o pipefail{{% endif -%}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

There is one more problem, and that is a serious one and it causes the fail of the testing farm CI jobs. On other products, this reduces the whitespace and accidentally removes the newline. For example, when you build rhel9, you will see this in the built cotnent:

     set -o pipefailgrep -e '$IncludeConfig' {{ rsyslog_etc_config }} | cut -d ' ' -f 2 || true

Please make sure this won't happen. Dtto for other occurrences.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It should be fixed by now.
Thank you for your patience.

Copy link

codeclimate bot commented Dec 13, 2023

Code Climate has analyzed commit 2d92005 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 58.5% (0.0% change).

View more on Code Climate.

Copy link
Collaborator

@jan-cerny jan-cerny left a comment

Choose a reason for hiding this comment

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

I have checked the built debian12 content and I have seen that the ANSSI BP28 profiles are present there.

@jan-cerny jan-cerny merged commit 0ed28da into ComplianceAsCode:master Dec 13, 2023
35 of 36 checks passed
@vojtapolasek vojtapolasek added Highlight This PR/Issue should make it to the featured changelog. New Profile Issues or pull requests related to new Profiles. labels Feb 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ANSSI ANSSI Benchmark related. Debian Debian product related. Highlight This PR/Issue should make it to the featured changelog. needs-ok-to-test Used by openshift-ci bot. New Profile Issues or pull requests related to new Profiles.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants