-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Always return valid go-get meta, even if unauthorized #2010
Conversation
LGTM |
modules/context/context.go
Outdated
branchName := "master" | ||
|
||
owner, err := models.GetUserByName(ownerName) | ||
if err != nil { |
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.
It will leak users/organizations, it should skip searching for repository by name if there is error and never return 500 or any other error
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.
Seems to be fetching the default branch-name, so if err { branchName = "master" }
?
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.
I would say something like that:
owner, err := models.GetUserByName(ownerName)
if err == nil {
repo, err := models.GetRepositoryByName(owner.ID, repoName)
if err == nil && len(repo.DefaultBranch) > 0 {
branchName = repo.DefaultBranch
}
}
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.
Maybe just return meta tag with no GetUserByName
and GetRepositoryByName
.
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.
Done :)
Just return even if repo is not exist. |
modules/context/context.go
Outdated
branchName := "master" | ||
|
||
owner, err := models.GetUserByName(ownerName) | ||
if err != nil { |
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.
Maybe just return meta tag with no GetUserByName
and GetRepositoryByName
.
Now it should be done :) @lunny |
LGTM |
@lunny that would break default branches 🙄 |
Where? |
☝️ that 😄 |
(Not leaking information, returns valid metadata for ALL requests... even broken ones...)
This is required because
go get
doesn't know about.netrc