github-advanced-security[bot] commented on code in PR #45126:
URL: https://github.com/apache/airflow/pull/45126#discussion_r1895551972
##########
airflow/dag_processing/bundles/git.py:
##########
@@ -126,3 +126,25 @@
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()
+ if url.startswith("https://github.com"):
Review Comment:
## Incomplete URL substring sanitization
The string [https://github.com](1) may be at an arbitrary position in the
sanitized URL.
[Show more
details](https://github.com/apache/airflow/security/code-scanning/284)
##########
airflow/dag_processing/bundles/git.py:
##########
@@ -126,3 +126,25 @@
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()
+ if url.startswith("https://github.com"):
+ return f"{url}/tree/{version}"
+ if url.startswith("https://gitlab.com"):
Review Comment:
## Incomplete URL substring sanitization
The string [https://gitlab.com](1) may be at an arbitrary position in the
sanitized URL.
[Show more
details](https://github.com/apache/airflow/security/code-scanning/285)
##########
airflow/dag_processing/bundles/git.py:
##########
@@ -126,3 +126,25 @@
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()
+ if url.startswith("https://github.com"):
+ return f"{url}/tree/{version}"
+ if url.startswith("https://gitlab.com"):
+ return f"{url}/-/tree/{version}"
+ if url.startswith("https://bitbucket.org"):
Review Comment:
## Incomplete URL substring sanitization
The string [https://bitbucket.org](1) may be at an arbitrary position in the
sanitized URL.
[Show more
details](https://github.com/apache/airflow/security/code-scanning/286)
--
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]