Blame SOURCES/scap-security-guide-0.1.61-selinux_state_rhel8_anssi_enhanced-PR_8182.patch

62ebbd
diff --git a/controls/anssi.yml b/controls/anssi.yml
62ebbd
index ff3736711dd..5c3d5f34ea8 100644
62ebbd
--- a/controls/anssi.yml
62ebbd
+++ b/controls/anssi.yml
62ebbd
@@ -72,6 +72,7 @@ controls:
62ebbd
       SELinux policies limit the privileges of services and daemons to only what they require.
62ebbd
     rules:
62ebbd
     - selinux_state
62ebbd
+    - var_selinux_state=enforcing
62ebbd
 
62ebbd
   - id: R4
62ebbd
     levels:
62ebbd
diff --git a/products/rhel8/profiles/anssi_bp28_enhanced.profile b/products/rhel8/profiles/anssi_bp28_enhanced.profile
62ebbd
index 2a49527c10a..8f2ee31493b 100644
62ebbd
--- a/products/rhel8/profiles/anssi_bp28_enhanced.profile
62ebbd
+++ b/products/rhel8/profiles/anssi_bp28_enhanced.profile
62ebbd
@@ -17,4 +17,3 @@ description: |-
62ebbd
 
62ebbd
 selections:
62ebbd
     - anssi:all:enhanced
62ebbd
-    - '!selinux_state'
62ebbd
diff --git a/products/rhel9/profiles/anssi_bp28_enhanced.profile b/products/rhel9/profiles/anssi_bp28_enhanced.profile
62ebbd
index 89e0d260390..da048c9b556 100644
62ebbd
--- a/products/rhel9/profiles/anssi_bp28_enhanced.profile
62ebbd
+++ b/products/rhel9/profiles/anssi_bp28_enhanced.profile
62ebbd
@@ -17,4 +17,3 @@ description: |-
62ebbd
 
62ebbd
 selections:
62ebbd
     - anssi:all:enhanced
62ebbd
-    - '!selinux_state'
62ebbd
diff --git a/tests/unit/ssg-module/data/controls_dir/abcd-levels.yml b/tests/unit/ssg-module/data/controls_dir/abcd-levels.yml
62ebbd
index 2e60ec43532..b201c495b8d 100644
62ebbd
--- a/tests/unit/ssg-module/data/controls_dir/abcd-levels.yml
62ebbd
+++ b/tests/unit/ssg-module/data/controls_dir/abcd-levels.yml
62ebbd
@@ -42,3 +42,29 @@ controls:
62ebbd
         rules:
62ebbd
           - var_password_pam_minlen=2
62ebbd
           - var_some_variable=3
62ebbd
+
62ebbd
+  # S5, S6 and S7 are used to test if level inheritance is working corectly
62ebbd
+  # when multiple levels select the same rule
62ebbd
+  - id: S5
62ebbd
+    title: Default Crypto Policy
62ebbd
+    levels:
62ebbd
+    - low
62ebbd
+    rules:
62ebbd
+      - configure_crypto_policy
62ebbd
+      - var_system_crypto_policy=default_policy
62ebbd
+
62ebbd
+  - id: S6
62ebbd
+    title: FIPS Crypto Policy
62ebbd
+    levels:
62ebbd
+    - medium
62ebbd
+    rules:
62ebbd
+      - configure_crypto_policy
62ebbd
+      - var_system_crypto_policy=fips
62ebbd
+
62ebbd
+  - id: S7
62ebbd
+    title: Future Crypto Policy
62ebbd
+    levels:
62ebbd
+    - high
62ebbd
+    rules:
62ebbd
+      - configure_crypto_policy
62ebbd
+      - var_system_crypto_policy=future
62ebbd
diff --git a/tests/unit/ssg-module/test_controls.py b/tests/unit/ssg-module/test_controls.py
62ebbd
index d3d6280042a..fb569280736 100644
62ebbd
--- a/tests/unit/ssg-module/test_controls.py
62ebbd
+++ b/tests/unit/ssg-module/test_controls.py
62ebbd
@@ -92,6 +92,20 @@ def test_controls_levels():
62ebbd
     c_4b = controls_manager.get_control("abcd-levels", "S4.b")
62ebbd
     assert c_4b.levels == ["high"]
62ebbd
 
