redacttest

package
v1.235.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 5 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 redacttest holds the credential-bearing inputs that every URL redaction helper must handle. The helpers in pkg/artifact and pkg/utils share one security property, so they share one table: a test feeds the same cases to each helper and asserts that no secret survives.

Index

Constants

View Source
const (
	// User is a distinctive user name, so a test can tell it apart from any host or path.
	User = "usr7"
	// SecretA and SecretB are distinctive password fragments.
	SecretA = "S3cr3tA"
	// SecretB is the second password fragment, used when a delimiter splits a password in two.
	SecretB = "S3cr3tB"
	// SecretC is the third password fragment, used when two delimiters split a password in three.
	SecretC = "S3cr3tC"
	// Marker starts every secret the generated inputs carry, so a leak of any fragment of a secret,
	// however a delimiter cut it, is a leak of the marker.
	Marker = "S3cr3t"
)

Variables

This section is empty.

Functions

func Leaks

func Leaks(out string) []string

Leaks returns what survives in out of the user name and of the secret: every fragment of a secret starts with Marker, so a delimiter inside the secret cannot hide a leak.

func RequireNoLeak

func RequireNoLeak(t testing.TB, entry string, in Input, out string)

RequireNoLeak fails the test when out, the redacted output of the entry point named entry for in, still holds the user name or any fragment of the secret.

func SecretOf

func SecretOf(first, separator, second string) string

SecretOf builds a secret that carries Marker twice, joined by an arbitrary separator, so a delimiter inside the secret splits it into fragments that each start with the marker.

func Seeds

func Seeds() []string

Seeds returns the separators a fuzz run starts from: one for every delimiter the shared table splits a password at, so that the corpus covers every input of Cases as a generated secret.

Types

type Case

type Case struct {
	// Name describes the shape of the input.
	Name string
	// Raw is the URL, or URL-like address, that carries the credential.
	Raw string
	// Secrets are the strings that must never appear in the redacted form of Raw: the user, the
	// password, and every fragment a delimiter inside the password could leave behind.
	Secrets []string
	// Quoted are the passwords an error may quote on their own, in any form a parser can decode.
	Quoted []string
}

Case is one credential-bearing input.

func Cases

func Cases() []Case

Cases returns the shared table of nasty inputs. Each call returns a fresh slice, so a caller may not alias or mutate another caller's table.

type Input

type Input struct {
	// Name describes the template the address was built from.
	Name string
	// Raw is the address.
	Raw string
	// Password is the password as it was typed into Raw, or empty when Raw has none.
	Password string
}

Input is one generated credential-bearing address and the ways an error may quote it.

func Generate

func Generate(secret string) []Input

Generate embeds secret as the password of many address templates: user information of every scheme, with the secret before and after other delimiters, in an escaped form, repeated in the query and the fragment, and with hosts named like digests. Each address ends its user information with an "@" of its own, so the secret is always a credential and never a host. The secret may hold any delimiter, so the same template covers a password that closes the authority early.

func (Input) Messages

func (in Input) Messages() []string

Messages returns error texts that quote the input the way fetch, parse, and decode errors do: verbatim, quoted with %q, stripped of its scheme, as the password on its own, and as the text of a URL parse error.

Jump to

Keyboard shortcuts

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