ecosystem

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ecosystem encapsulates all language-specific behavior needed to detect and apply dependency-vulnerability bumps for a melange package. Exactly one Ecosystem is selected per package (see internal/gobump's language-detection logic); every ecosystem implementation renders melange bump/go-bump pipeline entries in its own grammar, but the pipeline reconciliation logic in internal/gobump treats those entries as opaque strings and is itself language-agnostic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Names

func Names() []string

Names returns every registered language token, sorted, so callers can enumerate known languages (e.g. to check for a per-language annotation) without hardcoding the list themselves.

func Register

func Register(language string, factory func() Ecosystem)

Register registers a factory for the named ecosystem language token.

func WriteTempFiles

func WriteTempFiles(files map[string][]byte) (dir string, cleanup func(), err error)

WriteTempFiles materializes files into a fresh temporary directory, preserving their relative paths, for ecosystems whose underlying tooling requires a real directory rather than in-memory content (see the Rust ecosystem, whose omnibump analyzer has no checkout-free AnalyzeRemote). The caller must call the returned cleanup func when done.

Types

type Dep

type Dep struct {
	// Coord is the ecosystem-natural coordinate: Go "module/path", Rust
	// "crate", Java "groupId:artifactId".
	Coord string
	// Name is the OSV query name for this dependency (often equal to Coord).
	Name       string
	Version    string
	GroupID    string // Java only
	ArtifactID string // Java only
	Indirect   bool
}

Dep is a single dependency in a modroot's normalized view.

type Ecosystem

type Ecosystem interface {
	// Name is the melange with.language: token ("go", "rust", "java").
	Name() string

	// ManifestFiles are the modroot-relative filenames to fetch for a modroot.
	ManifestFiles() []string

	// Analyze turns fetched manifest content into a normalized per-modroot
	// dependency view. files is keyed by the basenames from ManifestFiles().
	// Implementations that can't analyze in-memory content (because the
	// underlying tooling requires a real directory) are responsible for
	// materializing files to a temporary directory internally.
	Analyze(ctx context.Context, files map[string][]byte) (*ModuleDeps, error)

	// ScanPackages maps the modroot's dependencies into OSV query inputs.
	ScanPackages(deps *ModuleDeps) []scan.Package

	// FilterBumps merges a modroot's existing declared melange deps with
	// fresh OSV security bumps and returns the desired melange deps for
	// that modroot, rendered in this language's grammar, deduplicated and
	// with no-ops/downgrades/missing entries removed. ctx bounds any
	// network access an implementation may need; current implementations
	// are offline and ignore it.
	FilterBumps(ctx context.Context, existing []string, bumps []scan.SecurityBump, deps *ModuleDeps) []string

	// BumpCoords maps each OSV security bump to the coordinate this
	// ecosystem's rendered dep grammar uses for it - the segment before the
	// LAST "@" of a rendered entry. OSV's own package names don't always
	// match: Maven's are "groupId:artifactId" (colon) while the rendered
	// grammar is "groupId@artifactId@version", and OSV names v2+ Go modules
	// without the /vN path suffix go.mod requires. Callers use the keys to
	// recognize which rendered deps fix a flagged vulnerability, and the
	// values to attribute advisory IDs / prior versions to them.
	BumpCoords(bumps []scan.SecurityBump, deps *ModuleDeps) map[string]scan.SecurityBump
}

Ecosystem encapsulates all language-specific behavior for dependency vulnerability bumping.

func New

func New(language string) (Ecosystem, error)

New returns the Ecosystem implementation for a melange with.language: token ("go", "rust", "java"). The corresponding language package must have been blank-imported for its factory to be registered.

type Fetcher

type Fetcher struct {
	// contains filtered or unexported fields
}

Fetcher fetches manifest/lockfile content from GitHub repositories without a local checkout, via omnibump's remote fetcher (raw content first, falling back to the authenticated Contents API for private repositories). It is shared across all ecosystems - the transport is language-agnostic.

func NewFetcher

func NewFetcher(httpClient *http.Client) *Fetcher

NewFetcher creates a new fetcher with the provided HTTP client. The httpClient parameter is required and should be obtained from httpclient.NewHTTPClient()

func (*Fetcher) FetchFile

func (f *Fetcher) FetchFile(ctx context.Context, repoURL, tag, path string) ([]byte, error)

FetchFile fetches a single file's content from a git repository at the given modroot-relative path.

type ModuleDeps

type ModuleDeps struct {
	// Deps lists every dependency this ecosystem found for the modroot.
	Deps []Dep

	// Raw carries the ecosystem's own internal representation (e.g. a
	// *golang.GoModInfo), opaque to callers outside that ecosystem's package.
	// FilterBumps type-asserts it back; nothing else should depend on its shape.
	Raw any
}

ModuleDeps is a normalized dependency view for one modroot.

Directories

Path Synopsis
Package golang implements the Go ecosystem.Ecosystem: go.mod/go.sum parsing, v2+ module path normalization, replace-directive resolution, and bump decisioning.
Package golang implements the Go ecosystem.Ecosystem: go.mod/go.sum parsing, v2+ module path normalization, replace-directive resolution, and bump decisioning.
Package java implements the Maven-based Java ecosystem.Ecosystem, backed by omnibump's MavenAnalyzer.
Package java implements the Maven-based Java ecosystem.Ecosystem, backed by omnibump's MavenAnalyzer.
Package rust implements the Rust/Cargo ecosystem.Ecosystem, backed by omnibump's RustAnalyzer.
Package rust implements the Rust/Cargo ecosystem.Ecosystem, backed by omnibump's RustAnalyzer.

Jump to

Keyboard shortcuts

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