crawl

package
v0.3.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

This section is empty.

Types

type ArchiveFileLister

type ArchiveFileLister func(ctx context.Context, path string) ([]string, error)

ArchiveFileLister lists the files contained within an archive.

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 the given filesystem, fSys, from the root of it. Each file will be passed to the math function, which should return true if the path should then be processed by the process function. On encountering a directory, the path will be compared against all IgnoreDirs configured in the Crawler. If any pattern matches, all files nested inside the directory will be ignored.

type Finding

type Finding int

type Identifier

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

func NewIdentifier

func NewIdentifier(archiveListTimeout time.Duration, zipLister, tgzLister ArchiveFileLister) Identifier

type MatchFunc

type MatchFunc func(ctx context.Context, path string, d fs.DirEntry) (Finding, string, 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 string)

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, version string)

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

Jump to

Keyboard shortcuts

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