Skip to content

Commit

Permalink
Different data validation method
Browse files Browse the repository at this point in the history
  • Loading branch information
kjohn-msft committed Nov 7, 2024
1 parent abc68fc commit d17070e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
7 changes: 3 additions & 4 deletions src/core/src/core_logic/ExecutionConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
3 changes: 0 additions & 3 deletions src/core/tests/Test_AptitudePackageManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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')
Expand All @@ -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')
Expand Down

0 comments on commit d17070e

Please sign in to comment.