Documentation
¶
Overview ¶
Package blockreason is the contract of a policy refusal on the download path of proxy and group repositories.
A download the repository's policy refuses, whatever the format, answers 403 and names the policy that refused it twice, so a build tool or a CI task can tell "blocked on purpose" from a transport failure without parsing prose:
- the X-OA-Block-Reason response header carries the policy;
- the JSON body is {"error", "code": "BLOCKED_BY_POLICY", "policy", "package", "version"} ("package" and "version" are empty when the refused file does not name them).
Docker clients only understand the distribution-spec error body, so for the registry API the body stays {"errors":[{"code":"DENIED",...}]} and the same facts move into its "detail" member; the header is the same.
Index ¶
Constants ¶
const Code = "BLOCKED_BY_POLICY"
Code is the "code" of the JSON body of every policy refusal.
const Header = "X-Oa-Block-Reason"
Header is the response header that carries the Policy of a refusal. Header names are case-insensitive: it is documented as X-OA-Block-Reason, and this is its canonical form in Go.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Block ¶
type Block struct {
Policy Policy
// Package and Version identify what was refused; either may be empty.
Package, Version string
// Message is the human-readable reason.
Message string
}
Block is one refusal.
func (Block) Write ¶
func (b Block) Write(w http.ResponseWriter)
Write answers the request with the refusal: 403, the header and the JSON body.
func (Block) WriteOCI ¶
func (b Block) WriteOCI(w http.ResponseWriter)
WriteOCI is Write for the registry API: the distribution-spec error DENIED with the policy, the package (the image) and the version (the reference) in its detail.
type Policy ¶
type Policy string
Policy is the kind of policy that refused a download.
const ( // Quarantine is a vulnerability or secret scan that quarantined the artifact. Quarantine Policy = "quarantine" // Curation is the repository's package denylist or allowlist. Curation Policy = "curation" // MinAge is the repository's minimum age of a published version. MinAge Policy = "min_age" // License is a license policy that blocks the artifact. License Policy = "license" )
The policies that refuse downloads.