From 11286210e5252ede626769714c42c5d2b2b8819b Mon Sep 17 00:00:00 2001 From: mzack Date: Thu, 24 Feb 2022 22:50:41 +0100 Subject: [PATCH] using helper dedupeint --- v2/go.mod | 1 + v2/go.sum | 2 ++ v2/pkg/protocols/file/request.go | 15 ++------------- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/v2/go.mod b/v2/go.mod index 8ac00128..1c81e97c 100644 --- a/v2/go.mod +++ b/v2/go.mod @@ -132,6 +132,7 @@ require ( github.com/projectdiscovery/blackrock v0.0.0-20210415162320-b38689ae3a2e // indirect github.com/projectdiscovery/mapcidr v0.0.8 // indirect github.com/projectdiscovery/networkpolicy v0.0.1 // indirect + github.com/projectdiscovery/sliceutil v0.0.0-20220224214822-d49100b78872 // indirect github.com/rivo/uniseg v0.2.0 // indirect github.com/tklauser/go-sysconf v0.3.9 // indirect github.com/tklauser/numcpus v0.3.0 // indirect diff --git a/v2/go.sum b/v2/go.sum index 7b060379..77964e01 100644 --- a/v2/go.sum +++ b/v2/go.sum @@ -467,6 +467,8 @@ github.com/projectdiscovery/retryabledns v1.0.13-0.20211109182249-43d38df59660/g github.com/projectdiscovery/retryablehttp-go v1.0.1/go.mod h1:SrN6iLZilNG1X4neq1D+SBxoqfAF4nyzvmevkTkWsek= github.com/projectdiscovery/retryablehttp-go v1.0.2 h1:LV1/KAQU+yeWhNVlvveaYFsjBYRwXlNEq0PvrezMV0U= github.com/projectdiscovery/retryablehttp-go v1.0.2/go.mod h1:dx//aY9V247qHdsRf0vdWHTBZuBQ2vm6Dq5dagxrDYI= +github.com/projectdiscovery/sliceutil v0.0.0-20220224214822-d49100b78872 h1:wEFENYLz3Nol3XFvSRuOqWUTTEwFk/zF7JmbDaVbWx8= +github.com/projectdiscovery/sliceutil v0.0.0-20220224214822-d49100b78872/go.mod h1:QHXvznfPfA5f0AZUIBkbLapoUJJlsIDgUlkKva6dOr4= github.com/projectdiscovery/stringsutil v0.0.0-20210804142656-fd3c28dbaafe/go.mod h1:oTRc18WBv9t6BpaN9XBY+QmG28PUpsyDzRht56Qf49I= github.com/projectdiscovery/stringsutil v0.0.0-20210823090203-2f5f137e8e1d/go.mod h1:oTRc18WBv9t6BpaN9XBY+QmG28PUpsyDzRht56Qf49I= github.com/projectdiscovery/stringsutil v0.0.0-20210830151154-f567170afdd9/go.mod h1:oTRc18WBv9t6BpaN9XBY+QmG28PUpsyDzRht56Qf49I= diff --git a/v2/pkg/protocols/file/request.go b/v2/pkg/protocols/file/request.go index 08d22183..4beb010a 100644 --- a/v2/pkg/protocols/file/request.go +++ b/v2/pkg/protocols/file/request.go @@ -19,6 +19,7 @@ import ( "github.com/projectdiscovery/nuclei/v2/pkg/protocols/common/helpers/eventcreator" "github.com/projectdiscovery/nuclei/v2/pkg/protocols/common/helpers/responsehighlighter" templateTypes "github.com/projectdiscovery/nuclei/v2/pkg/templates/types" + "github.com/projectdiscovery/sliceutil" ) var _ protocols.Request = &Request{} @@ -161,19 +162,7 @@ func calculateLineFunc(allMatches []*output.InternalEvent, words map[string]stru } _ = word } - lines = unique(lines) + lines = sliceutil.DedupeInt(lines) sort.Ints(lines) return lines } - -func unique(intSlice []int) []int { - keys := make(map[int]bool) - list := []int{} - for _, entry := range intSlice { - if _, value := keys[entry]; !value { - keys[entry] = true - list = append(list, entry) - } - } - return list -}