Documentation ¶
Index ¶
- func CountTreeEntries(tree *git.Tree) int
- func Decompress(algo string, compressedStream io.Reader) (io.Reader, error)
- func DumpDockerImage(i *record.DockerImage)
- func FileFromBlob(r *git.Repository, name string, blobID *git.Oid) *record.File
- func FileFromExistingBlob(r *git.Repository, name string, blobID *git.Oid) *record.File
- func FilesChannelFromTree(tree *git.Tree, numberOfBlobsInTree int) <-chan *record.File
- func FindArchives(fp *record.Fingerprint) []*record.ArchiveFile
- func FindFiles(f *record.Fingerprint) []*record.File
- func FindMatchingFingerprint(matcher FingerprintMatcher) *record.Fingerprint
- func FindRepos(fp *record.Fingerprint) []*record.GitRepoSource
- func GetStore() record.Store
- func GitRepoSourceFromRef(ref *git.Reference) *record.GitRepoSource
- func IdentifyArchiveContents(fileName string, size int64, stat os.FileInfo, archiveBody io.Reader, ...) (*record.File, *record.ArchiveFile)
- func IdentifyFile(fileName string) *record.File
- func IdentifyFileWithStat(fileName string, stat os.FileInfo, bar *pb.ProgressBar) *record.File
- func IdentifyPackageContents(fileName string, size int64, stat os.FileInfo, pkgBody io.Reader, depth int, ...) (*record.File, *record.ArchiveFile)
- func InterestingGitRefs(path string) []*git.Reference
- func IsScannableArchive(name string) bool
- func IsScannableImage(name string) bool
- func IsScannablePackage(name string) bool
- func IsScannablePath(name string, stat os.FileInfo) bool
- func PersistRememberedObjects()
- func RestoreRememberedObjects()
- func ScanAndInventoryPath(dir string)
- func ScanDockerImages(names []string) []*record.DockerImage
- type FingerprintMatcher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CountTreeEntries ¶
CountTreeEntries returns the number of blobs in the given tree, scanning recursively through sub-trees.
func Decompress ¶
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 ¶
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 ¶
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 ¶
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 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 ¶
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 ¶
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 ¶
InterestingGitRefs identifies the refs in a repo that look "interesting" and worthy of scanning.
func IsScannableArchive ¶
IsScannableArchive checks whether the given file name looks like a supported archive format
func IsScannableImage ¶
IsScannableImage returns true if the name matches a Docker image that exists on the local Docker daemon.
func IsScannablePackage ¶
IsScannablePackage returns true if the given filename looks like a supported package format
func IsScannablePath ¶
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.