You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "phanikumv (via GitHub)" <gi...@apache.org> on 2023/06/20 09:59:02 UTC

[GitHub] [airflow] phanikumv commented on a diff in pull request #32016: Fix an issue that crashes Airflow Webserver when passed invalid private key path to Snowflake

phanikumv commented on code in PR #32016:
URL: https://github.com/apache/airflow/pull/32016#discussion_r1235033593


##########
airflow/providers/snowflake/hooks/snowflake.py:
##########
@@ -216,7 +216,16 @@ def _get_conn_params(self) -> dict[str, str | None]:
                 "Please remove one."
             )
         elif private_key_file:
-            private_key_pem = Path(private_key_file).read_bytes()
+            private_key_file_path = Path(private_key_file)
+            if not private_key_file_path.is_file() or private_key_file_path.stat().st_size == 0:
+                raise ValueError(
+                    "The private_key_file path points to an empty or invalid file."
+                )
+            if private_key_file_path.stat().st_size > 4096:
+                raise ValueError(
+                    "File size of private_key_file is too big."

Review Comment:
   Let's also add a note in the docs about the size limitation.



##########
airflow/providers/snowflake/hooks/snowflake.py:
##########
@@ -216,7 +216,16 @@ def _get_conn_params(self) -> dict[str, str | None]:
                 "Please remove one."
             )
         elif private_key_file:
-            private_key_pem = Path(private_key_file).read_bytes()
+            private_key_file_path = Path(private_key_file)
+            if not private_key_file_path.is_file() or private_key_file_path.stat().st_size == 0:
+                raise ValueError(
+                    "The private_key_file path points to an empty or invalid file."
+                )
+            if private_key_file_path.stat().st_size > 4096:
+                raise ValueError(
+                    "File size of private_key_file is too big."

Review Comment:
   ```suggestion
                       "The private_key_file size is too big. Please keep it less than 4 KB"
   ```



-- 
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