Help us shape the future of Go! Take the 2026 Go Developer Survey

profile

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

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

View Source
const (
	SourceS3    = "s3"
	SourceSFTP  = "sftp"
	SourceLocal = "local"
)

Source kinds.

View Source
const (
	AuthKey      = "key"
	AuthPassword = "password"
)

SFTP authentication modes.

View Source
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.

View Source
const DefaultMaxWorkspaceBytes = 1 << 30

DefaultMaxWorkspaceBytes bounds all fetched files together.

Variables

View Source
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.

View Source
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.

View Source
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.

View Source
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

func AppendProfile(path, name string, keys []string, values map[string]any) error

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

func RemoveMarketplace(path, name string) error

RemoveMarketplace cuts the [[marketplaces]] block named name from the config file at path.

func SignerWarnings added in v0.3.0

func SignerWarnings(re string) []string

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

func ValidMarketplaceName(s string) bool

ValidMarketplaceName reports whether s is a valid unofficial marketplace name (safe to quote in an error).

Types

type File

type File struct {
	Workspace    Workspace
	Profiles     map[string]Profile
	Marketplaces []Trust
}

File is a decoded, validated config file.

func Parse

func Parse(data []byte, name string) (*File, error)

Parse decodes and validates config data; name labels errors.

func ReadFile

func ReadFile(path string) (*File, error)

ReadFile reads and validates the config file at path.

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 FromFile

func FromFile(f *File, name string, store plugin.Store) (*Policy, error)

FromFile builds the policy of profile name.

func Load

func Load(path, name string, store plugin.Store) (*Policy, error)

Load reads the profile name of the config file at path and the plugins installed in store.

func (*Policy) Describe

func (p *Policy) Describe() []string

Describe implements config.Policy: the lines of the console's policy review and status screen.

func (*Policy) Diff

func (p *Policy) Diff(approved config.Policy) []config.Change

Diff implements config.Policy: the loosening rules listed in docs/security-model.md.

func (*Policy) Pin

func (p *Policy) Pin(name string) (PluginPin, bool)

Pin returns the pin of the qualified plugin name.

func (*Policy) Profile

func (p *Policy) Profile() console.Profile

Profile implements console.Policy.

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.

func (Profile) Console

func (p Profile) Console() console.Profile

Console is the profile as lockkit's console needs it.

func (Profile) Where

func (p Profile) Where() string

Where names the source for the human: never a secret.

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.

func (Trust) String

func (t Trust) String() string

type Workspace

type Workspace struct {
	Dir      string `json:"dir"` // "" = the default under the state dir
	MaxBytes int64  `json:"max_bytes"`
}

Workspace is the workspace part of the config.

Jump to

Keyboard shortcuts

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