2020-07-16 08:57:28 +00:00
|
|
|
package executer
|
2020-04-26 00:20:33 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
"strings"
|
|
|
|
"unsafe"
|
|
|
|
)
|
|
|
|
|
2020-06-27 14:49:43 +00:00
|
|
|
type jsonOutput struct {
|
|
|
|
Template string `json:"template"`
|
|
|
|
Type string `json:"type"`
|
|
|
|
Matched string `json:"matched"`
|
|
|
|
MatcherName string `json:"matcher_name,omitempty"`
|
|
|
|
ExtractedResults []string `json:"extracted_results,omitempty"`
|
|
|
|
Severity string `json:"severity"`
|
|
|
|
Author string `json:"author"`
|
2020-07-08 18:54:36 +00:00
|
|
|
Description string `json:"description"`
|
2020-06-27 14:49:43 +00:00
|
|
|
}
|
|
|
|
|
2020-04-26 00:20:33 +00:00
|
|
|
// unsafeToString converts byte slice to string with zero allocations
|
|
|
|
func unsafeToString(bs []byte) string {
|
|
|
|
return *(*string)(unsafe.Pointer(&bs))
|
|
|
|
}
|
|
|
|
|
|
|
|
// headersToString converts http headers to string
|
|
|
|
func headersToString(headers http.Header) string {
|
|
|
|
builder := &strings.Builder{}
|
|
|
|
|
|
|
|
for header, values := range headers {
|
|
|
|
builder.WriteString(header)
|
|
|
|
builder.WriteString(": ")
|
|
|
|
|
|
|
|
for i, value := range values {
|
|
|
|
builder.WriteString(value)
|
|
|
|
if i != len(values)-1 {
|
|
|
|
builder.WriteRune(',')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
builder.WriteRune('\n')
|
|
|
|
}
|
|
|
|
return builder.String()
|
|
|
|
}
|