62ebbd
+    c_5 = controls_manager.get_control("abcd-levels", "S5")
62ebbd
+    assert c_5.levels == ["low"]
62ebbd
+
62ebbd
+    c_6 = controls_manager.get_control("abcd-levels", "S6")
62ebbd
+    assert c_6.levels == ["medium"]
62ebbd
+
62ebbd
+    c_7 = controls_manager.get_control("abcd-levels", "S7")
62ebbd
+    assert c_7.levels == ["high"]
62ebbd
+
62ebbd
+    # test if all crypto-policy controls have the rule selected
62ebbd
+    assert "configure_crypto_policy" in c_5.selections
62ebbd
+    assert "configure_crypto_policy" in c_6.selections
62ebbd
+    assert "configure_crypto_policy" in c_7.selections
62ebbd
+
62ebbd
     # just the essential controls
62ebbd
     low_controls = controls_manager.get_all_controls_of_level(
62ebbd
         "abcd-levels", "low")
62ebbd
@@ -104,25 +118,34 @@ def test_controls_levels():
62ebbd
 
62ebbd
     assert len(high_controls) == len(all_controls)
62ebbd
     assert len(low_controls) <= len(high_controls)
62ebbd
-    assert len(low_controls) == 4
62ebbd
-    assert len(medium_controls) == 5
62ebbd
+    assert len(low_controls) == 5
62ebbd
+    assert len(medium_controls) == 7
62ebbd
 
62ebbd
     # test overriding of variables in levels
62ebbd
     assert c_2.variables["var_password_pam_minlen"] == "1"
62ebbd
     assert "var_password_pam_minlen" not in c_3.variables.keys()
62ebbd
     assert c_4b.variables["var_password_pam_minlen"] == "2"
62ebbd
 
62ebbd
+    variable_found = False
62ebbd
     for c in low_controls:
62ebbd
         if "var_password_pam_minlen" in c.variables.keys():
62ebbd
+            variable_found = True
62ebbd
             assert c.variables["var_password_pam_minlen"] == "1"
62ebbd
+    assert variable_found
62ebbd
 
62ebbd
+    variable_found = False
62ebbd
     for c in medium_controls:
62ebbd
         if "var_password_pam_minlen" in c.variables.keys():
62ebbd
+            variable_found = True
62ebbd
             assert c.variables["var_password_pam_minlen"] == "1"
62ebbd
+    assert variable_found
62ebbd
 
62ebbd
+    variable_found = False
62ebbd
     for c in high_controls:
62ebbd
         if "var_password_pam_minlen" in c.variables.keys():
62ebbd
+            variable_found = True
62ebbd
             assert c.variables["var_password_pam_minlen"] == "2"
62ebbd
+    assert variable_found
62ebbd
 
62ebbd
     # now test if controls of lower level has the variable definition correctly removed
62ebbd
     # because it is overriden by higher level controls
62ebbd
@@ -141,6 +164,28 @@ def test_controls_levels():
62ebbd
     assert s2_low[0].variables["var_some_variable"] == "1"
62ebbd
     assert s2_low[0].variables["var_password_pam_minlen"] == "1"
62ebbd
 
62ebbd
+    # check that low, medium and high levels have crypto policy selected
62ebbd
+    s5_low = [c for c in low_controls if c.id == "S5"]
62ebbd
+    assert len(s5_low) == 1
62ebbd
+    assert "configure_crypto_policy" in s5_low[0].selections
62ebbd
+
62ebbd
+    s5_medium = [c for c in medium_controls if c.id == "S5"]
62ebbd
+    assert len(s5_medium) == 1
62ebbd
+    assert "configure_crypto_policy" in s5_medium[0].selections
62ebbd
+    s6_medium = [c for c in medium_controls if c.id == "S6"]
62ebbd
+    assert len(s6_medium) == 1
62ebbd
+    assert "configure_crypto_policy" in s6_medium[0].selections
62ebbd
+
62ebbd
+    s5_high = [c for c in high_controls if c.id == "S5"]
62ebbd
+    assert len(s5_high) == 1
62ebbd
+    assert "configure_crypto_policy" in s5_high[0].selections
62ebbd
+    s6_high = [c for c in high_controls if c.id == "S6"]
62ebbd
+    assert len(s6_high) == 1
62ebbd
+    assert "configure_crypto_policy" in s6_high[0].selections
62ebbd
+    s7_high = [c for c in high_controls if c.id == "S7"]
62ebbd
+    assert len(s7_high) == 1
62ebbd
+    assert "configure_crypto_policy" in s7_high[0].selections
62ebbd
+
62ebbd
 
62ebbd
 def test_controls_load_product():
62ebbd
     product_yaml = os.path.join(ssg_root, "products", "rhel8", "product.yml")