diagnostics

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 8 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 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.
	// Matching ignores Unicode case, dashes and underscores, conservatively
	// covering aliases accepted by encoding/json/v2's case:ignore fields.
	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 explicitly typed opaque bodies remain visible. A missing content type uses JSON, matching the HTTP decoders.

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. Opaque URLs are omitted because they can contain credentials outside the parsed userinfo/query fields. An authored credential path also clears RawPath so an alternate escaped rendering cannot disclose it.

Jump to

Keyboard shortcuts

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