Documentation
¶
Index ¶
- func IsLeafValue(v interface{}) bool
- type EnvFile
- type EnvLine
- type EnvLineType
- type FileFormat
- type IdentityLoader
- type MatchResult
- type Matcher
- type Processor
- func (p *Processor) CheckFile(filePath string, formatOverride ...string) ([]MatchResult, error)
- func (p *Processor) ComputeMAC(content []byte, fileFormat FileFormat) ([]byte, error)
- func (p *Processor) Config() *config.Config
- func (p *Processor) EncryptMAC(hash []byte) (string, error)
- func (p *Processor) HasEncryptedValues(content []byte, filePath string, formatOverride ...string) bool
- func (p *Processor) HasUnencryptedValues(content []byte, filePath string, formatOverride ...string) bool
- func (p *Processor) MatchFile(filePath string, formatOverride ...string) ([]MatchResult, error)
- func (p *Processor) ProcessContent(content []byte, filePath string, encrypt bool, fileFormat FileFormat) ([]byte, bool, error)
- func (p *Processor) ProcessFile(filePath string, encrypt bool, formatOverride ...string) ([]byte, bool, error)
- func (p *Processor) SaveEncryptedSecrets() error
- func (p *Processor) SetupDecryption(identities []age.Identity) (string, error)
- func (p *Processor) SetupEncryption() error
- func (p *Processor) SetupEncryptionWithIdentities(identities []age.Identity) error
- func (p *Processor) UpdateMAC(filePath string, content []byte, formatOverride ...string) error
- func (p *Processor) VerifyMAC(filePath string, content []byte, formatOverride ...string) error
- func (p *Processor) WriteFile(filePath string, content []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsLeafValue ¶
func IsLeafValue(v interface{}) bool
IsLeafValue checks if a value is a leaf (not a map or slice)
Types ¶
type EnvFile ¶ added in v1.7.0
type EnvFile struct {
Lines []EnvLine
}
EnvFile represents a parsed .env file preserving structure
func ParseEnvFile ¶ added in v1.7.0
ParseEnvFile parses .env file content preserving structure
func (*EnvFile) Marshal ¶ added in v1.7.0
Marshal converts the EnvFile back to bytes, preserving structure
type EnvLine ¶ added in v1.7.0
type EnvLine struct {
Type EnvLineType
Key string // For key-value pairs
Value string // Raw value after = (may include quotes)
Raw string // Original line content
Comment string // Inline comment (not encrypted)
Export bool // Whether line had "export " prefix
}
EnvLine represents a single line in an .env file
type EnvLineType ¶ added in v1.7.0
type EnvLineType int
EnvLineType represents the type of line in an .env file
const ( EnvLineBlank EnvLineType = iota EnvLineComment EnvLineKeyValue )
type FileFormat ¶
type FileFormat int
FileFormat represents the format of a config file
const ( FormatYAML FileFormat = iota FormatJSON FormatEnv FormatFull // Full file encryption (binary or text) )
func DetectFormat ¶
func DetectFormat(filePath string, override ...string) FileFormat
DetectFormat determines the file format from extension and optional override The override parameter can be "full", "yaml", "json", or "env" to force a specific format
type IdentityLoader ¶
IdentityLoader is a function that loads age identities
type MatchResult ¶
type MatchResult struct {
Path []string // Full path to the key
KeyName string // Name of the key
Value interface{}
Encrypted bool // Whether the value is already encrypted
}
MatchResult represents the result of checking a value for encryption
type Matcher ¶
type Matcher struct {
// contains filtered or unexported fields
}
Matcher handles key matching logic for encryption
func NewMatcher ¶
NewMatcher creates a new Matcher from include and exclude rules
func (*Matcher) FindMatchingKeys ¶
func (m *Matcher) FindMatchingKeys(data interface{}) []MatchResult
FindMatchingKeys traverses a data structure and finds all keys that should be encrypted
type Processor ¶
type Processor struct {
// contains filtered or unexported fields
}
Processor handles encryption/decryption of config files
func NewProcessor ¶
func NewProcessor(cfg *config.Config, identityLoader IdentityLoader) (*Processor, error)
NewProcessor creates a new Processor
func (*Processor) CheckFile ¶
func (p *Processor) CheckFile(filePath string, formatOverride ...string) ([]MatchResult, error)
CheckFile checks a file for unencrypted keys that should be encrypted The optional formatOverride parameter can be used to force a specific format
func (*Processor) ComputeMAC ¶
func (p *Processor) ComputeMAC(content []byte, fileFormat FileFormat) ([]byte, error)
ComputeMAC computes the MAC (SHA256 hash of all encrypted values) for a file
func (*Processor) EncryptMAC ¶
EncryptMAC encrypts the MAC hash using AES-GCM
func (*Processor) HasEncryptedValues ¶
func (p *Processor) HasEncryptedValues(content []byte, filePath string, formatOverride ...string) bool
HasEncryptedValues checks if file content contains any encrypted values The optional formatOverride parameter can be used to force a specific format
func (*Processor) HasUnencryptedValues ¶ added in v1.4.0
func (p *Processor) HasUnencryptedValues(content []byte, filePath string, formatOverride ...string) bool
HasUnencryptedValues checks if file content contains any unencrypted values that match encryption rules The optional formatOverride parameter can be used to force a specific format
func (*Processor) MatchFile ¶ added in v1.11.0
func (p *Processor) MatchFile(filePath string, formatOverride ...string) ([]MatchResult, error)
MatchFile returns all keys matching the configured patterns, regardless of encryption state.
func (*Processor) ProcessContent ¶ added in v1.10.0
func (p *Processor) ProcessContent(content []byte, filePath string, encrypt bool, fileFormat FileFormat) ([]byte, bool, error)
ProcessContent processes content with a specific format for encryption or decryption
func (*Processor) ProcessFile ¶
func (p *Processor) ProcessFile(filePath string, encrypt bool, formatOverride ...string) ([]byte, bool, error)
ProcessFile processes a single file for encryption or decryption The optional formatOverride parameter can be used to force a specific format
func (*Processor) SaveEncryptedSecrets ¶
SaveEncryptedSecrets encrypts the AES key for all recipients and saves to config
func (*Processor) SetupDecryption ¶
SetupDecryption prepares the processor for decryption. Returns the public key of the recipient that was used for decryption.
func (*Processor) SetupEncryption ¶
SetupEncryption prepares the processor for encryption
func (*Processor) SetupEncryptionWithIdentities ¶
SetupEncryptionWithIdentities prepares the processor for encryption with optional identities If identities is nil, it will try to load them from environment/default location
func (*Processor) UpdateMAC ¶
UpdateMAC computes and stores the MAC for a file The optional formatOverride parameter can be used to force a specific format