Changeset - 7163feda7140
[Not reviewed]
stable
0 2 0
Mads Kiilerich (kiilerix) - 5 years ago 2020-01-25 20:26:01
mads@kiilerich.com
Grafted from: f6aef97f7aab
ssh: ignore trailing '/' after repo name in URLs (Issue #352)

Make SSH URLs similar to how HTTP URLs are handled in simplehg.py / simplegit.py .

We will consistently use the stripped repo name, so there should be no security
or ambiguities or reliability concerns.
2 files changed with 10 insertions and 16 deletions:
0 comments (0 inline, 0 general) First comment
kallithea/lib/vcs/backends/ssh.py
Show inline comments
 
@@ -56,7 +56,7 @@ class BaseSshHandler(object):
 
        raise NotImplementedError
 

	
 
    def __init__(self, repo_name):
 
        self.repo_name = repo_name
 
        self.repo_name = repo_name.rstrip('/')
 

	
 
    def serve(self, user_id, key_id, client_ip):
 
        """Verify basic sanity of the repository, and that the user is
kallithea/tests/other/test_vcs_operations.py
Show inline comments
 
@@ -425,25 +425,19 @@ class TestVCSOperations(TestController):
 
        else:
 
            assert issubclass(vt, SshVcsTest)
 
            if vt.repo_type == 'git':
 
                assert "abort: Access to './%s/' denied" % vt.repo_name in stderr
 
                assert "abort: Access to './%s' denied" % vt.repo_name in stderr
 
            else:
 
                assert "abort: Access to './%s/' denied" % vt.repo_name in stdout
 
                assert "abort: Access to './%s' denied" % vt.repo_name in stdout
 

	
 
        stdout, stderr = Command(dest_dir).execute(vt.repo_type, 'pull', clone_url.replace('/' + vt.repo_name, '/%s/' % vt.repo_name), ignoreReturnCode=True)
 
        if issubclass(vt, HttpVcsTest):
 
            if vt.repo_type == 'git':
 
                assert 'Already up to date.' in stdout
 
            else:
 
                assert vt.repo_type == 'hg'
 
                assert "no changes found" in stdout
 
            assert "denied" not in stderr
 
            assert "denied" not in stdout
 
            assert "404" not in stdout
 
        if vt.repo_type == 'git':
 
            assert 'Already up to date.' in stdout
 
        else:
 
            if vt.repo_type == 'git':
 
                assert "denied" in stderr
 
            else:
 
                assert "denied" in stdout
 
            assert vt.repo_type == 'hg'
 
            assert "no changes found" in stdout
 
        assert "denied" not in stderr
 
        assert "denied" not in stdout
 
        assert "404" not in stdout
 

	
 
    @parametrize_vcs_test
 
    def test_push_invalidates_cache(self, webserver, testfork, vt):
0 comments (0 inline, 0 general) First comment
You need to be logged in to comment. Login now