Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customise text prompt for secrets #943

Closed
lonix1 opened this issue Aug 31, 2022 · 9 comments
Closed

Customise text prompt for secrets #943

lonix1 opened this issue Aug 31, 2022 · 9 comments

Comments

@lonix1
Copy link
Contributor

lonix1 commented Aug 31, 2022

Is your feature request related to a problem? Please describe.
The text prompt for secrets echoes asterisks (***) to the console.

This is acceptable. But it feels weird on unixy systems, where the traditional secret prompt (sudo) echoes nothing.

Describe the solution you'd like
It would be nice to be able to customise the masking character. I would set it to null, so nothing is echoed to the console.

Describe alternatives you've considered
/

Additional context
/

@patriksvensson patriksvensson changed the title [Feature Request] Customise text prompt for secrets Customise text prompt for secrets Aug 31, 2022
@GaryMcD
Copy link
Contributor

GaryMcD commented Sep 11, 2022

I would like to take a stab at this one if possible.

I am thinking....

I would add a char to TextPrompt that defaults to an asterisk. Maybe named MaskingCharacter. And then whenever we are checking if secret is set instead of using the hardcoded asterisk currently in place, we use the masking character.

Looks like I would need to touch these locations in code.

image

@lonix1
Copy link
Contributor Author

lonix1 commented Sep 11, 2022

Consider whether it's char or char?. It should be nullable so one can type "sudo-style" - i.e. without showing feedback.

The alternative is to allow the NUL char - (char)0 - but that is a non-printing char and could cause unintended issues.

@patriksvensson
Copy link
Contributor

I would say public char? Mask { get; set; } = '*'

@GaryMcD
Copy link
Contributor

GaryMcD commented Sep 12, 2022

Began working on this.

Question.

The following occurs on line 129 and 210 of TextPrompt.cs
IsSecret ? "******" : converter(DefaultValue.Value)

I was considering creating a private string with just a get that will create a six character string of whatever the Mask char is, and call that in these two spots instead of the hard coded six asterisk.

Actually, why not just make a private method that will "Mask" any string passed to it with the Mask character defined...

Not sure if that's the proper way to resolve?

Then I came to wonder if the string should actually be as long as the default value. So if default value is 5 characters, then the mask of the default value should be 5 characters.

Let me know your thoughts!

@GaryMcD
Copy link
Contributor

GaryMcD commented Sep 18, 2022

You can start reviewing what I put together if you like.

#970

@GaryMcD
Copy link
Contributor

GaryMcD commented Sep 26, 2022

This has been merged in :) @patriksvensson do we close this?

@patriksvensson
Copy link
Contributor

Yes, we should 😁

@patriksvensson
Copy link
Contributor

Closed via #970

@lonix1
Copy link
Contributor Author

lonix1 commented Sep 27, 2022

Thanks guys 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants