crawl

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NothingDetected      Finding = 0
	ClassName                    = 1 << iota
	JarName                      = 1 << iota
	JarNameInsideArchive         = 1 << iota
	ClassPackageAndName          = 1 << iota
	ClassFileMd5                 = 1 << iota
)
View Source
const (
	UnknownVersion = "unknown"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Crawler

type Crawler struct {
	IgnoreDirs []*regexp.Regexp
}

Crawler crawls filesystems, matching and conditionally processing files.

func (Crawler) Crawl

func (c Crawler) Crawl(ctx context.Context, root string, match MatchFunc, process ProcessFunc) error

Crawl crawls the provided root directory. Each file is passed to the provided match function, which returns true if the path should be processed by the provided process function. On encountering a directory, the path will be compared against all IgnoreDirs configured in the Crawler. If any pattern matches, the directory (and all files nested inside the directory) will be ignored.

type Finding

type Finding int

func (Finding) String added in v0.5.0

func (f Finding) String() string

type Identifier

type Identifier interface {
	Identify(ctx context.Context, path string, d fs.DirEntry) (Finding, Versions, error)
}

func NewIdentifier

func NewIdentifier(archiveListTimeout time.Duration, zipWalker, tgzWalker archive.WalkFn) Identifier

type MatchFunc

type MatchFunc func(ctx context.Context, path string, d fs.DirEntry) (Finding, Versions, error)

MatchFunc is used to match a file for processing. If returning a positive finding, a file will be passed onto the ProcessFunc.

type ProcessFunc

type ProcessFunc func(ctx context.Context, path string, d fs.DirEntry, result Finding, version Versions)

ProcessFunc processes the given matched file.

type Reporter

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

func (*Reporter) Collect

func (r *Reporter) Collect(ctx context.Context, path string, d fs.DirEntry, result Finding, versionSet Versions)

Collect increments the count of number of calls to Reporter.Collect and logs the path of the vulnerable file to disk.

func (Reporter) Count

func (r Reporter) Count() int64

Count returns the number of times that Collect has been called

type Versions added in v0.5.0

type Versions map[string]struct{}

Jump to

Keyboard shortcuts

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