diff --git a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx index a721f41cbf560..6e374f85c8955 100644 --- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx +++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx @@ -63,6 +63,7 @@ import { ExtraJson, } from 'src/views/CRUD/data/database/types'; import Loading from 'src/components/Loading'; +import { pick } from 'lodash'; import ExtraOptions from './ExtraOptions'; import SqlAlchemyForm from './SqlAlchemyForm'; import DatabaseConnectionForm from './DatabaseConnectionForm'; @@ -372,29 +373,41 @@ export function dbReducer( [action.payload.name]: action.payload.value, }, }; - case ActionType.setSSHTunnelLoginMethod: + case ActionType.setSSHTunnelLoginMethod: { + let ssh_tunnel = {}; + if (trimmedState?.ssh_tunnel) { + // remove any attributes that are considered sensitive + ssh_tunnel = pick(trimmedState.ssh_tunnel, [ + 'id', + 'server_address', + 'server_port', + 'username', + ]); + } if (action.payload.login_method === AuthType.privateKey) { - const { password, ...rest } = trimmedState?.ssh_tunnel ?? {}; return { ...trimmedState, ssh_tunnel: { - ...rest, + private_key: trimmedState?.ssh_tunnel?.private_key, + private_key_password: + trimmedState?.ssh_tunnel?.private_key_password, + ...ssh_tunnel, }, }; } if (action.payload.login_method === AuthType.password) { - const { private_key, private_key_password, ...rest } = - trimmedState?.ssh_tunnel ?? {}; return { ...trimmedState, ssh_tunnel: { - ...rest, + password: trimmedState?.ssh_tunnel?.password, + ...ssh_tunnel, }, }; } return { ...trimmedState, }; + } case ActionType.removeSSHTunnelConfig: return { ...trimmedState,