Skip to content

Commit c29dd2b

Browse files
committed
refactor: adjust handling of severity
1 parent a472e95 commit c29dd2b

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

config/default/templates/documents/adoc/rule.adoc.jinja

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,13 @@ Deploy a configuration profile containing the following payload.
8686
|===
8787

8888
|ID
89-
|{{ rule.rule_id }}
90-
{{ rule.severity if rule.severity is not none and rule.tags not in check_tags }}
89+
|{{ rule.rule_id }}
90+
91+
{% if rule.severity is not none %}
92+
|{% trans %}Severity{% endtrans %}
93+
|{{ rule.severity }}
94+
{% endif %}
95+
9196

9297
|{% trans %}References{% endtrans %}
9398
|

src/mscp/classes/macsecurityrule.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@ class Macsecurityrule(BaseModelWithAccessors):
235235
Attributes:
236236
title (str): The title of the security rule.
237237
rule_id (str): Unique identifier for the rule.
238-
severity (str): Severity level of the rule.
239238
discussion (str): Detailed discussion or rationale for the rule.
240239
references (References): Reference information (e.g., NIST, CIS) associated with the rule.
241240
odv (dict[str, Any] | None): Organizational Defined Values for the rule, if applicable.
@@ -255,7 +254,7 @@ class Macsecurityrule(BaseModelWithAccessors):
255254
os_version: float = Field(default_factory=float)
256255
check (str): The commands to evaluate the state of a rule.
257256
fix: (str): The commands to remediate and set the configuration for a rule.
258-
severity: (dict[str, Any]): The category for impact assigned to a rule for associated benchmarks.
257+
severity: (str): The category for impact assigned to a rule for associated benchmarks.
259258
default_state: (str): The command to restore the system to the default configuration for a rule.
260259
261260
Class Methods:
@@ -300,7 +299,7 @@ class Macsecurityrule(BaseModelWithAccessors):
300299
os_version: float = Field(default_factory=float)
301300
check: str | None = None
302301
fix: str | None = None
303-
severity: dict[str, Any] | None = None
302+
severity: str | None = None
304303
default_state: str | None = None
305304

306305
@classmethod
@@ -361,7 +360,7 @@ def load_rules(
361360
default_state_value: str | None = None
362361
mechanism: str = "Manual"
363362
payloads: list[Mobileconfigpayload] | None = []
364-
severity: dict[str, Any] | None = {}
363+
severity: str | None = None
365364
tags: list[str] = []
366365

367366
rule_file = next(
@@ -502,8 +501,8 @@ def load_rules(
502501
if benchmarks:
503502
for benchmark in benchmarks:
504503
name = benchmark.get("name")
505-
if "severity" in benchmark:
506-
severity[name] = benchmark["severity"]
504+
if "severity" in benchmark and name == parent_values:
505+
severity = benchmark.get("severity", "")
507506

508507
match tags:
509508
case "inherent":

0 commit comments

Comments
 (0)