fix: validate cron expression before writing to crontab
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import uuid
|
||||
from crontab import CronTab
|
||||
from crontab import CronTab, CronSlices
|
||||
|
||||
|
||||
class CrontabManager:
|
||||
@@ -39,6 +39,9 @@ class CrontabManager:
|
||||
command: str,
|
||||
is_enabled: bool = True,
|
||||
):
|
||||
if not CronSlices.is_valid(cron_expression):
|
||||
raise ValueError(f"Invalid cron expression: {cron_expression!r}")
|
||||
|
||||
if not alarm_id:
|
||||
alarm_id = str(uuid.uuid4())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user