bito-code-review[bot] commented on code in PR #37616:
URL: https://github.com/apache/superset/pull/37616#discussion_r2755662990


##########
superset/extensions/ssh.py:
##########
@@ -21,7 +21,7 @@
 
 import sshtunnel
 from flask import Flask
-from paramiko import RSAKey
+from paramiko import DSSKey, ECDSAKey, Ed25519Key, PKey, RSAKey, SSHException

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Security: Remove DSS Key Support</b></div>
   <div id="fix">
   
   DSS (DSA) keys are deprecated and insecure; OpenSSH removed support for 
them. Avoid enabling weak cryptography by removing DSS support.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #136992</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



##########
superset/extensions/ssh.py:
##########
@@ -38,6 +38,41 @@ def __init__(self, app: Flask) -> None:
         sshtunnel.TUNNEL_TIMEOUT = app.config["SSH_TUNNEL_TIMEOUT_SEC"]
         sshtunnel.SSH_TIMEOUT = app.config["SSH_TUNNEL_PACKET_TIMEOUT_SEC"]
 
+    @staticmethod
+    def _load_private_key(key_str: str, password: str | None = None) -> PKey:
+        """
+        Load a private key from a string, automatically detecting the key type.
+
+        Paramiko supports multiple key types (RSA, Ed25519, ECDSA, DSS).
+        This method tries each type until one succeeds, enabling support for
+        modern key formats without hardcoding specific key types.
+
+        :param key_str: Private key content as a string
+        :param password: Optional passphrase for encrypted keys
+        :return: Loaded PKey instance
+        :raises SSHException: If the key cannot be loaded with any supported 
type
+        """
+        key_file = StringIO(key_str)
+        # Try key types in order of common usage
+        # RSA: Most common, legacy standard
+        # Ed25519: Modern, recommended by security best practices
+        # ECDSA: Modern elliptic curve
+        # DSS: Legacy DSA keys
+        key_classes = [RSAKey, Ed25519Key, ECDSAKey, DSSKey]

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Security: Update DSS References</b></div>
   <div id="fix">
   
   Remove DSS from the supported key types list and related documentation to 
complete DSS removal.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #136992</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to