salt.modules.cmd.run with template argument should render env values
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 5.6k
- Avg merge
- 2d 44m
- Merged PRs (30d)
- 80
Description
Is your feature request related to a problem? Please describe.
I want to execute commands with sensitive informations in a secure way.
Describe the solution you'd like
I would like to be able to execute:
salt target cmd.run 'echo ${FOO}' env='{"FOO": "{{ pillar[foo] | traverse(auth:password) }}"}' template=jinja
Describe alternatives you've considered
First, I created a temporary state file like:
command-with-pillar-in-env:
cmd.run:
- name: "echo ${FOO}"
- template: jinja
- env:
- FOO: {{ pillar["foo"] | traverse("auth:password") }}
Then, I tried to pass the password directly in the command like with:
salt target cmd.run 'echo {{ pillar[foo] | traverse(auth:password) }}' template=jinja
Additional context
Passing the pillar directly on the command line may leak information to tools like snoopy or auditd.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the salt.modules.cmd.run entry point and trace how its template and env arguments are handled. Determine how Jinja rendering should apply to environment values without requiring the secret in the command text. Done means the supplied command can expand a rendered env value while preserving the security motivation described in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli, devops
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100