hughhhh commented on code in PR #23099:
URL: https://github.com/apache/superset/pull/23099#discussion_r1110219873
##########
superset/databases/schemas.py:
##########
@@ -719,6 +723,65 @@ def validate_password(self, data: Dict[str, Any],
**kwargs: Any) -> None:
if password == PASSWORD_MASK and data.get("password") is None:
raise ValidationError("Must provide a password for the database")
+ @validates_schema
+ def validate_ssh_tunnel_password(self, data: Dict[str, Any], **kwargs:
Any) -> None:
+ """If ssh_tunnel has a masked password, password is required"""
+ uuid = data["uuid"]
+ existing = db.session.query(Database).filter_by(uuid=uuid).first()
+ if existing:
+ return
+
+ # Our DB has a ssh_tunnel in it
+ if ssh_tunnel := data.get("ssh_tunnel"):
+ if not is_feature_enabled("SSH_TUNNELING"):
+ raise SSHTunnelingNotEnabledError()
+ password = ssh_tunnel.get("password")
+ if password == PASSWORD_MASK:
+ raise ValidationError("Must provide a password for the ssh
tunnel")
+ return
+
+ @validates_schema
+ def validate_ssh_tunnel_private_key(
+ self, data: Dict[str, Any], **kwargs: Any
+ ) -> None:
+ """If ssh_tunnel has a masked private key, private key is required"""
+ uuid = data["uuid"]
+ existing = db.session.query(Database).filter_by(uuid=uuid).first()
+ if existing:
+ return
+
+ # Our DB has a ssh_tunnel in it
+ if ssh_tunnel := data.get("ssh_tunnel"):
+ if not is_feature_enabled("SSH_TUNNELING"):
+ raise SSHTunnelingNotEnabledError()
+ private_key = ssh_tunnel.get("private_key")
+ if private_key == PASSWORD_MASK:
+ raise ValidationError("Must provide a private key for the ssh
tunnel")
Review Comment:
can we add a test to make sure this will raise when the user is missing the
private key
--
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]