httpadapter

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: Apache-2.0 Imports: 14 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 httpadapter holds request handling shared by the adapters that receive requests over net/http: the reverse proxy and forward-auth.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsEvent

func IsEvent(v pipeline.Verdict) bool

IsEvent reports whether a verdict is logged as a security event: blocks and detections, and every request that went uninspected unexpectedly (timeout, error, overload). Client cancellations and requests uninspected by configuration (a skipped route, no policy for the route, inspection suspended) are not events: they are counted in the metrics, and logging each would flood the logs. Neither are the requests an engine denies before it has a policy bundle (bootstrap deny): the engine logs that once.

func IsToken

func IsToken(s string) bool

IsToken reports whether s is an HTTP token (RFC 9110), the syntax of a method.

func LogEvent

func LogEvent(ctx context.Context, logger *slog.Logger, rec *events.Recorder, req *request.Request, path string, v pipeline.Verdict)

LogEvent writes one security event for req, and records it for the operator when rec is set.

func NewRequestID

func NewRequestID() string

NewRequestID returns a random 16-hex-digit request ID.

func PeerAddr

func PeerAddr(remoteAddr string) netip.Addr

PeerAddr parses the address of the direct TCP peer from r.RemoteAddr.

func RequestID

func RequestID(id string) string

RequestID returns id if it is a safe correlation ID (at most 128 of [A-Za-z0-9._:-]), and "" otherwise so that one is generated. The value is client-controlled and ends up in logs and events.

func SnapshotHeaders

func SnapshotHeaders(r *http.Request) http.Header

SnapshotHeaders returns a private copy of r's headers for inspection, with Transfer-Encoding and Content-Length restored.

The copy matters because an evaluation that times out keeps running after the handler has returned, and must not read the live request. Copying costs about 0.3µs, well under 0.1% of an evaluation.

net/http moves Transfer-Encoding out of the header map, and Content-Length can be absent (HTTP/2) even when the length is known. Without them, rules see a POST with neither header and raise a false positive.

func URIPath

func URIPath(rawURI string) (string, error)

URIPath validates a request target received from a proxy and returns its decoded path. The target must be in origin form and must not contain a fragment: rules stop reading the URI at '#' while the application may not.

Types

This section is empty.

Jump to

Keyboard shortcuts

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