-
-
Notifications
You must be signed in to change notification settings - Fork 604
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
Add ability to set whether environment variables to be displayed #281
Conversation
Fixes filp#119 Add $environmentDisplay member in PrettyPageHandler. Defaults to true. Add getEnvVariables() method that returns $_ENV or message stating that display of environment variables has been disabled Add setEnvironmentDisplay() method that casts to a boolean and sets the $environmentDisplay member.
Thank you for your contribution. |
@@ -2,3 +2,5 @@ vendor/* | |||
report/* | |||
phpunit.xml | |||
composer.lock | |||
|
|||
.idea/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps you may want to use a user-global gitignore
file to minimize noise and also to minimize work for yourself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah cool, This wasn't meant to be part if the pull request - I don't have a lot of experience with pull requests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the advice about the global .gitignore
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't worry about it, if we choose to merge, I'll quickly rebase it myself.
Hi Denis. A lot of people use environment variables to store sensitive config (third party services passwords, etc). While one would never use Whoops in production, I've found that the environment between my local development environment and the production ready site (staging environment) needs to be accessible from the outside - whether I'm reviewing with remote design teams or getting client's input. In the staging environment I use leave all debug ability turned on - being that at this stage bugfixes are still really likely. But leaving my database username & password, my AWS username and password and all of that open for anyone to stumble upon is extremely dangerous. When looking into whether there was a flag to disable the display of $_ENV i came across #119 - Indicating to me that it was a function of Whoops others wanted too. The fact that you added it to the Features to add list motivated me to do the work. |
Do you want me to write tests for this? |
Perhaps there could be an apposing method to |
if( $this->environmentDisplay ) | ||
return $_ENV; | ||
|
||
return ['PLEASE NOTE' => 'Display of environment variables has been disabled']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also going to wrap these strings in double quotes, it seems that's the style you've used in the class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will fix the short array syntax I used.
Edit: see the more up-to-date comment. I have now realized why I am against this. I do not want to create an illusion of security. If you absolutely really need a short term hack, just mask the data yourself: $run->pushHandler(new PrettyPageHandler());
$run->pushHandler(function($exception, $inspector, $run) {
$_ENV['SENSITIVE_KEY'] = 'censored';
}); Thank you for your contribution. |
That actually makes a lot of sense, Stay well. |
1 similar comment
That actually makes a lot of sense, Stay well. |
I think you have totally missed the point behind creating a way of masking sensitive values or hiding them at all. For a user of Whoops to think that because there is now an option to hide e.g. envs means they can now enable We realise that it's not secure, in any case, to enable that mode on production - the real value here is accidental enabling of the handler e.g. enabling debug mode (in Laravel) and suddenly BOOM you have exposed every database env password, API key, everything. One silly mistake is all it takes. We're all human, and this extra bit of security on top will only help in those cases. Your view is basically this - don't enable debugging / tracing in production. What if MySQL connection by PDO took the same view and exposed the "Using password: < MY LOVELY PASSWORD >" because, hey, you shouldn't be displaying errors / stack traces in production. Mistakes happen. This is a way of helping when things go badly wrong. It's nothing to do with adding a false sense of security, it's about realising we're human. |
Another example - Whoops has now been officially added back into Laravel 5.5 What if a malicious user or very bad pull request came in for Laravel which meant that Now sites are exposing database passwords, API keys, everything. Yes, it's also exposing code traces, and other stuff, but at least information that is clearly sensitive is hidden and damage is kept to a minimum. Don't get me wrong, this would be a terrible thing to happen and I really hope it doesn't, but it's a frightening thought. Anything we can do to help mitigate potential problems is a win in my mind. PS - I've submitted a PR to Laravel to only install Whoops on development and not production, this will help mitigate any security problems by exposing envs and stuff accidentally. |
My more up-to-date comment might be of interest to you, @garygreen. |
@denis-sokolov thanks for the link, glad to see you have changed your thoughts towards masking of sensitive information, the PR looks awesome. It might be an idea to update your original comment above with the link so people coming to this issue will see the most recent changes. |
If you are able, you are welcome to ignore the first commit of the two - it's just an amendment to the .gitignore file.
The second commit's message explains the code changes well.