]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/snap_schedule: restrict retention period multipliers set
authorMilind Changire <mchangir@redhat.com>
Sat, 4 May 2024 10:39:39 +0000 (16:09 +0530)
committerJos Collin <jcollin@redhat.com>
Tue, 14 Apr 2026 03:02:36 +0000 (08:32 +0530)
Fixes: https://tracker.ceph.com/issues/65801
Signed-off-by: Milind Changire <mchangir@redhat.com>
(cherry picked from commit 32ced0c496e8f546dcfe76b46e4f9034f10b6ce5)

src/pybind/mgr/snap_schedule/fs/schedule.py

index 5a8bee2bbb1b194059b00dae7c5d29716c4be18f..748d3fd36e7c49d79e6de661bceb64e52fb0a960 100644 (file)
@@ -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():