Documentation
¶
Overview ¶
Package policy contient le moteur de permissions : chaque appel d'outil y est vérifié avant exécution.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrJurisdiction = errors.New("fournisseur hors UE sans consentement")
ErrJurisdiction is returned when a non-EU provider has no recorded consent.
Functions ¶
This section is empty.
Types ¶
type Decision ¶
type Decision int
Decision est le verdict du moteur pour un appel.
func ParseDecision ¶
ParseDecision accepte exactement "allow", "ask" ou "deny".
type Outbound ¶
type Outbound struct {
// contains filtered or unexported fields
}
Outbound gates and redacts every message sent to an LLM provider.
func NewOutbound ¶
NewOutbound returns an Outbound using r for masking.
func (*Outbound) Check ¶
func (o *Outbound) Check(p llm.ProviderInfo, msgs []llm.Message) ([]llm.Message, map[string]int, error)
Check enforces the jurisdiction rule, then returns a redacted deep copy of msgs with the number of masks per type. The input is never modified. Only EU and local providers pass freely; any other jurisdiction (including an empty one) requires consent.
type Permissions ¶
type Permissions struct {
// contains filtered or unexported fields
}
Permissions évalue les appels selon les règles et le confinement au projet.
func NewPermissions ¶
func NewPermissions(root string, rules []Rule) (*Permissions, error)
NewPermissions résout root via EvalSymlinks.
func (*Permissions) Check ¶
func (p *Permissions) Check(c Call) Decision
Check applique l'algorithme : deny, validation forcée (ForceAsk), confinement/fichiers sensibles, ask du projet, allow, ask, défaut.
type RedactionRule ¶
type RedactionRule struct{ Name, Pattern string }
RedactionRule is a user-defined masking rule. Matches are masked under the type strings.ToUpper(Name).
type Redactor ¶
type Redactor struct {
// contains filtered or unexported fields
}
Redactor masks secrets and personal data. It is stateful (same value, same marker) and safe for concurrent use.
func NewRedactor ¶
func NewRedactor(custom []RedactionRule) (*Redactor, error)
NewRedactor builds a Redactor with the built-in rules followed by custom.
func (*Redactor) AddKeyringSecret ¶
AddKeyringSecret masks a key read from the system keyring: its decoded value and the encoded forms go-keyring stores on macOS (and that the keychain tools print): "go-keyring-base64:"+base64, "go-keyring-encoded:"+hex and the bare base64. Each form shorter than 8 bytes is ignored.
func (*Redactor) AddLiteral ¶
AddLiteral masks every exact occurrence of value as SECRET (e.g. a provider API key without a recognisable prefix). Literal steps run before the pattern rules. An empty value is ignored.
func (*Redactor) Redact ¶
Redact masks s and returns the masked text with the number of masks per type.
func (*Redactor) RedactJSON ¶
RedactJSON masks a JSON payload and returns the masked text with the number of masks per type. Each string is masked once decoded: in raw JSON text a newline is the two characters `\n`, so line-anchored rules (KEY=value alone on its line) would not apply. Values under a secret-looking key are masked whole. The re-encoded text then goes through raw masking (patterns spanning a key and its value); if that pass breaks the JSON, the per-string result is kept. Text that is not a single JSON value is masked raw.