Alternera.Plugin.Provisional.ChildEnv (alternera_plugin_sdk v0.9.0)

Copy Markdown View Source

The environment a plugin gives an OS process it starts.

A port's child inherits the node's whole environment unless told otherwise, and the node's environment holds what the proxy itself runs on: the vault key, the database URL, the session secret, the release cookie. A host process runs code the proxy did not write (an operator's command, a JVM running routes, a WASM runtime running tenants' modules), and each has /proc/self/environ; a guard around that code that failed would hand over the installation, not the one tenant.

Two answers, both in the shape Port.open/2's :env takes (a name with false is unset in the child):

  • without_proxy_secrets/1 unsets the proxy's own secrets and leaves everything else, for a process an operator configured and whose other variables (JAVA_HOME, a driver's own settings) are theirs to rely on;
  • only/2 unsets everything outside an allowlist, for a process that needs nothing from the environment.

Summary

Functions

Unsets every inherited variable whose name is not in allowed.

Unsets the proxy's own secrets in the child; every other variable is inherited.

Types

port_env()

@type port_env() :: [{charlist(), charlist() | false}]

Functions

only(allowed, inherited \\ System.get_env())

@spec only([String.t()], %{required(String.t()) => String.t()}) :: port_env()

Unsets every inherited variable whose name is not in allowed.

without_proxy_secrets(inherited \\ System.get_env())

@spec without_proxy_secrets(%{required(String.t()) => String.t()}) :: port_env()

Unsets the proxy's own secrets in the child; every other variable is inherited.