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