Documentation
¶
Overview ¶
Package config loads lockmq profiles from the project and user config files, applies the defaults, refuses anything that looks like a secret, and computes the security-relevant policy of a profile. The file lookup, the secret-safe decoding, the shared profile base and the diff helpers are lockkit's.
Index ¶
- Constants
- func DefaultBodyMode(production bool) string
- func DefaultDetectors() []string
- func Load(cwd string) (map[string]Profile, string, error)
- func LoadFile(path string) (map[string]Profile, error)
- func LoadFrom(cwd, userConfigPath string) (map[string]Profile, string, error)
- func ParseProfiles(data []byte, name string) (map[string]Profile, error)
- type Limits
- type ParsedURL
- type Policy
- type Profile
- type Tier
Constants ¶
const ( // BodyRedactUnknown redacts every string leaf no allow rule names. BodyRedactUnknown = "redact-unknown" // BodyDetect masks what mask rules, key names and detectors find. BodyDetect = "detect" )
Body modes: how the string leaves of a JSON message body are masked.
const ( ReadMaxCeiling = 200 PeekMaxCeiling = 20 )
Hard ceilings of the per-request message counts.
const ( MinIdleTimeout = time.Minute MaxMaxSession = 24 * time.Hour )
Bounds of the session limits: MinIdleTimeout <= idle_timeout <= max_session <= MaxMaxSession.
const ( DefaultIdleTimeout = 20 * time.Minute DefaultMaxSession = 4 * time.Hour )
Default session limits.
const DefaultMaskMode = "redact"
DefaultMaskMode is the mode of a mask rule that sets none.
Variables ¶
This section is empty.
Functions ¶
func DefaultBodyMode ¶
DefaultBodyMode is redact-unknown on production, detect elsewhere.
func DefaultDetectors ¶
func DefaultDetectors() []string
DefaultDetectors is the detector set of a profile that sets none. National id detectors are opt-in.
func Load ¶
Load reads the project config (found by walking up from cwd) and the user config. On a profile name present in both, the project profile wins as a whole. It also returns the project root ("" when none).
Types ¶
type Limits ¶
type Limits struct {
RequestTimeout time.Duration `json:"request_timeout"`
// ReadMax and PeekMax are the most messages one stream read or one
// queue peek returns.
ReadMax int `json:"read_max"`
PeekMax int `json:"peek_max"`
// DeliveryHeadroom refuses a quorum queue peek this close to the
// queue's delivery limit.
DeliveryHeadroom int `json:"delivery_headroom"`
// MaxBodyBytes caps one message body after masking.
MaxBodyBytes int `json:"max_body_bytes"`
MaxOutputBytes int `json:"max_output_bytes"`
ListPageSize int `json:"list_page_size"`
}
Limits bound the cost and size of one request.
func DefaultLimits ¶
func DefaultLimits() Limits
DefaultLimits returns the limits applied to unset limit fields.
type Policy ¶
type Policy struct {
Profile Profile `json:"profile"`
Mask []string `json:"pii_mask"`
Allow []string `json:"pii_allow"`
// Modes maps a mask rule to its mode when it is not redact.
Modes map[string]string `json:"pii_modes,omitempty"`
}
Policy is the security-relevant view of one profile plus its PII rules: what the console fingerprints, compares with the last approved one and asks the human about before applying any loosening. Mask and Allow hold rules in their canonical text form (package msgmask).
func Canonical ¶
Canonical sorts and de-duplicates the lists of p and drops the modes of rules it does not hold and the default mode: its JSON is the fingerprinted form.
func (Policy) Diff ¶
Diff lists the changes from approved to p and marks each loosening (design §4): read → peek, a lower delivery_headroom, any larger limit, a longer request_timeout, a new vhost (or every vhost), any change of url, amqp_url or stream_url, body_mode redact-unknown → detect, a removed detector or mask rule, an added allow rule, a mask mode away from redact, and the shared rules of the profile base (kconfig.DiffBase).
type Profile ¶
type Profile struct {
Name string `json:"name"`
kconfig.Base
// URL is the management HTTP API; AMQPURL and StreamURL are optional.
// None holds a user or a password.
URL string `json:"url"`
AMQPURL string `json:"amqp_url,omitempty"`
StreamURL string `json:"stream_url,omitempty"`
// VHosts are the vhosts served, sorted; empty serves every vhost the
// account can see.
VHosts []string `json:"vhosts"`
Tier Tier `json:"tier"`
Detectors []string `json:"detectors"`
BodyMode string `json:"body_mode"`
Limits Limits `json:"limits"`
}
Profile is one named broker with its policy. It never holds a secret.
type Tier ¶
type Tier int
Tier is what a profile lets the agent read. The order is TierRead < TierPeek: peek also reads classic and quorum queue messages, which is not strictly read-only.
func (Tier) MarshalText ¶
MarshalText encodes the tier by name.
func (*Tier) UnmarshalText ¶
UnmarshalText decodes a tier name.