Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommandExecutor ¶
type CommandExecutor interface {
Execute(ctx context.Context, name string, args ...string) ([]byte, error)
}
CommandExecutor is an interface for executing commands. This allows for dependency injection and easier testing.
type InstallItem ¶
type InstallItem struct {
Metadata PackageMetadata `json:"metadata"`
Requested bool `json:"requested"` // True if explicitly requested in requirements
}
InstallItem represents a single package in the pip install report.
func (InstallItem) IsDirectDependency ¶
func (item InstallItem) IsDirectDependency() bool
IsDirectDependency returns true if this package is a direct dependency.
type PackageMetadata ¶
type PackageMetadata struct {
Name string `json:"name"`
Version string `json:"version"`
RequiresDist []string `json:"requires_dist"` // List of dependencies (e.g., "urllib3 (<3,>=1.21.1)")
}
PackageMetadata contains the package name, version, and dependencies.
type Plugin ¶
type Plugin struct{}
func (Plugin) BuildDepGraphsFromDir ¶
func (p Plugin) BuildDepGraphsFromDir(ctx context.Context, dir string, options *ecosystems.SCAPluginOptions) ([]ecosystems.SCAResult, error)
BuildDepGraphsFromDir discovers and builds dependency graphs for Python pip projects.
type Report ¶
type Report struct {
Install []InstallItem `json:"install"`
}
Report represents the minimal JSON output from pip install --report needed to build a dependency graph.
func GetInstallReport ¶
GetInstallReport runs pip install with --dry-run and --report flags to get a JSON report of what would be installed from a requirements file. No files are written to disk; the report is captured from stdout.
This is a convenience wrapper around GetInstallReportWithExecutor that uses the default executor. For testing, use GetInstallReportWithExecutor directly.
func GetInstallReportWithExecutor ¶
func GetInstallReportWithExecutor(ctx context.Context, requirementsFile string, executor CommandExecutor) (*Report, error)
GetInstallReportWithExecutor is a testable version that accepts a CommandExecutor. It runs pip install with the following flags:
- --dry-run: Don't actually install anything
- --ignore-installed: Show all packages, not just new ones
- --report -: Output JSON report to stdout (dash means stdout)
- --quiet: Suppress non-error output (except the report)
- -r: Read from requirements file
- --index-url: Custom PyPI index (if PIP_TEST_INDEX_URL is set)