diagnostics

package
v1.10.0-alpha.10 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package diagnostics owns credential masking for transport previews and access logs. It operates on already captured data and never reads application bodies.

Index

Constants

View Source
const (
	// BodyCaptureLimit bounds development body previews without limiting wire bytes.
	BodyCaptureLimit = 64 << 10
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Fields

type Fields struct {
	// Headers lists credential header names, compared without case sensitivity.
	Headers []string
	// Query lists credential query parameter names.
	Query []string
	// JSON lists credential JSON member names, masked at any nesting depth.
	JSON []string
	// Form lists credential URL-encoded form field names.
	Form []string
	// Body omits the entire body, for example when the body is a scalar credential.
	Body bool
	// Path omits the URL path and all separately printed route variables.
	Path bool
}

Fields identifies authored credential locations in the actual wire format. Diagnostic constructors copy these slices; later caller changes have no effect.

type Policy

type Policy struct {
	// contains filtered or unexported fields
}

Policy is an immutable union of authored credential locations and conventional credential names. A zero Policy applies conventional masking only.

func New

func New(fields ...Fields) *Policy

New copies and merges fields into an immutable policy. The same physical name is masked across all observed methods, even if only one method declares it secret.

func (*Policy) Body

func (p *Policy) Body(contentType string, data []byte, omitted, complete bool) []byte

Body returns a safe preview of captured bytes. It never reads or modifies the application body. Omitted, malformed or incomplete structured captures are represented by an omission marker. Known body credentials with an unsupported content type cause whole-body omission; ordinary opaque bodies remain visible.

func (*Policy) Headers

func (p *Policy) Headers(headers http.Header) http.Header

Headers returns a masked copy without changing the application's headers.

func (*Policy) PathValues

func (p *Policy) PathValues(values map[string]string) map[string]string

PathValues returns a masked copy of separately captured route variables. A credential-bearing path omits every route value, matching whole-path omission.

func (*Policy) URL

func (p *Policy) URL(original *url.URL) *url.URL

URL returns a masked copy. An authored credential path also clears RawPath; credentials must not remain in an alternate escaped or opaque URL rendering.

Jump to

Keyboard shortcuts

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