Documentation ¶
Index ¶
- func CombinePackage(p1, p2 *model.Package) *model.Package
- func EqualPackage(p1, p2 *model.Package) bool
- func OrganizePackage(pkgs []model.Package) []model.Package
- func SortPackage(pkgs []model.Package) []model.Package
- func StrictMode() bool
- type BaseCollector
- type Collector
- type DependencyTree
- func (tree *DependencyTree) AddDependency(mainPurl, depPurl string)
- func (tree *DependencyTree) AddPackage(pkg *model.Package)
- func (tree *DependencyTree) GetDependencies(purl string) []model.Package
- func (tree *DependencyTree) GetPackage(purl string) *model.Package
- func (tree *DependencyTree) GetPackagesByName(name string) []model.Package
- func (tree *DependencyTree) GetRootPackages() []model.Package
- func (tree *DependencyTree) IsExist(purl string) bool
- func (tree *DependencyTree) ToList() []model.Package
- type File
- type FileMatcher
- type FileMeta
- type FileMimeMatcher
- type FileNameMatcher
- type FileParser
- type FilePatternMatcher
- type FileRegexpMatcher
- type MainPkgParser
- type Request
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CombinePackage ¶
CombinePackage combines two packages into one package
func EqualPackage ¶
EqualPackage checks two packages are equal
func OrganizePackage ¶
OrganizePackage remove and merge duplicate packages
func SortPackage ¶
SortPackage sorts packages by PURL
Types ¶
type BaseCollector ¶
type BaseCollector struct { Name string PurlType string Parsers []FileParser Requests []Request }
BaseCollector provide common properties and behaviors inherited by other collectors
func (*BaseCollector) GetName ¶
func (c *BaseCollector) GetName() string
func (*BaseCollector) GetParsers ¶
func (c *BaseCollector) GetParsers() []FileParser
func (*BaseCollector) GetPurlType ¶
func (c *BaseCollector) GetPurlType() string
func (*BaseCollector) GetRequests ¶
func (c *BaseCollector) GetRequests() []Request
func (*BaseCollector) TryToAccept ¶
func (c *BaseCollector) TryToAccept(file File)
type Collector ¶
type Collector interface { // GetName uniquely describes a Collector GetName() string // GetPurlType return a string value according to the package url spec. For details, // ref https://github.com/package-url/purl-spec GetPurlType() string // GetParsers return inner FileParsers GetParsers() []FileParser // TryToAccept try to match the given file using inner FileParsers respectively, accept the file if matched TryToAccept(file File) // GetRequests return requests generated at TryToAccept phase GetRequests() []Request // Collect analyze the accepted files and return discovered packages Collect() (pkgs []model.Package, err error) }
Collector contains a group of FileParsers, and define common method among the FileParsers
type DependencyTree ¶
type DependencyTree struct {
// contains filtered or unexported fields
}
DependencyTree maintains the package list and dependencies, and provides some useful methods
func NewDependencyTree ¶
func NewDependencyTree() *DependencyTree
func (*DependencyTree) AddDependency ¶
func (tree *DependencyTree) AddDependency(mainPurl, depPurl string)
AddDependency adds a dependency, will add the dependency's PURL to the dependency list of the main package, and the main package must exist
func (*DependencyTree) AddPackage ¶
func (tree *DependencyTree) AddPackage(pkg *model.Package)
AddPackage adds package to the list, check whether the package exists through PURL, if exists, the package properties will be combined
func (*DependencyTree) GetDependencies ¶
func (tree *DependencyTree) GetDependencies(purl string) []model.Package
GetDependencies get a package's dependency list via PURL
func (*DependencyTree) GetPackage ¶
func (tree *DependencyTree) GetPackage(purl string) *model.Package
GetPackage get a package via PURL
func (*DependencyTree) GetPackagesByName ¶
func (tree *DependencyTree) GetPackagesByName(name string) []model.Package
GetPackagesByName get packages via name
func (*DependencyTree) GetRootPackages ¶
func (tree *DependencyTree) GetRootPackages() []model.Package
GetRootPackages get root packages
func (*DependencyTree) IsExist ¶
func (tree *DependencyTree) IsExist(purl string) bool
IsExist Check if package exists via PURL
func (*DependencyTree) ToList ¶
func (tree *DependencyTree) ToList() []model.Package
ToList returns a list of all packages
type File ¶
type File interface { FullName() string Dir() string FileName() string Mime() string Stat() os.FileInfo }
File define file basic information
func NewFileMeta ¶
type FileMatcher ¶
FileMatcher is a file parser, check whether a file matches a rule
type FileMeta ¶
type FileMeta struct {
// contains filtered or unexported fields
}
FileMeta contains file basic information
type FileMimeMatcher ¶
type FileMimeMatcher struct {
Mimes []string
}
FileMimeMatcher match a file by file mime
func (*FileMimeMatcher) Description ¶
func (f *FileMimeMatcher) Description() string
func (*FileMimeMatcher) Match ¶
func (f *FileMimeMatcher) Match(file File) bool
type FileNameMatcher ¶
type FileNameMatcher struct {
Names []string
}
FileNameMatcher match a file by file name
func (*FileNameMatcher) Description ¶
func (f *FileNameMatcher) Description() string
func (*FileNameMatcher) Match ¶
func (f *FileNameMatcher) Match(file File) bool
type FileParser ¶
type FileParser interface { // Matcher return the specified file parser Matcher() FileMatcher // Parse the given path and return discovered packages Parse(path string) (pkgs []model.Package, err error) }
FileParser specify a FileMatcher to match files, and parse the recognizable files to discover packages
type FilePatternMatcher ¶
type FilePatternMatcher struct { // the pattern ref https://pkg.go.dev/path/filepath#Match Patterns []string }
FilePatternMatcher match a file by file pattern
func (*FilePatternMatcher) Description ¶
func (f *FilePatternMatcher) Description() string
func (*FilePatternMatcher) Match ¶
func (f *FilePatternMatcher) Match(file File) bool
type FileRegexpMatcher ¶
FileRegexpMatcher match a file by regexp
func (*FileRegexpMatcher) Description ¶
func (f *FileRegexpMatcher) Description() string
func (*FileRegexpMatcher) Match ¶
func (f *FileRegexpMatcher) Match(file File) bool
type MainPkgParser ¶
MainPkgParser parse a file and generate main package
type Request ¶
type Request struct { File File Parser FileParser }
Request represents a file and parser pair, and the parser can recognize and parse the file