Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix warning in ssh tunnel #22912

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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, [
AAfghahi marked this conversation as resolved.
Show resolved Hide resolved
'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,
Expand Down