filter

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const AllStatuses = 0

Variables

This section is empty.

Functions

func FromConfig

func FromConfig(opts *ffuf.ConfigOptions, addDefaultStatusMatcher bool) (ffuf.MatcherManager, error)

FromConfig builds a MatcherManager from the parsed ConfigOptions. It is the pure, global-free core of what main.SetupFilters used to do inline, so matcher/filter setup is now unit-testable without the CLI flag package. The one CLI-explicit decision - whether to install the default status matcher - needs the global flag set, so it stays in main and is passed in as addDefaultStatusMatcher.

func NewFilterByName

func NewFilterByName(name string, value string) (ffuf.FilterProvider, error)

func NewLineFilter

func NewLineFilter(value string) (ffuf.FilterProvider, error)

func NewMatcherManager

func NewMatcherManager() ffuf.MatcherManager

func NewRegexpFilter

func NewRegexpFilter(value string) (ffuf.FilterProvider, error)

func NewSizeFilter

func NewSizeFilter(value string) (ffuf.FilterProvider, error)

func NewStatusFilter

func NewStatusFilter(value string) (ffuf.FilterProvider, error)

func NewTimeFilter

func NewTimeFilter(value string) (ffuf.FilterProvider, error)

func NewWordFilter

func NewWordFilter(value string) (ffuf.FilterProvider, error)

Types

type LineFilter

type LineFilter struct {
	Value []ffuf.ValueRange
}

func (*LineFilter) Filter

func (f *LineFilter) Filter(response *ffuf.Response) (bool, error)

func (*LineFilter) MarshalJSON

func (f *LineFilter) MarshalJSON() ([]byte, error)

func (*LineFilter) Repr

func (f *LineFilter) Repr() string

func (*LineFilter) ReprVerbose

func (f *LineFilter) ReprVerbose() string

type MatcherManager

type MatcherManager struct {
	// contains filtered or unexported fields
}

MatcherManager handles both filters and matchers. Writers serialize under mu, copy only the maps they change, then atomically publish a fully immutable snapshot. Matches reads one snapshot without locks or per-response map copies. The public map getters still return defensive copies because their callers are outside this package and may retain or modify the returned map.

func (*MatcherManager) AddFilter

func (f *MatcherManager) AddFilter(name string, option string, replace bool) error

AddFilter adds a new filter to MatcherManager

func (*MatcherManager) AddFilters

func (f *MatcherManager) AddFilters(options map[string]string) error

AddFilters appends a batch of metric filters and publishes the complete update with one atomic snapshot store. This is intentionally narrower than AddFilter: live web scans retain only response metrics, not response bodies, so regexp filters cannot be applied consistently to results seen before the update. Callers use this method for monotonic post-start filtering.

Existing values of the same type are retained. For the normal "or" filter mode this can only remove additional findings; it can never make a previously filtered response visible. Per-domain autocalibration snapshots receive the same additions so -ach does not bypass a filter added while a scan is live.

func (*MatcherManager) AddMatcher

func (f *MatcherManager) AddMatcher(name string, option string) error

AddMatcher adds a new matcher to Config

func (*MatcherManager) AddPerDomainFilter

func (f *MatcherManager) AddPerDomainFilter(domain string, name string, option string) error

AddPerDomainFilter adds a new filter to PerDomainFilter configuration

func (*MatcherManager) Calibrated

func (f *MatcherManager) Calibrated() bool

func (*MatcherManager) CalibratedForDomain

func (f *MatcherManager) CalibratedForDomain(domain string) bool

func (*MatcherManager) FiltersForDomain

func (f *MatcherManager) FiltersForDomain(domain string) map[string]ffuf.FilterProvider

func (*MatcherManager) GetFilters

func (f *MatcherManager) GetFilters() map[string]ffuf.FilterProvider

func (*MatcherManager) GetMatchers

func (f *MatcherManager) GetMatchers() map[string]ffuf.FilterProvider

func (*MatcherManager) MarshalJSON

func (f *MatcherManager) MarshalJSON() ([]byte, error)

MarshalJSON preserves MatcherManager's historical exported JSON shape even though its mutable maps now live behind an unexported atomic snapshot.

