Documentation
¶
Overview ¶
Package httpcheck implements POST /v1/check, the engine's own check API (api/engine/v1). It serves proxies without a native protocol (the ingress-nginx Lua plugin, the Traefik plugin), inkwallctl and tests.
The caller describes one client request in a CheckRequest, protobuf (Content-Type: application/x-protobuf) or JSON (application/json), and gets the verdict back in a CheckResponse in the same encoding. Any well-formed check is answered with 200; the verdict is in the body.
The caller is trusted: the engine inspects the request it describes and takes its client_ip as given. Listen only where the proxy alone can reach it (a Unix socket or localhost).
Index ¶
Constants ¶
const ( ContentTypeProtobuf = "application/x-protobuf" ContentTypeJSON = "application/json" )
Content types of the two encodings.
const Path = "/v1/check"
Path is where check requests are sent.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// MaxBodyBytes is how much of a request body is inspected; longer bodies
// are treated as truncated. Zero disables body inspection.
MaxBodyBytes int64
// Logger receives one security event per denied or logged request.
// Nil uses slog.Default().
Logger *slog.Logger
// Metrics counts the requests the adapter can't read (nil: none).
Metrics *telemetry.Metrics
// Events records each security event for the operator (nil: logged
// only).
Events *events.Recorder
}
Config configures a Handler.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler answers check requests.
func (*Handler) CheckExchange ¶ added in v0.5.0
func (h *Handler) CheckExchange(ctx context.Context, in *enginev1.CheckRequest, resp *request.Response) (req, res *enginev1.CheckResponse, err error)
CheckExchange inspects the request in describes, as ServeHTTP does but without logging a security event, and then resp, its response, as the ext_proc adapter does: when the request was let through and its policy inspects responses, with the body inspected when the rules read its Content-Type, up to the policy's response body limit (a longer one has its prefix inspected and is truncated). It is for offline tests (inkwallctl test --suite): the check API itself has no response. res is nil when the response wasn't inspected: the request was denied, or its policy (or the pipeline) doesn't inspect responses.