Skip to content

Commit

Permalink
(feat) add none writer
Browse files Browse the repository at this point in the history
  • Loading branch information
leonjza committed Oct 13, 2024
1 parent 4ff862a commit 7ccc4c9
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cmd/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down Expand Up @@ -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")
}
1 change: 1 addition & 0 deletions pkg/runner/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ type Writer struct {
Jsonl bool
JsonlFile string
Stdout bool
None bool
}

// Scan is scanning related options
Expand Down
19 changes: 19 additions & 0 deletions pkg/writers/none.go
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 7ccc4c9

Please # to comment.