-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #638 from projectdiscovery/fix-bugs
v2.3.1 bug fixes
- Loading branch information
Showing
17 changed files
with
260 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package disk | ||
|
||
import ( | ||
"bytes" | ||
"io/ioutil" | ||
"os" | ||
"path" | ||
"strings" | ||
|
||
"github.com/projectdiscovery/nuclei/v2/pkg/output" | ||
"github.com/projectdiscovery/nuclei/v2/pkg/reporting/format" | ||
) | ||
|
||
type Exporter struct { | ||
directory string | ||
options *Options | ||
} | ||
|
||
// Options contains the configuration options for github issue tracker client | ||
type Options struct { | ||
// Directory is the directory to export found results to | ||
Directory string `yaml:"directory"` | ||
} | ||
|
||
// New creates a new disk exporter integration client based on options. | ||
func New(options *Options) (*Exporter, error) { | ||
directory := options.Directory | ||
if options.Directory == "" { | ||
dir, err := os.Getwd() | ||
if err != nil { | ||
return nil, err | ||
} | ||
directory = dir | ||
} | ||
_ = os.MkdirAll(directory, os.ModePerm) | ||
return &Exporter{options: options, directory: directory}, nil | ||
} | ||
|
||
// Export exports a passed result event to disk | ||
func (i *Exporter) Export(event *output.ResultEvent) error { | ||
summary := format.Summary(event) | ||
description := format.MarkdownDescription(event) | ||
|
||
filenameBuilder := &strings.Builder{} | ||
filenameBuilder.WriteString(event.TemplateID) | ||
filenameBuilder.WriteString("-") | ||
filenameBuilder.WriteString(strings.ReplaceAll(strings.ReplaceAll(event.Matched, "/", "_"), ":", "_")) | ||
filenameBuilder.WriteString(".md") | ||
finalFilename := filenameBuilder.String() | ||
|
||
dataBuilder := &bytes.Buffer{} | ||
dataBuilder.WriteString("### ") | ||
dataBuilder.WriteString(summary) | ||
dataBuilder.WriteString("\n---\n") | ||
dataBuilder.WriteString(description) | ||
data := dataBuilder.Bytes() | ||
|
||
err := ioutil.WriteFile(path.Join(i.directory, finalFilename), data, 0644) | ||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.