github-advanced-security[bot] commented on code in PR #66892: URL: https://github.com/apache/airflow/pull/66892#discussion_r3246161065
########## providers/airbyte/src/airflow/providers/airbyte/links/airbyte_connection.py: ########## @@ -0,0 +1,126 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +from __future__ import annotations + +from typing import TYPE_CHECKING, Any, ClassVar +from urllib.parse import urlparse + +from airflow.plugins_manager import AirflowPlugin +from airflow.providers.airbyte.version_compat import AIRFLOW_V_3_0_PLUS +from airflow.providers.common.compat.sdk import BaseOperatorLink, XCom + +if TYPE_CHECKING: + from airflow.providers.airbyte.operators.airbyte import AirbyteTriggerSyncOperator + from airflow.providers.airbyte.version_compat import BaseOperator + from airflow.providers.common.compat.sdk import Context, TaskInstanceKey + + +AIRBYTE_CLOUD_BASE_LINK = "https://cloud.airbyte.com" +AIRBYTE_WORKSPACE_LINK = "/workspaces/{workspace_id}" +AIRBYTE_CONNECTIONS_LINK = "/connections/{connection_id}" + + +class AirbyteConnectionLink(BaseOperatorLink): + """ + Constructs a link to the Airbyte connection details page. + + :meta private: + """ + + key: ClassVar[str] = "airbyte_connection" + + @property + def name(self): + return "Airbyte Connection" + + @property + def xcom_key(self): + return self.key + + @classmethod + def persist(cls, context: Context, **value): + """ + Push arguments to the XCom to use later for link formatting at the `get_link` method. + + Note: for Airflow 2 we need to call this function with context variable only + where we have the extra_links_params property method defined + """ + params = {} + # TODO: remove after Airflow v2 support dropped + if not AIRFLOW_V_3_0_PLUS: + common_params = getattr(context["task"], "extra_links_params", None) + if common_params: + params.update(common_params) + + context["ti"].xcom_push( + key=cls.key, + value={ + **params, + **value, + }, + ) + + def _get_config(self, link_value: dict[str, Any]): + conf = {} + server_url = link_value.pop("server_url") + + if "airbyte.com" in server_url: Review Comment: ## CodeQL / Incomplete URL substring sanitization The string [airbyte.com](1) may be at an arbitrary position in the sanitized URL. [Show more details](https://github.com/apache/airflow/security/code-scanning/601) -- 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]
