Skip to content

Commit

Permalink
Merge pull request #149 from rollbar/small-fixes
Browse files Browse the repository at this point in the history
Small fixes
  • Loading branch information
rokob authored May 1, 2017
2 parents 815f853 + cb6af16 commit 9e3573d
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 13 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 1.0.1
- Bug fix related to scrubbing potential query strings
- Update notifier to send the correct version number in the payload

## 1.0.0

Almost everything has been refactored or rewritten. The updated README has all of the current
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Add `rollbar/rollbar` to your `composer.json`:
```json
{
"require": {
"rollbar/rollbar": "~1.0.0"
"rollbar/rollbar": "~1.0.1"
}
}
```
Expand Down
10 changes: 3 additions & 7 deletions src/DataBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -775,14 +775,10 @@ public function scrub(&$data, $replacement = '*')
$parsedValues = array_values($parsed);

/**
* If parsing a string results in an associative array
* with multiple elements it's valid query string (key
* recognition).
*
* Also, if it results in first key having an assigned value
* it's also a valid query string (values recognition).
* If we have at least one key/value pair (i.e. a=b) then
* we treat the whole string as a query string.
*/
if (count($parsed) > 1 || $parsedValues[0]) {
if (count(array_filter($parsedValues)) > 0) {
$query = $data;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Payload/Notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class Notifier implements \JsonSerializable
{
const NAME = "rollbar-php";
const VERSION = "1.0.0-beta";
const VERSION = "1.0.1";

public static function defaultNotifier()
{
Expand Down
35 changes: 32 additions & 3 deletions tests/DataBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,29 @@ public function scrubDataProvider()
$this->scrubRecursiveStringDataProvider(),
'string encoded recursive values in recursive array' =>
$this->scrubRecursiveStringRecursiveDataProvider()
), $this->scrubUrlDataProvider());
), $this->scrubUrlDataProvider(), $this->scrubJSONNumbersProvider());
}


private function scrubJSONNumbersProvider()
{
return array(
'plain array' => array(
'[1023,1924]',
array(
'sensitive'
),
'[1023,1924]'
),
'param equals array' => array(
'b=[1023,1924]',
array(
'sensitive'
),
'b=%5B1023%2C1924%5D'
)
);
}

private function scrubFlatDataProvider()
{
return array(
Expand All @@ -255,9 +275,13 @@ private function scrubRecursiveDataProvider()
array( // $testData
'non sensitive data 1' => '123',
'non sensitive data 2' => '456',
'non sensitive data 3' => '4&56',
'non sensitive data 4' => 'a=4&56',
'non sensitive data 6' => 'baz&foo=bar',
'sensitive data' => '456',
array(
'non sensitive data 3' => '789',
'non sensitive data 5' => '789&5=',
'recursive sensitive data' => 'qwe',
'non sensitive data 3' => 'rty',
array(
Expand All @@ -267,14 +291,19 @@ private function scrubRecursiveDataProvider()
),
array( // $scrubFields
'sensitive data',
'recursive sensitive data'
'recursive sensitive data',
'foo'
),
array( // $expected
'non sensitive data 1' => '123',
'non sensitive data 2' => '456',
'non sensitive data 3' => '4&56',
'non sensitive data 4' => 'a=4&56=', // this is a weird edge case
'non sensitive data 6' => 'baz=&foo=xxxxxxxx',
'sensitive data' => '********',
array(
'non sensitive data 3' => '789',
'non sensitive data 5' => '789&5=',
'recursive sensitive data' => '********',
'non sensitive data 3' => 'rty',
array(
Expand Down
2 changes: 1 addition & 1 deletion tests/NotifierTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ public function testEncode()
{
$notifier = Notifier::defaultNotifier();
$encoded = json_encode($notifier->jsonSerialize());
$this->assertEquals('{"name":"rollbar-php","version":"1.0.0-beta"}', $encoded);
$this->assertEquals('{"name":"rollbar-php","version":"1.0.1"}', $encoded);
}
}

0 comments on commit 9e3573d

Please sign in to comment.