gobump

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2025 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewGoBumpPipeline

func NewGoBumpPipeline(analyzer *Analyzer) *processor.Pipeline

NewGoBumpPipeline creates the gobump pipeline with the critical fix

Types

type Analyzer

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

Analyzer handles vulnerability analysis and bump logic for Go dependencies

func NewAnalyzer

func NewAnalyzer(httpClient *http.Client) *Analyzer

NewAnalyzer creates a new analyzer with the provided HTTP client

func (*Analyzer) AnalyzeBumps

func (a *Analyzer) AnalyzeBumps(deps []string, goModInfo *GoModInfo) ([]BumpAnalysis, []string)

AnalyzeBumps analyzes each bump and determines whether to keep or remove it

func (*Analyzer) GetFetcher

func (a *Analyzer) GetFetcher() *Fetcher

GetFetcher returns the fetcher for external use

func (*Analyzer) GetParser

func (a *Analyzer) GetParser() *Parser

GetParser returns the parser for external use

func (*Analyzer) GetVulnerabilityScanner

func (a *Analyzer) GetVulnerabilityScanner() *scan.VulnerabilityScanner

GetVulnerabilityScanner returns the vulnerability scanner for external use

func (*Analyzer) HaveDepsChanged

func (a *Analyzer) HaveDepsChanged(existing, merged []string) bool

HaveDepsChanged compares two dependency lists to determine if they're different

type BumpAction

type BumpAction struct {
	Action       string   `json:"action" yaml:"action"`             // "insert", "update", "remove"
	PipelineIdx  int      `json:"pipeline_idx" yaml:"pipeline_idx"` // pipeline index for update/remove
	Dependencies []string `json:"dependencies" yaml:"dependencies"` // dependencies to insert/update with
	Reason       string   `json:"reason" yaml:"reason"`             // human-readable reason
}

BumpAction represents a planned action for go/bump pipelines

type BumpAnalysis

type BumpAnalysis struct {
	Module       string
	BumpVersion  string
	GoModVersion string
	Action       string // "keep", "remove-noop", "remove-downgrade", "remove-missing"
	Reason       string
}

BumpAnalysis represents the analysis result for a single bump

type Fetcher

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

Fetcher handles fetching go.mod and go.sum files from git repositories

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) FetchGoMod

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

FetchGoMod fetches go.mod content from a git repository Uses GitHub API for private repos, falls back to raw.githubusercontent.com for public repos

func (*Fetcher) FetchGoSum

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

FetchGoSum fetches go.sum content from a git repository Uses GitHub API for private repos, falls back to raw.githubusercontent.com for public repos

type GitHubFileResponse

type GitHubFileResponse struct {
	Content  string `json:"content"`
	Encoding string `json:"encoding"`
}

GitHubFileResponse represents the GitHub API response for file content

type GoBumpApplier

type GoBumpApplier struct {
	processor.BaseStage
	Analyzer *Analyzer
}

GoBumpApplier applies go/bump pipeline changes

func NewGoBumpApplier

func NewGoBumpApplier(analyzer *Analyzer) *GoBumpApplier

func (*GoBumpApplier) Apply

func (*GoBumpApplier) ShouldRun

func (g *GoBumpApplier) ShouldRun(ctx context.Context, p processor.Processor) (bool, error)

type GoBumpProcessor

type GoBumpProcessor struct {
	*processor.BaseProcessor

	// Security-specific fields
	VulnerabilityAnalysis *VulnerabilityAnalysis `json:"vulnerability_analysis,omitempty"`
	SecurityFixes         []SecurityFix          `json:"security_fixes"`
	ActualChangesApplied  bool                   `json:"actual_changes_applied"`
}

GoBumpProcessor extends BaseProcessor with security-specific fields

func NewGoBumpProcessor

func NewGoBumpProcessor(filePath, packageName, currentVersion string, currentEpoch int64) *GoBumpProcessor

NewGoBumpProcessor creates a new gobump processor

func (*GoBumpProcessor) AddSecurityFix

func (p *GoBumpProcessor) AddSecurityFix(fix SecurityFix)

AddSecurityFix adds a security fix to the processor

func (*GoBumpProcessor) HasActualChanges

func (p *GoBumpProcessor) HasActualChanges() bool

HasActualChanges returns true if actual file modifications were made (not just vulnerabilities found)

func (*GoBumpProcessor) MarkActualChangesApplied

func (p *GoBumpProcessor) MarkActualChangesApplied()

MarkActualChangesApplied marks that actual changes were made to the YAML This is critical for the epoch bumping logic - epoch should only bump when file changes occur

func (*GoBumpProcessor) ToResult

func (p *GoBumpProcessor) ToResult() *GoBumpResult

ToResult converts the processor state to a GoBumpResult

type GoBumpResult

type GoBumpResult struct {
	PackageName          string        `json:"package_name" yaml:"package_name"`
	FilePath             string        `json:"file_path" yaml:"file_path"`
	VulnerabilitiesFound int           `json:"vulnerabilities_found" yaml:"vulnerabilities_found"`
	VulnerabilitiesFixed int           `json:"vulnerabilities_fixed" yaml:"vulnerabilities_fixed"`
	CriticalFixed        int           `json:"critical_fixed" yaml:"critical_fixed"`
	HighFixed            int           `json:"high_fixed" yaml:"high_fixed"`
	SecurityFixes        []SecurityFix `json:"security_fixes" yaml:"security_fixes"`
	ActionsApplied       []BumpAction  `json:"actions_applied" yaml:"actions_applied"`
	OldEpoch             int64         `json:"old_epoch" yaml:"old_epoch"`
	NewEpoch             int64         `json:"new_epoch" yaml:"new_epoch"`
	EpochChanged         bool          `json:"epoch_changed" yaml:"epoch_changed"`
	FileWasWritten       bool          `json:"file_was_written" yaml:"file_was_written"`
	Messages             []string      `json:"messages" yaml:"messages"`
	Error                string        `json:"error,omitempty" yaml:"error,omitempty"`
}

GoBumpResult represents the result of a go bump operation

func ProcessFile

func ProcessFile(ctx context.Context, filePath string, opts ProcessorOptions, analyzer *Analyzer) (*GoBumpResult, error)

ProcessFile processes a single file using the shared pipeline architecture

type GoModInfo

type GoModInfo struct {
	Requirements    map[string]string           // module -> version (direct dependencies)
	AllRequirements map[string]string           // module -> version (all dependencies including indirect)
	Replacements    map[string]*modfile.Replace // module -> replacement
}

GoModInfo contains parsed go.mod information including requirements and replacements

type Parser

type Parser struct{}

Parser handles parsing go.mod and go.sum files

func NewParser

func NewParser() *Parser

NewParser creates a new parser

func (*Parser) CreateVulnScanInput

func (p *Parser) CreateVulnScanInput(goModInfo *GoModInfo) string

CreateVulnScanInput creates a vulnerability scanner input from GoModInfo This provides a unified list of dependencies for vulnerability scanning

func (*Parser) ParseGoMod

func (p *Parser) ParseGoMod(content []byte) (*GoModInfo, error)

ParseGoMod parses go.mod content and extracts module requirements and replacements

func (*Parser) ParseGoModWithSum

func (p *Parser) ParseGoModWithSum(goModContent, goSumContent []byte) (*GoModInfo, error)

ParseGoModWithSum parses both go.mod and go.sum to get complete dependency information

func (*Parser) ParseGoSum

func (p *Parser) ParseGoSum(content []byte) (map[string]string, error)

ParseGoSum parses go.sum content and extracts all module versions This is used to get indirect dependencies that aren't listed in go.mod (Go < 1.17)

type ProcessorOptions

type ProcessorOptions struct {
	DryRun       bool   `json:"dry_run" yaml:"dry_run"`
	BackupSuffix string `json:"backup_suffix" yaml:"backup_suffix"`
	TempDir      string `json:"temp_dir" yaml:"temp_dir"`
}

ProcessorOptions configures processor behavior

type SecurityFix

type SecurityFix struct {
	Module        string `json:"module" yaml:"module"`               // Go module affected
	Vulnerability string `json:"vulnerability" yaml:"vulnerability"` // CVE or vulnerability ID
	OldVersion    string `json:"old_version" yaml:"old_version"`     // version before fix
	NewVersion    string `json:"new_version" yaml:"new_version"`     // version after fix
	Severity      string `json:"severity" yaml:"severity"`           // critical, high, medium, low
}

SecurityFix represents a security vulnerability fix applied

type VulnerabilityAnalysis

type VulnerabilityAnalysis struct {
	GoModInfo            *GoModInfo       `json:"go_mod_info" yaml:"go_mod_info"`
	ScanResult           *scan.ScanResult `json:"scan_result" yaml:"scan_result"`
	VulnerabilitiesFound int              `json:"vulnerabilities_found" yaml:"vulnerabilities_found"`
	CriticalCount        int              `json:"critical_count" yaml:"critical_count"`
	HighCount            int              `json:"high_count" yaml:"high_count"`
	SecurityBumps        []string         `json:"security_bumps" yaml:"security_bumps"`
	BumpActions          []BumpAction     `json:"bump_actions" yaml:"bump_actions"`
	Analysis             []BumpAnalysis   `json:"analysis" yaml:"analysis"`
}

VulnerabilityAnalysis contains the results of scanning go dependencies

type VulnerabilityChecker

type VulnerabilityChecker struct {
	processor.BaseStage
	Analyzer *Analyzer
}

VulnerabilityChecker checks for Go module vulnerabilities

func NewVulnerabilityChecker

func NewVulnerabilityChecker(analyzer *Analyzer) *VulnerabilityChecker

func (*VulnerabilityChecker) Check

Jump to

Keyboard shortcuts

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