| 1 | package filterscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/ |
| 2 | |
| 3 | import ( |
| 4 | "encoding/jsonscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/" |
| 5 | "fmtscip-go gomod github.com/golang/go/src go1.18 fmt/" |
| 6 | "regexpscip-go gomod github.com/golang/go/src go1.18 regexp/" |
| 7 | "stringsscip-go gomod github.com/golang/go/src go1.18 strings/" |
| 8 | |
| 9 | "github.com/ffuf/ffuf/v2/pkg/ffufscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/" |
| 10 | ) |
| 11 | |
| 12 | type RegexpFilterscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/RegexpFilter# struct { |
| 13 | Valuescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/RegexpFilter#Value. *regexpscip-go gomod github.com/golang/go/src go1.18 regexp/.Regexpscip-go gomod github.com/golang/go/src go1.18 regexp/Regexp# |
| 14 | valueRawscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/RegexpFilter#valueRaw. string |
| 15 | } |
| 16 | |
| 17 | func NewRegexpFilterscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/NewRegexpFilter().(value string) (ffufscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/.FilterProviderscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/FilterProvider#, error) { |
| 18 | re, err := regexpscip-go gomod github.com/golang/go/src go1.18 regexp/.Compilescip-go gomod github.com/golang/go/src go1.18 regexp/Compile().(value) |
| 19 | if err != nil { |
| 20 | return &RegexpFilterscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/RegexpFilter#{}, fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.18 fmt/Errorf().("Regexp filter or matcher (-fr / -mr): invalid value: %s", value) |
| 21 | } |
| 22 | return &RegexpFilterscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/RegexpFilter#{Valuescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/RegexpFilter#Value.: re, valueRawscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/RegexpFilter#valueRaw.: value}, nil |
| 23 | } |
| 24 | |
| 25 | func (f *RegexpFilterscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/RegexpFilter#) MarshalJSONscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/RegexpFilter#MarshalJSON().() ([]byte, error) { |
| 26 | return jsonscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/.Marshalscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/Marshal().(&struct { |
| 27 | Value string `json:"value"` |
| 28 | }{ |
| 29 | Value: f.valueRawscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/RegexpFilter#valueRaw., |
| 30 | }) |
| 31 | } |
| 32 | |
| 33 | func (f *RegexpFilterscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/RegexpFilter#) Filterscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/RegexpFilter#Filter().(response *ffufscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/.Responsescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Response#) (bool, error) { |
| 34 | matchheaders := "" |
| 35 | for k, v := range response.Headersscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Response#Headers. { |
| 36 | for _, iv := range v { |
| 37 | matchheaders += k + ": " + iv + "\r\n" |
| 38 | } |
| 39 | } |
| 40 | matchdata := []byte(matchheaders) |
| 41 | matchdata = append(matchdata, response.Datascip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Response#Data....) |
| 42 | pattern := f.valueRawscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/RegexpFilter#valueRaw. |
| 43 | for keyword, inputitem := range response.Requestscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Response#Request..Inputscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Request#Input. { |
| 44 | pattern = stringsscip-go gomod github.com/golang/go/src go1.18 strings/.ReplaceAllscip-go gomod github.com/golang/go/src go1.18 strings/ReplaceAll().(pattern, keyword, regexpscip-go gomod github.com/golang/go/src go1.18 regexp/.QuoteMetascip-go gomod github.com/golang/go/src go1.18 regexp/QuoteMeta().(string(inputitem))) |
| 45 | } |
| 46 | matched, err := regexpscip-go gomod github.com/golang/go/src go1.18 regexp/.Matchscip-go gomod github.com/golang/go/src go1.18 regexp/Match().(pattern, matchdata) |
| 47 | if err != nil { |
| 48 | return false, nil |
| 49 | } |
| 50 | return matched, nil |
| 51 | } |
| 52 | |
| 53 | func (f *RegexpFilterscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/RegexpFilter#) Reprscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/RegexpFilter#Repr().() string { |
| 54 | return f.valueRawscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/RegexpFilter#valueRaw. |
| 55 | } |
| 56 | |
| 57 | func (f *RegexpFilterscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/RegexpFilter#) ReprVerbosescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/RegexpFilter#ReprVerbose().() string { |
| 58 | return fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.18 fmt/Sprintf().("Regexp: %s", f.valueRawscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/RegexpFilter#valueRaw.) |
| 59 | } |