Add: [system] max_vevent_rrule_entries option to catch DoS by problematic RRULE early enough
This commit is contained in:
@@ -103,6 +103,7 @@ def predict_tag_of_whole_collection(
|
||||
|
||||
def check_and_sanitize_items(
|
||||
vobject_items: List[vobject.base.Component],
|
||||
max_vevent_rrule_entries: int,
|
||||
is_collection: bool = False, tag: str = "") -> None:
|
||||
"""Check vobject items for common errors and add missing UIDs.
|
||||
|
||||
@@ -387,7 +388,7 @@ def find_time_range(vobject_item: vobject.base.Component, tag: str
|
||||
return math.floor(start.timestamp()), math.ceil(end.timestamp())
|
||||
|
||||
|
||||
def verify(file: str, encoding: str):
|
||||
def verify(file: str, encoding: str, max_vevent_rrule_entries: int):
|
||||
logger.info("Verifying item: %s", file)
|
||||
with open(file, "rb") as f:
|
||||
content_raw = f.read()
|
||||
@@ -407,7 +408,7 @@ def verify(file: str, encoding: str):
|
||||
try:
|
||||
tag = radicale_item.predict_tag_of_whole_collection(vobject_items)
|
||||
if tag is not None:
|
||||
radicale_item.check_and_sanitize_items(vobject_items, tag=tag)
|
||||
radicale_item.check_and_sanitize_items(vobject_items, tag=tag, max_vevent_rrule_entries=max_vevent_rrule_entries)
|
||||
else:
|
||||
raise ValueError("collection tag cannot be predicted")
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user