-
-
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
Never add labels not from this repository or organisation and remove org labels on transfer #14928
Never add labels not from this repository or organisation and remove org labels on transfer #14928
Conversation
…org labels on transfer Prevent the addition of labels from outside of the repository or organisation and remove organisation labels on transfer. Related go-gitea#14908 Signed-off-by: Andrew Thornton <art27@cantab.net>
This is an extract from #14912 without the broken migration and consistency check - which should be fixed in that or another PR. |
…t-in-repository-part-1
Damn! This still has the broken query. |
Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
This comment has been minimized.
This comment has been minimized.
Signed-off-by: Andrew Thornton <art27@cantab.net>
…m:zeripath/gitea into fix-14908-labels-not-in-repository-part-1
Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
finally fixed the damned SQL! |
How about to create a new function named (i *Issue) CanAddLabel(l *Label) bool {
switch {
case l.RepoID > 0:
return l.RepoID == issue.RepoID
case l.OrgID > 0:
return l.OrgID == issue.Owner.ID
default:
return false
}
} |
That's not going to improve the complexity of repo_transfer.go. It would also have to be: func (issue *Issue) isValidLabel(e Engine, label *Label) (bool, error) {
if err := issue.loadRepo(e); err != nil {
return false, err
}
return (label.RepoID == issue.RepoID || label.OrgID == issue.Repo.OwnerID), nil
}
// IsValidLabel returns true if the label is a valid label for this issue.
func (issue *Issue) IsValidLabel(label *Label) (bool, error) {
return issue.isValidLabel(x, label)
} i.e. it would have to return an error which would significantly increase the complexity of ReplaceLabels and newIssueLabels |
We can't check hasLabel in there because it would still require duplication in the code for replace labels. |
Signed-off-by: Andrew Thornton <art27@cantab.net>
Aha the test failure was a real failure - the others were passing in error! |
🚀 |
Prevent the addition of labels from outside of the repository or
organisation and remove organisation labels on transfer.
Related #14908
Related #14912
Signed-off-by: Andrew Thornton art27@cantab.net