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

Method dumpConfigYAML

cmd/crowdsec-cli/clisupport/support.go:346–363  ·  view source on GitHub ↗
(zw *zip.Writer)

Source from the content-addressed store, hash-verified

344}
345
346func (cli *cliSupport) dumpConfigYAML(zw *zip.Writer) error {
347 fmt.Fprintln(os.Stdout, "Collecting crowdsec config")
348
349 cfg := cli.cfg()
350
351 config, err := os.ReadFile(cfg.FilePath)
352 if err != nil {
353 return fmt.Errorf("could not read config file: %w", err)
354 }
355
356 r := regexp.MustCompile(`(\s+password:|\s+user:|\s+host:)\s+.*`)
357
358 redacted := r.ReplaceAll(config, []byte("$1 ****REDACTED****"))
359
360 cli.writeToZip(zw, SUPPORT_CROWDSEC_CONFIG_PATH, time.Now(), bytes.NewReader(redacted))
361
362 return nil
363}
364
365func (cli *cliSupport) dumpPprof(ctx context.Context, zw *zip.Writer, prometheusCfg csconfig.PrometheusCfg, endpoint string) error {
366 fmt.Fprintf(os.Stdout, "Collecting pprof/%s data\n", endpoint)

Callers 1

dumpMethod · 0.95

Calls 3

writeToZipMethod · 0.95
cfgMethod · 0.80
NewReaderMethod · 0.80

Tested by

no test coverage detected