-
Notifications
You must be signed in to change notification settings - Fork 120
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
GitHub Issue #122: fix scrubbing and provide test coverage #126
Conversation
Uses manual recursion to enable scrubbing of entire array fields like "Cookie".
This wasn't quite working very well before, and was masking values that shouldn't have been masked. Turning on strict mode fixes this and should be fairly backward compatible.
…t's not instance dependent; overwriting a constructor in PHPUnit tests is not common practice and there is no need for it in DataBuilderTest, move initialization to setUp(); cover DataBuilder::scrub with detailed scrubbing test case data
…ill stick with previous approach of testing through makeData()
… testGetRequest; wrote a test for DataBuilder::getUrl
…pty, return an empty array - no need to force nulls
…es - better solution in progress
…ramesWithContext so that changing source of tests/DataBuilderTest.php doesn't break PHPUnit test run
…provide more input data coverage
…t before sending out the request to Rollbar so all data can be scrubbed; test coverage for the GET arguments
This is ready for review |
src/DataBuilder.php
Outdated
|
||
protected function scrub($arr, $fields, $replacement = '*') | ||
public function scrubArray(&$arr, $replacement = '*') |
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.
Do these really need to be public?
@coryvirok Good point. I made them public earlier for unit testing, but since tests for scrub() already cover the same data structures no need to expose those methods. Just pushed a commit with a change fo this. |
Is there anything blocking this PR from being merged? cc @rokob |
src/DataBuilder.php
Outdated
$val = str_repeat($replacement, 8); | ||
} | ||
|
||
$val = $dataBuilder->scrub($val, $replacement); |
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.
Why not have this in an else block? It would seem that it is okay to not have it in an else because $val just ends up as the string '********' which scrub will just ignore, but why not avoid that call to scrub altogether?
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.
Good point
tests/DataBuilderTest.php
Outdated
@@ -28,6 +24,9 @@ public function setUp() | |||
public function testMakeData() | |||
{ | |||
$output = $this->dataBuilder->makeData(Level::fromName('error'), "testing", array()); | |||
/** | |||
* @todo test for scrub data in makeData() |
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.
Do we need this?
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. I'm going to clean this up.
LGTM besides some minor comments |
@rokob @coryvirok with this message: Do you guys have any suggestion to how to structure this code to not use the else statement? The only way without an else block I can think of is, but that's worse in my opinion:
Also what do you guys about other items brought up by Code Climate? |
I would disregard the CodeClimate suggestion in this instance. As for the other items from CC, they're not high priority as long as we have good coverage. i.e. we can do a cleanup round after release. |
Also, "never use else" seems like terrible advice. |
@coryvirok @rokob All suggestions addressed so if there is nothing more this can be merged into master. |
👍 |
This pull request covers the following GitHub issues: #122 #52 #31 #15
It's still work in progress but I encourage collaboration.
It includes work on the following: