|
@@ -72,7 +72,9 @@ func sanitizeHeaders(s string) string {
|
|
re := regexp.MustCompile(`[a-zA-Z]{4,32}|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})|([0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12})`)
|
|
re := regexp.MustCompile(`[a-zA-Z]{4,32}|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})|([0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12})`)
|
|
matched := re.FindAllString(s, -1)
|
|
matched := re.FindAllString(s, -1)
|
|
|
|
|
|
- tmpSt := strings.ToLower(strings.Join(matched, " "))
|
|
|
|
|
|
+ uMatched := Unique(matched)
|
|
|
|
+
|
|
|
|
+ tmpSt := strings.ToLower(strings.Join(uMatched, " "))
|
|
|
|
|
|
log.Println("Matched: " + tmpSt)
|
|
log.Println("Matched: " + tmpSt)
|
|
|
|
|
|
@@ -124,3 +126,19 @@ func formatRequest(req *http.Request) string {
|
|
return fmt.Sprintf("%s\n", requestDump)
|
|
return fmt.Sprintf("%s\n", requestDump)
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+//Unique returns unique elements in the string
|
|
|
|
+func Unique(slice []string) []string {
|
|
|
|
+ // create a map with all the values as key
|
|
|
|
+ uniqMap := make(map[string]struct{})
|
|
|
|
+ for _, v := range slice {
|
|
|
|
+ uniqMap[v] = struct{}{}
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // turn the map keys into a slice
|
|
|
|
+ uniqSlice := make([]string, 0, len(uniqMap))
|
|
|
|
+ for v := range uniqMap {
|
|
|
|
+ uniqSlice = append(uniqSlice, v)
|
|
|
|
+ }
|
|
|
|
+ return uniqSlice
|
|
|
|
+}
|