You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "eric-briscoe (via GitHub)" <gi...@apache.org> on 2023/01/31 00:33:49 UTC

[GitHub] [superset] eric-briscoe commented on a diff in pull request #22912: fix: fix warning in ssh tunnel

eric-briscoe commented on code in PR #22912:
URL: https://github.com/apache/superset/pull/22912#discussion_r1091305586


##########
superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx:
##########
@@ -374,21 +375,21 @@ export function dbReducer(
       };
     case ActionType.setSSHTunnelLoginMethod:
       if (action.payload.login_method === AuthType.privateKey) {
-        const { password, ...rest } = trimmedState?.ssh_tunnel ?? {};
         return {
           ...trimmedState,
           ssh_tunnel: {
-            ...rest,
+            ...omit(trimmedState?.ssh_tunnel, ['password']),

Review Comment:
   @AAfghahi It might be worth adding a conditional check to skip cases where no ssh tunnel info exists and consolidating the omit to a single check like:
   
   ```
   case ActionType.setSSHTunnelLoginMethod:
     let ssh_tunnel;
     if (trimmedState?.ssh_tunnel) {
       // remove any attributes that are considered sensitive
       ssh_tunnel = omit(trimmedState.ssh_tunnel, [
         'password'
         'private_key',
         'private_key_password',
       ]);
     }
   
     return {
       ...trimmedState,
       ssh_tunnel,
     };
   ```
   This way if additional fields get added at some point that also need to be filtered you can just add to the array of fields passed to omit without having more if blocks to differentiate between the AuthType.  omit will work fine getting attributes that may or may not exist on trimmedState.ssh_tunnel so we can just keep a single array of sensitive attributes



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org