From 7ccc4c999d12d8afa1a695d1e46d62086750d746 Mon Sep 17 00:00:00 2001 From: Leon Jacobs Date: Sun, 13 Oct 2024 08:56:21 +0200 Subject: [PATCH] (feat) add none writer --- cmd/scan.go | 9 +++++++++ pkg/runner/options.go | 1 + pkg/writers/none.go | 19 +++++++++++++++++++ 3 files changed, 29 insertions(+) create mode 100644 pkg/writers/none.go diff --git a/cmd/scan.go b/cmd/scan.go index a2aff44e..5b317429 100644 --- a/cmd/scan.go +++ b/cmd/scan.go @@ -105,6 +105,14 @@ flags.`)), scanWriters = append(scanWriters, w) } + if opts.Writer.None { + w, err := writers.NewNoneWriter() + if err != nil { + return err + } + scanWriters = append(scanWriters, w) + } + if len(scanWriters) == 0 { log.Warn("no writers have been configured. to persist probe results, add writers using --write-* flags") } @@ -160,4 +168,5 @@ func init() { scanCmd.PersistentFlags().BoolVar(&opts.Writer.Jsonl, "write-jsonl", false, "Write results as JSON lines") scanCmd.PersistentFlags().StringVar(&opts.Writer.JsonlFile, "write-jsonl-file", "gowitness.jsonl", "The file to write JSON lines to") scanCmd.PersistentFlags().BoolVar(&opts.Writer.Stdout, "write-stdout", false, "Write successful results to stdout (usefull in a shell pipeline)") + scanCmd.PersistentFlags().BoolVar(&opts.Writer.None, "write-none", false, "Use an empty writer to silence warnings") } diff --git a/pkg/runner/options.go b/pkg/runner/options.go index d85c58b2..b9d67dff 100644 --- a/pkg/runner/options.go +++ b/pkg/runner/options.go @@ -52,6 +52,7 @@ type Writer struct { Jsonl bool JsonlFile string Stdout bool + None bool } // Scan is scanning related options diff --git a/pkg/writers/none.go b/pkg/writers/none.go new file mode 100644 index 00000000..96aae866 --- /dev/null +++ b/pkg/writers/none.go @@ -0,0 +1,19 @@ +package writers + +import ( + "github.com/sensepost/gowitness/pkg/models" +) + +// NoneWriter is a None writer +type NoneWriter struct { +} + +// NewStdoutWriter initialises a none writer +func NewNoneWriter() (*NoneWriter, error) { + return &NoneWriter{}, nil +} + +// Write does nothing +func (s *NoneWriter) Write(result *models.Result) error { + return nil +}