You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/04/16 20:46:53 UTC

[GitHub] [airflow] uranusjr commented on a diff in pull request #23043: Add exception to catch single line private keys

uranusjr commented on code in PR #23043:
URL: https://github.com/apache/airflow/pull/23043#discussion_r851669478


##########
airflow/providers/ssh/hooks/ssh.py:
##########
@@ -415,6 +415,9 @@ def _pkey_from_private_key(self, private_key: str, passphrase: Optional[str] = N
         :return: ``paramiko.PKey`` appropriate for given key
         :raises AirflowException: if key cannot be read
         """
+        if private_key.count("\n") < 2:

Review Comment:
   ```suggestion
           if private_key.split("\n", 2) < 2:
   ```
   
   Using `count()` here would unnecessarily scan the entire key. It feels wrong to waste time for that since valid values are expected (which usually contains many lines).



-- 
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: commits-unsubscribe@airflow.apache.org

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