diff --git a/contentctl/objects/abstract_security_content_objects/security_content_object_abstract.py b/contentctl/objects/abstract_security_content_objects/security_content_object_abstract.py index 6eea44b6..02f1cd1d 100644 --- a/contentctl/objects/abstract_security_content_objects/security_content_object_abstract.py +++ b/contentctl/objects/abstract_security_content_objects/security_content_object_abstract.py @@ -492,6 +492,25 @@ class SecurityContentObject_Abstract(BaseModel, abc.ABC): "limitations in Type Checking." ) + @field_validator("date", mode="after") + @classmethod + def ensure_date_is_not_in_future(cls, value: datetime.date) -> datetime.date: + """Ensure that the date is not in the future. + Args: + value (datetime.date): The date of the content, read from the YML. + Raises: + ValueError: The date of the content is in the future. + Returns: + datetime.date: The validated date of the content, read from the YML. + """ + todays_date = datetime.datetime.now(datetime.UTC).date() + if value > todays_date: + raise ValueError( + f"Content date [{value}], is in the future. The date of content must be today ({todays_date}) or earlier. " + "Note that this date is relative to UTC, not your current locale." + ) + return value + def checkDeprecationInfo( self, app: CustomApp, deprecation_info: DeprecationInfoInFile | None ): diff --git a/pyproject.toml b/pyproject.toml index 904308f4..a919b670 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [tool.poetry] name = "contentctl" -version = "5.5.14" +version = "5.5.15" description = "Splunk Content Control Tool" authors = ["STRT "]