secrets

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxSecretKeys       = 256
	MaxSecretKeyLength  = 256
	MaxSecretValueSize  = 65536   // 64 KB per value
	MaxSecretsTotalSize = 1048576 // 1 MB aggregate
)

Secrets validation limits.

Variables

View Source
var ErrSecretsValidation = errors.New("secrets validation failed")

ErrSecretsValidation is returned when the provided secrets fail validation against the manifest or size constraints.

Functions

func DecryptBytes

func DecryptBytes(ciphertext []byte, key []byte) ([]byte, error)

DecryptBytes is the inverse of EncryptBytes.

func DecryptToken

func DecryptToken(ciphertext []byte, key []byte) (string, error)

DecryptToken decrypts an AES-256-GCM ciphertext (with prepended nonce) back to a plaintext token. The key must be exactly 32 bytes.

func EncryptBytes

func EncryptBytes(plaintext []byte, key []byte) ([]byte, error)

EncryptBytes encrypts an arbitrary byte payload (e.g. a JSON-encoded secret map) using AES-256-GCM. It is the byte-oriented sibling of EncryptToken: same algorithm, same key requirements, same wire format (nonce || ciphertext || tag), but the caller doesn't have to pretend their bytes are UTF-8 to use it.

func EncryptToken

func EncryptToken(plaintext string, key []byte) ([]byte, error)

EncryptToken encrypts a plaintext token using AES-256-GCM. The key must be exactly 32 bytes. The returned ciphertext has the nonce prepended (first 12 bytes).

func ExtractRequiredSecrets

func ExtractRequiredSecrets(manifestJSON []byte) (map[string]bool, error)

ExtractRequiredSecrets parses a compiled manifest JSON and returns the set of secret names referenced by services via env vars.

func RedactSecretValues

func RedactSecretValues(msg string, secrets map[string]string) string

RedactSecretValues replaces occurrences of secret values in msg with [REDACTED]. Only redacts values of 8+ characters to avoid false positives on short strings. Processes longest values first to prevent partial matches.

func SecretKeyNames

func SecretKeyNames(secrets map[string]string) []string

SecretKeyNames returns sorted key names from a secrets map. Used for audit logging — never log values.

func ValidateSecrets

func ValidateSecrets(manifestJSON []byte, secrets map[string]string) error

ValidateSecrets checks that the provided secrets map satisfies size constraints and that all manifest-required secrets are present. Returns a wrapped ErrSecretsValidation on failure.

Types

type VMCredentials

type VMCredentials struct {
	AuthToken string // hex-encoded random 32 bytes (64 chars)
	CertPEM   []byte // PEM-encoded self-signed X.509 certificate
	KeyPEM    []byte // PEM-encoded ECDSA private key
}

VMCredentials holds the plaintext materials generated for a single VM.

func GenerateVMCredentials

func GenerateVMCredentials(vmName string) (*VMCredentials, error)

GenerateVMCredentials creates a random auth token and a self-signed TLS certificate+key pair for a single VM. The cert uses the VM name as CN, includes 127.0.0.1 and 0.0.0.0 as SANs, and expires in 7 days.

Jump to

Keyboard shortcuts

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