Documentation
¶
Overview ¶
Package security enforces security outside the LLM (§43): redaction, path guards, HTML sanitization, trust classification, and the local-API token.
Index ¶
- Variables
- func FindCredential(s string) string
- func LoadOrCreateToken(path string) (string, error)
- func Redact(s string) string
- func ResolveWithin(root, rel string) (string, error)
- func SanitizeMarkdown(s string) string
- func TokenEqual(a, b string) bool
- func TrustFor(selector string) domain.TrustLevel
- type Redactor
Constants ¶
This section is empty.
Variables ¶
var ErrPathEscape = errors.New("security: path escapes allowed root")
ErrPathEscape is returned when a path resolves outside its allowed root.
Functions ¶
func FindCredential ¶
FindCredential returns the first credential-like pattern found in s, or "" if none. It is the detection counterpart to Redact: the same catalog, used as a hard rejection signal (§45) rather than a redaction.
func LoadOrCreateToken ¶
LoadOrCreateToken returns the per-install API token, creating it (0600) if absent. The token authenticates every local-API request (§15).
func Redact ¶
Redact applies pattern-based redaction only (no known values). Used as a convenience for callers without resolved secrets.
func ResolveWithin ¶
ResolveWithin joins rel to root, canonicalizes it, and guarantees the result (after symlink resolution of the deepest existing ancestor) stays within root. It is the single path guard for blob/config/cache/log access (§15).
func SanitizeMarkdown ¶
SanitizeMarkdown neutralizes raw HTML and dangerous URLs in artifact bodies before they are served to the UI (§15, stored-XSS containment). The frontend additionally renders markdown with a renderer that escapes raw HTML.
func TokenEqual ¶
TokenEqual compares two tokens in constant time.
func TrustFor ¶
func TrustFor(selector string) domain.TrustLevel
TrustFor classifies context trust deterministically from its selector (§38). Trust is assigned by deterministic code here — never declared by model output.
Types ¶
type Redactor ¶
type Redactor struct {
// contains filtered or unexported fields
}
Redactor redacts known secret values and credential patterns from content.
func NewRedactor ¶
NewRedactor builds a Redactor with the given known secret values.
func (*Redactor) ContainsCredential ¶
ContainsCredential reports whether s contains any known secret value or credential pattern. It is the detection counterpart to RedactString, used as a hard-reject signal (nil-safe: a nil Redactor falls back to patterns only).
func (*Redactor) RedactString ¶
RedactString redacts a string. It is safe to call concurrently.