security

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package security provides password input methods and redaction for sensitive data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsBecomeSupported

func IsBecomeSupported() bool

IsBecomeSupported returns true if the current platform supports become (sudo)

func ResolvePassword

func ResolvePassword(cfg PasswordConfig) (string, error)

ResolvePassword resolves the sudo password based on configuration Priority: Interactive > File > Env > CLI (if --insecure-sudo-pass)

Types

type CLIPasswordProvider

type CLIPasswordProvider struct {
	Password string
}

CLIPasswordProvider wraps the existing --sudo-pass flag

func (*CLIPasswordProvider) GetPassword

func (p *CLIPasswordProvider) GetPassword() (string, error)

func (*CLIPasswordProvider) Source

func (p *CLIPasswordProvider) Source() string

type EnvPasswordProvider

type EnvPasswordProvider struct {
	ProgramPath string
}

EnvPasswordProvider executes SUDO_ASKPASS helper program

func (*EnvPasswordProvider) GetPassword

func (p *EnvPasswordProvider) GetPassword() (string, error)

func (*EnvPasswordProvider) Source

func (p *EnvPasswordProvider) Source() string

type FilePasswordProvider

type FilePasswordProvider struct {
	FilePath string
}

FilePasswordProvider reads password from a file

func (*FilePasswordProvider) GetPassword

func (p *FilePasswordProvider) GetPassword() (string, error)

func (*FilePasswordProvider) Source

func (p *FilePasswordProvider) Source() string

type InteractivePasswordProvider

type InteractivePasswordProvider struct{}

InteractivePasswordProvider prompts the user for password input

func (*InteractivePasswordProvider) GetPassword

func (p *InteractivePasswordProvider) GetPassword() (string, error)

func (*InteractivePasswordProvider) Source

func (p *InteractivePasswordProvider) Source() string

type PasswordConfig

type PasswordConfig struct {
	CLIPassword    string
	AskInteractive bool
	PasswordFile   string
	InsecureCLI    bool
}

PasswordConfig holds configuration for password resolution

type PasswordProvider

type PasswordProvider interface {
	GetPassword() (string, error)
	Source() string
}

PasswordProvider defines an interface for obtaining sudo passwords

type Redactor

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

Redactor provides thread-safe string redaction for sensitive values

func NewRedactor

func NewRedactor() *Redactor

NewRedactor creates a new Redactor instance

func (*Redactor) AddSensitive

func (r *Redactor) AddSensitive(value string)

AddSensitive adds a sensitive value to be redacted Empty strings are ignored

func (*Redactor) Redact

func (r *Redactor) Redact(text string) string

Redact replaces all occurrences of sensitive values with [REDACTED]

Jump to

Keyboard shortcuts

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