func (*MatcherManager) Matches

func (f *MatcherManager) Matches(resp *ffuf.Response, perHost bool, matcherMode string, filterMode string) bool

Matches reports whether resp passes the configured matchers and filters. It is the match decision that used to live in Job.isMatch, moved here so it sits with the rule data it decides over and is unit-testable without an engine. perHost selects the per-domain filter set (autocalibration -ach); matcherMode/filterMode are the and/or combination modes. One atomic load pins all rule maps for the decision; writers never mutate maps reachable from a published snapshot.

func (*MatcherManager) RemoveFilter

func (f *MatcherManager) RemoveFilter(name string)

RemoveFilter removes a filter of a given type

func (*MatcherManager) SetCalibrated

func (f *MatcherManager) SetCalibrated(value bool)

func (*MatcherManager) SetCalibratedForHost

func (f *MatcherManager) SetCalibratedForHost(host string, value bool)

type PerDomainFilter

type PerDomainFilter struct {
	IsCalibrated bool
	Filters      map[string]ffuf.FilterProvider
}

PerDomainFilter is kept as a detached compatibility value for callers of NewPerDomainFilter. MatcherManager never publishes this mutable type.

func NewPerDomainFilter

func NewPerDomainFilter(globfilters map[string]ffuf.FilterProvider) *PerDomainFilter

NewPerDomainFilter copies the supplied (global) filter map. Storing the map by reference aliased the global Filters, so a per-domain filter write mutated the global filter set and leaked into every host.

func (*PerDomainFilter) SetCalibrated

func (p *PerDomainFilter) SetCalibrated(value bool)

type RegexpFilter

type RegexpFilter struct {
	Value *regexp.Regexp
	// contains filtered or unexported fields
}

func (*RegexpFilter) Filter

func (f *RegexpFilter) Filter(response *ffuf.Response) (bool, error)

func (*RegexpFilter) MarshalJSON

func (f *RegexpFilter) MarshalJSON() ([]byte, error)

func (*RegexpFilter) Repr

func (f *RegexpFilter) Repr() string

func (*RegexpFilter) ReprVerbose

func (f *RegexpFilter) ReprVerbose() string

type SizeFilter

type SizeFilter struct {
	Value []ffuf.ValueRange
}

func (*SizeFilter) Filter

func (f *SizeFilter) Filter(response *ffuf.Response) (bool, error)

func (*SizeFilter) MarshalJSON

func (f *SizeFilter) MarshalJSON() ([]byte, error)

func (*SizeFilter) Repr

func (f *SizeFilter) Repr() string

func (*SizeFilter) ReprVerbose

func (f *SizeFilter) ReprVerbose() string

type StatusFilter

type StatusFilter struct {
	Value []ffuf.ValueRange
}

func (*StatusFilter) Filter

func (f *StatusFilter) Filter(response *ffuf.Response) (bool, error)

func (*StatusFilter) MarshalJSON

func (f *StatusFilter) MarshalJSON() ([]byte, error)

func (*StatusFilter) Repr

func (f *StatusFilter) Repr() string

func (*StatusFilter) ReprVerbose

func (f *StatusFilter) ReprVerbose() string

type TimeFilter

type TimeFilter struct {
	// contains filtered or unexported fields
}

func (*TimeFilter) Filter

func (f *TimeFilter) Filter(response *ffuf.Response) (bool, error)

func (*TimeFilter) MarshalJSON

func (f *TimeFilter) MarshalJSON() ([]byte, error)

func (*TimeFilter) Repr

func (f *TimeFilter) Repr() string

func (*TimeFilter) ReprVerbose

func (f *TimeFilter) ReprVerbose() string

type WordFilter

type WordFilter struct {
	Value []ffuf.ValueRange
}

func (*WordFilter) Filter

func (f *WordFilter) Filter(response *ffuf.Response) (bool, error)

func (*WordFilter) MarshalJSON

func (f *WordFilter) MarshalJSON() ([]byte, error)

func (*WordFilter) Repr

func (f *WordFilter) Repr() string

func (*WordFilter) ReprVerbose

func (f *WordFilter) ReprVerbose() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL