blacklist

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2025 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package blacklist provides a filter meant to exclude files from scanning.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Blacklist

type Blacklist struct {
	Patterns []Item
	// contains filtered or unexported fields
}

Blacklist wraps a number of Items.

func NewBlacklist

func NewBlacklist(patterns ...Item) *Blacklist

NewBlacklist creates a new Blacklist from the given patterns.

func (*Blacklist) Len

func (b *Blacklist) Len() int

func (*Blacklist) Less

func (b *Blacklist) Less(i, j int) bool

func (*Blacklist) Match

func (b *Blacklist) Match(path string) bool

Match tries to match the given path against all patterns in the Blacklist, until either one matches or the list is exhausted.

func (*Blacklist) Swap

func (b *Blacklist) Swap(i, j int)

type GlobItem

type GlobItem struct {
	ID      int64
	Raw     string
	Pattern glob.Glob
	Count   int64
}

GlobItem matches paths using the well-known globbing mechanism.

func (*GlobItem) GetID

func (i *GlobItem) GetID() int64

GetID returns the Item's ID

func (*GlobItem) GetPattern

func (i *GlobItem) GetPattern() string

GetPattern returns the Item's Pattern string

func (*GlobItem) HitCount

func (i *GlobItem) HitCount() int64

HitCount returns the number of times the Item has matched a path successfully

func (*GlobItem) IsGlob

func (i *GlobItem) IsGlob() bool

IsGlob returns true if the Item uses globbing (in this case: true)

func (*GlobItem) Match

func (i *GlobItem) Match(path string) bool

Match matches the given path against the Item.

type Item

type Item interface {
	GetID() int64
	GetPattern() string
	IsGlob() bool
	Match(path string) bool
	HitCount() int64
}

Item is the common interface for several types of Blacklist patterns.

func NewGlobItem

func NewGlobItem(id, cnt int64, pattern string) (Item, error)

NewGlobItem creates a new GlobItem from the given pattern

func NewReItem

func NewReItem(id, cnt int64, pattern string) (Item, error)

NewReItem creates a new Regexp-based Item

type ReItem

type ReItem struct {
	ID      int64
	Pattern *regexp.Regexp
	Count   int64
}

ReItem matches filenames against a regular expression.

func (*ReItem) GetID

func (i *ReItem) GetID() int64

GetID returns the Item's ID

func (*ReItem) GetPattern

func (i *ReItem) GetPattern() string

GetPattern returns the Item's pattern string

func (*ReItem) HitCount

func (i *ReItem) HitCount() int64

HitCount returns the number of times the Item has matched a path successfully

func (*ReItem) IsGlob

func (i *ReItem) IsGlob() bool

IsGlob returns true if the Item uses globbing (i.e. false)

func (*ReItem) Match

func (i *ReItem) Match(path string) bool

Match matches the given path against the Item.

Jump to

Keyboard shortcuts

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