fix

package
v4.24.35 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: AGPL-3.0 Imports: 17 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(root string, plans []FixCandidate) error

func ApplyOverride

func ApplyOverride(root string, p FixCandidate) error

ApplyOverride pins the (transitive) package to its safe version via the package manager's override mechanism in the nearest package.json:

npm / bun → "overrides"
pnpm      → "pnpm": { "overrides" }
yarn      → "resolutions"

No-op (nil) when no package.json is found in the manifest's directory.

func BestInRange

func BestInRange(candidates []string, constraint string) string

BestInRange returns the highest candidate that satisfies constraint, or "".

func EditManifestText

func EditManifestText(content string, p FixCandidate) (string, bool)

EditManifestText applies a version bump to manifest content and returns the rewritten text, reporting whether anything changed.

The file-based Apply path exists for the CLI, which owns the working tree. The language server does not: it holds the editor's unsaved buffer and must hand back a text edit for the editor to apply, so that the change lands in the user's undo history and cannot race a concurrent edit. Both go through the same per-ecosystem rewriters, so a fix suggested in the editor is the one `vulnetix fix` would have written.

func PipCommand added in v4.24.2

func PipCommand(sourceFile string) string

PipCommand is the plain-pip install for a Python manifest. The command runs in the manifest's own directory (FixBatch.Dir), so it names the file by its base name: a root-relative path would not resolve from there. Only a requirements file can be passed to `-r`; pip reads anything else as a list of requirement lines and fails, so a pyproject.toml, setup.py or setup.cfg project is reinstalled from its directory instead, which re-resolves its declared dependencies against the edited pins. A Pipfile belongs to pipenv. A lockfile naming a manager (uv, poetry, pdm, pipenv) replaces this command before it runs (cmd/fix_autofix.go pythonCommandForManager).

func RunInstall

func RunInstall(ctx context.Context, batches []FixBatch, dryRun bool, w io.Writer) error

func Satisfies

func Satisfies(version, constraint string) bool

Satisfies reports whether version satisfies an npm-style constraint (^, ~, ranges) via Masterminds/semver.

NOTE: Masterminds constraints EXCLUDE prerelease versions unless the constraint itself contains one (">= 1.0.0" does not match "1.2.0-beta"). That posture is acceptable here because Satisfies is only used for fix-version SELECTION (picking an upgrade target); it must never be used for affected-status determination — that lives in internal/versions, where prereleases are included in vulnerability ranges.

The implementation is shared with the server through github.com/Vulnetix/vdb-manifest.

func StrategyList

func StrategyList() string

StrategyList renders the names for help and error text: "a, b, c or d".

func ValidStrategies

func ValidStrategies() []string

ValidStrategies returns the accepted strategy names.

Types

type Batch

type Batch struct {
	Plans  []FixCandidate
	Counts ProofCounts
}

func BuildPlans

func BuildPlans(vulns []scan.EnrichedVuln, packages []scan.ScopedPackage, groups []scan.ManifestGroup, insights []vdb.CliPackageInsight, opts Options) Batch

type FixBatch

type FixBatch struct {
	SourceFile string
	Ecosystem  string
	Dir        string
	Plans      []FixCandidate
}

func GroupBatches

func GroupBatches(root string, plans []FixCandidate) []FixBatch

type FixCandidate

type FixCandidate struct {
	PackageName      string
	Ecosystem        string
	CurrentVer       string
	SourceFile       string
	IsDirect         bool
	ParentName       string
	ParentRange      string
	ParentTarget     string // resolved parent version for a parent-upgrade (npm only)
	TargetVer        string
	Method           FixMethod
	PackageManager   string // concrete resolver (npm/pnpm/yarn/bun/...) for the manifest, when known
	Command          string
	CveIDs           []string
	Reason           string
	Skipped          bool
	SkipReason       string
	RejectedVersions []SafeVersionRejection // populated when SkipReason contains "no Safe-Harbour"
	LatestAvailable  string                 // newest known version for context in the proof-of-work output
}

func SelectManifests

func SelectManifests(plans []FixCandidate, manifest string, yes bool) ([]FixCandidate, error)

type FixMethod

type FixMethod string
const (
	MethodDirectBump    FixMethod = "direct-bump"
	MethodOverride      FixMethod = "override"
	MethodParentUpdate  FixMethod = "parent-update"
	MethodParentUpgrade FixMethod = "parent-upgrade"
)

type Options

type Options struct {
	Strategy     Strategy
	MaxMajorBump int
	Manifest     string
	Yes          bool
	PathExplicit bool
}

type ProofCounts

type ProofCounts struct {
	Direct                  int
	TransitiveParentUpdate  int
	TransitiveParentUpgrade int
	TransitiveOverride      int
	UnresolvedDeepChains    int
}

func CountPlans

func CountPlans(plans []FixCandidate) ProofCounts

type SafeVersionRejection

type SafeVersionRejection struct {
	Version   string
	VulnCount int
	ExplCount int
	IsMalware bool
}

SafeVersionRejection records why a candidate Safe-Harbour version could not be used as an autofix target (vuln count, exploit count, or malware flag).

type Strategy

type Strategy string
const (
	StrategyLatest  Strategy = "latest"
	StrategySafest  Strategy = "safest"
	StrategyStable  Strategy = "stable"
	StrategyRolling Strategy = "rolling"
)

func ValidateStrategy

func ValidateStrategy(s string) (Strategy, error)

type TargetDecision

type TargetDecision struct {
	Skipped bool
	Reason  string
	// Note is set when the target was chosen by a different route than the
	// strategy asked for, so the caller can print one line saying so.
	Note string
}

func ResolveTarget

func ResolveTarget(current string, strategy Strategy, latest []vdb.CliVersionStamp, safe []vdb.CliSafeHarbourVersion, summary *vdb.CliSafeHarbourSummary, maxMajorBump int) (string, TargetDecision)

Jump to

Keyboard shortcuts

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