forked from go-gitea/gitea
-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Description
Problem
Location: modules/actions/workflows.go (lines 377-398)
actions := []string{}
switch issuePayload.Action {
case api.HookIssueLabelUpdated:
if len(issuePayload.Changes.AddedLabels) > 0 {
actions = append(actions, "labeled")
}
if len(issuePayload.Changes.RemovedLabels) > 0 {
actions = append(actions, "unlabeled")
}Issue: If both AddedLabels and RemovedLabels are empty (which could happen with a malformed webhook payload), actions will be empty and the subsequent loop will not match anything, potentially causing unexpected behavior.
Solution
Fix: Add validation:
actions := []string{}
switch issuePayload.Action {
case api.HookIssueLabelUpdated:
if len(issuePayload.Changes.AddedLabels) > 0 {
actions = append(actions, "labeled")
}
if len(issuePayload.Changes.RemovedLabels) > 0 {
actions = append(actions, "unlabeled")
}
// If no labels were added or removed, this is invalid
if len(actions) == 0 {
log.Warn("HookIssueLabelUpdated action without added or removed labels")
return false
}Metadata
Metadata
Assignees
Labels
No labels