securitytest

package
v1.9.13 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: AGPL-3.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 securitytest contains redacted, deterministic fixtures and assertion helpers for security tests. It is intentionally separate from the runtime utility package so production code cannot accidentally depend on test data.

Index

Constants

View Source
const (
	FixtureUserA            = "01J00000000000000000000001"
	FixtureUserB            = "01J00000000000000000000002"
	FixtureTenantA          = "01J00000000000000000000003"
	FixtureTenantB          = "01J00000000000000000000004"
	FixtureWorkerActor      = "01J00000000000000000000005"
	FixtureProjectGeneral   = "security_general"
	FixtureProjectShared    = "security_shared"
	FixtureProjectIso       = "security_isolated"
	FixtureWorkerOwnedRow   = "01J00000000000000000000006"
	FixtureWorkerNoOwnerRow = "01J00000000000000000000007"

	CredentialPlaneBootstrap = "project_api_key_bootstrap"
	CredentialPlaneAppUser   = "project_api_key_user"
	CredentialPlaneOperator  = "access_token"
)

These are valid, deterministic ULIDs for exercising real authorization paths. They are identifiers only; this package never contains credentials.

Variables

View Source
var SecurityFixtureCredentials = [...]FixtureCredential{
	{Name: "login-bootstrap", Plane: CredentialPlaneBootstrap},
	{Name: "app-user-session", Plane: CredentialPlaneAppUser},
	{Name: "operator-access-token", Plane: CredentialPlaneOperator},
}

Functions

func AssertSecurityDecision

func AssertSecurityDecision(got SecurityDecision, want SecurityDecision) error

AssertSecurityDecision checks the full security outcome, including the absence of privileged fallbacks and secret leakage.

func AssertSecurityPhaseDecision

func AssertSecurityPhaseDecision(
	phase string,
	got SecurityDecision,
	want SecurityDecision,
) error

AssertSecurityPhaseDecision gives each remediation phase a stable assertion boundary without putting credentials in failure output.

func RedactSecret

func RedactSecret(value string) string

RedactSecret returns a non-reversible marker suitable for test logs.

func SecretBearingHeaderNames

func SecretBearingHeaderNames(headers map[string]string) []string

SecretBearingHeaderNames reports header names, never header values.

func ValidateSecurityFixture

func ValidateSecurityFixture(f SecurityFixture) error

ValidateSecurityFixture checks the invariants needed by the shared fixture.

Types

type FixtureCredential

type FixtureCredential struct {
	Name  string
	Plane string
}

FixtureCredential describes a credential plane without carrying its secret.

type SecurityDecision

type SecurityDecision struct {
	Status        int
	ErrorCode     string
	UserID        string
	TenantID      string
	Credential    string
	RequestCount  int
	FallbackCalls int
	SecretHeaders []string
	SecretLogged  bool
}

SecurityDecision is a redacted result for a security assertion.

func ObserveSecurityRequests

func ObserveSecurityRequests(
	base SecurityDecision,
	requests []SecurityRequestEvidence,
) SecurityDecision

ObserveSecurityRequests converts request evidence into a redacted decision.

type SecurityFixture

type SecurityFixture struct {
	GeneralProject   string
	SharedProject    string
	IsolatedProject  string
	UserA            string
	UserB            string
	TenantA          string
	TenantB          string
	WorkerActor      string
	WorkerOwnedRow   string
	WorkerNoOwnerRow string
}

SecurityFixture is the common deterministic topology used by adversarial security tests.

func DefaultSecurityFixture

func DefaultSecurityFixture() SecurityFixture

DefaultSecurityFixture returns a fresh value so individual tests can extend it without mutating shared state.

type SecurityRequestEvidence

type SecurityRequestEvidence struct {
	CredentialPlane       string
	PrivilegedFallback    bool
	SecretBearingHeaders  []string
	SecretBearingLogEntry bool
}

SecurityRequestEvidence is safe to retain in test output: it stores only normalized names of headers that contained secret material.

Jump to

Keyboard shortcuts

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