diff --git a/src/core/src/core_logic/ExecutionConfig.py b/src/core/src/core_logic/ExecutionConfig.py index 51bdec1f..0f19ce1b 100644 --- a/src/core/src/core_logic/ExecutionConfig.py +++ b/src/core/src/core_logic/ExecutionConfig.py @@ -135,12 +135,11 @@ def __get_max_patch_publish_date_from_inclusions(self, included_package_name_mas continue # good candidate already found, or candidate not found and does not match what we are looking for candidate = included_package_name_mask_list[i].replace("MaxPatchPublishDate=", "") - candidate_split = candidate.split("T") - if (len(candidate) == 16 and len(candidate_split) == 2 and candidate_split[0].isdigit() and len(candidate_split[0]) == 8 - and candidate_split[1].endswith("Z") and candidate_split[1][0:6].isdigit()): + try: + datetime.datetime.strptime(candidate, "%Y%m%dT%H%M%SZ") self.composite_logger.log_debug("[EC] Discovered effective MaxPatchPublishDate in patch inclusions. [MaxPatchPublishDate={0}]".format(str(candidate))) candidate_pos = i - else: + except ValueError: self.composite_logger.log_debug("[EC] Invalid match on MaxPatchPublishDate in patch inclusions. [MaxPatchPublishDate={0}]".format(str(candidate))) candidate = str() diff --git a/src/core/tests/Test_AptitudePackageManager.py b/src/core/tests/Test_AptitudePackageManager.py index 2572e0d7..e7ea4999 100644 --- a/src/core/tests/Test_AptitudePackageManager.py +++ b/src/core/tests/Test_AptitudePackageManager.py @@ -606,7 +606,6 @@ def test_maxpatchpublishdate_mitigation_mode(self): # retains valid inclusions while honoring mitigation mode entries argument_composer = ArgumentComposer() - argument_composer.classifications_to_include = [Constants.PackageClassification.CRITICAL] argument_composer.patches_to_include = ["*kernel*", "MaxPatchPublishDate=20250101T010203Z", "AzGPS_Mitigation_Mode_No_SLA"] self.runtime = RuntimeCompositor(argument_composer.get_composed_arguments(), True, Constants.APT) execution_config = self.runtime.container.get('execution_config') @@ -616,7 +615,6 @@ def test_maxpatchpublishdate_mitigation_mode(self): # missing required disclaimer entry argument_composer = ArgumentComposer() - argument_composer.classifications_to_include = [Constants.PackageClassification.CRITICAL] argument_composer.patches_to_include = ["MaxPatchPublishDate=20250101T010203Z", "*firefox=1.1"] self.runtime = RuntimeCompositor(argument_composer.get_composed_arguments(), True, Constants.APT) execution_config = self.runtime.container.get('execution_config') @@ -626,7 +624,6 @@ def test_maxpatchpublishdate_mitigation_mode(self): # badly formatted date argument_composer = ArgumentComposer() - argument_composer.classifications_to_include = [Constants.PackageClassification.CRITICAL] argument_composer.patches_to_include = ["*firefox*", "MaxPatchPublishDate=20250101010203Z", "AzGPS_Mitigation_Mode_No_SLA", "*kernel*"] self.runtime = RuntimeCompositor(argument_composer.get_composed_arguments(), True, Constants.APT) execution_config = self.runtime.container.get('execution_config')