Documentation
¶
Overview ¶
Package npm downloads a published npm package's tarball and unpacks it with internal/supplychain/archive. It never runs npm install, a lifecycle script (preinstall/install/postinstall), or any other package code - the tarball is treated purely as data to extract and hand to other analyzers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Fetcher ¶
type Fetcher struct {
Registry string
Client *http.Client
Limits archive.Limits
// Policy is what CheckURL runs the tarball URL through. Tests point it
// at an httptest.Server and so need AllowPrivateNetworks; production
// use leaves it at its default.
Policy httpx.Policy
}
Fetcher downloads packages from an npm registry. Both the registry metadata request and the tarball download - whose URL the registry response names, not the caller - go through httpx.DefaultPolicy: no private-network destination, guarded at dial time, no cross-origin redirect followed.
func New ¶
func New() *Fetcher
New builds a Fetcher pointed at the public npm registry with the package's default archive safety limits
func (*Fetcher) Download ¶
func (f *Fetcher) Download(ctx context.Context, name, version, destDir string) (archive.Result, string, error)
Download fetches name@version's tarball, verifies it against the registry's declared integrity (preferred) or shasum, and extracts it under destDir. destDir must already exist. Nothing in the package is ever executed: this is a download and an archive.Extract call, nothing else.