Documentation
¶
Overview ¶
Package policy decides whether a package coordinate is allowed by the GitLab Dependency Firewall. It is the seam between the inspection proxy (which identifies a coordinate) and the verdict source. A fake, environment-driven Checker exists for testing; the REST-backed Checker that calls the real policy API lands in a follow-up. Callers wrap the chosen Checker in a CachingChecker.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotImplemented = errors.New("policy: real checker not yet implemented")
ErrNotImplemented is returned by the placeholder checker until the REST-backed checker is wired in a follow-up. It fails closed so a misconfigured build denies rather than silently allows.
Functions ¶
This section is empty.
Types ¶
type CachingChecker ¶
type CachingChecker struct {
// contains filtered or unexported fields
}
CachingChecker wraps a Checker with per-request memoization and a fail-closed error policy. It is the only place caching and fail-mode live, so both Checker implementations stay simple. Safe for concurrent use: the proxy calls Check from multiple tunnel goroutines.
Concurrent calls for the same request are coalesced: the first caller runs the inner check while the rest block on the entry's sync.Once, so a popular transitive dependency triggers a single inner check at cold start rather than one per tunnel goroutine.
Lifetime invariant: the cache grows unbounded and is never evicted. It is sized for a single package-manager run (the proxy's lifetime). Callers must not share one CachingChecker across unrelated or long-lived workloads.
func NewCachingChecker ¶
func NewCachingChecker(inner Checker, log Logf) *CachingChecker
NewCachingChecker wraps inner. log may be nil.
func (*CachingChecker) Check ¶
Check returns the policy result for r, memoized per request for the lifetime of the checker. The error return is always nil: an inner failure is mapped to a fail-closed Blocked result rather than surfaced, so callers get a verdict on every path. It is part of the signature only to satisfy Checker.
type Coordinate ¶
type Coordinate struct {
Ecosystem string // "npm", "pypi", "maven", "gem"
Name string
Version string
}
Coordinate is the exact package identity a check is performed against.
func (Coordinate) Key ¶
func (c Coordinate) Key() string
Key is the cache and dedupe key for a coordinate.
type Logf ¶
Logf logs a diagnostic line. It matches iostreams.IOStreams.LogErrorf so callers can pass io.LogErrorf directly; nil is allowed (no logging).
type Request ¶
type Request struct {
Coordinate Coordinate
ProjectID string // project id or full-path slug, from git repo context
Operation Operation
}
Request is a single policy question.
func (Request) Key ¶
Key is the cache and dedupe key for a request. It includes the project and operation, not just the coordinate: the same package can get a different verdict per project (policies are project-scoped) and per operation (download vs upload), so keying on the coordinate alone would leak one project's or operation's verdict to another once the real checker lands.