mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-24 06:25:26 +00:00
Merge pull request #1755 from projectdiscovery/issue-1713-gitlab-report
Adding HexOrString helper
This commit is contained in:
commit
5364d91b8a
@ -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```")
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user