Documentation
¶
Overview ¶
Package sopsenc encrypts a repository's secret files for the age recipients of the matching creation rule of its .sops.yaml. It holds public keys only: there is no private key and no decryption code path anywhere in the package (sopsenc's tests assert this for the whole module). Secret values it generates exist only in the encrypted output; the package logs nothing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoRule is returned when no creation rule of the .sops.yaml matches a // secret file's path; such a file is never committed in plaintext. ErrNoRule = errors.New("no creation rule matches") // ErrNoRecipients is returned for a creation rule without age recipients; // age public keys are the only key type the package encrypts for. ErrNoRecipients = errors.New("creation rule has no age recipients") )
var ( // ErrDuplicatePath is returned when a fileset names one path twice. ErrDuplicatePath = errors.New("duplicate file path") // ErrGeneratedInPlainFile is returned when a file that is not a secret file // declares generated values: a generated value only lives encrypted. ErrGeneratedInPlainFile = errors.New("generated values are only allowed in secret files") // ErrValueFrozen is returned when a new secret file shares a generated // value with a secret file that already exists in the repository. The // existing value cannot be reproduced without decryption, so the caller // has to reference the existing Secret instead. ErrValueFrozen = errors.New("generated value exists in an encrypted file already in the repository") )
var ErrInvalidGenerated = errors.New("invalid generated value declaration")
ErrInvalidGenerated is returned for a Generated declaration that is incomplete, inconsistent across files, or whose placeholder is absent from the file it is declared on.
Functions ¶
func IsSecretFile ¶
IsSecretFile reports whether a path names a secret file by the convention the .sops.yaml creation rules follow: a base name containing "secret" or "credential".
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config is a repository's parsed .sops.yaml.
func ParseConfig ¶
ParseConfig parses a .sops.yaml. Every rule's path_regex must compile and every rule must name at least one valid age recipient.
type Encryptor ¶
type Encryptor struct {
// contains filtered or unexported fields
}
Encryptor encrypts secret files for one repository's .sops.yaml.
func (*Encryptor) Encrypt ¶
Encrypt returns the fileset ready to commit, keyed by repository-relative path. Files that are not secret files pass through unchanged. A secret file that exists in the repository (exists reports its path) is left as it is and absent from the result: it is never re-generated. Every other secret file has its generated values filled in — one value per name across all files — and is encrypted for the recipients of its creation rule.
type File ¶
type File struct {
// Path is repository-relative, the path .sops.yaml's path_regex sees.
Path string
Content []byte
// Generated declares the placeholders in Content that receive generated
// values. Only a secret file may declare them.
Generated []Generated
}
File is one rendered file of a repository's fileset.
type Generated ¶
Generated declares a secret value the package generates at commit time and writes in place of Placeholder in the declaring file. The same Name in two files is one value; its Kind and Length must agree wherever it is declared. The value exists only in the encrypted output.
type Rule ¶
type Rule struct {
PathRegex *regexp.Regexp
// Recipients are age public keys.
Recipients []string
EncryptedRegex string
UnencryptedRegex string
EncryptedSuffix string
UnencryptedSuffix string
}
Rule is one creation rule: the paths it covers and the recipients it encrypts for. Files match the first rule in .sops.yaml order; a rule without path_regex matches every path.