2020-07-16 10:57:28 +02:00
|
|
|
package executer
|
2020-04-26 05:50:33 +05:30
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"net/http"
|
|
|
|
|
"strings"
|
|
|
|
|
"unsafe"
|
|
|
|
|
)
|
|
|
|
|
|
2020-06-27 20:19:43 +05:30
|
|
|
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"`
|
2020-08-27 22:13:42 +02:00
|
|
|
Name string `json:"name"`
|
2020-06-27 20:19:43 +05:30
|
|
|
Severity string `json:"severity"`
|
|
|
|
|
Author string `json:"author"`
|
2020-07-08 19:54:36 +01:00
|
|
|
Description string `json:"description"`
|
2020-07-15 13:38:45 +02:00
|
|
|
Request string `json:"request,omitempty"`
|
|
|
|
|
Response string `json:"response,omitempty"`
|
2020-06-27 20:19:43 +05:30
|
|
|
}
|
|
|
|
|
|
2020-04-26 05:50:33 +05:30
|
|
|
// 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)
|
2020-08-25 23:24:31 +02:00
|
|
|
|
2020-04-26 05:50:33 +05:30
|
|
|
if i != len(values)-1 {
|
2020-09-09 16:24:59 +02:00
|
|
|
builder.WriteRune('\n')
|
|
|
|
|
builder.WriteString(header)
|
|
|
|
|
builder.WriteString(": ")
|
2020-04-26 05:50:33 +05:30
|
|
|
}
|
|
|
|
|
}
|
2020-08-25 23:24:31 +02:00
|
|
|
|
2020-04-26 05:50:33 +05:30
|
|
|
builder.WriteRune('\n')
|
|
|
|
|
}
|
2020-08-25 23:24:31 +02:00
|
|
|
|
2020-04-26 05:50:33 +05:30
|
|
|
return builder.String()
|
|
|
|
|
}
|