Restrict the environment variables a tool can see using env_isolation: strict — the child process gets only the bare essentials.
# .factorly/factorly.yaml
tools:
deploy:
type: cli
command: ./deploy.sh
args: ["--env", "{{environment}}"]
env_isolation: strict
env:
AWS_PROFILE: "{{env:AWS_PROFILE}}"
DEPLOY_TOKEN: "{{vault:DEPLOY_TOKEN}}"
parameters:
- name: environment
required: true# See what a strict-isolated command actually receives
factorly exec --env-isolation strict -- envPATH=/usr/local/bin:/usr/bin:/bin
HOME=/home/user
USER=user
LANG=en_US.UTF-8
TERM=xterm-256color
# Forward specific variables into the restricted environment
factorly exec --env-isolation strict --env AWS_PROFILE={{env:AWS_PROFILE}} -- envPATH=/usr/local/bin:/usr/bin:/bin
HOME=/home/user
USER=user
LANG=en_US.UTF-8
TERM=xterm-256color
AWS_PROFILE=staging
# Call the configured tool — only PATH, HOME, USER, LANG, TERM + explicit env
factorly call deploy --environment production- With
env_isolation: strict, the child process starts with onlyPATH,HOME,USER,LANG, andTERMfrom the parent. - Variables listed in
env:are added on top of that minimal set. HereAWS_PROFILEis forwarded from the host andDEPLOY_TOKENis decrypted from the vault. - Everything else —
GITHUB_TOKEN,AWS_SECRET_ACCESS_KEY, shell history, editor configs — is invisible to the subprocess. - Without
env_isolation(the default), the child inherits the full parent environment plus anyenv:additions.