Documentation
¶
Overview ¶
Package profile reads lockfile's configuration (docs/usage.md) on lockkit's config base: source profiles, limits and marketplaces, from the config file of the lockfile account. It never reads a secret: credentials come from the console (ask, the OS keychain or Vault).
Index ¶
- Constants
- Variables
- func AppendProfile(path, name string, keys []string, values map[string]any) error
- func RemoveMarketplace(path, name string) error
- func SignerWarnings(re string) []string
- func ValidMarketplaceName(s string) bool
- type File
- type PluginPin
- type Policy
- type Profile
- type Raw
- type RawMarketplace
- type RawProfile
- type Trust
- type Workspace
Constants ¶
const ( SourceS3 = "s3" SourceSFTP = "sftp" SourceLocal = "local" )
Source kinds.
const ( AuthKey = "key" AuthPassword = "password" )
SFTP authentication modes.
const ( DefaultMaxObjectBytes = 50 << 20 DefaultMaxObjectsPerPlan = 5 DefaultMaxPluginsPerHandle = 16 DefaultHandleTTL = 30 * time.Minute DefaultAnswerQuantum = 5 * time.Second // DefaultIdleTimeout and DefaultMaxSession are lockkit's console // defaults, applied here so the approved policy states them. DefaultIdleTimeout = 20 * time.Minute DefaultMaxSession = 4 * time.Hour MaxPluginsPerHandleCap = 64 DefaultSFTPPort = 22 )
Defaults, as docs/usage.md lists them.
const DefaultMaxWorkspaceBytes = 1 << 30
DefaultMaxWorkspaceBytes bounds all fetched files together.
Variables ¶
var ErrInvalidProfile = errors.New("invalid profile")
ErrInvalidProfile wraps the refusal of the profile AppendProfile was given (its name or its keys), as opposed to a config file that cannot be read, parsed or written.
var ErrNoProfile = errors.New("config: no such profile (a [profiles.NAME] table of the config file)")
ErrNoProfile refuses a profile name the config file does not define. It does not quote the name: a value typed on the command line is not a key of the file, and may be anything pasted there.
var ErrProfileExists = errors.New("the profile is already in the config file")
ErrProfileExists refuses a profile the config file already defines: AppendProfile never rewrites one.
var ErrPublicKeyRoot = errors.New("public-key trust roots need lockkit support (not in lockkit yet): use a keyless identity_regexp and oidc_issuer")
ErrPublicKeyRoot refuses a public-key trust root: lockkit's signature check is keyless only.
Functions ¶
func AppendProfile ¶
AppendProfile adds [profiles.<name>] with the given keys (TOML names; string, int or bool values, written in the order of keys) at the end of the config file at path, after checking the profile alone, then the whole file, with Parse. A profile the file already has is never rewritten (ErrProfileExists).
func RemoveMarketplace ¶
RemoveMarketplace cuts the [[marketplaces]] block named name from the config file at path.
func SignerWarnings ¶ added in v0.3.0
SignerWarnings lists the weaknesses of an identity_regexp that let other signers in: an unescaped '.' between two name characters ("github.com" also matches "githubXcom"), and a literal prefix that does not pin host, owner and repository each followed by '/' ("^https://github\.com/acme" also matches "acme-evil").
func ValidMarketplaceName ¶ added in v0.5.2
ValidMarketplaceName reports whether s is a valid unofficial marketplace name (safe to quote in an error).
Types ¶
type File ¶
File is a decoded, validated config file.
type PluginPin ¶
type PluginPin struct {
Name string `json:"name"` // qualified
Version string `json:"version"`
Marketplace string `json:"marketplace"`
ManifestSHA256 string `json:"manifest_sha256"`
BinarySHA256 string `json:"binary_sha256"`
Official bool `json:"official"`
}
PluginPin is an installed plugin as the policy sees it. A new pin, or a pin whose manifest changed (its question may have), loosens the policy.
type Policy ¶
type Policy struct {
P Profile `json:"profile"`
Plugins []PluginPin `json:"plugins"`
Marketplaces []Trust `json:"marketplaces"`
// Workspace is where fetched files live and how much they may take:
// moving it or raising its cap is a loosening the human reviews.
Workspace Workspace `json:"workspace"`
}
Policy is what the console enforces for one profile: the profile, the installed plugins and the trusted marketplaces. Its JSON form is the approved policy lockkit stores, so it is canonical (sorted, defaults applied).
func Load ¶
Load reads the profile name of the config file at path and the plugins installed in store.
func (*Policy) Describe ¶
Describe implements config.Policy: the lines of the console's policy review and status screen.
func (*Policy) Diff ¶
Diff implements config.Policy: the loosening rules listed in docs/security-model.md.
type Profile ¶
type Profile struct {
config.Base
Name string `json:"name"`
Source string `json:"source"`
// Prefix bounds the keys of every source kind ("" = any key).
Prefix string `json:"prefix"`
S3 source.S3Config `json:"s3"`
SFTP source.SFTPConfig `json:"sftp"`
// SFTPAuth is key or password; SFTPKey the private key path (in the
// lockfile account) for key.
SFTPAuth string `json:"sftp_auth,omitempty"`
SFTPKey string `json:"sftp_key,omitempty"`
LocalPath string `json:"local_path,omitempty"`
MaxObjectBytes int64 `json:"max_object_bytes"`
MaxObjectsPerPlan int `json:"max_objects_per_plan"`
MaxPluginsPerHandle int `json:"max_plugins_per_handle"`
HandleTTL time.Duration `json:"handle_ttl"`
AnswerQuantum time.Duration `json:"answer_quantum"`
}
Profile is a validated profile with its defaults applied.
type Raw ¶
type Raw struct {
WorkDir string `toml:"work_dir"`
MaxWorkspaceBytes string `toml:"max_workspace_bytes"`
Profiles map[string]RawProfile `toml:"profiles"`
Marketplaces []RawMarketplace `toml:"marketplaces"`
}
Raw is the config file as written.
type RawMarketplace ¶
type RawMarketplace struct {
Name string `toml:"name"`
IndexURL string `toml:"index_url"`
IdentityRegexp string `toml:"identity_regexp"`
OIDCIssuer string `toml:"oidc_issuer"`
PublicKey string `toml:"public_key"`
}
RawMarketplace is one [[marketplaces]] entry (docs/usage.md).
type RawProfile ¶
type RawProfile struct {
Source string `toml:"source"`
// s3
Bucket string `toml:"bucket"`
Region string `toml:"region"`
Endpoint string `toml:"endpoint"`
Prefix string `toml:"prefix"`
// sftp
Host string `toml:"host"`
Port int `toml:"port"`
Auth string `toml:"auth"`
Key string `toml:"key"`
KnownHosts string `toml:"known_hosts"`
BaseDir string `toml:"base_dir"`
// local
Path string `toml:"path"`
// shared with lockkit's config.Base
User string `toml:"user"`
Credentials string `toml:"credentials"`
VaultPath string `toml:"vault_path"`
CredentialsTTL string `toml:"credentials_ttl"`
Production bool `toml:"production"`
IdleTimeout string `toml:"idle_timeout"`
MaxSession string `toml:"max_session"`
// limits
MaxObjectBytes string `toml:"max_object_bytes"`
MaxObjectsPerPlan int `toml:"max_objects_per_plan"`
MaxPluginsPerHandle int `toml:"max_plugins_per_handle"`
HandleTTL string `toml:"handle_ttl"`
AnswerQuantum string `toml:"answer_quantum"`
}
RawProfile is one [profiles.NAME] table.
type Trust ¶
type Trust struct {
Name string `json:"name"`
IndexURL string `json:"index_url"`
IdentityRegexp string `json:"identity_regexp"`
OIDCIssuer string `json:"oidc_issuer"`
}
Trust is an unofficial marketplace and its keyless trust root.
func AppendMarketplace ¶
func AppendMarketplace(path string, r RawMarketplace) (Trust, error)
AppendMarketplace adds an unofficial marketplace at the end of the config file at path (created 0600 when missing).
func CheckMarketplace ¶
func CheckMarketplace(r RawMarketplace) (Trust, error)
CheckMarketplace validates an unofficial marketplace entry.
func (Trust) Marketplace ¶
func (t Trust) Marketplace() marketplace.Marketplace
Marketplace is t for the installer: never official.