Closed matusmarhefka closed 1 week ago
This datastream diff is auto generated by the check Compare DS/Generate Diff
Code Climate has analyzed commit c937fae5 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 60.9% (0.0% change).
View more on Code Climate.
Test scenarios pass when using a VM back end:
jcerny@fedora:~/work/git/scap-security-guide (pr/12608)$ python3 tests/automatus.py rule --libvirt qemu:///system ssgts_rhel9 --datastream build/ssg-rhel9-ds.xml firewalld_sshd_port_enabled
Setting console output to log level INFO
INFO - The base image option has not been specified, choosing libvirt-based test environment.
INFO - Logging into /home/jcerny/work/git/scap-security-guide/logs/rule-custom-2024-11-14-1643/test_suite.log
INFO - xccdf_org.ssgproject.content_rule_firewalld_sshd_port_enabled
INFO - Script customized_zone_configured.pass.sh using profile (all) OK
INFO - Script customized_zone_without_ssh.fail.sh using profile (all) OK
INFO - Script new_zone_configured.pass.sh using profile (all) OK
INFO - Script new_zone_without_ssh.fail.sh using profile (all) OK
INFO - Script only_nics_configured.fail.sh using profile (all) OK
INFO - Script zones_and_nics_configured.pass.sh using profile (all) OK
INFO - Script zones_and_nics_ok_no_custom_files.pass.sh using profile (all) OK
INFO - Script zones_and_nics_ok_port_changed.pass.sh using profile (all) OK
INFO - Script only_zones_configured.pass.sh using profile (all) OK
jcerny@fedora:~/work/git/scap-security-guide (pr/12608)$ python3 tests/automatus.py rule --libvirt qemu:///system ssgts_rhel9 --datastream build/ssg-rhel9-ds.xml --remediate-using ansible firewalld_sshd_port_enabled
Setting console output to log level INFO
INFO - The base image option has not been specified, choosing libvirt-based test environment.
INFO - Logging into /home/jcerny/work/git/scap-security-guide/logs/rule-custom-2024-11-14-1647/test_suite.log
INFO - xccdf_org.ssgproject.content_rule_firewalld_sshd_port_enabled
INFO - Script customized_zone_configured.pass.sh using profile (all) OK
INFO - Script customized_zone_without_ssh.fail.sh using profile (all) OK
INFO - Script new_zone_configured.pass.sh using profile (all) OK
INFO - Script new_zone_without_ssh.fail.sh using profile (all) OK
INFO - Script only_nics_configured.fail.sh using profile (all) OK
INFO - Script zones_and_nics_configured.pass.sh using profile (all) OK
INFO - Script zones_and_nics_ok_no_custom_files.pass.sh using profile (all) OK
INFO - Script zones_and_nics_ok_port_changed.pass.sh using profile (all) OK
INFO - Script only_zones_configured.pass.sh using profile (all) OK
Remediation of the rule
firewalld_sshd_port_enabled
has been updated to work in the bootable container build environment. By default, NetworkManager interfaces are created only once container image is booted so we do not have information about what interfaces will be created during container build time. Therefore, we will rely on NetworkManager to automatically assign interfaces to the default firewalld zone. For more details see: https://firewalld.org/documentation/man-pages/firewalld.zone.html https://firewalld.org/documentation/zone/connections-interfaces-and-sources.html This means that the remediation, when running in bootable container build environment, only works if zone defined in thefirewalld_sshd_zone
variable equals to the default zone of firewalld. Otherwise, the remediation is aborted.OVAL check of the rule has also been slightly updated as once container is booted the bootc system doesn't contain any NetworkManager keyfiles under
/etc/NetworkManager/system-connections
and this made the OVAL testtest_firewalld_sshd_port_enabled_all_nics_in_zones
to fail because it expected at least one keyfile in the directory.The test
only_zones_configured.fail.sh
was incorrectly expecting failure result while in reality this is a pass test scenario. NetworkManager automatically assigns the default firewalld zone (public) to interfaces which don't define any zone - and the test configures firewalld to allow ssh access for each zone (including the default one).