dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.5k stars 10.04k forks source link

dotnet user-secrets should allow for entry from stdin without echo #28094

Open reinux opened 3 years ago

reinux commented 3 years ago

Is your feature request related to a problem? Please describe.

dotnet user-scripts add <key> <value> has at least two problems:

  1. Depending on the shell, different symbols are escaped. In PowerShell, "woohoo i got $$!" will replace $$ with some token based on context. Bash has its own issues, apparently: https://github.com/aspnet/UserSecrets/issues/76 . And Windows Terminal behaves differently from cmd.exe. All in all, there's far too much room for error, especially when entering things like passwords.

  2. Many shells and terminals log all inputs as a convenience feature, which could lead to accidental exposure of secrets.

Describe the solution you'd like

An interaction like this would be nice:

> dotnet user-secrets set
Enter secret name: test
Enter secret value:
Successfully saved test = <25 characters>

Or, entering dotnet user-secrets set "test" prompts for the value.

In either case, I think a warning to encourage users to enter values this way would also be helpful.

Describe alternatives you've considered

Writing directly to the to secrets.json, aside from being cumbersome, suffers a similar problem as 1, as the user would need to be aware of JavaScript's escape sequences.

ghost commented 3 years ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

jikuja commented 3 years ago

An interaction like this would be nice:

> dotnet user-secrets set
Enter secret name: test
Enter secret value:
Successfully saved test = <25 characters>

Command dotnet user-secrets set already reads and parses JSON from stdin. New behavior should be toggled as an extra command-line argument e.g. dotnet user-secrets set -m