netutil

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package netutil provides network helpers, including SSRF-safe validation of user-supplied integration and outbound URLs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SanitizeLogValue

func SanitizeLogValue(s string) string

SanitizeLogValue strips line breaks from remote-derived values before they reach structured logs, so a crafted value cannot forge additional log entries.

func SanitizeSensitiveText

func SanitizeSensitiveText(text string) string

SanitizeSensitiveText redacts credentials and common secret query parameters from error strings before they are logged or returned through API responses. Line breaks are also removed so the result is safe to log.

func ValidateIntegrationURL

func ValidateIntegrationURL(rawURL string) error

ValidateIntegrationURL checks admin-initiated integration test URLs (Prowlarr, Kavita, etc.). Private and loopback addresses are allowed — homelab services commonly run at http://192.168.x.x:port or http://localhost:port.

func ValidateOutboundURL

func ValidateOutboundURL(rawURL string) error

ValidateOutboundURL checks that rawURL is a safe http(s) target for server-side requests. It rejects loopback, private, link-local, and metadata addresses (see LIBRARR_INSECURE_ALLOW_PRIVATE_URLS for the LAN-mirror escape hatch).

func ValidateSameOriginHTTPURL

func ValidateSameOriginHTTPURL(rawURL, allowedOrigin string) (*url.URL, error)

ValidateSameOriginHTTPURL parses rawURL and verifies that it has the same normalized host and effective port as allowedOrigin. It is intended for integration-owned URLs, such as Prowlarr download links, where the server may legitimately be private or loopback but redirects must not escape the configured origin.

Types

This section is empty.

Jump to

Keyboard shortcuts

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