Documentation
¶
Overview ¶
Package safety implements FR-CLI-06: a target allowlist plus hard caps on RPS, duration, and concurrency, enforced by default on every run.
It knows nothing about the engine, protocols, or scripting — it only answers two questions a caller (cmd/vegaload's run command today, the MCP run_test tool tomorrow) must act on: is this target one the run is allowed to hit without extra confirmation, and does this run's shape exceed the hard caps.
Index ¶
- Variables
- func CheckLimits(vus int, dur time.Duration, rate float64, limits Limits) error
- func FormatLimits(l Limits) string
- func HostRefusal(host string) error
- func IsAllowed(host string, extra []string) bool
- func IsHostRefusal(err error) bool
- func ParseExtraPort(hostport string) (host string, port string)
- func TargetHost(raw string) (string, error)
- type Limits
Constants ¶
This section is empty.
Variables ¶
var DefaultLimits = Limits{ MaxVUs: 10000, MaxDuration: 24 * time.Hour, MaxRate: 100000, }
DefaultLimits is deliberately generous for local development while still catching an obvious mistake (an extra zero on -vus, a -duration of "30h" instead of "30s").
Functions ¶
func CheckLimits ¶
CheckLimits returns an error describing the first cap a run's shape exceeds, or nil if it stays within limits. rate may be 0 for executors that don't use a rate (fixed-vus, ramp, step).
func FormatLimits ¶
FormatLimits renders limits for a confirmation prompt or error message.
func HostRefusal ¶ added in v0.9.0
HostRefusal refuses host. The caller records nothing for it.
func IsAllowed ¶
IsAllowed reports whether host may be hit without extra confirmation: a local hostname/loopback/link-local address, or a case-insensitive match against extra (the caller's -allow-target list).
func IsHostRefusal ¶ added in v0.9.0
IsHostRefusal reports whether err is a HostRefusal.
func ParseExtraPort ¶
ParseExtraPort is a small helper so cmd/vegaload can accept -allow-target entries with or without a port and still compare sensibly; kept here so the matching rule lives in one place.
func TargetHost ¶
TargetHost extracts the bare host (no port) a run's target string resolves to. raw may be a full URL (http://host:8080/path, grpcs://host:443) or a bare host:port (the form gRPC and WebSocket targets sometimes use). An empty raw (a scripted run with no protocol-direct target) returns "" and no error — callers should treat that as "nothing to check".
Types ¶
type Limits ¶
Limits are the hard caps enforced on every run, regardless of target. They exist to stop a typo or a runaway agent-generated scenario from becoming a much larger run than anyone intended. The caller may raise them explicitly (see cmd/vegaload's -cap-* flags); they are never silently skipped.