pkgmgr

package
v1.3.18 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PackageTypeNpm   = "npm"
	PackageTypeMaven = "maven"
	PackageTypePyPI  = "pypi"
	PackageTypeNuGet = "nuget"
)

Package type identifiers used in registry URLs and client detection.

View Source
const (
	CommandNpm    = "npm"
	CommandMvn    = "mvn"
	CommandPip    = "pip"
	CommandDotnet = "dotnet"
)

Command names for each package manager CLI tool.

Variables

This section is empty.

Functions

func DisplayBlockedScanResults

func DisplayBlockedScanResults(f *cmdutils.Factory, scans []ar_v3.BulkScanResultItem, progress p.Reporter) error

DisplayBlockedScanResults shows detailed scan info for each blocked/warned package.

func DisplayScanDetails

func DisplayScanDetails(scanDetails *ar_v3.ArtifactScanDetails)

DisplayScanDetails shows policy violations for a single scan result.

func ExecuteWithFirewall

func ExecuteWithFirewall(
	client Client,
	f *cmdutils.Factory,
	command string,
	args []string,
	explicitRegistry string,
	progress p.Reporter,
) error

ExecuteWithFirewall runs the common 4-phase flow for any package manager:

  1. Detect HAR registry
  2. Resolve registry UUID
  3. Run native command
  4. On 403: resolve deps → firewall evaluation

func ResolveRegistryUUID

func ResolveRegistryUUID(f *cmdutils.Factory, registryIdentifier, org, project string, progress p.Reporter) (uuid.UUID, error)

ResolveRegistryUUID looks up the registry UUID from the registry identifier.

func RunFirewallExplain

func RunFirewallExplain(f *cmdutils.Factory, registryUUID uuid.UUID, artifacts []ar_v3.ArtifactScanInput, org, project string, progress p.Reporter) (int, error)

RunFirewallExplain evaluates artifacts against firewall policies and displays results. Automatically batches into chunks of 50 (API limit). Returns the number of scan results and any error.

func RunNativeCommand

func RunNativeCommand(binary string, args []string) error

Types

type Client

type Client interface {
	// Name returns the client name, e.g. "npm", "maven", "pip", "nuget".
	Name() string

	// PackageType returns the registry package type, e.g. "npm", "maven", "pypi", "nuget".
	PackageType() string

	// DetectRegistry detects the HAR registry from saved config or native config files.
	// explicitRegistry is an optional user-provided registry identifier.
	DetectRegistry(explicitRegistry string) (*RegistryInfo, error)

	// RunCommand executes the native package manager command (e.g. "npm install").
	// command is the subcommand ("install", "ci", etc.), args are pass-through arguments.
	RunCommand(command string, args []string) (*InstallResult, error)

	// ResolveDependencies returns the full dependency list (including transitive).
	// Used for firewall evaluation after a 403 is detected.
	ResolveDependencies(progress p.Reporter) (*DependencyResult, error)

	// DetectFirewallError checks if stderr contains a 403/firewall block pattern.
	DetectFirewallError(stderr string) bool

	// FallbackOrgProject returns org/project from saved client config.
	// Used as fallback when global config and env vars don't have them.
	FallbackOrgProject() (org string, project string)
}

Client defines the interface that each package manager must implement.

type DependencyResult

type DependencyResult struct {
	Dependencies []regcmd.Dependency
	Cleanup      func()
}

DependencyResult holds resolved dependencies and an optional cleanup function.

type InstallResult

type InstallResult struct {
	Status string // "SUCCESS" or "FAILURE"
	Stderr string
	Err    error
}

InstallResult holds the result of running a native package manager command.

type ParsedArgs

type ParsedArgs struct {
	RegistryName string
	NativeArgs   []string
}

func ParseWrappedArgs

func ParseWrappedArgs(args []string) ParsedArgs

type RegistryInfo

type RegistryInfo struct {
	RegistryURL        string
	RegistryIdentifier string
	AccountID          string
	AuthToken          string
}

RegistryInfo holds detected HAR registry details.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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