]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: mgr orchestrator module raise exception if there is trailing tab in... 61921/head
authorShweta Bhosale <Shweta.Bhosale1@ibm.com>
Wed, 11 Dec 2024 07:37:15 +0000 (13:07 +0530)
committerAdam King <adking@redhat.com>
Wed, 19 Feb 2025 21:54:45 +0000 (16:54 -0500)
Fixes: https://tracker.ceph.com/issues/69192
Signed-off-by: Shweta Bhosale <Shweta.Bhosale1@ibm.com>
(cherry picked from commit dfa632b42558278d26cabb88248aa7ae8ba8fcfc)

src/pybind/mgr/orchestrator/module.py

index cde6448b3c0ee47d8f0417a383cc5458186c9905..9bb56ae15a19b2a51c6f8065c2007c0846bf0799 100644 (file)
@@ -1548,7 +1548,13 @@ Usage:
             specs: List[Union[ServiceSpec, HostSpec]] = []
             # YAML '---' document separator with no content generates
             # None entries in the output. Let's skip them silently.
-            content = [o for o in yaml_objs if o is not None]
+            try:
+                content = [o for o in yaml_objs if o is not None]
+            except yaml.scanner.ScannerError as e:
+                msg = f"Invalid YAML received : {str(e)}"
+                self.log.exception(msg)
+                return HandleCommandResult(-errno.EINVAL, stderr=msg)
+
             for s in content:
                 spec = json_to_generic_spec(s)
 
@@ -1939,7 +1945,13 @@ Usage:
             specs: List[TunedProfileSpec] = []
             # YAML '---' document separator with no content generates
             # None entries in the output. Let's skip them silently.
-            content = [o for o in yaml_objs if o is not None]
+            try:
+                content = [o for o in yaml_objs if o is not None]
+            except yaml.scanner.ScannerError as e:
+                msg = f"Invalid YAML received : {str(e)}"
+                self.log.exception(msg)
+                return HandleCommandResult(-errno.EINVAL, stderr=msg)
+
             for spec in content:
                 specs.append(TunedProfileSpec.from_json(spec))
         else: