Skip to content

Commit 019feea

Browse files
authored
Merge pull request #473 from splunk/date_cannot_be_future
Date cannot be future. Intentionally merging this even though there are failures since the fixed content has not been merged into security_content yet.
2 parents 0e5ddc1 + 6e690ad commit 019feea

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

contentctl/objects/abstract_security_content_objects/security_content_object_abstract.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,25 @@ class SecurityContentObject_Abstract(BaseModel, abc.ABC):
492492
"limitations in Type Checking."
493493
)
494494

495+
@field_validator("date", mode="after")
496+
@classmethod
497+
def ensure_date_is_not_in_future(cls, value: datetime.date) -> datetime.date:
498+
"""Ensure that the date is not in the future.
499+
Args:
500+
value (datetime.date): The date of the content, read from the YML.
501+
Raises:
502+
ValueError: The date of the content is in the future.
503+
Returns:
504+
datetime.date: The validated date of the content, read from the YML.
505+
"""
506+
todays_date = datetime.datetime.now(datetime.UTC).date()
507+
if value > todays_date:
508+
raise ValueError(
509+
f"Content date [{value}], is in the future. The date of content must be today ({todays_date}) or earlier. "
510+
"Note that this date is relative to UTC, not your current locale."
511+
)
512+
return value
513+
495514
def checkDeprecationInfo(
496515
self, app: CustomApp, deprecation_info: DeprecationInfoInFile | None
497516
):

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[tool.poetry]
22
name = "contentctl"
33

4-
version = "5.5.14"
4+
version = "5.5.15"
55

66
description = "Splunk Content Control Tool"
77
authors = ["STRT <research@splunk.com>"]

0 commit comments

Comments
 (0)