nuclei/v2/pkg/workflows/compile.go

33 lines
456 B
Go
Raw Normal View History

2020-06-26 08:23:54 +00:00
package workflows
import (
2020-06-26 12:37:55 +00:00
"errors"
2020-06-26 08:23:54 +00:00
"os"
"gopkg.in/yaml.v2"
)
// Parse a yaml workflow file
func Parse(file string) (*Workflow, error) {
workflow := &Workflow{}
f, err := os.Open(file)
if err != nil {
return nil, err
}
defer f.Close()
err = yaml.NewDecoder(f).Decode(workflow)
if err != nil {
return nil, err
}
2020-06-26 12:37:55 +00:00
if workflow.Logic == "" {
return nil, errors.New("no logic provided")
2020-06-26 12:37:55 +00:00
}
workflow.path = file
2020-06-26 08:23:54 +00:00
return workflow, nil
}