github-advanced-security[bot] commented on code in PR #45126:
URL: https://github.com/apache/airflow/pull/45126#discussion_r1898440895


##########
airflow/dag_processing/bundles/git.py:
##########
@@ -126,3 +127,28 @@
 
         self.bare_repo.remotes.origin.fetch("+refs/heads/*:refs/heads/*")
         self.repo.remotes.origin.pull()
+
+    def _convert_git_ssh_url_to_https(self) -> str:
+        if not self.repo_url.startswith("git@"):
+            raise ValueError(f"Invalid git SSH URL: {self.repo_url}")
+        parts = self.repo_url.split(":")
+        domain = parts[0].replace("git@", "https://";)
+        repo_path = parts[1].replace(".git", "")
+        return f"{domain}/{repo_path}"
+
+    def view_url(self, version: str | None = None) -> str | None:
+        if not version:
+            return None
+        url = self.repo_url
+        if url.startswith("git@"):
+            url = self._convert_git_ssh_url_to_https()
+        host = urlparse(url).hostname
+        if not host:
+            return None
+        if host.endswith("github.com"):
+            return f"{url}/tree/{version}"
+        if host.endswith("gitlab.com"):

Review Comment:
   ## Incomplete URL substring sanitization
   
   The string [gitlab.com](1) may be at an arbitrary position in the sanitized 
URL.
   
   [Show more 
details](https://github.com/apache/airflow/security/code-scanning/288)



##########
airflow/dag_processing/bundles/git.py:
##########
@@ -126,3 +127,28 @@
 
         self.bare_repo.remotes.origin.fetch("+refs/heads/*:refs/heads/*")
         self.repo.remotes.origin.pull()
+
+    def _convert_git_ssh_url_to_https(self) -> str:
+        if not self.repo_url.startswith("git@"):
+            raise ValueError(f"Invalid git SSH URL: {self.repo_url}")
+        parts = self.repo_url.split(":")
+        domain = parts[0].replace("git@", "https://";)
+        repo_path = parts[1].replace(".git", "")
+        return f"{domain}/{repo_path}"
+
+    def view_url(self, version: str | None = None) -> str | None:
+        if not version:
+            return None
+        url = self.repo_url
+        if url.startswith("git@"):
+            url = self._convert_git_ssh_url_to_https()
+        host = urlparse(url).hostname
+        if not host:
+            return None
+        if host.endswith("github.com"):

Review Comment:
   ## Incomplete URL substring sanitization
   
   The string [github.com](1) may be at an arbitrary position in the sanitized 
URL.
   
   [Show more 
details](https://github.com/apache/airflow/security/code-scanning/287)



##########
airflow/dag_processing/bundles/git.py:
##########
@@ -126,3 +127,28 @@
 
         self.bare_repo.remotes.origin.fetch("+refs/heads/*:refs/heads/*")
         self.repo.remotes.origin.pull()
+
+    def _convert_git_ssh_url_to_https(self) -> str:
+        if not self.repo_url.startswith("git@"):
+            raise ValueError(f"Invalid git SSH URL: {self.repo_url}")
+        parts = self.repo_url.split(":")
+        domain = parts[0].replace("git@", "https://";)
+        repo_path = parts[1].replace(".git", "")
+        return f"{domain}/{repo_path}"
+
+    def view_url(self, version: str | None = None) -> str | None:
+        if not version:
+            return None
+        url = self.repo_url
+        if url.startswith("git@"):
+            url = self._convert_git_ssh_url_to_https()
+        host = urlparse(url).hostname
+        if not host:
+            return None
+        if host.endswith("github.com"):
+            return f"{url}/tree/{version}"
+        if host.endswith("gitlab.com"):
+            return f"{url}/-/tree/{version}"
+        if host.endswith("bitbucket.org"):

Review Comment:
   ## Incomplete URL substring sanitization
   
   The string [bitbucket.org](1) may be at an arbitrary position in the 
sanitized URL.
   
   [Show more 
details](https://github.com/apache/airflow/security/code-scanning/289)



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

Reply via email to