From 964a3ea3f56168e157db2cb2f9f4dbcf854d7306 Mon Sep 17 00:00:00 2001 From: Chris PeBenito Date: Mon, 1 Feb 2016 11:20:32 -0500 Subject: [PATCH] MLS/RBAC/TERulesDifference: revise unknown rule exceptions to log instead Change to error logging so the processing continues, as the error is not fatal. Also specify in the message that it is a bug, so users know it isn't their fault. --- setools/diff/mlsrules.py | 6 ++++-- setools/diff/rbacrules.py | 6 ++++-- setools/diff/terules.py | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/setools/diff/mlsrules.py b/setools/diff/mlsrules.py index 7722251..75f443e 100644 --- a/setools/diff/mlsrules.py +++ b/setools/diff/mlsrules.py @@ -68,7 +68,8 @@ class MLSRulesDifference(Difference): if rule.ruletype == "range_transition": self._left_range_transitions.append(rule) else: - raise TypeError("Unknown rule type: {0}".format(rule.ruletype)) + self.log.error("Unknown rule type: {0} (This is an SETools bug)". + format(rule.ruletype)) self._right_range_transitions = [] for rule in self.right_policy.mlsrules(): @@ -77,7 +78,8 @@ class MLSRulesDifference(Difference): if rule.ruletype == "range_transition": self._right_range_transitions.append(rule) else: - raise TypeError("Unknown rule type: {0}".format(rule.ruletype)) + self.log.error("Unknown rule type: {0} (This is an SETools bug)". + format(rule.ruletype)) def _diff_mls_rules(self, left_list, right_list): """Common method for comparing type_* rules.""" diff --git a/setools/diff/rbacrules.py b/setools/diff/rbacrules.py index a5893d9..8a51b88 100644 --- a/setools/diff/rbacrules.py +++ b/setools/diff/rbacrules.py @@ -91,7 +91,8 @@ class RBACRulesDifference(Difference): elif rule.ruletype == "role_transition": self._left_role_transitions.append(rule) else: - raise TypeError("Unknown rule type: {0}".format(rule.ruletype)) + self.log.error("Unknown rule type: {0} (This is an SETools bug)". + format(rule.ruletype)) self._right_role_allows = [] self._right_role_transitions = [] @@ -103,7 +104,8 @@ class RBACRulesDifference(Difference): elif rule.ruletype == "role_transition": self._right_role_transitions.append(rule) else: - raise TypeError("Unknown rule type: {0}".format(rule.ruletype)) + self.log.error("Unknown rule type: {0} (This is an SETools bug)". + format(rule.ruletype)) def _diff_rbac_rules(self, left_list, right_list): """Common method for comparing rbac rules.""" diff --git a/setools/diff/terules.py b/setools/diff/terules.py index bdabc39..179e5ec 100644 --- a/setools/diff/terules.py +++ b/setools/diff/terules.py @@ -230,7 +230,8 @@ class TERulesDifference(Difference): elif rule.ruletype == "type_member": self._left_type_members.append(rule) else: - raise TypeError("Unknown rule type: {0}".format(rule.ruletype)) + self.log.error("Unknown rule type: {0} (This is an SETools bug)". + format(rule.ruletype)) self._right_allows = [] self._right_auditallows = [] @@ -257,7 +258,8 @@ class TERulesDifference(Difference): elif rule.ruletype == "type_member": self._right_type_members.append(rule) else: - raise TypeError("Unknown rule type: {0}".format(rule.ruletype)) + self.log.error("Unknown rule type: {0} (This is an SETools bug)". + format(rule.ruletype)) def _diff_av_rules(self, left_list, right_list): """Common method for comparing access vector rules."""