]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/smb: add support for converting/filtering passwords in ceph smb show
authorJohn Mulligan <jmulligan@redhat.com>
Mon, 17 Mar 2025 20:11:56 +0000 (16:11 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Tue, 1 Apr 2025 12:02:39 +0000 (08:02 -0400)
Add a new --password-filter option for `ceph smb show` that can hide or
obscure (using base64) passwords in the resources returned.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/pybind/mgr/smb/module.py

index 17c6db14b512b6cdacd241cb1950d2fe0b675985..a10642611baf40ca525e4e7978302de280d342ad 100644 (file)
@@ -21,6 +21,7 @@ from . import (
 from .enums import (
     AuthMode,
     JoinSourceType,
+    PasswordFilter,
     ShowResults,
     SMBClustering,
     UserGroupSourceType,
@@ -340,6 +341,7 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule):
         self,
         resource_names: Optional[List[str]] = None,
         results: ShowResults = ShowResults.COLLAPSED,
+        password_filter: PasswordFilter = PasswordFilter.NONE,
     ) -> Simplified:
         """Show resources fetched from the local config store based on resource
         type or resource type and id(s).
@@ -351,6 +353,10 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule):
                 resources = self._handler.matching_resources(resource_names)
             except handler.InvalidResourceMatch as err:
                 raise cli.InvalidInputValue(str(err)) from err
+        if password_filter is not PasswordFilter.NONE:
+            op = (PasswordFilter.NONE, password_filter)
+            log.debug('Password filtering for smb show: %r', op)
+            resources = [r.convert(op) for r in resources]
         if len(resources) == 1 and results is ShowResults.COLLAPSED:
             return resources[0].to_simplified()
         return {"resources": [r.to_simplified() for r in resources]}