Documentation
¶
Overview ¶
Package manifests parses dependency manifest and lockfile formats across package ecosystems.
It supports 40+ ecosystems including npm, gem, pypi, cargo, maven, and more. Each ecosystem uses its PURL type as the identifier.
Basic usage:
result, err := manifests.Parse("package.json", content)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Ecosystem: %s, Kind: %s\n", result.Ecosystem, result.Kind)
for _, dep := range result.Dependencies {
fmt.Printf(" %s %s\n", dep.Name, dep.Version)
}
Index ¶
- Constants
- func Ecosystems() []string
- type Declaration
- type Dependency
- type DiscoveredManifest
- type FSReader
- type Kind
- type Match
- type Options
- type ParseError
- type ParseResult
- type RepositoryReader
- type Scope
- type Source
- type SourceKind
- type UnknownFileError
- type VendorDiscovery
- type VendorRoot
- type VendoredDependency
Constants ¶
const ( Manifest Kind = core.Manifest Lockfile Kind = core.Lockfile Supplement Kind = core.Supplement Vendor Kind = core.Vendor Runtime Scope = core.Runtime Development Scope = core.Development Test Scope = core.Test Build Scope = core.Build Optional Scope = core.Optional SourceRegistry SourceKind = core.SourceRegistry SourceGit SourceKind = core.SourceGit SourcePath SourceKind = core.SourcePath SourceGitHub SourceKind = core.SourceGitHub SourceURL SourceKind = core.SourceURL )
Re-export constants.
Variables ¶
This section is empty.
Functions ¶
func Ecosystems ¶
func Ecosystems() []string
Ecosystems returns a list of all supported PURL ecosystem types.
Types ¶
type Declaration ¶ added in v0.9.0
type Declaration = core.Declaration
Declaration represents a dependency-like reference at a stable logical location in a manifest. Location is ecosystem-specific and opaque. Before v1, callers constructing values should use keyed fields so additive metadata fields remain source-compatible.
type Dependency ¶
type Dependency = core.Dependency
Dependency represents a parsed dependency. Its Integrity field is an opaque verification value whose digest encoding depends on the source format. Before v1, callers constructing values should use keyed fields so additive metadata fields remain source-compatible.
type DiscoveredManifest ¶ added in v0.8.0
DiscoveredManifest identifies a project or workspace manifest. ParentPath is the repository-relative workspace configuration that selected a nested manifest; it is empty for root and path-based manifests.
func DiscoverManifests ¶ added in v0.8.0
func DiscoverManifests(reader RepositoryReader) ([]DiscoveredManifest, []error)
DiscoverManifests returns the project and workspace manifests selected from a rooted repository. It does not parse dependency declarations. Warnings report workspace configurations or lookups that could not be processed; successfully discovered manifests are still returned.
type FSReader ¶ added in v0.8.0
type FSReader struct {
// contains filtered or unexported fields
}
FSReader adapts an fs.FS to RepositoryReader. It supports recursive ** globs.
func NewFSReader ¶ added in v0.8.0
NewFSReader returns a repository reader rooted at fsys. Use os.DirFS to discover manifests in a working tree.
type Match ¶
Match represents a file type match.
func IdentifyAll ¶
IdentifyAll returns all matching ecosystems for a filename.
type Options ¶ added in v0.5.1
type Options struct {
// FSRoot, when non-empty, allows parsers that consult neighbouring
// files on disk (currently only pom.xml, for parent <relativePath>
// resolution) to do so within this directory. Paths outside it are
// refused. When empty, parsing is a pure function of content and no
// filesystem access occurs; this is the safe choice for untrusted
// input.
FSRoot string
}
Options configures Parse.
type ParseResult ¶
type ParseResult struct {
Ecosystem string
Kind Kind
// Name is the package's own name as declared in the manifest, when
// the format has one. Empty for lockfiles and for formats that
// only list dependencies (Gemfile, requirements.txt, etc.).
Name string
// Version is the package's own version as declared in the
// manifest, when present.
Version string
// Licenses holds the package's declared license values, verbatim as
// written in the manifest. Empty when the format has no license field
// or none is set. Scalar formats produce a single-element slice.
Licenses []string
// LicenseFile is a manifest-relative path to a license file when the
// format declares one instead of, or as well as, an expression.
LicenseFile string
// Digest is a file-level verification value whose meaning is defined by
// the manifest format. It does not apply to individual dependencies.
Digest string
Dependencies []Dependency
// Declarations holds source-level references when the parser preserves
// their logical locations. Unlike Dependencies, these entries are not
// merged, inherited, or otherwise resolved into an effective model.
Declarations []Declaration
// Sources preserves manifest-level source declarations in source order.
// A source declaration does not imply that any dependency resolved there.
Sources []Source
}
ParseResult contains the parsed dependencies from a manifest or lockfile. Before v1, callers constructing values should use keyed fields so additive metadata fields remain source-compatible.
type RepositoryReader ¶ added in v0.8.0
type RepositoryReader interface {
ReadFile(name string) ([]byte, error)
Glob(pattern string) ([]string, error)
}
RepositoryReader provides bounded access to files in a repository. Paths and glob patterns use forward slashes and are relative to the repository root. Glob must support the doublestar dialect, including recursive ** patterns. ReadFile should return an error matching fs.ErrNotExist for absent files.
type Source ¶ added in v0.11.0
Source preserves a literal manifest source declaration. It does not report a resolved package location.
type SourceKind ¶ added in v0.11.0
type SourceKind = core.SourceKind
Re-export types from internal/core for public API.
type UnknownFileError ¶
type UnknownFileError struct {
Filename string
}
UnknownFileError is returned when a file type is not recognized.
func (*UnknownFileError) Error ¶
func (e *UnknownFileError) Error() string
type VendorDiscovery ¶ added in v0.8.0
type VendorDiscovery struct {
Roots []VendorRoot
Dependencies []VendoredDependency
}
VendorDiscovery contains classified vendor roots and the package identities discovered beneath them.
func DiscoverVendors ¶ added in v0.8.0
func DiscoverVendors(reader RepositoryReader) (VendorDiscovery, []error)
DiscoverVendors finds package-manager vendor roots and exact package identities in a rooted repository. Warnings report malformed configuration, unreadable evidence, or incomplete package identities while retaining all successfully discovered results.
type VendorRoot ¶ added in v0.8.0
VendorRoot identifies a repository directory containing vendored packages. ConfigPath is the configuration or inventory that selected the root. It is empty for convention-based roots such as node_modules.
type VendoredDependency ¶ added in v0.8.0
type VendoredDependency struct {
Name string
Version string
Ecosystem string
Kind Kind
PURL string
RootPath string
EvidencePath string
}
VendoredDependency is an exact package version stored under a vendor root. EvidencePath identifies the repository file from which the package identity was read.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
chef
Package chef parses Chef cookbook manifests without evaluating Ruby.
|
Package chef parses Chef cookbook manifests without evaluating Ruby. |
|
core
Package core provides shared types and the parser registry.
|
Package core provides shared types and the parser registry. |
|
vagrant
Package vagrant parses Vagrant box declarations without evaluating Ruby.
|
Package vagrant parses Vagrant box declarations without evaluating Ruby. |