Skip to content
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

BUG: registry.ParseReference returns false positive when registry is empty #698

Closed
qweeah opened this issue Jan 30, 2024 · 0 comments · Fixed by #729
Closed

BUG: registry.ParseReference returns false positive when registry is empty #698

qweeah opened this issue Jan 30, 2024 · 0 comments · Fixed by #729
Labels
bug Something isn't working
Milestone

Comments

@qweeah
Copy link
Contributor

qweeah commented Jan 30, 2024

Below code is expected to panic but can parse the invalid reference /oras

package main

import (
	"fmt"

	_ "crypto/sha256"

	"oras.land/oras-go/v2/registry"
)

func main() {
	rawRef := "/oras"
	ref, err := registry.ParseReference(rawRef)
	if err != nil {
		panic(err)
	}

	fmt.Println("Registry:", ref.Registry)
	fmt.Println("Repository:", ref.Repository)
} 

Version: oras.land/oras-go/v2 v2.4.0

The root cause is url.ParseRequestURI allows empty domain name, ORAS-go should enforce the non-empty checking.

@shizhMSFT shizhMSFT added the bug Something isn't working label Feb 18, 2024
@shizhMSFT shizhMSFT added this to the v2.5.0 milestone Mar 19, 2024
Wwwsylvia pushed a commit that referenced this issue Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants