scanner

package
v0.0.0-...-19e16ce Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2018 License: Apache-2.0 Imports: 35 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CountTreeEntries

func CountTreeEntries(tree *git.Tree) int

CountTreeEntries returns the number of blobs in the given tree, scanning recursively through sub-trees.

func Decompress

func Decompress(algo string, compressedStream io.Reader) (io.Reader, error)

Decompress returns an io.Reader of the decompressed contents of the given reader using the compression method specified by `algo`

func DumpDockerImage

func DumpDockerImage(i *record.DockerImage)

DumpDockerImage lists the files in an image, by layer

func FileFromBlob

func FileFromBlob(r *git.Repository, name string, blobID *git.Oid) *record.File

FileFromBlob creates a full binprint.File record from a given path and blob id. The blob id is used as the git sha and doesn't need to be calculated, but the rest of the digests are generated by reading the blob contents from the git repo and performing the normal hashing operations. If this blob was previously recorded in a binprint.Fingerprint via the FileFromExistingBlob method then this call will back-fill any of the missing digest information.

func FileFromExistingBlob

func FileFromExistingBlob(r *git.Repository, name string, blobID *git.Oid) *record.File

FileFromExistingBlob is a variant of FileFromBlob that will create a binprint.File record from the given name and blob id (what we calculate as a git sha). If there is no existing fingerprint with that git sha then nil is returned. If the existing fingerprint is incomplete (missing some digests) then this method will NOT fill them in. This method is intended to be a fastpath for git repo scanning that reads only information available in git object indices.

func FilesChannelFromTree

func FilesChannelFromTree(tree *git.Tree, numberOfBlobsInTree int) <-chan *record.File

FilesChannelFromTree creates a channel of binprint.File objects representing each file/blob in the given tree.

func FindArchives

func FindArchives(fp *record.Fingerprint) []*record.ArchiveFile

FindArchives finds all archives that directly contain a file with the given fingerprint

func FindFiles

func FindFiles(f *record.Fingerprint) []*record.File

FindFiles searches for all file records matching the provided fingerprint.

func FindMatchingFingerprint

func FindMatchingFingerprint(matcher FingerprintMatcher) *record.Fingerprint

FindMatchingFingerprint searches the in-memory database for the first fingerprint that matches the provided FingerprintMatcher

func FindRepos

func FindRepos(fp *record.Fingerprint) []*record.GitRepoSource

FindRepos finds all git repo sources (aka, git commits) that contain the provided fingerprint

func GetStore

func GetStore() record.Store

GetStore returns the current backing store being used

func GitRepoSourceFromRef

func GitRepoSourceFromRef(ref *git.Reference) *record.GitRepoSource

GitRepoSourceFromRef scans the given git ref and returns a GitRepoSource containing files/fingerprints for all the files in that ref.

func IdentifyArchiveContents

func IdentifyArchiveContents(fileName string, size int64, stat os.FileInfo, archiveBody io.Reader, depth int, limit int) (*record.File, *record.ArchiveFile)

IdentifyArchiveContents recursively scans an archive to fingerprint everything it finds

func IdentifyFile

func IdentifyFile(fileName string) *record.File

IdentifyFile scans the specified file and returns a binprint.File record of it. The result may be cached, based on the inode, mtime, and size of the file.

func IdentifyFileWithStat

func IdentifyFileWithStat(fileName string, stat os.FileInfo, bar *pb.ProgressBar) *record.File

IdentifyFileWithStat returns digest results for the provided file, either from cache or by scanning the file

func IdentifyPackageContents

func IdentifyPackageContents(fileName string, size int64, stat os.FileInfo, pkgBody io.Reader, depth int, limit int) (*record.File, *record.ArchiveFile)

IdentifyPackageContents recursively scans an package to fingerprint everything it finds

func InterestingGitRefs

func InterestingGitRefs(path string) []*git.Reference

InterestingGitRefs identifies the refs in a repo that look "interesting" and worthy of scanning.

func IsScannableArchive

func IsScannableArchive(name string) bool

IsScannableArchive checks whether the given file name looks like a supported archive format

func IsScannableImage

func IsScannableImage(name string) bool

IsScannableImage returns true if the name matches a Docker image that exists on the local Docker daemon.

func IsScannablePackage

func IsScannablePackage(name string) bool

IsScannablePackage returns true if the given filename looks like a supported package format

func IsScannablePath

func IsScannablePath(name string, stat os.FileInfo) bool

IsScannablePath returns true if the name matches an existing path that looks like something we can scan.

func PersistRememberedObjects

func PersistRememberedObjects()

PersistRememberedObjects persists the in-memory store to disk for resuscitation in future runs.

func RestoreRememberedObjects

func RestoreRememberedObjects()

RestoreRememberedObjects loads a previously persisted dump of the in-memory store in to memory so that previous work does not need to be repeated.

func ScanAndInventoryPath

func ScanAndInventoryPath(dir string)

ScanAndInventoryPath performs a recursive scan of all the files and directories rooted at the given path. Some paths are scanned using intelligent format-specific scanners. Git repos (.git folders) are scanned as a git repositories instead of as directories of files. Archive files of supported types (based on file extension only) are scanned both as a file as well as their contents being recursively scanned using the same rules. Nested archives and git repos are also scanned recursively.

func ScanDockerImages

func ScanDockerImages(names []string) []*record.DockerImage

ScanDockerImages scans docker images, by name, making use of a locally running daemon

Types

type FingerprintMatcher

type FingerprintMatcher struct {
	hash.DigestMatcher
}

FingerprintMatcher is a search operand for finding a specific Fingerprint. It is typically a truncated form of a hex encoded digest, such as "git:561fc183", which is more user friendly than the full-length sha1 digest.

func NewFingerprintMatcher

func NewFingerprintMatcher(pat string) (FingerprintMatcher, error)

NewFingerprintMatcher creates a new matcher based on the partial or complete hash of the form <algorithm>:<hex>, such as "git:561fc183".

func (FingerprintMatcher) IsExact

func (matcher FingerprintMatcher) IsExact() bool

IsExact is true for matchers that do not specify a hash algorithm and should therefore be compared to all the hashes present in a Fingerprint when matching.

func (FingerprintMatcher) Match

func (matcher FingerprintMatcher) Match(f *record.Fingerprint) bool

Match compares the matcher to the given Fingerprint and returns true if the given fingerprint satisfies the matcher.

func (FingerprintMatcher) String

func (matcher FingerprintMatcher) String() string

String returns an informational string describing the matcher, including whether or not it can be optimized for direct Fingerprint comparison or not.

Jump to

Keyboard shortcuts

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