RES-84 # Improve Nuclei CLI interface

* reused some common logic
dev
forgedhallpass 2021-08-05 18:19:59 +03:00
parent ccf65ab1d3
commit e999229952
2 changed files with 4 additions and 33 deletions

View File

@ -49,7 +49,7 @@ func MarkdownDescription(event *output.ResultEvent) string { // TODO remove the
builder.WriteString(event.Timestamp.Format("Mon Jan 2 15:04:05 -0700 MST 2006"))
builder.WriteString("\n\n**Template Information**\n\n| Key | Value |\n|---|---|\n")
builder.WriteString(toMarkdownTableString(&event.Info))
builder.WriteString(ToMarkdownTableString(&event.Info))
if event.Request != "" {
builder.WriteString("\n**Request**\n\n```http\n")
@ -169,11 +169,7 @@ func GetMatchedTemplate(event *output.ResultEvent) string {
return template
}
/*
TODO remove and reuse the duplicated logic below jira.go <-> format.go
*/
func toMarkdownTableString(templateInfo *model.Info) string {
func ToMarkdownTableString(templateInfo *model.Info) string {
fields := map[string]string{
"Name": templateInfo.Name,
"Authors": sliceToString(templateInfo.Authors),

View File

@ -8,13 +8,12 @@ import (
"github.com/andygrunwald/go-jira"
"github.com/projectdiscovery/nuclei/v2/pkg/model"
"github.com/projectdiscovery/nuclei/v2/pkg/output"
"github.com/projectdiscovery/nuclei/v2/pkg/reporting/format"
"github.com/projectdiscovery/nuclei/v2/pkg/types"
)
// Integration is a client for a issue tracker integration
// Integration is a client for an issue tracker integration
type Integration struct {
jira *jira.Client
options *Options
@ -116,7 +115,7 @@ func jiraFormatDescription(event *output.ResultEvent) string { // TODO remove th
builder.WriteString(event.Timestamp.Format("Mon Jan 2 15:04:05 -0700 MST 2006"))
builder.WriteString("\n\n*Template Information*\n\n| Key | Value |\n")
builder.WriteString(toMarkdownTableString(&event.Info))
builder.WriteString(format.ToMarkdownTableString(&event.Info))
builder.WriteString("\n*Request*\n\n{code}\n")
builder.WriteString(event.Request)
@ -215,27 +214,3 @@ func jiraFormatDescription(event *output.ResultEvent) string { // TODO remove th
data := builder.String()
return data
}
/*
TODO remove and reuse the duplicated logic below jira.go <-> format.go
*/
func toMarkdownTableString(templateInfo *model.Info) string {
fields := map[string]string{
"Name": templateInfo.Name,
"Authors": sliceToString(templateInfo.Authors),
"Tags": sliceToString(templateInfo.Tags),
"Description": templateInfo.Description,
"Severity": templateInfo.SeverityHolder.Severity.String(),
}
builder := &bytes.Buffer{}
for k, v := range fields {
builder.WriteString(fmt.Sprintf("| %s | %s |\n", k, v))
}
return builder.String()
}
func sliceToString(stringSlice model.StringSlice) string {
return strings.Join(stringSlice.ToSlice(), ", ")
}