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

[Ubuntu2404] Template sysctl improvement #12970

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

alanmcanonical
Copy link
Contributor

Description:

  • Check & remediate /etc/ufw/sysctl.conf in template sysctl

Rationale:

  • Fix the Ubuntu2404 cis rule 3.3.9 Ensure suspicious packets are logged
  • The configuration file /etc/ufw/sysctl.conf will override the overlapped and active kernel parameter. We need to check this file and comment out any occurrence of sysctlvar
  • The existing {oval,bash,sce-bash} use the sysctlvar as part of their regex. The sysctlvar is organised using "." which can also represent the kernel format in /etcufw/sysctl.conf e.g. net.ipv4.conf.default.log_martians can capture literal string "net.ipv4.conf.default.log_martians" and also "net/ipv4/conf/default/log_martians" in /etc/ufw/sysctl.conf

@openshift-ci openshift-ci bot added the needs-ok-to-test Used by openshift-ci bot. label Feb 4, 2025
Copy link

openshift-ci bot commented Feb 4, 2025

Hi @alanmcanonical. 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-sigs/prow repository.

@dodys dodys self-assigned this Feb 5, 2025
@dodys dodys requested a review from a team February 5, 2025 08:26
@dodys dodys added Ubuntu Ubuntu product related. CIS CIS Benchmark related. labels Feb 5, 2025
@dodys dodys added this to the 0.1.77 milestone Feb 5, 2025
Copy link
Contributor

@mpurg mpurg left a comment

Choose a reason for hiding this comment

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

Could you add a test for /etc/ufw/sysctl.conf?

@alanmcanonical
Copy link
Contributor Author

Update the tests.

@@ -7,7 +7,9 @@
# Comment out any occurrences of {{{ SYSCTLVAR }}} from /etc/sysctl.d/*.conf files
{{% if product in [ "sle12", "sle15", "slmicro5"] %}}
for f in /etc/sysctl.d/*.conf /run/sysctl.d/*.conf /usr/local/lib/sysctl.d/*.conf /lib/sysctl.d/*.conf; do
{{% elif product not in [ "ol7", "ol8", "ol9", "rhcos4", "rhel8", "rhel9", "rhel10", "ubuntu2004", "ubuntu2204", "ubuntu2404"] %}}
{{% elif product in [ "ubuntu2004", "ubuntu2204", "ubuntu2404"] %}}
for f in /etc/sysctl.d/*.conf /run/sysctl.d/*.conf /usr/local/lib/sysctl.d/*.conf /etc/ufw/sysctl.conf; do
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you remove /usr/lib/sysctl.d/*.conf from ubuntu platforms on purpose?

Copy link
Contributor Author

@alanmcanonical alanmcanonical Feb 7, 2025

Choose a reason for hiding this comment

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

Not by intention, but the original branch that ubuntu will fall into doesn't have "/usr/lib/sysctl.d/*.conf" in file list. The original if-else branch for ref:

{{% else %}}
for f in /etc/sysctl.d/*.conf /run/sysctl.d/*.conf /usr/local/lib/sysctl.d/*.conf; do

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, you're absolutely right... I missed the "not" in the original elif statement.

Created tests for ufw case
Copy link

codeclimate bot commented Feb 7, 2025

Code Climate has analyzed commit 0f356f9 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 61.9% (0.0% change).

View more on Code Climate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CIS CIS Benchmark related. needs-ok-to-test Used by openshift-ci bot. Ubuntu Ubuntu product related.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants