tools

package
v0.0.0-...-e601d7c Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecCommand

func ExecCommand(ctx context.Context, name string, args []string, env []string, timeout time.Duration) (stdout, stderr string, err error)

ExecCommand executes a command with the given arguments and environment variables. It returns stdout, stderr, and any error that occurred.

Types

type ToolInstaller

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

ToolInstaller checks tool availability and auto-installs missing tools.

func NewToolInstaller

func NewToolInstaller() *ToolInstaller

NewToolInstaller creates a new tool installer.

func (*ToolInstaller) CheckAllTools

func (i *ToolInstaller) CheckAllTools(ctx context.Context, config interface{}) error

CheckAllTools checks all required tools for a given security configuration

func (*ToolInstaller) CheckInstalled

func (i *ToolInstaller) CheckInstalled(ctx context.Context, toolName string) error

CheckInstalled checks if a tool is available in PATH.

func (*ToolInstaller) CheckInstalledWithVersion

func (i *ToolInstaller) CheckInstalledWithVersion(ctx context.Context, toolName string) error

CheckInstalledWithVersion checks if a tool is installed and meets minimum version requirements

func (*ToolInstaller) GetInstallURL

func (i *ToolInstaller) GetInstallURL(toolName string) (string, error)

GetInstallURL returns the installation URL for a tool

func (*ToolInstaller) GetToolCommand

func (i *ToolInstaller) GetToolCommand(toolName string) (string, error)

GetToolCommand returns the command name for a tool

func (*ToolInstaller) InstallIfMissing

func (i *ToolInstaller) InstallIfMissing(ctx context.Context, toolName string) error

InstallIfMissing checks if a tool is installed and auto-installs it if not. Supports: cosign, syft, grype, trivy.

func (*ToolInstaller) IsToolAvailable

func (i *ToolInstaller) IsToolAvailable(ctx context.Context, toolName string) bool

IsToolAvailable checks if a tool is available without returning an error

func (*ToolInstaller) ListAvailableTools

func (i *ToolInstaller) ListAvailableTools() []ToolMetadata

ListAvailableTools returns all available tools in the registry

type ToolMetadata

type ToolMetadata struct {
	Name        string // Tool name (e.g., "cosign", "syft")
	Command     string // Command to execute (usually same as name)
	MinVersion  string // Minimum required version (e.g., "3.0.2")
	InstallURL  string // URL with installation instructions
	Description string // Brief description
	VersionFlag string // Flag to get version (e.g., "version" or "--version")
}

ToolMetadata contains metadata about a security tool

type ToolRegistry

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

ToolRegistry maintains a registry of available security tools

func NewToolRegistry

func NewToolRegistry() *ToolRegistry

NewToolRegistry creates a new tool registry with default tools

func (*ToolRegistry) Count

func (r *ToolRegistry) Count() int

Count returns the number of registered tools

func (*ToolRegistry) GetInstallURL

func (r *ToolRegistry) GetInstallURL(name string) (string, error)

GetInstallURL returns the installation URL for a tool

func (*ToolRegistry) GetMinVersion

func (r *ToolRegistry) GetMinVersion(name string) (string, error)

GetMinVersion returns the minimum version for a tool

func (*ToolRegistry) GetRequiredTools

func (r *ToolRegistry) GetRequiredTools(operations []string) []ToolMetadata

GetRequiredTools returns tools required for a given operation

func (*ToolRegistry) GetTool

func (r *ToolRegistry) GetTool(name string) (ToolMetadata, error)

GetTool retrieves tool metadata by name

func (*ToolRegistry) GetToolsByCategory

func (r *ToolRegistry) GetToolsByCategory(category string) []ToolMetadata

GetToolsByCategory returns tools that match a category Category can be: "signing", "sbom", "scan", "provenance"

func (*ToolRegistry) HasTool

func (r *ToolRegistry) HasTool(name string) bool

HasTool checks if a tool is registered

func (*ToolRegistry) ListTools

func (r *ToolRegistry) ListTools() []ToolMetadata

ListTools returns all registered tools

func (*ToolRegistry) Register

func (r *ToolRegistry) Register(tool ToolMetadata)

Register adds or updates a tool in the registry

func (*ToolRegistry) Unregister

func (r *ToolRegistry) Unregister(name string)

Unregister removes a tool from the registry

type Version

type Version struct {
	Major int
	Minor int
	Patch int
	Raw   string
}

Version represents a semantic version

func ParseVersion

func ParseVersion(v string) (*Version, error)

ParseVersion parses a version string into a Version struct

func (*Version) Compare

func (v *Version) Compare(other *Version) int

Compare compares two versions Returns: -1 if v < other, 0 if v == other, 1 if v > other

func (*Version) IsAtLeast

func (v *Version) IsAtLeast(other *Version) bool

IsAtLeast returns true if this version is at least the given version

func (*Version) String

func (v *Version) String() string

String returns the string representation of the version

type VersionChecker

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

VersionChecker validates tool versions against minimum requirements

func NewVersionChecker

func NewVersionChecker() *VersionChecker

NewVersionChecker creates a new version checker

func (*VersionChecker) CheckAllToolVersions

func (c *VersionChecker) CheckAllToolVersions(ctx context.Context, tools []string) error

CheckAllToolVersions validates all tool versions

func (*VersionChecker) GetInstalledVersion

func (c *VersionChecker) GetInstalledVersion(ctx context.Context, toolName string) (string, error)

GetInstalledVersion retrieves the installed version of a tool

func (*VersionChecker) ValidateVersion

func (c *VersionChecker) ValidateVersion(toolName, installedVersion string) error

ValidateVersion checks if the installed version meets minimum requirements

Jump to

Keyboard shortcuts

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