Skip to content

Secret values are exposed in tasks #1862

@stoney95

Description

@stoney95

Describe the problem

I want to install dependencies when creating a project from a copier template. The dependencies are hosted on a private pypi mirror. Credentials are required to install dependencies from there. I run the installation via a python script. But we could also assume that we want to set an environment variable etc.

So, in the template I ask for the username and password. I mark the password as secret. I did not find any proper documentation of how to use this password securely.

In the documentation for tasks the template variables are inserted via {{ var_name }}. Using this exposes the secret variable.

Template

username:
  type: str

password:
  type: str
  secret: true
  default: "1234"

_tasks:
  - "python my_script.py --username={{ username }} --password={{ password }}"

To Reproduce

  1. Run copier copy --trust with the template from above
  2. Answer
    1. username="user"
    2. password="secret1234"
  3. Output will be
> Running task 1 of 1: python my_script.py --username=user --password=secret1234

With this the password is exposed in the terminal

Logs

No response

Expected behavior

There a multiple options:

  1. I can surpress the output of tasks, e.g only show Running task 1 of 1.
  2. The output of the tasks detects the password to be a secret and uses asteriks instead, e.g. Running task 1 of 1: python my_script.py --username=user --password=***
  3. There is another way to access information provided via a secret template variable, e.g. an environment variable.

I prefer option 2, but am also happy with any other option

Screenshots/screencasts/logs

No response

Operating system

Windows

Operating system distribution and version

Windows 11

Copier version

9.4.1

Python version

3.11

Installation method

pip+pypi

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugtriageTrying to make sure if this is valid or not

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions