-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: change clone URL check for gitlab to account for possible subpath #5177
base: main
Are you sure you want to change the base?
fix: change clone URL check for gitlab to account for possible subpath #5177
Conversation
…ted with subpath Signed-off-by: Philipp Winkler <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make sense, can you add a test for it?
…ab instances hosted with subpath Signed-off-by: Philipp Winkler <[email protected]>
Hi @chenrui333 - thanks for your review and apololgies for taking so long. I have now added a test for the new functionality |
if vcsHostType == Gitlab { | ||
// For GitLab, we need to check if the path ends with our expected path | ||
// This handles cases where GitLab is hosted at a subpath (e.g., acme.com/gitlab) | ||
if !strings.HasSuffix(cloneURLParsed.Path, expClonePath) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now not checking that the hostname is as expected, so needs adding as a second check. A test also needs adding for this scenario.
what
This change allows GitLab URLs that include a subpath in the hostname while maintaining the security checks for repository path validation. The validation will pass as long as the full URL path ends with the expected repository path, which accommodates the case where ATLANTIS_GITLAB_HOSTNAME includes a path component.
why
In one of my projects github enterprise unfortunately was setup with a basepath (like git.acme.com/gitlab). Setting ATLANTIS_GITLAB_HOSTNAME to git.acme.com/gitlab results in an error like:
expected clone url to have path "/path/to/repo.git" but had "/gitlab/path/to/repo.git"
tests
references
closes #1450