secrets

package
v0.59.0 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package secrets provides utilities for secure handling of sensitive data. This package ensures API keys and other secrets are never exposed in logs, error messages, or exported configurations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatKeySource

func FormatKeySource(envVarName string, hasDirectKey bool) string

FormatKeySource returns a display string for where an API key came from.

func IsPotentialSecret

func IsPotentialSecret(s string) bool

IsPotentialSecret checks if a string looks like it might be a secret.

func MaskAPIKey

func MaskAPIKey(key string) string

MaskAPIKey masks an API key for safe display. Shows only the first 4 and last 4 characters. For very short keys, returns "***".

func MaskAllSecrets

func MaskAllSecrets(s string) string

MaskAllSecrets masks all known secret patterns in a string. Useful for sanitizing log output or error messages.

func MaskBearer

func MaskBearer(s string) string

MaskBearer masks a Bearer token in a string.

func MaskJSONSecrets

func MaskJSONSecrets(jsonData []byte) []byte

MaskJSONSecrets masks sensitive fields in JSON data. This is useful for sanitizing request/response logs.

func RedactForLog

func RedactForLog(s string) string

RedactForLog returns a string safe for logging. This is the primary function to use when logging any user-provided or configuration-derived data that might contain secrets.

func SanitizeHeaders

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

SanitizeHeaders masks sensitive headers for logging. Returns a new map with sensitive values masked.

Types

This section is empty.

Jump to

Keyboard shortcuts

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