Skip to content

Commit

Permalink
Merge pull request #471 from marcusburghardt/unselected_rules
Browse files Browse the repository at this point in the history
fix: CPLYTM-574 - do not include unselected rules
  • Loading branch information
marcusburghardt authored Feb 26, 2025
2 parents 257f68e + 2f6ed28 commit 6c1cf5a
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions trestlebot/tasks/sync_cac_content_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ def _collect_rules(self) -> None:
profiles = get_profiles_from_products(self.cac_content_root, [self.product])
for profile in profiles:
if profile.profile_id == self.cac_profile_id:
self.rules = profile.rules
self.rules = list(
filter(lambda x: x not in profile.unselected_rules, profile.rules)
)
break

def _get_rules_properties(self) -> List[Property]:
Expand Down Expand Up @@ -357,7 +359,21 @@ def _create_implemented_requirement(
implemented_req = generate_sample_model(ImplementedRequirement)
implemented_req.control_id = control_id
self._handle_response(implemented_req, control)
rule_ids = self._process_rule_ids(control.rules)
# Rules and variables are collected from rules section in control files, but for
# product agnostic control files some rules are unselected or variables are overridden
# in the profile level of products and should not be included in transformed content.
unselected_rules_or_vars = list(
filter(lambda x: x not in self.rules, control.rules)
)
if unselected_rules_or_vars:
logger.info(
f"Unselected rules or vars in {self.cac_profile_id} profile for {self.product}:"
f"{', '.join(unselected_rules_or_vars)}"
)
only_rules_in_profile = list(
filter(lambda x: x in self.rules, control.rules)
)
rule_ids = self._process_rule_ids(only_rules_in_profile)
self._attach_rules(implemented_req, rule_ids, rules_transformer)
return implemented_req
return None
Expand Down

0 comments on commit 6c1cf5a

Please sign in to comment.