mirror of
https://github.com/ffuf/ffuf
synced 2024-12-04 17:19:16 +00:00
Fix an issue where output file was created regardless of -or (#444)
* Fix an issue where output file was created regardless of -or * Add CHANGELOG entry
This commit is contained in:
parent
958f738b7d
commit
ee0705e224
9 changed files with 14 additions and 33 deletions
|
@ -2,6 +2,7 @@
|
||||||
- master
|
- master
|
||||||
- New
|
- New
|
||||||
- Changed
|
- Changed
|
||||||
|
- Fixed an issue where output file was created regardless of `-or`
|
||||||
|
|
||||||
- v1.3.1
|
- v1.3.1
|
||||||
- New
|
- New
|
||||||
|
|
2
main.go
2
main.go
|
@ -58,7 +58,7 @@ func ParseFlags(opts *ffuf.ConfigOptions) *ffuf.ConfigOptions {
|
||||||
flag.BoolVar(&ignored, "compressed", true, "Dummy flag for copy as curl functionality (ignored)")
|
flag.BoolVar(&ignored, "compressed", true, "Dummy flag for copy as curl functionality (ignored)")
|
||||||
flag.BoolVar(&ignored, "i", true, "Dummy flag for copy as curl functionality (ignored)")
|
flag.BoolVar(&ignored, "i", true, "Dummy flag for copy as curl functionality (ignored)")
|
||||||
flag.BoolVar(&ignored, "k", false, "Dummy flag for backwards compatibility")
|
flag.BoolVar(&ignored, "k", false, "Dummy flag for backwards compatibility")
|
||||||
flag.BoolVar(&opts.Output.OutputCreateEmptyFile, "or", opts.Output.OutputCreateEmptyFile, "Don't create the output file if we don't have results")
|
flag.BoolVar(&opts.Output.OutputSkipEmptyFile, "or", opts.Output.OutputSkipEmptyFile, "Don't create the output file if we don't have results")
|
||||||
flag.BoolVar(&opts.General.AutoCalibration, "ac", opts.General.AutoCalibration, "Automatically calibrate filtering options")
|
flag.BoolVar(&opts.General.AutoCalibration, "ac", opts.General.AutoCalibration, "Automatically calibrate filtering options")
|
||||||
flag.BoolVar(&opts.General.Colors, "c", opts.General.Colors, "Colorize output.")
|
flag.BoolVar(&opts.General.Colors, "c", opts.General.Colors, "Colorize output.")
|
||||||
flag.BoolVar(&opts.General.Noninteractive, "noninteractive", opts.General.Noninteractive, "Disable the interactive console functionality")
|
flag.BoolVar(&opts.General.Noninteractive, "noninteractive", opts.General.Noninteractive, "Disable the interactive console functionality")
|
||||||
|
|
|
@ -34,7 +34,7 @@ type Config struct {
|
||||||
OutputDirectory string `json:"outputdirectory"`
|
OutputDirectory string `json:"outputdirectory"`
|
||||||
OutputFile string `json:"outputfile"`
|
OutputFile string `json:"outputfile"`
|
||||||
OutputFormat string `json:"outputformat"`
|
OutputFormat string `json:"outputformat"`
|
||||||
OutputCreateEmptyFile bool `json:"OutputCreateEmptyFile"`
|
OutputSkipEmptyFile bool `json:"OutputSkipEmptyFile"`
|
||||||
ProgressFrequency int `json:"-"`
|
ProgressFrequency int `json:"-"`
|
||||||
ProxyURL string `json:"proxyurl"`
|
ProxyURL string `json:"proxyurl"`
|
||||||
Quiet bool `json:"quiet"`
|
Quiet bool `json:"quiet"`
|
||||||
|
|
|
@ -78,7 +78,7 @@ type OutputOptions struct {
|
||||||
OutputDirectory string
|
OutputDirectory string
|
||||||
OutputFile string
|
OutputFile string
|
||||||
OutputFormat string
|
OutputFormat string
|
||||||
OutputCreateEmptyFile bool
|
OutputSkipEmptyFile bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type FilterOptions struct {
|
type FilterOptions struct {
|
||||||
|
@ -146,7 +146,7 @@ func NewConfigOptions() *ConfigOptions {
|
||||||
c.Output.OutputDirectory = ""
|
c.Output.OutputDirectory = ""
|
||||||
c.Output.OutputFile = ""
|
c.Output.OutputFile = ""
|
||||||
c.Output.OutputFormat = "json"
|
c.Output.OutputFormat = "json"
|
||||||
c.Output.OutputCreateEmptyFile = false
|
c.Output.OutputSkipEmptyFile = false
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -382,7 +382,7 @@ func ConfigFromOptions(parseOpts *ConfigOptions, ctx context.Context, cancel con
|
||||||
conf.InputShell = parseOpts.Input.InputShell
|
conf.InputShell = parseOpts.Input.InputShell
|
||||||
conf.OutputFile = parseOpts.Output.OutputFile
|
conf.OutputFile = parseOpts.Output.OutputFile
|
||||||
conf.OutputDirectory = parseOpts.Output.OutputDirectory
|
conf.OutputDirectory = parseOpts.Output.OutputDirectory
|
||||||
conf.OutputCreateEmptyFile = parseOpts.Output.OutputCreateEmptyFile
|
conf.OutputSkipEmptyFile = parseOpts.Output.OutputSkipEmptyFile
|
||||||
conf.IgnoreBody = parseOpts.HTTP.IgnoreBody
|
conf.IgnoreBody = parseOpts.HTTP.IgnoreBody
|
||||||
conf.Quiet = parseOpts.General.Quiet
|
conf.Quiet = parseOpts.General.Quiet
|
||||||
conf.StopOn403 = parseOpts.General.StopOn403
|
conf.StopOn403 = parseOpts.General.StopOn403
|
||||||
|
|
|
@ -12,11 +12,6 @@ import (
|
||||||
var staticheaders = []string{"url", "redirectlocation", "position", "status_code", "content_length", "content_words", "content_lines", "content_type", "resultfile"}
|
var staticheaders = []string{"url", "redirectlocation", "position", "status_code", "content_length", "content_words", "content_lines", "content_type", "resultfile"}
|
||||||
|
|
||||||
func writeCSV(filename string, config *ffuf.Config, res []ffuf.Result, encode bool) error {
|
func writeCSV(filename string, config *ffuf.Config, res []ffuf.Result, encode bool) error {
|
||||||
|
|
||||||
if config.OutputCreateEmptyFile && (len(res) == 0) {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
header := make([]string, 0)
|
header := make([]string, 0)
|
||||||
f, err := os.Create(filename)
|
f, err := os.Create(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -177,11 +177,6 @@ func colorizeResults(results []ffuf.Result) []ffuf.Result {
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeHTML(filename string, config *ffuf.Config, results []ffuf.Result) error {
|
func writeHTML(filename string, config *ffuf.Config, results []ffuf.Result) error {
|
||||||
|
|
||||||
if config.OutputCreateEmptyFile && (len(results) == 0) {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
results = colorizeResults(results)
|
results = colorizeResults(results)
|
||||||
|
|
||||||
ti := time.Now()
|
ti := time.Now()
|
||||||
|
|
|
@ -37,11 +37,6 @@ type jsonFileOutput struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeEJSON(filename string, config *ffuf.Config, res []ffuf.Result) error {
|
func writeEJSON(filename string, config *ffuf.Config, res []ffuf.Result) error {
|
||||||
|
|
||||||
if config.OutputCreateEmptyFile && (len(res) == 0) {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
t := time.Now()
|
t := time.Now()
|
||||||
outJSON := ejsonFileOutput{
|
outJSON := ejsonFileOutput{
|
||||||
CommandLine: config.CommandLine,
|
CommandLine: config.CommandLine,
|
||||||
|
|
|
@ -21,11 +21,6 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
func writeMarkdown(filename string, config *ffuf.Config, res []ffuf.Result) error {
|
func writeMarkdown(filename string, config *ffuf.Config, res []ffuf.Result) error {
|
||||||
|
|
||||||
if config.OutputCreateEmptyFile && (len(res) == 0) {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
ti := time.Now()
|
ti := time.Now()
|
||||||
|
|
||||||
keywords := make([]string, 0)
|
keywords := make([]string, 0)
|
||||||
|
|
|
@ -225,10 +225,6 @@ func (s *Stdoutput) writeToAll(filename string, config *ffuf.Config, res []ffuf.
|
||||||
// Go through each type of write, adding
|
// Go through each type of write, adding
|
||||||
// the suffix to each output file.
|
// the suffix to each output file.
|
||||||
|
|
||||||
if config.OutputCreateEmptyFile && (len(res) == 0) {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
s.config.OutputFile = BaseFilename + ".json"
|
s.config.OutputFile = BaseFilename + ".json"
|
||||||
err = writeJSON(filename, s.config, res)
|
err = writeJSON(filename, s.config, res)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -272,6 +268,10 @@ func (s *Stdoutput) writeToAll(filename string, config *ffuf.Config, res []ffuf.
|
||||||
// SaveFile saves the current results to a file of a given type
|
// SaveFile saves the current results to a file of a given type
|
||||||
func (s *Stdoutput) SaveFile(filename, format string) error {
|
func (s *Stdoutput) SaveFile(filename, format string) error {
|
||||||
var err error
|
var err error
|
||||||
|
if s.config.OutputSkipEmptyFile && len(s.Results) == 0 {
|
||||||
|
s.Info("No results and -or defined, output file not written.")
|
||||||
|
return err
|
||||||
|
}
|
||||||
switch format {
|
switch format {
|
||||||
case "all":
|
case "all":
|
||||||
err = s.writeToAll(filename, s.config, append(s.Results, s.CurrentResults...))
|
err = s.writeToAll(filename, s.config, append(s.Results, s.CurrentResults...))
|
||||||
|
|
Loading…
Reference in a new issue