From: Milind Changire Date: Sat, 4 May 2024 10:39:39 +0000 (+0530) Subject: mgr/snap_schedule: restrict retention period multipliers set X-Git-Tag: v19.2.5~36^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=34c6bd833c5cfb1d5f8027d10acf9ec6ba445a27;p=ceph.git mgr/snap_schedule: restrict retention period multipliers set Fixes: https://tracker.ceph.com/issues/65801 Signed-off-by: Milind Changire (cherry picked from commit 32ced0c496e8f546dcfe76b46e4f9034f10b6ce5) --- diff --git a/src/pybind/mgr/snap_schedule/fs/schedule.py b/src/pybind/mgr/snap_schedule/fs/schedule.py index 5a8bee2bbb1b..748d3fd36e7c 100644 --- a/src/pybind/mgr/snap_schedule/fs/schedule.py +++ b/src/pybind/mgr/snap_schedule/fs/schedule.py @@ -55,10 +55,7 @@ def parse_timestamp(ts: str) -> datetime: def parse_retention(retention: str) -> Dict[str, int]: ret = {} log.debug(f'parse_retention({retention})') - matches = re.findall(r'\d+[a-z]', retention) - for m in matches: - ret[m[-1]] = int(m[0:-1]) - matches = re.findall(r'\d+[A-Z]', retention) + matches = re.findall(r'\d+[nmhdwMy]', retention) for m in matches: ret[m[-1]] = int(m[0:-1]) log.debug(f'parse_retention({retention}) -> {ret}') @@ -381,6 +378,8 @@ class Schedule(object): if row is None: raise ValueError(f'No schedule found for {path}') retention = parse_retention(retention_spec) + if not retention: + raise ValueError(f'Retention spec {retention_spec} is invalid') current = row['retention'] current_retention = json.loads(current) for r, v in retention.items():