security

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package security enforces security outside the LLM (§43): redaction, path guards, HTML sanitization, trust classification, and the local-API token.

Index

Constants

This section is empty.

Variables

View Source
var ErrPathEscape = errors.New("security: path escapes allowed root")

ErrPathEscape is returned when a path resolves outside its allowed root.

Functions

func FindCredential

func FindCredential(s string) string

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

func LoadOrCreateToken(path string) (string, error)

LoadOrCreateToken returns the per-install API token, creating it (0600) if absent. The token authenticates every local-API request (§15).

func Redact

func Redact(s string) string

Redact applies pattern-based redaction only (no known values). Used as a convenience for callers without resolved secrets.

func ResolveWithin

func ResolveWithin(root, rel string) (string, error)

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

func SanitizeMarkdown(s string) string

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

func TokenEqual(a, b string) bool

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

func NewRedactor(knownValues ...string) *Redactor

NewRedactor builds a Redactor with the given known secret values.

func (*Redactor) ContainsCredential

func (r *Redactor) ContainsCredential(s string) bool

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) Redact

func (r *Redactor) Redact(content []byte) ([]byte, error)

Redact implements the blob.Redactor contract ([]byte in, []byte out).

func (*Redactor) RedactString

func (r *Redactor) RedactString(s string) string

RedactString redacts a string. It is safe to call concurrently.

Jump to

Keyboard shortcuts

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