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

[Feature Request] Ability to hide string of command using execute #429

Closed
NorseGaud opened this issue Jun 6, 2018 · 4 comments
Closed

Comments

@NorseGaud
Copy link
Contributor

Howdy!

I'm working on the capistrano-postgresql gem and we've switched to using execute instead of test for better user experience when they run cap setup.

The problem: We're seeing the password in the capistrano.log and also the STDOUT.

Request: I'd love a way to wrap the '#{fetch(:pg_password)}' in execute :psql, "-d #{database}", '-c', %Q{"CREATE USER \\"#{fetch(:pg_username)}\\" PASSWORD '#{fetch(:pg_password)}';"} with something to prevent STDOUT and the log from showing it. Maybe replace it with [HIDDEN] or something.

@leehambley
Copy link
Member

Hi @NorseGaud thanks for the issue report. The first place I can imagine looking is at a custom logger where we could do the redaction.

SSHKit and Capistrano use the same IO.write pass-thru scheme for writing logs that MiniTest and a few others do, and the most objects pass through still structured the logger.

This would enable you to make a special case for when the logger gets a Execute type command object and redact certain fields and/or values.

How we handle that in regards of telling the logger what to redact is another problem, but at least I think the experimentation starts there.

@leehambley
Copy link
Member

I looked up where the code is - apparently it lives here - https://github.com/capistrano/sshkit/blob/master/lib/sshkit/formatters/pretty.rb#L18-L40
Note that Capistrano actually uses AirbruSSH for formatting, which @mattbrictson maintains, which behaves differently

@NorseGaud
Copy link
Contributor Author

I'll play around a bit in a fork of sshkit and see if I can accomplish this easily. I'll submit a pull request for your review after that. Thanks Lee!

@NorseGaud
Copy link
Contributor Author

Ok, ready for your review: #430

I'm going to bed. Been up too long 👍

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

No branches or pull requests

2 participants