add template level stop-at-first-match to workflows
@@ -81,7 +81,7 @@ func (e *Executer) Execute(input string) (bool, error) {
}
gologger.Warning().Msgf("[%s] Could not execute request for %s: %s\n", e.options.TemplateID, input, err)
}
- //
+ // If a match was found and stop at first match is set, break out of the loop and return
if results && (e.options.StopAtFirstMatch || e.options.Options.StopAtFirstMatch) {
gologger.Info().Msgf("[%s] Stopping execution at first match for %s\n", e.options.TemplateID, input)
break
@@ -94,6 +94,7 @@ func (e *Executer) Execute(input string) (bool, error) {
func (e *Executer) ExecuteWithResults(input string, callback protocols.OutputEventCallback) error {
dynamicValues := make(map[string]interface{})
previous := make(map[string]interface{})
+ var results bool
for _, req := range e.requests {
req := req
@@ -113,6 +114,7 @@ func (e *Executer) ExecuteWithResults(input string, callback protocols.OutputEve
if event.OperatorsResult == nil {
return
}
+ results = true
callback(event)
})
if err != nil {
@@ -123,6 +125,11 @@ func (e *Executer) ExecuteWithResults(input string, callback protocols.OutputEve
}
gologger.Warning().Msgf("[%s] Could not execute request for %s: %s\n", e.options.TemplateID, input, err)
}
+ // If a match was found and stop at first match is set, break out of the loop and return
+ if results && (e.options.StopAtFirstMatch || e.options.Options.StopAtFirstMatch) {
+ gologger.Info().Msgf("[%s] Stopping execution at first match for %s\n", e.options.TemplateID, input)
+ break
+ }
}
return nil
}
