Prevent addition of labels from outside the repository or organisation in issues (#14912)
* Never add labels not from this repository or organisation and remove org labels on transfer Prevent the addition of labels from outside of the repository or organisation and remove organisation labels on transfer. Related #14908 Signed-off-by: Andrew Thornton <[email protected]> * switch to use sql Signed-off-by: Andrew Thornton <[email protected]> * remove AS Signed-off-by: Andrew Thornton <[email protected]> * subquery alias Signed-off-by: Andrew Thornton <[email protected]> * Give me some AS? Signed-off-by: Andrew Thornton <[email protected]> * double AS Signed-off-by: Andrew Thornton <[email protected]> * try try again Signed-off-by: Andrew Thornton <[email protected]> * once more around the merry go round Signed-off-by: Andrew Thornton <[email protected]> * fix api problem Signed-off-by: Andrew Thornton <[email protected]> * Add outside label consistency check into doctor This PR adds another consistency check into doctor in order to detect labels that have been added from outside of repositories and organisations Fix #14908 Signed-off-by: Andrew Thornton <[email protected]> * fix migration Signed-off-by: Andrew Thornton <[email protected]> * prep for merge Signed-off-by: Andrew Thornton <[email protected]> Co-authored-by: 6543 <[email protected]> Co-authored-by: Lauris BH <[email protected]>
This commit is contained in:
co-authored by
6543
Lauris BH
parent
54d7b0f8e7
commit
dace0ce1b1
@@ -130,6 +130,45 @@ func checkDBConsistency(logger log.Logger, autofix bool) error {
|
||||
logger.Warn("%d label comments with empty labels", count)
|
||||
}
|
||||
}
|
||||
|
||||
// find label comments with labels from outside the repository
|
||||
count, err = models.CountCommentTypeLabelWithOutsideLabels()
|
||||
if err != nil {
|
||||
logger.Critical("Error: %v whilst counting label comments with outside labels", err)
|
||||
return err
|
||||
}
|
||||
if count > 0 {
|
||||
if autofix {
|
||||
updatedCount, err := models.FixCommentTypeLabelWithOutsideLabels()
|
||||
if err != nil {
|
||||
logger.Critical("Error: %v whilst removing label comments with outside labels", err)
|
||||
return err
|
||||
}
|
||||
log.Info("%d label comments with outside labels removed", updatedCount)
|
||||
} else {
|
||||
log.Warn("%d label comments with outside labels", count)
|
||||
}
|
||||
}
|
||||
|
||||
// find issue_label with labels from outside the repository
|
||||
count, err = models.CountIssueLabelWithOutsideLabels()
|
||||
if err != nil {
|
||||
logger.Critical("Error: %v whilst counting issue_labels from outside the repository or organisation", err)
|
||||
return err
|
||||
}
|
||||
if count > 0 {
|
||||
if autofix {
|
||||
updatedCount, err := models.FixIssueLabelWithOutsideLabels()
|
||||
if err != nil {
|
||||
logger.Critical("Error: %v whilst removing issue_labels from outside the repository or organisation", err)
|
||||
return err
|
||||
}
|
||||
logger.Info("%d issue_labels from outside the repository or organisation removed", updatedCount)
|
||||
} else {
|
||||
logger.Warn("%d issue_labels from outside the repository or organisation", count)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: function to recalc all counters
|
||||
|
||||
if setting.Database.UsePostgreSQL {
|
||||
|
||||
Reference in New Issue
Block a user