MCPcopy
hub / github.com/crowdsecurity/crowdsec / LoadStages

Function LoadStages

pkg/parser/stage.go:39–65  ·  view source on GitHub ↗
(stageFiles []Stagefile, pctx *UnixParserCtx, ectx EnricherCtx)

Source from the content-addressed store, hash-verified

37}
38
39func LoadStages(stageFiles []Stagefile, pctx *UnixParserCtx, ectx EnricherCtx) ([]Node, error) {
40 var allNodes []Node
41
42 tmpStages := make(map[string]bool)
43 pctx.Stages = []string{}
44
45 for _, sf := range stageFiles {
46 nodes, err := processStageFile(sf, pctx, ectx)
47 if err != nil {
48 return nil, err
49 }
50
51 for _, n := range nodes { //nolint:gocritic // rangeValCopy
52 allNodes = append(allNodes, n)
53 tmpStages[n.Stage] = true
54 }
55 }
56
57 for k := range tmpStages {
58 pctx.Stages = append(pctx.Stages, k)
59 }
60
61 sort.Strings(pctx.Stages)
62 log.Infof("Loaded %d nodes from %d stages", len(allNodes), len(pctx.Stages))
63
64 return allNodes, nil
65}
66
67func processStageFile(stageFile Stagefile, pctx *UnixParserCtx, ectx EnricherCtx) ([]Node, error) {
68 if !strings.HasSuffix(stageFile.Filename, ".yaml") && !strings.HasSuffix(stageFile.Filename, ".yml") {

Callers 2

LoadParsersFunction · 0.85
testOneParserFunction · 0.85

Calls 2

processStageFileFunction · 0.85
StringsMethod · 0.80

Tested by 1

testOneParserFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…