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

Method OneShot

pkg/acquisition/modules/file/run.go:31–54  ·  view source on GitHub ↗
(ctx context.Context, out chan pipeline.Event)

Source from the content-addressed store, hash-verified

29const defaultPollInterval = 30 * time.Second
30
31func (s *Source) OneShot(ctx context.Context, out chan pipeline.Event) error {
32 s.logger.Debug("In oneshot")
33
34 for _, file := range s.files {
35 fi, err := os.Stat(file)
36 if err != nil {
37 return fmt.Errorf("could not stat file %s : %w", file, err)
38 }
39
40 if fi.IsDir() {
41 s.logger.Warnf("%s is a directory, ignoring it.", file)
42 continue
43 }
44
45 s.logger.Infof("reading %s at once", file)
46
47 err = s.readFile(ctx, file, out)
48 if err != nil {
49 return err
50 }
51 }
52
53 return nil
54}
55
56func (s *Source) StreamingAcquisition(_ context.Context, out chan pipeline.Event, t *tomb.Tomb) error {
57 s.logger.Debug("Starting live acquisition")

Callers 1

TestOneShotFunction · 0.95

Calls 2

readFileMethod · 0.95
DebugMethod · 0.45

Tested by 1

TestOneShotFunction · 0.76