proxy

package
v1.116.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Match added in v1.116.0

type Match struct {
	Matched    bool
	Coordinate policy.Coordinate
	Operation  policy.Operation
	Pass       bool
	Reason     string
}

Match is the result of running a Matcher against a request. When Matched is false the request is metadata/index/sidecar traffic that passes straight through. When Matched is true the request is an in-scope artifact download or upload.

Pass gates the policy check and is deliberately fail-closed: only a matched request whose Coordinate the matcher fully determined sets Pass true and is forwarded to the policy checker. A matched request that leaves Pass false — because the matcher recognized an in-scope upload but could not determine the coordinate (for example an upload body larger than the inspection limit), or simply forgot to set the field — is rejected outright by the proxy rather than letting an un-inspectable payload through. Reason carries the operator message for that synthesized block.

type Matcher added in v1.116.0

type Matcher interface {
	Match(req *http.Request) Match
}

Matcher inspects an intercepted request and reports whether it carries an exact package coordinate (an artifact download or an upload). Each ecosystem implements one, keyed off the public-upstream URL/body shape. Implementations that read an upload body MUST restore req.Body so the upstream RoundTrip still sees the full payload.

type NPMMatcher added in v1.116.0

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

NPMMatcher recognizes npm artifact tarball downloads and publish uploads against the public npm registry (registry.npmjs.org) or any npm-protocol upstream with the same URL shape.

func (NPMMatcher) Match added in v1.116.0

func (m NPMMatcher) Match(req *http.Request) Match

type Option

type Option func(*Proxy)

Option configures a Proxy at construction time.

func WithUpstreamRootCAs

func WithUpstreamRootCAs(pool *x509.CertPool) Option

WithUpstreamRootCAs overrides the certificate pool the proxy uses to verify the upstream registry's TLS certificate. When unset, the proxy verifies against the system trust store, which is the correct default. This option exists for tests (which need to trust an httptest.Server's self-signed cert) and for future support of enterprise CA bundles.

type Proxy

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

func New

func New(matcher Matcher, checker policy.Checker, projectID string, opts ...Option) (*Proxy, error)

func (*Proxy) Addr

func (p *Proxy) Addr() string

func (*Proxy) CACertificate

func (p *Proxy) CACertificate() *x509.Certificate

func (*Proxy) Start

func (p *Proxy) Start() error

func (*Proxy) Stop

func (p *Proxy) Stop()

func (*Proxy) Verdicts

func (p *Proxy) Verdicts() []verdict.Entry

Jump to

Keyboard shortcuts

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