httppolicy

package
v3.0.0-rc67 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 6 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type T

type T struct {
	// AllowedUrl defines the list of URL patterns that are explicitly
	// permitted by the policy regardless BlockedUrl setting.
	AllowedUrl []string

	// BlockedURL define the URLs patterns that are explicitly disallowed by the policy.
	// Empty value is treated the same as a []string{"*"} (all URLs are blocked
	// unless explicitly allowed).
	BlockedUrl []string

	// AllowedCIDR defines CIDR blocks explicitly allowed by the policy,
	// overriding any entries in BlockedCIDR.
	AllowedCIDR []string

	// BlockedCIDR defines a list of CIDR blocks that are explicitly disallowed
	// by the policy for incoming requests.
	BlockedCIDR []string
}

func New

func New(allowedURL, blockedURL, allowedCIDR, blockedCIDR []string) *T

New creates and returns a new instance of T initialized with the provided whitelist URLs and blocked CIDRs.

func (*T) Check

func (t *T) Check(rawURL string) (ip net.IP, port string, err error)

Check validates the given rawURL, resolves its IP, determines its port, and ensures it complies with set rules. The accepted ip, port is returned to prevent TOCTOU bugs.

func (*T) CheckRedirect

func (t *T) CheckRedirect(rawURL string) (ip net.IP, port string, err error)

CheckRedirect validates the target of a redirect served by a url Check accepted: its addresses are held to the cidr lists, as every request is, and its url is not held to the url lists. The url lists say which sources an operator trusts, by the url a configuration names; where that source keeps its content, as the storage a release download redirects to, is the source's to say. An address blocked is refused whatever redirects to it.

Jump to

Keyboard shortcuts

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