diff --git a/v2/pkg/reporting/format/format.go b/v2/pkg/reporting/format/format.go index 14153037e..0e18f1ac1 100644 --- a/v2/pkg/reporting/format/format.go +++ b/v2/pkg/reporting/format/format.go @@ -54,7 +54,7 @@ func MarkdownDescription(event *output.ResultEvent) string { // TODO remove the if event.Request != "" { builder.WriteString("\n**Request**\n\n```http\n") - builder.WriteString(event.Request) + builder.WriteString(types.ToHexOrString(event.Request)) builder.WriteString("\n```\n") } if event.Response != "" { @@ -135,7 +135,7 @@ func MarkdownDescription(event *output.ResultEvent) string { // TODO remove the if event.CURLCommand != "" { builder.WriteString("\n**CURL Command**\n```\n") - builder.WriteString(event.CURLCommand) + builder.WriteString(types.ToHexOrString(event.CURLCommand)) builder.WriteString("\n```") } diff --git a/v2/pkg/types/interfaces.go b/v2/pkg/types/interfaces.go index b92064dcb..25dd68567 100644 --- a/v2/pkg/types/interfaces.go +++ b/v2/pkg/types/interfaces.go @@ -3,10 +3,12 @@ package types import ( + "encoding/hex" "fmt" "strconv" "strings" + "github.com/asaskevich/govalidator" "github.com/projectdiscovery/nuclei/v2/pkg/model/types/severity" ) @@ -75,6 +77,20 @@ func ToString(data interface{}) string { } } +func ToHexOrString(data interface{}) string { + switch s := data.(type) { + case string: + if govalidator.IsASCII(s) { + return s + } + return hex.Dump([]byte(s)) + case []byte: + return hex.Dump(s) + default: + return fmt.Sprintf("%v", data) + } +} + // ToStringSlice casts an interface to a []string type. func ToStringSlice(i interface{}) []string { var a []string