fix github registry URL scheme validation
This commit is contained in:
parent
ef6fbef559
commit
383b13b11e
2 changed files with 15 additions and 0 deletions
|
|
@ -187,6 +187,9 @@ func matchesGitHubWebBase(repoURL *url.URL, webBaseURL string) bool {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if !strings.EqualFold(repoURL.Scheme, baseURL.Scheme) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
if !strings.EqualFold(repoURL.Host, baseURL.Host) {
|
if !strings.EqualFold(repoURL.Host, baseURL.Host) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -200,6 +200,18 @@ func TestParseGitHubRefWithBaseURL(t *testing.T) {
|
||||||
if !strings.Contains(err.Error(), `invalid GitHub URL host "gitlab.example.com"`) {
|
if !strings.Contains(err.Error(), `invalid GitHub URL host "gitlab.example.com"`) {
|
||||||
t.Fatalf("unexpected error = %v", err)
|
t.Fatalf("unexpected error = %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_, err = parseGitHubRefWithBaseURL(
|
||||||
|
"http://ghe.example.com/git/org/repo/tree/dev/skills/test",
|
||||||
|
"https://ghe.example.com/git",
|
||||||
|
"main",
|
||||||
|
)
|
||||||
|
if err == nil {
|
||||||
|
t.Fatal("parseGitHubRefWithBaseURL() error = nil, want invalid host error for scheme mismatch")
|
||||||
|
}
|
||||||
|
if !strings.Contains(err.Error(), `invalid GitHub URL host "ghe.example.com"`) {
|
||||||
|
t.Fatalf("unexpected scheme mismatch error = %v", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSkillInstallerResolveGitHubRefUsesDefaultBranch(t *testing.T) {
|
func TestSkillInstallerResolveGitHubRefUsesDefaultBranch(t *testing.T) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue