| 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 | "strconvscip-go gomod github.com/golang/go/src go1.18 strconv/" |
| 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 TimeFilterscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/TimeFilter# struct { |
| 13 | msscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/TimeFilter#ms. int64 // milliseconds since first response byte |
| 14 | gtscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/TimeFilter#gt. bool // filter if response time is greater than |
| 15 | ltscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/TimeFilter#lt. bool // filter if response time is less than |
| 16 | valueRawscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/TimeFilter#valueRaw. string |
| 17 | } |
| 18 | |
| 19 | func NewTimeFilterscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/NewTimeFilter().(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) { |
| 20 | var milliseconds int64 |
| 21 | gt, lt := false, false |
| 22 | |
| 23 | gt = stringsscip-go gomod github.com/golang/go/src go1.18 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.18 strings/HasPrefix().(value, ">") |
| 24 | lt = stringsscip-go gomod github.com/golang/go/src go1.18 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.18 strings/HasPrefix().(value, "<") |
| 25 | |
| 26 | if (!lt && !gt) || (lt && gt) { |
| 27 | return &TimeFilterscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/TimeFilter#{}, fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.18 fmt/Errorf().("Time filter or matcher (-ft / -mt): invalid value: %s", value) |
| 28 | } |
| 29 | |
| 30 | milliseconds, err := strconvscip-go gomod github.com/golang/go/src go1.18 strconv/.ParseIntscip-go gomod github.com/golang/go/src go1.18 strconv/ParseInt().(value[1:], 10, 64) |
| 31 | if err != nil { |
| 32 | return &TimeFilterscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/TimeFilter#{}, fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.18 fmt/Errorf().("Time filter or matcher (-ft / -mt): invalid value: %s", value) |
| 33 | } |
| 34 | return &TimeFilterscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/TimeFilter#{msscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/TimeFilter#ms.: milliseconds, gtscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/TimeFilter#gt.: gt, ltscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/TimeFilter#lt.: lt, valueRawscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/TimeFilter#valueRaw.: value}, nil |
| 35 | } |
| 36 | |
| 37 | func (f *TimeFilterscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/TimeFilter#) MarshalJSONscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/TimeFilter#MarshalJSON().() ([]byte, error) { |
| 38 | 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 { |
| 39 | Value string `json:"value"` |
| 40 | }{ |
| 41 | Value: f.valueRawscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/TimeFilter#valueRaw., |
| 42 | }) |
| 43 | } |
| 44 | |
| 45 | func (f *TimeFilterscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/TimeFilter#) Filterscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/TimeFilter#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) { |
| 46 | if f.gtscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/TimeFilter#gt. { |
| 47 | if response.Durationscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Response#Duration..Millisecondsscip-go gomod github.com/golang/go/src go1.18 time/Duration#Milliseconds().() > f.msscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/TimeFilter#ms. { |
| 48 | return true, nil |
| 49 | } |
| 50 | |
| 51 | } else if f.ltscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/TimeFilter#lt. { |
| 52 | if response.Durationscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Response#Duration..Millisecondsscip-go gomod github.com/golang/go/src go1.18 time/Duration#Milliseconds().() < f.msscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/TimeFilter#ms. { |
| 53 | return true, nil |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | return false, nil |
| 58 | } |
| 59 | |
| 60 | func (f *TimeFilterscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/TimeFilter#) Reprscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/TimeFilter#Repr().() string { |
| 61 | return f.valueRawscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/TimeFilter#valueRaw. |
| 62 | } |
| 63 | |
| 64 | func (f *TimeFilterscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/TimeFilter#) ReprVerbosescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/TimeFilter#ReprVerbose().() string { |
| 65 | return fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.18 fmt/Sprintf().("Response time: %s", f.Reprscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/filter`/TimeFilter#Repr().()) |
| 66 | } |