blockreason

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const Code = "BLOCKED_BY_POLICY"

Code is the "code" of the JSON body of every policy refusal.

View Source
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.

Jump to

Keyboard shortcuts

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