diff --git a/.appveyor.yml b/.appveyor.yml new file mode 100644 index 000000000..06a569d33 --- /dev/null +++ b/.appveyor.yml @@ -0,0 +1,8 @@ +version: 1.x-{build} +build: false +clone_depth: 2 +clone_folder: c:\projects\sentry-php +skip_branch_with_pr: true +branches: + only: + - master diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 9f84d3027..82b213165 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -5,7 +5,7 @@ tools: php_code_coverage: true external_code_coverage: timeout: 2400 # There can be another pull request in progress - runs: 6 # PHP 5.3 + PHP 5.4 + PHP 5.5 + PHP 5.6 + PHP 7.0 + PHP 7.1 + runs: 7 # PHP 5.3 + PHP 5.4 + PHP 5.5 + PHP 5.6 + PHP 7.0 + PHP 7.1 + PHP 7.2 build: environment: diff --git a/.travis.yml b/.travis.yml index ac14dc682..e871542ac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,18 +1,21 @@ language: php sudo: false - +dist: trusty php: - - 5.3 - 5.4 - 5.5 - 5.6 - 7.0 - 7.1 + - 7.2 - nightly env: - - REMOVE_XDEBUG="0" - - REMOVE_XDEBUG="1" - + matrix: + - REMOVE_XDEBUG="0" + - REMOVE_XDEBUG="1" + global: + - NODE_ENV=production + - TRAVIS_NODE_VERSION=8.9.1 matrix: allow_failures: - php: hhvm-3.12 @@ -21,22 +24,28 @@ matrix: include: - php: hhvm-3.12 env: REMOVE_XDEBUG="0" HHVM="1" - dist: trusty + - php: 5.3 + env: REMOVE_XDEBUG="0" + dist: precise + - php: 5.3 + env: REMOVE_XDEBUG="1" + dist: precise + exclude: + - php: nightly + env: REMOVE_XDEBUG="1" cache: directories: - $HOME/.composer/cache - before_install: - if [ "$REMOVE_XDEBUG" = "1" ]; then phpenv config-rm xdebug.ini; fi - composer self-update - -install: travis_retry composer install --no-interaction --prefer-dist - +install: + - nvm install $TRAVIS_NODE_VERSION + - travis_retry composer install --no-interaction --prefer-dist script: - composer phpcs - composer tests-travis - after_script: - wget https://scrutinizer-ci.com/ocular.phar - if [ $(phpenv version-name) = "5.3" ] && [ "$REMOVE_XDEBUG" = "0" ]; then php ocular.phar code-coverage:upload --format=php-clover test/clover.xml --revision=$TRAVIS_COMMIT; fi @@ -45,3 +54,16 @@ after_script: - if [ $(phpenv version-name) = "5.6" ] && [ "$REMOVE_XDEBUG" = "0" ]; then php ocular.phar code-coverage:upload --format=php-clover test/clover.xml --revision=$TRAVIS_COMMIT; fi - if [ $(phpenv version-name) = "7.0" ] && [ "$REMOVE_XDEBUG" = "0" ]; then php ocular.phar code-coverage:upload --format=php-clover test/clover.xml --revision=$TRAVIS_COMMIT; fi - if [ $(phpenv version-name) = "7.1" ] && [ "$REMOVE_XDEBUG" = "0" ]; then php ocular.phar code-coverage:upload --format=php-clover test/clover.xml --revision=$TRAVIS_COMMIT; fi + - if [ $(phpenv version-name) = "7.2" ] && [ "$REMOVE_XDEBUG" = "0" ]; then php ocular.phar code-coverage:upload --format=php-clover test/clover.xml --revision=$TRAVIS_COMMIT; fi + - npm install -g @zeus-ci/cli + - $(npm bin -g)/zeus upload -t "application/x-junit+xml" test/junit.xml + - $(npm bin -g)/zeus upload -t "application/x-clover+xml" test/clover.xml +notifications: + webhooks: + urls: + - https://zeus.ci/hooks/cf8597c4-ffba-11e7-89c9-0a580a281308/public/provider/travis/webhook + on_success: always + on_failure: always + on_start: always + on_cancel: always + on_error: always diff --git a/CHANGELOG.md b/CHANGELOG.md index f86e0ad68..e4c31a0c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,82 @@ # CHANGELOG -## 1.7.0 +## 1.11.0 (2020-02-12) + +- Fixed array and string offset access syntax with curly braces deprecations (#975) +- Fixed curl verify host for synchronous mode (#767) +- Use `mb_substr` instead of `substr` if available (#734) +- Make it possible to change `default_max_depth` in `Raven_Serializer` (#632) + +## 1.10.0 (2018-11-09) + +- Added passing data from context in monolog breadcrumb handler (#683) +- Do not return error id if we know we did not send the error (#667) +- Do not force IPv4 protocol by default (#654) + +## 1.9.2 (2018-08-17) + +- Remove secret_key from required keys for CLI test command. (#645) +- Proper case in Raven_Util class name usage. (#642) +- Support longer creditcard numbers. (#635) +- Use configured message limit when creating serializers. (#634) +- Do not truncate strings if message limit is set to zero. (#630) +- Add option to ignore SERVER_PORT getting added to url. (#629) +- Cleanup the PHP version reported. (#604) + +## 1.9.1 (2018-06-19) + +- Allow the use of a public DSN (private part of the DSN was deprecated in Sentry 9) (#615) +- Send transaction as transaction not as culprit (#601) + +## 1.9.0 (2018-05-03) + +- Fixed undefined variable (#588) +- Fix for exceptions throwing exceptions when setting event id (#587) +- Fix monolog handler not accepting Throwable (#586) +- Add `excluded_exceptions` option to exclude exceptions and their extending exceptions (#583) +- Fix `HTTP_X_FORWARDED_PROTO` header detection (#578) +- Fix sending events async in PHP 5 (#576) +- Avoid double reporting due to `ErrorException`s (#574) +- Make it possible to overwrite serializer message limit of 1024 (#559) +- Allow request data to be nested up to 5 levels deep (#554) +- Update serializer to handle UTF-8 characters correctly (#553) + +## 1.8.4 (2018-03-20) + +- Revert ignoring fatal errors on PHP 7+ (#571) +- Add PHP runtime information (#564) +- Cleanup the `site` value if it's empty (#555) +- Add `application/json` input handling (#546) + +## 1.8.3 (2018-02-07) + +- Serialize breadcrumbs to prevent issues with binary data (#538) +- Fix notice array_key_exists() expects parameter 2 to be array, null given (#527) + +## 1.8.2 (2017-12-21) + +- Improve handling DSN with "null" like values (#522) +- Prevent warning in Raven_Stacktrace (#493) + +## 1.8.1 (2017-11-09) + +- Add setters for the serializers on the `Raven_Client` (#515) +- Avoid to capture `E_ERROR` in PHP 7+, because it's also a `Throwable` that gets captured and duplicates the error (#514) + +## 1.8.0 (2017-10-29) + +- Use namespaced classes in test for PHPUnit (#506) +- Prevent segmentation fault on PHP `<5.6` (#504) +- Remove `ini_set` call for unneeded functionality (#501) +- Exclude single `.php` files from the app path (#500) +- Start testing PHP 7.2 (#489) +- Exclude anonymous frames from app path (#482) + +## 1.7.1 (2017-08-02) + +- Fix of filtering sensitive data when there is an exception with multiple 'values' (#483) + +## 1.7.0 (2017-06-07) - Corrected some issues with argument serialization in stacktraces (#399). - The default exception handler will now re-raise exceptions when `call_existing` is true and no exception handler is registered (#421). diff --git a/README.md b/README.md index 08c7e347a..3ca488a26 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,22 @@
# Sentry for PHP +> Please note that the `1.x` branch of the Sentry PHP SDK is no longer maintained. +> +> For the most recent Sentry PHP SDK see the [default branch](https://github.com/getsentry/sentry-php). + +--- + [](http://travis-ci.org/getsentry/sentry-php) -[](https://packagist.org/packages/sentry/sentry) -[](https://packagist.org/packages/sentry/sentry) -[](https://packagist.org/packages/sentry/sentry) -[](https://packagist.org/packages/sentry/sentry) +[](https://packagist.org/packages/sentry/sentry) +[](https://packagist.org/packages/sentry/sentry) +[](https://packagist.org/packages/sentry/sentry) +[](https://packagist.org/packages/sentry/sentry) [](https://scrutinizer-ci.com/g/getsentry/sentry-php/) [](https://scrutinizer-ci.com/g/getsentry/sentry-php/) @@ -30,7 +36,7 @@ more about [automatic PHP error reporting with Sentry](https://sentry.io/for/php ```php // Instantiate a new client with a compatible DSN and install built-in // handlers -$client = (new Raven_Client('http://public:secret@example.com/1'))->install(); +$client = (new Raven_Client('http://public@example.com/1'))->install(); // Capture an exception $event_id = $client->captureException($ex); @@ -47,9 +53,25 @@ For more information, see our [documentation](https://docs.getsentry.com/hosted/ Other packages exists to integrate this SDK into the most common frameworks. +### Official integrations + +The following integrations are fully supported and maintained by the Sentry team. + - [Symfony](https://github.com/getsentry/sentry-symfony) - [Laravel](https://github.com/getsentry/sentry-laravel) +### 3rd party integrations + +The following integrations are available and maintained by members of the Sentry community. + +- [Nette](https://github.com/Salamek/raven-nette) +- [ZendFramework](https://github.com/facile-it/sentry-module) +- [WordPress](https://wordpress.org/plugins/wp-sentry-integration/) +- [Drupal](https://www.drupal.org/project/raven) +- [OpenCart](https://github.com/BurdaPraha/oc_sentry) +- [Magento2](https://github.com/justbetter/magento2-sentry) +- [October CMS](https://github.com/OFFLINE-GmbH/oc-sentry-plugin/) +- ... feel free to be famous, create a port to your favourite platform! ## Community @@ -74,3 +96,75 @@ Tests can then be run via phpunit: ``` $ vendor/bin/phpunit ``` + + +Tagging a Release +----------------- + +1. Make sure ``CHANGES`` is up to date (add the release date) and ``master`` is green. + +2. Create a new branch for the minor version (if not present): + +``` +$ git checkout -b releases/1.11.x +``` + +3. Update the hardcoded version tag in ``Client.php``: + +```php +class Raven_Client +{ + const VERSION = '1.11.0'; +} +``` + +4. Commit the change: + +``` +$ git commit -a -m "1.11.0" +``` + +5. Tag the branch: + +``` +git tag 1.11.0 +``` + +6. Push the tag: + +``` +git push --tags +``` + +7. Switch back to ``master``: + +``` +git checkout master +``` + +8. Add the next minor release to the ``CHANGES`` file: + +``` +## 1.12.0 (unreleased) +``` + +9. Update the version in ``Client.php``: + +```php +class Raven_Client +{ + const VERSION = '1.12.x-dev'; +} +``` + +10. Lastly, update the composer version in ``composer.json``: + +```json + "extra": { + "branch-alias": { + "dev-master": "1.12.x-dev" + } + } +``` + +All done! Composer will pick up the tag and configuration automatically. diff --git a/bin/sentry b/bin/sentry index 4694cfcb4..5d30c44b6 100755 --- a/bin/sentry +++ b/bin/sentry @@ -21,13 +21,11 @@ function raven_cli_test($command, $args) function cmd_test($dsn) { - if (empty($dsn)) { - exit('ERROR: Missing DSN value'); - } - // Parse DSN as a test try { - $parsed = Raven_Client::parseDSN($dsn); + if (empty(Raven_Client::parseDSN($dsn))) { + exit('ERROR: Missing DSN value'); + } } catch (InvalidArgumentException $ex) { exit("ERROR: There was an error parsing your DSN:\n " . $ex->getMessage()); } @@ -40,7 +38,7 @@ function cmd_test($dsn) )); $config = get_object_vars($client); - $required_keys = array('server', 'project', 'public_key', 'secret_key'); + $required_keys = array('server', 'project', 'public_key'); echo "Client configuration:\n"; foreach ($required_keys as $key) { diff --git a/composer.json b/composer.json index 10967fe43..45c4465cc 100644 --- a/composer.json +++ b/composer.json @@ -13,8 +13,8 @@ ], "require-dev": { "friendsofphp/php-cs-fixer": "^1.8.0", - "phpunit/phpunit": "^4.8 || ^5.0", - "monolog/monolog": "*" + "phpunit/phpunit": "^4.8.35 || ^5.7", + "monolog/monolog": "^1.0" }, "require": { "php": "^5.3|^7.0", @@ -24,7 +24,6 @@ "ext-hash": "*", "ext-json": "*", "ext-mbstring": "*", - "immobiliare/sentry-php": "Fork that fixes support for PHP 5.2", "monolog/monolog": "Automatically capture Monolog events as breadcrumbs" }, "conflict": { @@ -43,7 +42,7 @@ "vendor/bin/phpunit --verbose" ], "tests-travis": [ - "vendor/bin/phpunit --verbose --configuration phpunit.xml --coverage-clover test/clover.xml" + "vendor/bin/phpunit --verbose --configuration phpunit.xml --coverage-clover test/clover.xml --log-junit test/junit.xml" ], "tests-report": [ "vendor/bin/phpunit --verbose --configuration phpunit.xml --coverage-html test/html-report" @@ -54,7 +53,7 @@ }, "extra": { "branch-alias": { - "dev-master": "1.7.x-dev" + "dev-master": "1.11.x-dev" } } } diff --git a/docs/config.rst b/docs/config.rst index ddfbababb..eb3cb525e 100644 --- a/docs/config.rst +++ b/docs/config.rst @@ -171,7 +171,7 @@ The following settings are available for the client: 'User-Agent' => $client->getUserAgent(), 'X-Sentry-Auth' => $client->getAuthHeader(), ), - 'body' => gzipCompress(jsonEncode($data)), + 'body' => gzcompress(jsonEncode($data)), )) }, @@ -221,7 +221,7 @@ The following settings are available for the client: .. describe:: processors An array of classes to use to process data before it is sent to - Sentry. By default, ``Raven_SanitizeDataProcessor`` is used + Sentry. By default, ``Raven_Processor_SanitizeDataProcessor`` is used .. describe:: processorOptions @@ -230,17 +230,48 @@ The following settings are available for the client: the list of processors used by ``Raven_Client`` An example of overriding the regular expressions in - ``Raven_SanitizeDataProcessor`` is below: + ``Raven_Processor_SanitizeDataProcessor`` is below: .. code-block:: php 'processorOptions' => array( - 'Raven_SanitizeDataProcessor' => array( + 'Raven_Processor_SanitizeDataProcessor' => array( 'fields_re' => '/(user_password|user_token|user_secret)/i', 'values_re' => '/^(?:\d[ -]*?){15,16}$/' ) ) +.. describe:: timeout + + The timeout for sending requests to the Sentry server in seconds, default is 2 seconds. + + .. code-block:: php + + 'timeout' => 2, + +.. describe:: excluded_exceptions + + Exception that should not be reported, exceptions extending exceptions in this list will also + be excluded, default is an empty array. + + In the example below, when you exclude ``LogicException`` you will also exclude ``BadFunctionCallException`` + since it extends ``LogicException``. + + .. code-block:: php + + 'excluded_exceptions' => array('LogicException'), + +.. describe:: ignore_server_port + + By default the server port will be added to the logged URL when it is a non + standard port (80, 443). + Setting this to ``true`` will ignore the server port altogether and will + result in the server port never getting appended to the logged URL. + + .. code-block:: php + + 'ignore_server_port' => true, + .. _sentry-php-request-context: Providing Request Context @@ -274,3 +305,46 @@ need to ensure you cleanup the context (to reset its state): .. code-block:: php $client->context->clear(); + +Processors +---------- + +The following processors are available bundled with sentry-php. They can be used in ``processors`` configuration, and configured through ``processorOptions`` as described above. + +.. describe:: Raven_Processor_SanitizeDataProcessor + + This is the default processor. It replaces fields or values with asterisks + in frames, http, and basic extra data. + + Available options: + + - ``fields_re``: takes a regex expression of fields to sanitize + Defaults to ``/(authorization|password|passwd|secret|password_confirmation|card_number|auth_pw)/i`` + - ``values_re``: takes a regex expression of values to sanitize + Defaults to ``/^(?:\d[ -]*?){13,16}$/`` + +.. describe:: Raven_Processor_SanitizeHttpHeadersProcessor + + This processor sanitizes the configured HTTP headers to ensure no sensitive + information is sent to the server. + + Available options: + + - ``sanitize_http_headers``: takes an array of headers to sanitize. + Defaults to ``['Authorization', 'Proxy-Authorization', 'X-Csrf-Token', 'X-CSRFToken', 'X-XSRF-TOKEN']`` + +.. describe:: Raven_Processor_SanitizeStacktraceProcessor + + This processor removes the `pre_context`, `context_line` and `post_context` + information from all exceptions captured by an event. + +.. describe:: Raven_Processor_RemoveHttpBodyProcessor + + This processor removes all the data of the HTTP body to ensure no sensitive + information is sent to the server in case the request method is POST, PUT, + PATCH or DELETE. + +.. describe:: Raven_Processor_RemoveCookiesProcessor + + This processor removes all the cookies from the request to ensure no sensitive + information is sent to the server. diff --git a/docs/index.rst b/docs/index.rst index 9f04540bd..87befbb5d 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -41,7 +41,7 @@ once and reference it from anywhere you want to interface with Sentry: .. code-block:: php - $client = new Raven_Client('___DSN___'); + $client = new Raven_Client('___PUBLIC_DSN___'); Once you have the client you can either use it manually or enable the automatic error and exception capturing which is recomended: diff --git a/docs/integrations/laravel.rst b/docs/integrations/laravel.rst index 7fa5b1274..d750ab763 100644 --- a/docs/integrations/laravel.rst +++ b/docs/integrations/laravel.rst @@ -1,7 +1,7 @@ Laravel ======= -Laravel is supported via a native extension, `sentry-laravel