diff --git a/framework/python/src/common/session.py b/framework/python/src/common/session.py index d619705b1..36294f955 100644 --- a/framework/python/src/common/session.py +++ b/framework/python/src/common/session.py @@ -74,7 +74,6 @@ def apply_session_tracker(cls): setattr(cls, attr, session_tracker(getattr(cls, attr))) return cls - @apply_session_tracker class TestrunSession(): """Represents the current session of Testrun.""" @@ -127,6 +126,7 @@ def __init__(self, root_dir): # System network interfaces self._ifaces = {} + # Loading methods self._load_version() self._load_config() @@ -478,7 +478,7 @@ def _load_profiles(self): encoding='utf-8') as f: # Parse risk profile json - json_data = json.load(f) + json_data: dict = json.load(f) # Validate profile JSON if not self.validate_profile_json(json_data): @@ -486,7 +486,22 @@ def _load_profiles(self): continue # Instantiate a new risk profile - risk_profile = RiskProfile() + risk_profile: RiskProfile = RiskProfile() + + questions: list[dict] = json_data.get('questions') + + # Remove any additional (outdated questions from the profile) + for question in questions: + + # Check if question exists in the profile format + if self.get_profile_format_question( + question=question.get('question')) is None: + + # Remove question from profile + questions.remove(question) + + # Pass questions back to the risk profile + json_data['questions'] = questions # Pass JSON to populate risk profile risk_profile.load(profile_json=json_data, @@ -605,7 +620,8 @@ def validate_profile_json(self, profile_json): if format_q is None: LOGGER.error(f'Unrecognized question: {question.get("question")}') - return False + # Just ignore additional questions + continue # Error handling if 'answer' is missing if 'answer' not in question and valid: