Documentation
¶
Overview ¶
Package pm runs a supported package manager (npm, pip, gem, ...) behind the Dependency Firewall's local MITM proxy. The shared Run flow starts the proxy, routes the manager's HTTPS traffic through it, makes the manager trust the proxy CA, forwards the command's args verbatim, records the firewall's per-coordinate verdicts to the CI log, renders a summary, and propagates the child's exit code. Each supported manager is a small implementation of PackageManager describing only what varies by ecosystem.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Run ¶
func Run(ctx context.Context, manager PackageManager, opts RunOptions) error
Run executes manager.Binary() with args forwarded verbatim, routing HTTPS traffic through a local MITM proxy that policy-checks each artifact/upload coordinate. Blocked packages are recorded and the summary is rendered on exit.
Types ¶
type Executor ¶
type Executor interface {
LookPath(file string) (string, error)
ExecWithIO(ctx context.Context, name string, args []string, env []string, stdin io.Reader, stdout, stderr io.Writer) error
}
Executor runs the package-manager binary. Satisfied by cmdutils.Executor.
type ExitError ¶
ExitError reports that the package-manager binary exited non-zero, was interrupted, or could not be run, carrying the exit Code the process should return. pm is a library package and must not import internal/cmdutils (command-layer only, enforced by depguard), so the calling command translates this into a *cmdutils.ExitError; see dfcmd.run.
type PackageManager ¶
type PackageManager interface {
// Name is the CLI noun and log key: "npm", "pip", "maven".
Name() string
// Binary is the executable looked up on PATH.
Binary() string
// Environment returns child-process env vars that route the manager's
// HTTPS traffic through proxyURL. The parent env (with proxy vars
// sanitized) is supplied by Run via proxyEnviron.
Environment(proxyURL string) []string
// CATrustEnviron returns the env vars that make the manager trust the
// proxy's MITM CA at caPath (NODE_EXTRA_CA_CERTS, SSL_CERT_FILE,
// PIP_CERT/REQUESTS_CA_BUNDLE, MAVEN_OPTS truststore, etc.).
CATrustEnviron(caPath string) []string
// ExistingBundleVars names every environment variable this manager's
// CATrustEnviron overwrites that could hold a user's pre-existing CA
// bundle (e.g. NODE_EXTRA_CA_CERTS, PIP_CERT and REQUESTS_CA_BUNDLE,
// SSL_CERT_FILE and BUNDLE_SSL_CA_CERT), so the engine can prepend those
// trust anchors to the proxy CA rather than replacing them. Every variable
// CATrustEnviron sets must appear here, or a user who set only the
// undeclared one loses their anchors and can no longer verify an internal
// index/mirror. An empty slice means the manager has no such variable to
// preserve (e.g. Maven, which trusts the proxy through a generated
// truststore rather than an env-named bundle).
ExistingBundleVars() []string
// CleanupCAFiles removes any files this manager derived from the CA
// bundle at caPath (for example a JVM truststore or a generated
// settings.xml). The engine always removes caPath itself; this covers
// ecosystem-specific sidecars the engine would otherwise not know about.
CleanupCAFiles(caPath string)
// Matcher returns the proxy coordinate matcher for this ecosystem's
// upstream URL shape.
Matcher() proxy.Matcher
}
PackageManager captures what varies between supported package managers so the shared run flow (proxy + exec + log + summary) is written once. In the upstream-MITM model managers no longer rewrite their own config: they route traffic through the proxy (Environment), trust the proxy CA (CATrustEnviron), and supply the coordinate matcher for their ecosystem (Matcher).
func Pnpm ¶
func Pnpm() PackageManager
Pnpm returns the pnpm package manager. pnpm honors HTTPS_PROXY and NODE_EXTRA_CA_CERTS the same as npm, so it differs only in name/binary.
func Yarn ¶
func Yarn() PackageManager
Yarn returns the Yarn (Berry) package manager. It routes through the proxy via YARN_HTTP(S)_PROXY and trusts the proxy CA via NODE_EXTRA_CA_CERTS.
Suspected gap (unverified): Berry's per-hostname networkSettings map (httpProxy/httpsProxy/enableNetwork/caFilePath keyed by host) is documented to override the global proxy settings for matching hosts, and a map-valued setting has no practical env pin. If that holds, a repo-committed ".yarnrc.yml" networkSettings entry for the registry host could route that host around the MITM while staying green. This has not been confirmed against a Berry install (getNetworkSettings in yarnpkg-core httpUtils); treat it as an open item to verify and then either guard or accept.
type RunOptions ¶
type RunOptions struct {
IO *iostreams.IOStreams
Executor Executor
BaseDir string
Client *gitlab.Client // authenticated API client, for the policy checker
ProjectID string // project id or full-path slug, for policy scoping
Args []string
// contains filtered or unexported fields
}
RunOptions are the inputs to Run. Registry/token fields are gone: the model no longer talks to a GitLab registry.