backend/git_service: check repo URLs from webhook

Since we are cloning a private repo we are using `ssh_url` in our case.

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2023-02-20 12:43:06 +01:00
parent 651ffc711a
commit a79d25f7e7
No known key found for this signature in database
GPG Key ID: FE65CD384D5BF7B4
1 changed files with 6 additions and 7 deletions

View File

@ -197,14 +197,13 @@ class GitService:
f" body: {webhook}"
)
clone_url = webhook["repository"]["clone_url"]
if (
clone_url
!= current_app.config["SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_CLONE_URL"]
):
config_clone_url = current_app.config["SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_CLONE_URL"]
repo = webhook["repository"]
valid_clone_urls = [repo["clone_url"], repo["git_url"], repo["ssh_url"]]
if config_clone_url not in valid_clone_urls:
raise GitCloneUrlMismatchError(
"Configured clone url does not match clone url from webhook:"
f" {clone_url}"
"Configured clone url does not match the repo URLs from webhook: %s =/= %s"
% (config_clone_url, valid_clone_urls)
)
if "ref" not in webhook: