-
Notifications
You must be signed in to change notification settings - Fork 761
Fix level inheritance when processing profiles #13666
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 level inheritance when processing profiles #13666
Conversation
641eea3 to
27822c6
Compare
jan-cerny
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have checked that this doesn't impact the profile selections in RHEL 9 data streams.
I have tried your test script and it works fine as expected. The change looks good to me. Would it be possible to have a unit test that tests this?
|
@jan-cerny Hi, Jan. Try use ssg to get selected rules and unselected rules for from ssg.profiles import get_profiles_from_products
profiles = get_profiles_from_products(cac_content_root, "rhel9")
for profile in profiles:
if profile.profile_id == "anssi_bp28_high":
print(f"profile rules: {profile.rules}")
print(f"profile unselected rules: {profile.unselected_rules}")
break This is selected rules result: ['kernel_config_strict_kernel_rwx', 'kernel_config_debug_wx', 'kernel_config_debug_fs', 'kernel_config_stackprotector', 'kernel_config_stackprotector_strong', 'kernel_config_sched_stack_end_check', 'kernel_config_hardened_usercopy', 'kernel_config_hardened_usercopy_fallback', 'kernel_config_vmap_stack', 'kernel_config_refcount_full', 'kernel_config_fortify_source', 'kernel_config_acpi_custom_method', 'kernel_config_devkmem', 'kernel_config_proc_kcore', 'kernel_config_compat_vdso', 'kernel_config_security_dmesg_restrict', 'kernel_config_retpoline', 'kernel_config_legacy_vsyscall_none', 'kernel_config_legacy_vsyscall_emulate', 'kernel_config_legacy_vsyscall_xonly', 'kernel_config_x86_vsyscall_emulation', 'kernel_config_debug_credentials', 'kernel_config_debug_notifiers', 'kernel_config_debug_list', 'kernel_config_debug_sg', 'kernel_config_bug_on_data_corruption', 'kernel_config_slab_freelist_random', 'kernel_config_slab_freelist_hardened', 'kernel_config_slab_merge_default', 'kernel_config_slub_debug', 'kernel_config_page_poisoning', 'kernel_config_page_poisoning_no_sanity', 'kernel_config_page_poisoning_zero', 'kernel_config_compat_brk', 'kernel_config_strict_module_rwx', 'kernel_config_module_sig', 'kernel_config_module_sig_force', 'kernel_config_module_sig_all', 'kernel_config_module_sig_sha512', 'kernel_config_module_sig_hash', 'kernel_config_module_sig_key', 'kernel_config_bug', 'kernel_config_panic_on_oops', 'kernel_config_panic_timeout', 'kernel_config_seccomp', 'kernel_config_seccomp_filter', 'kernel_config_security', 'kernel_config_security_yama', 'kernel_config_security_writable_hooks', 'kernel_config_gcc_plugin_latent_entropy', 'kernel_config_gcc_plugin_stackleak', 'kernel_config_gcc_plugin_structleak', 'kernel_config_gcc_plugin_structleak_byref_all', 'kernel_config_gcc_plugin_randstruct', 'kernel_config_syn_cookies', 'kernel_config_kexec', 'kernel_config_hibernation', 'kernel_config_binfmt_misc', 'kernel_config_legacy_ptys', 'kernel_config_default_mmap_min_addr', 'kernel_config_randomize_base', 'kernel_config_randomize_memory', 'kernel_config_page_table_isolation', 'kernel_config_ia32_emulation', 'kernel_config_modify_ldt_syscall', 'kernel_config_arm64_sw_ttbr0_pan', 'kernel_config_unmap_kernel_at_el0', 'selinux_policytype', 'sebool_selinuxuser_execheap', 'sebool_deny_execmem', 'sebool_selinuxuser_execstack', 'sebool_secure_mode_insmod', 'sebool_ssh_sysadm_login', 'package_setroubleshoot_removed', 'package_setroubleshoot-server_removed', 'package_setroubleshoot-plugins_removed', 'package_aide_installed', 'aide_build_database', 'aide_periodic_cron_checking', 'aide_periodic_checking_systemd_timer', 'aide_scan_notification', 'aide_verify_acls', 'aide_verify_ext_attributes']This is unselected rules result ['sebool_secure_mode_insmod', 'partition_for_opt', 'accounts_passwords_pam_tally2_deny_root', 'install_PAE_kernel_on_x86-32', 'partition_for_boot', 'aide_periodic_checking_systemd_timer', 'sudo_add_ignore_dot', 'audit_rules_privileged_commands_rmmod', 'audit_rules_privileged_commands_modprobe', 'package_dracut-fips-aesni_installed', 'cracklib_accounts_password_pam_lcredit', 'partition_for_usr', 'cracklib_accounts_password_pam_ocredit', 'enable_pam_namespace', 'audit_rules_privileged_commands_insmod', 'service_chronyd_or_ntpd_enabled', 'chronyd_configure_pool_and_server', 'accounts_passwords_pam_tally2', 'cracklib_accounts_password_pam_ucredit', 'accounts_passwords_pam_tally2_unlock_time', 'sudo_add_umask', 'sudo_add_env_reset', 'cracklib_accounts_password_pam_minlen', 'cracklib_accounts_password_pam_dcredit', 'ensure_oracle_gpgkey_installed', 'ensure_almalinux_gpgkey_installed', 'package_kea_removed', 'audit_rules_file_deletion_events_renameat2', 'audit_rules_dac_modification_fchmodat2', 'apparmor_configured', 'all_apparmor_profiles_enforced', 'grub2_enable_apparmor', 'package_apparmor_installed', 'package_pam_apparmor_installed', 'package_rsh-server_removed', 'package_rsh_removed', 'package_xinetd_removed', 'package_ypbind_removed', 'package_ypserv_removed', 'file_groupowner_efi_grub2_cfg', 'file_owner_efi_grub2_cfg', 'file_permissions_efi_grub2_cfg', 'file_groupowner_efi_user_cfg', 'file_owner_efi_user_cfg', 'file_permissions_efi_user_cfg', 'grub2_uefi_password', 'package_talk_removed', 'package_talk-server_removed']In |
|
Yes, both of us know this. |
Signed-off-by: Marcus Burghardt <[email protected]>
CodeClimate reported complexity 7 in the PR. This commit brings it down. Signed-off-by: Marcus Burghardt <[email protected]>
It is not necessary to use a dict at this point. Signed-off-by: Marcus Burghardt <[email protected]>
Also updated the testing control file to ensure different rules in different levels. Signed-off-by: Marcus Burghardt <[email protected]>
A unit test was using dynamic data, making unit tests unpredictable. Signed-off-by: Marcus Burghardt <[email protected]>
9145eb9 to
946ce0e
Compare
|
@marcusburghardt: The following test failed, say
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. |
|
Code Climate has analyzed commit 946ce0e 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.7% (0.0% change). View more on Code Climate. |
Description:
The
get_profiles_from_productsfunction was introduced to allow external tools, such ascomplyscribeto process profiles externally.During tests it was noticed that some rules were not available in profiles levels with inheritance.
Rationale:
Review Hints:
The
get_profiles_from_productsfunction is not used internally in the building system.But this simple script may help to test the changes after using
source .pyenv.sh: