Documentation
¶
Index ¶
- type Decomposer
- func (d *Decomposer) BuildNodeList(set *ModuleSet, opts *api.DecomposerOptions) (*sbom.NodeList, error)
- func (d *Decomposer) DefaultOptions() any
- func (d *Decomposer) Extract(opts *api.DecomposerOptions) (*sbom.NodeList, error)
- func (d *Decomposer) FindCodeBases(index *code.PathIndex) ([]string, error)
- func (d *Decomposer) Requirements(_ *api.DecomposerOptions) []api.Requirement
- type Module
- type ModuleSet
- type Options
- type Replacement
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Decomposer ¶
type Decomposer struct{}
func New ¶
func New() *Decomposer
func (*Decomposer) BuildNodeList ¶ added in v0.3.3
func (d *Decomposer) BuildNodeList(set *ModuleSet, opts *api.DecomposerOptions) (*sbom.NodeList, error)
BuildNodeList renders a module set as a protobom NodeList: a root node for the main module, the stdlib at the set's Go version, one node per module reached through the graph with its checksums, and typed edges between them. Edges come from each module's go.mod, read from the local module cache and, when the networking level allows, from the module proxy; with networking enabled, dependency nodes are also enriched with license and source repository data.
func (*Decomposer) DefaultOptions ¶
func (d *Decomposer) DefaultOptions() any
func (*Decomposer) Extract ¶
func (d *Decomposer) Extract(opts *api.DecomposerOptions) (*sbom.NodeList, error)
Extract parses the local go.mod file, fetches dependency information from the Go module proxy, and builds the complete dependency graph as a protobom NodeList.
func (*Decomposer) FindCodeBases ¶
func (d *Decomposer) FindCodeBases(index *code.PathIndex) ([]string, error)
func (*Decomposer) Requirements ¶
func (d *Decomposer) Requirements(_ *api.DecomposerOptions) []api.Requirement
Requirements returns the requirements for the decomposer. No external binary required - uses pure Go implementation.
type Module ¶ added in v0.3.3
Module identifies one Go module at one version. Sums carries the module's checksums the way go.sum and Go binaries record them, "h1:" prefixed.
type ModuleSet ¶ added in v0.3.3
type ModuleSet struct {
// Main is the module the graph is rooted at. Only its path is read.
Main Module
// GoVersion is the Go release the program targets, without the "go"
// prefix ("1.24.0"). When set, the root gets a stdlib dependency at
// that version.
GoVersion string
// Requires lists the modules the main module requires directly. Each
// becomes an edge from the root.
Requires []Module
// Indirect lists the modules the main module requires on behalf of
// its dependencies (go.mod's "// indirect"). They are part of the
// build, so each is expected to be reached through the go.mod of the
// module that needs it. One that no edge reaches (its parent declares
// no requirements, or its go.mod could not be read) is attached to
// the root instead, so that it is not lost from the graph.
Indirect []Module
// Modules lists every module in the build, Requires included. This is
// the set edges are resolved within: a requirement of one of these
// modules only becomes an edge when its target is also in the set.
Modules []Module
// Replaces maps a module path, or a module@version, to its replacement.
// It is consulted when matching a module's requirements against the
// set, so replaced paths resolve to the module actually built.
Replaces map[string]Replacement
}
ModuleSet is the input to the Go graph builder: a program's main module and the modules built into it. A go.mod/go.sum pair reduces to one, and so does the build info embedded in a Go binary, which is what lets the same builder render both.
Edges among Modules are resolved from each module's own go.mod (see resolveGraph). A module that no edge reaches, not even from the root, is not emitted, unless it is listed under Indirect; list every module a flat inventory must show under Requires.
type Options ¶
type Options struct {
IncludeGo bool
ProxyURL string // default: https://proxy.golang.org
HTTPClient *http.Client // allow HTTP custom client for testing
Concurrency int // number of parallel HTTP requests (default: 10)
// PreferModuleCache reads dependency go.mod files from the local Go
// module cache before asking the proxy. The cache holds a copy the
// go command has already verified against go.sum, so the data is the
// same, but the proxy stays authoritative unless this is set.
PreferModuleCache bool
}
Options configures the Go dependency extraction
type Replacement ¶ added in v0.3.3
Replacement is the target of a replace directive: the module path and version that stand in for the replaced module. An empty Path keeps the original path and replaces the version alone.