ssrf

package
v1.6.29 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2026 License: AGPL-3.0 Imports: 5 Imported by: ? 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 ssrf provides SSRF protection utilities.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidScheme indicates a URL used a non-http(s) scheme.
	ErrInvalidScheme = errors.New("invalid URL scheme")
	// ErrEmptyHostname indicates a URL is missing a hostname.
	ErrEmptyHostname = errors.New("empty hostname")
	// ErrBlockedHostname indicates a URL hostname is blocked by SSRF policy.
	ErrBlockedHostname = errors.New("hostname is blocked")
)

Functions

func IsBlockedHostname

func IsBlockedHostname(hostname string) bool

IsBlockedHostname reports whether a hostname should be blocked for SSRF protection.

It blocks:

  • IP literals that are blocked by IsBlockedIP
  • known internal/metadata hostnames and their subdomains (e.g. *.metadata.azure.com)

func IsBlockedIP

func IsBlockedIP(ip net.IP) bool

IsBlockedIP reports whether the IP should be blocked for SSRF protection.

func ValidateURL

func ValidateURL(u *url.URL) error

ValidateURL validates that a URL is safe to resolve and dial from an SSRF perspective.

It enforces: - http/https schemes only - non-empty hostname - hostname is not blocked by IsBlockedHostname (including IP literals)

func ValidateURLString

func ValidateURLString(raw string) (*url.URL, error)

ValidateURLString parses and validates a URL string using ValidateURL.

Types

This section is empty.

Jump to

Keyboard shortcuts

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