3
0

Fix trigger loading on workflow execution

Triggers are now loaded directly from store and
without access control
This commit is contained in:
Denis Arh
2021-09-20 20:32:25 +02:00
parent 49f86f916f
commit 3515cf2a06
2 changed files with 21 additions and 3 deletions
+14 -2
View File
@@ -616,12 +616,24 @@ func (svc *trigger) unregisterTriggers(tt ...*types.Trigger) {
}
}
func loadTrigger(ctx context.Context, s store.Storer, workflowID uint64) (res *types.Trigger, err error) {
func loadTrigger(ctx context.Context, s store.Storer, triggerID uint64) (res *types.Trigger, err error) {
if triggerID == 0 {
return nil, TriggerErrInvalidID()
}
if res, err = store.LookupAutomationTriggerByID(ctx, s, triggerID); errors.IsNotFound(err) {
return nil, TriggerErrNotFound()
}
return
}
func loadWorkflowTriggers(ctx context.Context, s store.Storer, workflowID uint64) (tt types.TriggerSet, err error) {
if workflowID == 0 {
return nil, TriggerErrInvalidID()
}
if res, err = store.LookupAutomationTriggerByID(ctx, s, workflowID); errors.IsNotFound(err) {
if tt, _, err = store.SearchAutomationTriggers(ctx, s, types.TriggerFilter{WorkflowID: []uint64{workflowID}}); errors.IsNotFound(err) {
return nil, TriggerErrNotFound()
}
+7 -1
View File
@@ -521,7 +521,9 @@ func (svc *workflow) Exec(ctx context.Context, workflowID uint64, p types.Workfl
// Find the trigger.
t, err = func() (*types.Trigger, error) {
var tt types.TriggerSet
tt, _, err = svc.triggers.Search(ctx, types.TriggerFilter{WorkflowID: []uint64{workflowID}})
// Load triggers directly from the store. At this point we do not care
// about trigger search or read permissions
tt, err = loadWorkflowTriggers(ctx, svc.store, workflowID)
if err != nil {
return nil, err
}
@@ -539,6 +541,10 @@ func (svc *workflow) Exec(ctx context.Context, workflowID uint64, p types.Workfl
return nil, nil
}()
if err != nil {
return
}
// Start with workflow scope
scope := wf.Scope.MustMerge()