Documentation
¶
Overview ¶
Package policy contient le moteur de permissions : chaque appel d'outil y est vérifié avant exécution.
Index ¶
- Variables
- func MatchWildcard(pattern, s string) bool
- type Call
- type Decision
- type Outbound
- func (o *Outbound) Check(p llm.ProviderInfo, msgs []llm.Message) ([]llm.Message, map[string]int, error)
- func (o *Outbound) Consent(providerID string)
- func (o *Outbound) SetAllowlists(lists []hostmatch.List)
- func (o *Outbound) SetHostPolicy(p *orgpolicy.Policy)
- func (o *Outbound) SetProfile(n profile.Name)
- type Permissions
- type RedactionRule
- type Redactor
- type Rule
Constants ¶
This section is empty.
Variables ¶
var ErrAllowlist = errors.New("allowlist violation")
ErrAllowlist est renvoyée quand l'hôte du fournisseur n'est pas dans une liste blanche (provider_allowlist).
var ErrJurisdiction = errors.New("non-EU provider without consent")
ErrJurisdiction is returned when a non-EU provider has no recorded consent.
Functions ¶
func MatchWildcard ¶ added in v0.7.0
MatchWildcard rapporte si s correspond à pattern. `*` correspond à toute suite de caractères (espaces et `/` compris) ; le reste est littéral.
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, in order: the compliance profile (its error wraps profile.ErrProfile), the policy host allowlist, the provider allowlists, then the jurisdiction rule. A recorded consent never bypasses the first three. It 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.
func (*Outbound) SetAllowlists ¶ added in v0.7.0
SetAllowlists fixe les listes blanches d'hôtes (globale, projet) revérifiées avant chaque envoi ; chacune doit accepter l'hôte (vide : aucune restriction).
func (*Outbound) SetHostPolicy ¶ added in v0.7.0
SetHostPolicy fixe la politique d'organisation dont la liste blanche d'hôtes est revérifiée avant chaque envoi (nil : aucune restriction).
func (*Outbound) SetProfile ¶ added in v0.7.0
SetProfile sets the compliance profile re-checked before every send (defense in depth: the CLI already refuses a non-compliant provider).
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.
func (*Permissions) Decide ¶ added in v0.5.0
func (p *Permissions) Decide(c Call) (d Decision, liftable bool)
Decide applique l'algorithme de Check et indique en plus si un Ask peut être levé par un hook : liftable vaut true seulement pour un Ask issu d'une règle ask globale ou du défaut selon le risque.
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.
type Rule ¶
Rule associe un outil ("*" = tous) et un motif à une décision. Project indique une règle de la config projet (.tenon/config.toml) : le projet ne peut que restreindre, ses règles ask priment donc les allow globales. Network ouvre le réseau à la commande shell isolée quand la règle allow correspond, ou quand l'utilisateur accepte la demande d'une règle ask.