Skip to content

Commit

Permalink
Support for JSON output #226
Browse files Browse the repository at this point in the history
  • Loading branch information
edoardottt committed May 12, 2024
1 parent be4f4f2 commit 4092f55
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions pkg/csprecon/csprecon.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func execute(r *Runner) {
tempResult := []string{}

for _, res := range result {
if domainOk(res, r.Options.Domain) {
if DomainOk(res, r.Options.Domain) {
tempResult = append(tempResult, res)
}
}
Expand All @@ -178,7 +178,7 @@ func execute(r *Runner) {
for _, res := range result {
if resTrimmed := strings.TrimSpace(res); resTrimmed != "" {
if len(r.Options.Domain) != 0 {
if domainOk(resTrimmed, r.Options.Domain) {
if DomainOk(resTrimmed, r.Options.Domain) {
r.Output <- resTrimmed
}
} else {
Expand Down Expand Up @@ -262,7 +262,7 @@ func writeJSONOutput(wg *sync.WaitGroup, m *sync.Mutex, options *input.Options,
m.Lock()

if options.Output != nil {
if _, err := options.Output.Write(out); err != nil && options.Verbose {
if _, err := options.Output.Write(append(out, byte('\n'))); err != nil && options.Verbose {
gologger.Fatal().Msg(err.Error())
}
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/output/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func FormatJSON(url string, result []string) ([]byte, error) {
return jsonOutput, nil
}

// PrepareJSONOutput returns the target URL and the findings.
func PrepareJSONOutput(out []string) (url string, result []string, err error) {
if len(out) == 0 {
return "", []string{}, ErrEmptyResult
Expand All @@ -47,6 +48,6 @@ func PrepareJSONOutput(out []string) (url string, result []string, err error) {
if len(out) == 1 {
return out[len(out)-1], []string{}, nil
} else {
return out[len(out)-1], out[0 : len(out)-2], nil
return out[len(out)-1], out[0 : len(out)-1], nil
}
}

0 comments on commit 4092f55

Please sign in to comment.