Help us shape the future of Go! Take the 2026 Go Developer Survey

report

package
v1.4.15 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ClassValue      = "value"
	ClassPEM        = "pem"
	ClassUserinfo   = "url_userinfo"
	ClassPattern    = "pattern"
	ClassAssignment = "assignment"
)

Redaction classes counted in manifest.json.

View Source
const ContainerLogTimeout = 60 * time.Second

ContainerLogTimeout bounds one container's log read (N3).

View Source
const DefaultMaxLogBytes = 4 << 20

DefaultMaxLogBytes caps one service log (the tail is kept).

View Source
const DoctorTimeout = 120 * time.Second

DoctorTimeout bounds the doctor child process.

View Source
const MinSecretLen = 6

MinSecretLen is the shortest value that is used as a literal scrub input.

Variables

This section is empty.

Functions

func DefaultName

func DefaultName(now time.Time) string

DefaultName is nself-report-<UTC timestamp>.tar.gz.

func IsKeyName

func IsKeyName(s string) bool

IsKeyName reports whether s is a valid config key name.

func IsSecretName

func IsSecretName(name string) bool

IsSecretName reports whether an env/compose key name looks secret-bearing.

func LogName

func LogName(service string) string

LogName maps a service name to logs/<name>.log with no path separators or dot-dot components.

func RunDoctorChild

func RunDoctorChild(ctx context.Context, dir string, exe func() (string, error)) (string, error)

RunDoctorChild runs `<this binary> doctor` in dir and returns its combined output. exe is the seam for os.Executable.

func TrimQuotes

func TrimQuotes(v string) string

TrimQuotes removes one matching pair of surrounding quotes.

func WriteTarball

func WriteTarball(b *Bundle, path string, now time.Time) (size int64, err error)

WriteTarball writes b to path and returns the archive size in bytes.

Types

type Bundle

type Bundle struct {
	Files      []File
	Redactions map[string]int
	Total      int
	Notes      []string
}

Bundle is the scrubbed result.

func Collect

func Collect(ctx context.Context, opt Options, src Sources) (*Bundle, error)

Collect gathers, scrubs and orders the bundle files; manifest.json is last.

type DockerSetup

type DockerSetup struct {
	ProjectDir   string
	DockerPath   string // empty: docker from PATH
	ComposeFiles []string
	EnvFiles     []string
}

DockerSetup tells the real log source which stack to read.

type File

type File struct {
	Name string
	Data []byte
	Dir  bool
}

File is one entry of the bundle. Dir entries have no data.

type Options

type Options struct {
	ProjectDir string
	// NginxDir is the served nginx directory (internal/nginxtopo); empty skips nginx.
	NginxDir string
	Notes    []string // caller notes carried into manifest.json
	LogLines int
	// ComposeFragments are the compose files of the stack (.nself/compose-files.txt
	// resolved): read as scrub inputs only, never bundled.
	ComposeFragments []string
	// ComposeEnvFiles are the env files `nself build` writes for compose
	// interpolation (build.ComposeEnvFiles: .env and .nself/compose.env); read as
	// scrub inputs only.
	ComposeEnvFiles []string
	// Environ is the process environment seam; nil means os.Environ.
	Environ func() []string
	// MaxLogBytes caps each service log; 0 means DefaultMaxLogBytes.
	MaxLogBytes int
}

Options configure one collection.

type Scrubber

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

Scrubber holds the literal inputs and the running counts.

func NewScrubber

func NewScrubber(values []SecretValue) *Scrubber

NewScrubber builds a scrubber over the given secret values.

func (*Scrubber) Counts

func (s *Scrubber) Counts() map[string]int

Counts returns a copy of the per-class redaction counts.

func (*Scrubber) Scrub

func (s *Scrubber) Scrub(text string) string

Scrub runs all passes over text.

func (*Scrubber) Total

func (s *Scrubber) Total() int

Total is the sum of all classes.

type SecretValue

type SecretValue struct {
	Key      string
	Variants []string
}

SecretValue is one literal to remove, in every spelling it may take.

func ExpandSecretValues

func ExpandSecretValues(key, value string) []SecretValue

ExpandSecretValues returns every literal the scrubber should learn from one key=value pair: the value itself when the key is secret-like; the password of a URL-shaped value (any key, DATABASE_URL style, even when url.Parse refuses it: see urlcreds.go); and, for a secret-like key holding a JSON object (HASURA_GRAPHQL_JWT_SECRET), each string field of it that is secret-like or named "key", so the inner key is scrubbed on its own.

func NewSecretValue

func NewSecretValue(key, value string) (SecretValue, bool)

NewSecretValue returns the scrub input for key=value, or false when the key is not secret-like, the value is too short, or it is only a ${REF}.

type Sources

type Sources struct {
	Versions func(ctx context.Context) map[string]string
	Doctor   func(ctx context.Context) (string, error)
	// Logs returns the log tail of each service, keyed by service name.
	Logs func(ctx context.Context, tail int) (map[string]string, error)
	// LogNotes returns the notes the Logs call collected (for example a
	// container whose log read timed out); optional, called right after Logs.
	LogNotes func() []string
	Now      func() time.Time
}

Sources are the seams tests replace.

func RealSources

func RealSources(ds DockerSetup) Sources

RealSources returns the production seams.

type TimeoutError

type TimeoutError struct{ After time.Duration }

TimeoutError reports that the doctor child ran out of time.

func (*TimeoutError) Error

func (e *TimeoutError) Error() string

Jump to

Keyboard shortcuts

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