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

Restart postfix service and add rule has_nonlocal_mta #10359

Merged
merged 6 commits into from
Mar 30, 2023

Conversation

dodys
Copy link
Contributor

@dodys dodys commented Mar 24, 2023

Description:

  • The rule postfix_network_listening_disabled was missing a restart of postfix service in bash remediation. I didn't touch the ansible for that, hopefully some other vendor can check it and add it if needed.
  • Add rule has_nonlocal_mta to actually check that the MTA is not listening on any non-loopback address ( 127.0.0.1 or ::1 )

Rationale:

  • This rule relates to CIS on different distributions.

@dodys dodys requested review from a team March 24, 2023 11:36
@dodys dodys requested a review from a team as a code owner March 24, 2023 11:36
@dodys dodys added the CIS CIS Benchmark related. label Mar 24, 2023
@github-actions
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

@github-actions
Copy link

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_postfix_network_listening_disabled' differs.
--- xccdf_org.ssgproject.content_rule_postfix_network_listening_disabled
+++ xccdf_org.ssgproject.content_rule_postfix_network_listening_disabled
@@ -19,6 +19,8 @@
 # Clean up after ourselves.
 rm "/etc/postfix/main.cf.bak"
 
+systemctl restart postfix
+
 else
 >&2 echo 'Remediation is not applicable, nothing was done'
 fi

@Mab879 Mab879 added the New Rule Issues or pull requests related to new Rules. label Mar 24, 2023
Copy link
Member

@marcusburghardt marcusburghardt left a comment

Choose a reason for hiding this comment

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

It would be great to have some test scenarios for this new rule. Could you include, please?

@marcusburghardt marcusburghardt self-assigned this Mar 28, 2023
@marcusburghardt marcusburghardt added this to the 0.1.68 milestone Mar 28, 2023
@dodys
Copy link
Contributor Author

dodys commented Mar 29, 2023

It would be great to have some test scenarios for this new rule. Could you include, please?

I'm not sure that's possible. There's no remediation on this rule.
Do you have an example for a rule like this?

@marcusburghardt
Copy link
Member

It would be great to have some test scenarios for this new rule. Could you include, please?

I'm not sure that's possible. There's no remediation on this rule. Do you have an example for a rule like this?

The rule checks if there is a service listening on tcp/25 and binding to anything different of localhost addresses.
However, there are different MTAs which can bind the tcp/25. Therefore, I agree that a remediation for this rule would complex and likely not able to cover all possible cases. I agree to not include a remediation for this rule.

Regarding the tests, we could use postfix MTA, for example, to test the check.
For example:
1 - Ensure the postfix package is installed
2 - Edit the inet_interfaces option in /etc/postfix/main.cf file.
3 - Restart the postfix service.

For a pass test scenario this value should be enough: inet_interfaces = localhost
For a fail test scenario this value should be enough: inet_interfaces = all

In the fail test scenario we can use the # remediation = none header.

@dodys
Copy link
Contributor Author

dodys commented Mar 29, 2023

It would be great to have some test scenarios for this new rule. Could you include, please?

I'm not sure that's possible. There's no remediation on this rule. Do you have an example for a rule like this?

The rule checks if there is a service listening on tcp/25 and binding to anything different of localhost addresses. However, there are different MTAs which can bind the tcp/25. Therefore, I agree that a remediation for this rule would complex and likely not able to cover all possible cases. I agree to not include a remediation for this rule.

Regarding the tests, we could use postfix MTA, for example, to test the check. For example: 1 - Ensure the postfix package is installed 2 - Edit the inet_interfaces option in /etc/postfix/main.cf file. 3 - Restart the postfix service.

For a pass test scenario this value should be enough: inet_interfaces = localhost For a fail test scenario this value should be enough: inet_interfaces = all

In the fail test scenario we can use the # remediation = none header.

nice! I completely forgot about # remediation = none
let me try it then

@codeclimate
Copy link

codeclimate bot commented Mar 29, 2023

Code Climate has analyzed commit 307508d 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 51.8% (-0.1% change).

View more on Code Climate.

@marcusburghardt
Copy link
Member

The testing-farm:centos-stream-8-x86_64 test error is probably unrelated to this PR but is a required test. We need to confirm.

@dodys
Copy link
Contributor Author

dodys commented Mar 30, 2023

/packit retest-failed

@marcusburghardt
Copy link
Member

marcusburghardt commented Mar 30, 2023

Automatus CS8, CS9 and Fedora tests are failing because the has_nonlocal_mta rule is restricted to ubuntu.

Copy link
Member

@marcusburghardt marcusburghardt left a comment

Choose a reason for hiding this comment

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

While the postfix_network_listening_disabled checks the postfix configuration, the new has_nonlocal_mta ensures there is no service listening on 25/tcp for addresses different than localhost. This rule is a useful complement for the related requirements. Thanks

@marcusburghardt
Copy link
Member

Overriding CODEOWNERS since a SUSE approver is not currently available and @dodys can't approve his own PR.

@marcusburghardt marcusburghardt merged commit 94fb584 into ComplianceAsCode:master Mar 30, 2023
@dodys dodys deleted the postfix branch April 17, 2023 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CIS CIS Benchmark related. New Rule Issues or pull requests related to new Rules.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants