Skip to content

Commit f9c3364

Browse files
committed
feat: forbid credentials in git url
This is to minimize the risk of credential leaks, see discussion: helm/community#321 (comment) Signed-off-by: Dominykas Blyžė <[email protected]>
1 parent 5002866 commit f9c3364

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

pkg/downloader/chart_downloader.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@ func (c *ChartDownloader) ResolveChartVersion(ref, version string) (*url.URL, er
214214
if err != nil {
215215
return nil, errors.Errorf("invalid git URL format: %s", gitURL)
216216
}
217+
if u.User != nil {
218+
return nil, errors.Errorf("git repository URL should not contain credentials - please use git credential helpers")
219+
}
217220
return u, nil
218221
}
219222
u, err := url.Parse(ref)

pkg/downloader/chart_downloader_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ func TestResolveChartRef(t *testing.T) {
4343
{name: "full URL, with authentication", ref: "http://username:[email protected]/foo-1.2.3.tgz", expect: "http://username:[email protected]/foo-1.2.3.tgz"},
4444
{name: "helmchart", ref: "git+https://github.com/helmchart/helmchart.git", expect: "https://github.com/helmchart/helmchart.git"},
4545
{name: "helmchart", ref: "git://github.com/helmchart/helmchart.git", expect: "git://github.com/helmchart/helmchart.git"},
46+
{name: "helmchart", ref: "git+https://username:[email protected]/helmchart/helmchart.git", expectError: "git repository URL should not contain credentials - please use git credential helpers"},
4647
{name: "reference, testing repo", ref: "testing/alpine", expect: "http://example.com/alpine-1.2.3.tgz"},
4748
{name: "reference, version, testing repo", ref: "testing/alpine", version: "0.2.0", expect: "http://example.com/alpine-0.2.0.tgz"},
4849
{name: "reference, version, malformed repo", ref: "malformed/alpine", version: "1.2.3", expect: "http://dl.example.com/alpine-1.2.3.tgz"},

0 commit comments

Comments
 (0)