pax_global_header 0000666 0000000 0000000 00000000064 13142120705 0014505 g ustar 00root root 0000000 0000000 52 comment=9aca1e64bc1dcb0df57a2da15a517c69d0ca9ef9
raven-ruby-2.6.3/ 0000775 0000000 0000000 00000000000 13142120705 0013607 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/.gitignore 0000664 0000000 0000000 00000000177 13142120705 0015604 0 ustar 00root root 0000000 0000000 coverage
pkg
ruby/
log/
docs/_build
.bundle
*.gem
gemfiles/*.lock
Gemfile.lock
.coveralls.yml
.ruby-version
.ruby-gemset
.idea
raven-ruby-2.6.3/.gitmodules 0000664 0000000 0000000 00000000155 13142120705 0015765 0 ustar 00root root 0000000 0000000 [submodule "docs/_sentryext"]
path = docs/_sentryext
url = https://github.com/getsentry/sentry-doc-support
raven-ruby-2.6.3/.rspec 0000664 0000000 0000000 00000000040 13142120705 0014716 0 ustar 00root root 0000000 0000000 --colour
--format documentation
raven-ruby-2.6.3/.rubocop.yml 0000664 0000000 0000000 00000002303 13142120705 0016057 0 ustar 00root root 0000000 0000000 AllCops:
Include:
- 'lib/**/*.rb'
- 'spec/**/*.rb'
Exclude:
- 'examples/**/*'
- 'vendor/**/*'
Metrics/ClassLength:
Max: 248
CountComments: false
Metrics/AbcSize:
Max: 58
Metrics/CyclomaticComplexity:
Max: 13
Metrics/PerceivedComplexity:
Max: 13
Metrics/LineLength:
Max: 155
Metrics/MethodLength:
Max: 41
Style/SignalException:
Enabled: false
Performance/Casecmp:
Enabled: false
Style/ClassAndModuleChildren:
Enabled: false
Style/ParallelAssignment:
Enabled: false
Style/Documentation:
Enabled: false
Style/RescueModifier:
Enabled: false
Style/StringLiterals:
Enabled: false
Style/CaseEquality:
Enabled: false
Style/DoubleNegation:
Enabled: false
Style/FileName:
Exclude:
- 'lib/sentry-raven-without-integrations.rb'
- 'lib/sentry-raven.rb'
Style/NumericLiterals:
Exclude:
- 'spec/raven/processors/sanitizedata_processor_spec.rb'
Style/HashSyntax:
EnforcedStyle: hash_rockets
Lint/RescueException:
Exclude:
- 'lib/raven/base.rb'
- 'lib/raven/instance.rb'
- 'lib/raven/integrations/delayed_job.rb'
- 'lib/raven/integrations/rack.rb'
- 'lib/raven/integrations/sidekiq.rb'
- 'spec/raven/event_spec.rb'
raven-ruby-2.6.3/.travis.yml 0000664 0000000 0000000 00000001333 13142120705 0015720 0 ustar 00root root 0000000 0000000 language: ruby
dist: trusty
sudo: false
group: beta
cache: bundler
branches:
only: [master]
rvm:
- 2.2.7
- 2.3.4
- 2.4.1
env:
- RAILS_VERSION=4
- RAILS_VERSION=5
- RAILS_VERSION=0
addons:
apt:
packages:
- haveged
before_install:
- service haveged start
matrix:
include:
- rvm: 1.9
env: RAILS_VERSION=4
- rvm: jruby-1.7.27
env: JRUBY_OPTS="--dev" RAILS_VERSION=4
- rvm: jruby-9.1.12.0
env: JRUBY_OPTS="--dev -J-Djruby.launch.inproc=true -J-Xmx1024M" RAILS_VERSION=4
- rvm: jruby-9.1.12.0
env: JRUBY_OPTS="--dev -J-Djruby.launch.inproc=true -J-Xmx1024M" RAILS_VERSION=5
- rvm: ruby-head
env: RAILS_VERSION=0
allow_failures:
- rvm: ruby-head
raven-ruby-2.6.3/Gemfile 0000664 0000000 0000000 00000001266 13142120705 0015107 0 ustar 00root root 0000000 0000000 source "https://rubygems.org/"
gemspec
if ENV["RAILS_VERSION"] && (ENV["RAILS_VERSION"].to_i == 4)
gem "rails", "< 5"
gem "rspec-rails"
elsif ENV["RAILS_VERSION"] && (ENV["RAILS_VERSION"].to_i == 0)
# no-op. No Rails.
else
gem "rails", "< 6"
gem "rspec-rails"
end
if RUBY_VERSION < '2.0'
gem "mime-types", "< 3.0.0"
gem "nokogiri", "~> 1.6.8"
gem "rack", "~> 1.6.8"
gem "sidekiq", "< 3.2"
else
gem "rack"
gem "sidekiq"
end
gem "pry"
gem "pry-coolline"
gem "benchmark-ips"
gem "benchmark-ipsa" if RUBY_VERSION > '2.0'
gem "ruby-prof", platform: :mri
gem "rake"
gem "rubocop", "~> 0.41.1"
gem "rspec"
gem "timecop"
gem "test-unit", platform: :mri if RUBY_VERSION > '2.2'
raven-ruby-2.6.3/LICENSE 0000664 0000000 0000000 00000025137 13142120705 0014624 0 ustar 00root root 0000000 0000000 Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2015 Functional Software, Inc
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
raven-ruby-2.6.3/README.md 0000664 0000000 0000000 00000012163 13142120705 0015071 0 ustar 00root root 0000000 0000000
# Raven-Ruby, the Ruby Client for Sentry
[](https://rubygems.org/gems/sentry-raven)
[](https://travis-ci.org/getsentry/raven-ruby)
[](https://rubygems.org/gems/sentry-raven/)
[Documentation](https://docs.getsentry.com/hosted/clients/ruby/) | [Bug Tracker](https://github.com/getsentry/raven-ruby/issues) | [Forum](https://forum.sentry.io/) | IRC: irc.freenode.net, #sentry
The official Ruby-language client and integration layer for the [Sentry](https://github.com/getsentry/sentry) error reporting API.
## Requirements
We test on Ruby 1.9, 2.2, 2.3, and 2.4 at the latest patchlevel/teeny version. We also support JRuby 1.7 and 9.0. Our Rails integration works with Rails 4.2+ (including Rails 5).
## Getting Started
### Install
```ruby
gem "sentry-raven"
```
### Raven only runs when SENTRY_DSN is set
Raven will capture and send exceptions to the Sentry server whenever its DSN is set. This makes environment-based configuration easy - if you don't want to send errors in a certain environment, just don't set the DSN in that environment!
```bash
# Set your SENTRY_DSN environment variable.
export SENTRY_DSN=http://public:secret@example.com/project-id
```
```ruby
# Or you can configure the client in the code (not recommended - keep your DSN secret!)
Raven.configure do |config|
config.dsn = 'http://public:secret@example.com/project-id'
end
```
### Raven doesn't report some kinds of data by default
**Raven ignores some exceptions by default** - most of these are related to 404s or controller actions not being found. [For a complete list, see the `IGNORE_DEFAULT` constant](https://github.com/getsentry/raven-ruby/blob/master/lib/raven/configuration.rb).
Raven doesn't report POST data or cookies by default. In addition, it will attempt to remove any obviously sensitive data, such as credit card or Social Security numbers. For more information about how Sentry processes your data, [check out the documentation on the `processors` config setting.](https://docs.getsentry.com/hosted/clients/ruby/config/)
### Usage
**If you use Rails, you're already done - no more configuration required!** Check [Integrations](https://docs.getsentry.com/hosted/clients/ruby/integrations/) for more details on other gems Sentry integrates with automatically.
Otherwise, Raven supports two methods of capturing exceptions:
```ruby
Raven.capture do
# capture any exceptions which happen during execution of this block
1 / 0
end
begin
1 / 0
rescue ZeroDivisionError => exception
Raven.capture_exception(exception)
end
```
### More configuration
You're all set - but there's a few more settings you may want to know about too!
#### async
When an error or message occurs, the notification is immediately sent to Sentry. Raven can be configured to send asynchronously:
```ruby
config.async = lambda { |event|
Thread.new { Raven.send_event(event) }
}
```
Using a thread to send events will be adequate for truly parallel Ruby platforms such as JRuby, though the benefit on MRI/CRuby will be limited. If the async callback raises an exception, Raven will attempt to send synchronously.
Note that the naive example implementation has a major drawback - it can create an infinite number of threads. We recommend creating a background job, using your background job processor, that will send Sentry notifications in the background.
```ruby
config.async = lambda { |event| SentryJob.perform_later(event) }
class SentryJob < ActiveJob::Base
queue_as :default
# Important for ActiveJob! Otherwise, we can get caught in an infinite loop.
rescue_from(ActiveJob::DeserializationError) { |e| Rails.logger.error e }
def perform(event)
Raven.send_event(event)
end
end
```
#### transport_failure_callback
If Raven fails to send an event to Sentry for any reason (either the Sentry server has returned a 4XX or 5XX response), this Proc or lambda will be called.
```ruby
config.transport_failure_callback = lambda { |event|
AdminMailer.email_admins("Oh god, it's on fire!", event).deliver_later
}
```
#### Context
Much of the usefulness of Sentry comes from additional context data with the events. Raven makes this very convenient by providing methods to set thread local context data that is then submitted automatically with all events.
There are three primary methods for providing request context:
```ruby
# bind the logged in user
Raven.user_context email: 'foo@example.com'
# tag the request with something interesting
Raven.tags_context interesting: 'yes'
# provide a bit of additional context
Raven.extra_context happiness: 'very'
```
For more information, see [Context](https://docs.sentry.io/clients/ruby/context/).
## More Information
* [Documentation](https://docs.getsentry.com/hosted/clients/ruby/)
* [Bug Tracker](https://github.com/getsentry/raven-ruby/issues)
* [Forum](https://forum.sentry.io/)
* [IRC](irc://irc.freenode.net/sentry>) (irc.freenode.net, #sentry)
raven-ruby-2.6.3/Rakefile 0000664 0000000 0000000 00000001156 13142120705 0015257 0 ustar 00root root 0000000 0000000 require 'rake'
require 'raven'
require 'rubygems/package_task'
require 'bundler/gem_tasks'
gemspec = Gem::Specification.load(Dir['*.gemspec'].first)
Gem::PackageTask.new(gemspec).define
begin
require 'rubygems'
require 'rspec/core/rake_task'
require 'rubocop/rake_task'
RuboCop::RakeTask.new(:rubocop) do |task|
task.patterns = ['lib/**/*.rb','spec/**/*.rb',]
end
RSpec::Core::RakeTask.new(:spec) do |spec|
spec.pattern = 'spec/**/*_spec.rb'
end
rescue LoadError
task :spec do
abort "Rspec is not available. bundle install to run unit tests"
end
end
task :default => [:rubocop, :spec]
raven-ruby-2.6.3/benchmarks/ 0000775 0000000 0000000 00000000000 13142120705 0015724 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/benchmarks/allocation_report.rb 0000664 0000000 0000000 00000001274 13142120705 0021775 0 ustar 00root root 0000000 0000000 require 'benchmark/ips'
require 'benchmark/ipsa'
require 'raven'
require 'raven/breadcrumbs/logger'
require 'raven/transports/dummy'
require_relative "../spec/support/test_rails_app/app"
TestApp.configure do |config|
config.middleware.delete ActionDispatch::DebugExceptions
config.middleware.delete ActionDispatch::ShowExceptions
end
Raven.configure do |config|
config.logger = Logger.new(nil)
config.dsn = "dummy://12345:67890@sentry.localdomain:3000/sentry/42"
end
TestApp.initialize!
@app = Rack::MockRequest.new(TestApp)
RAILS_EXC = begin
@app.get("/exception")
rescue => exc
exc
end
report = MemoryProfiler.report do
Raven.capture_exception(RAILS_EXC)
end
report.pretty_print
raven-ruby-2.6.3/benchmarks/async_benchmark.rb 0000664 0000000 0000000 00000002251 13142120705 0021400 0 ustar 00root root 0000000 0000000 require 'benchmark/ips'
require 'benchmark/ipsa'
require 'raven'
require 'raven/breadcrumbs/logger'
require 'raven/transports/dummy'
require 'rack/test'
require_relative "../spec/support/test_rails_app/app"
def build_exception
1 / 0
rescue ZeroDivisionError => exception
exception
end
TestApp.configure do |config|
config.middleware.delete ActionDispatch::DebugExceptions
config.middleware.delete ActionDispatch::ShowExceptions
end
Raven.configure do |config|
config.logger = Logger.new(nil)
config.dsn = "dummy://12345:67890@sentry.localdomain:3000/sentry/42"
config.async = ->(event) { event.to_hash } # Simulate throwing this into a Sidekiq job, etc
end
TestApp.initialize!
@app = Rack::MockRequest.new(TestApp)
RAILS_EXC = begin
@app.get("/exception")
rescue => exc
exc
end
DIVIDE_BY_ZERO = build_exception
LOGGER = Logger.new(nil)
Benchmark.ipsa do |x|
x.config(:time => 5, :warmup => 2)
x.report("simple") { Raven.capture_exception(DIVIDE_BY_ZERO) }
x.report("rails") { Raven.capture_exception(RAILS_EXC) }
x.report("lots o logs") do
100.times { LOGGER.debug(rand(100_000).to_s) }
Raven.capture_exception(DIVIDE_BY_ZERO)
end
x.compare!
end
raven-ruby-2.6.3/benchmarks/benchmark.rb 0000664 0000000 0000000 00000001712 13142120705 0020204 0 ustar 00root root 0000000 0000000 require 'benchmark/ips'
require 'benchmark/ipsa'
require 'raven'
require 'raven/breadcrumbs/logger'
require 'raven/transports/dummy'
require 'rack/test'
require_relative "../spec/support/test_rails_app/app"
def build_exception
1 / 0
rescue ZeroDivisionError => exception
exception
end
TestApp.configure do |config|
config.middleware.delete ActionDispatch::DebugExceptions
config.middleware.delete ActionDispatch::ShowExceptions
end
Raven.configure do |config|
config.logger = Logger.new(nil)
config.dsn = "dummy://12345:67890@sentry.localdomain:3000/sentry/42"
end
TestApp.initialize!
@app = Rack::MockRequest.new(TestApp)
RAILS_EXC = begin
@app.get("/exception")
rescue => exc
exc
end
DIVIDE_BY_ZERO = build_exception
LOGGER = Logger.new(nil)
Benchmark.ipsa do |x|
x.config(:time => 10, :warmup => 2)
x.report("simple") { Raven.capture_exception(DIVIDE_BY_ZERO) }
x.report("rails") { Raven.capture_exception(RAILS_EXC) }
x.compare!
end
raven-ruby-2.6.3/benchmarks/profile.rb 0000664 0000000 0000000 00000001534 13142120705 0017714 0 ustar 00root root 0000000 0000000 require 'raven'
require 'raven/breadcrumbs/logger'
require 'raven/transports/dummy'
require_relative "../spec/support/test_rails_app/app"
TestApp.configure do |config|
config.middleware.delete ActionDispatch::DebugExceptions
config.middleware.delete ActionDispatch::ShowExceptions
end
Raven.configure do |config|
config.logger = Logger.new(nil)
config.dsn = "dummy://12345:67890@sentry.localdomain:3000/sentry/42"
end
TestApp.initialize!
@app = Rack::MockRequest.new(TestApp)
RAILS_EXC = begin
@app.get("/exception")
rescue => exc
exc
end
require 'ruby-prof'
RubyProf.measure_mode = RubyProf::PROCESS_TIME
# profile the code
result = RubyProf.profile do
100.times { Raven.capture_exception(RAILS_EXC) }
end
# print a graph profile to text
printer = RubyProf::MultiPrinter.new(result)
printer.print(:path => "./tmp", :profile => "profile")
raven-ruby-2.6.3/changelog.md 0000664 0000000 0000000 00000042277 13142120705 0016074 0 ustar 00root root 0000000 0000000 2.6.3
-----
* BUGFIX: Fixed typo in the Heroku warning [@greysteil, #728]
* BUGFIX: Swallow IOErrors when reading the Rack request body [@nateberkopec]
* BUGFIX: Fix invalid UTF-8/circular references when using async [@nateberkopec, #730]
2.6.2
-----
* BUGFIX: If using the Sidekiq or DelayedJob adapters with ActiveJob, ActiveJob wouldn't re-raise upon capturing an exception. [@nateberkopec, 5b02ad4ff2]
* KNOWN ISSUE: When using `async`, Rack integration is not thread-safe [#721]
* KNOWN ISSUE: When using `async`, encoding errors may be raised [#725]
2.6.1
-----
* BUGFIX: Fix cases where ActionDispatch::RemoteIP would blow up during event creation [@cmoylan, #722]
* BUGFIX: In ActiveJob, don't report exceptions which can be rescued by rescue_from handlers [@bensheldon, #719]
2.6.0
-----
* FEATURE: raven-ruby now marks itself as the "ruby" logger by default, to match raven-js behavior [@nateberkopec]
* FEATURE: You may now override the default sanitization parameters [#712, @nateberkopec]
* FEATURE: Breadcrumb buffers are now publicly accessible [#686, @nateberkopec]
* FEATURE: We yell at you now if you're using Heroku but don't have runtime-dyno-metadata enabled [#715, @nateberkopec]
* FEATURE: project_root will always be set, regardless of framework [#716, @nateberkopec]
* BUGFIX: Request body and message limits now match Sentry server defaults [#714, @nateberkopec]
* BUGFIX: Sidekiq context now works as expected [#713, @nateberkopec]
* BUGFIX: Capture exceptions in ActiveJob when not using Sidekiq adapter [#709, #671, @nateberkopec]
2.5.3
-----
* BUGFIX: Deal properly with ASCII_8BIT/BINARY encodings [#689, #696, @nateberkopec]
2.5.2
-----
* BUGFIX: raven test executable should be available [#691, @nateberkopec]
* BUGFIX: Fix stack overflow when calling Backtrace#inspect [#690, @nateberkopec]
* KNOWN ISSUE: Character encoding errors [#689]
2.5.1
-----
* BUGFIX: Fix case where Pathname objects are on the load path [@nateberkopec]
* BUGFIX: Fix bad UTF-8 characters in the URL querystring [@nateberkopec]
* BUGFIX: Fix case where rack-timeout could be required twice [@nateberkopec]
* REFACTOR: Slightly cleaner character encoding fixing [@nateberkopec, @bf4]
2.5.0
-----
* FEATURE: Greatly improved performance (2-3x faster capture) [@nateberkopec]
* FEATURE: Frozen objects are now sanitized [@nateberkopec]
* BUGFIX: Grabbing Sidekiq context from "wrapped" classes works [@nateberkopec]
* BUGFIX: Relaxed Faraday dependency [@nateberkopec]
2.4.0
-----
* FEATURE: Allow customization of the Faraday adapter [#639, @StupidCodeFactory]
* BUGFIX: Report the SDK name as "raven-ruby", not "sentry-raven" [#641, @bretthoerner]
* BUGFIX: Sidekiq jobs now clear context/breadcrumbs properly between jobs [#637, @drewish]
* BUGFIX: Overriding the logger in Rails wasn't working [#638, @eugeneius]
2.3.1
-----
* BUGFIX: Backtrace parser fixed for JRuby 9k [#619, @the-michael-toy]
* BUGFIX: Rake tasks should show the correct task name [#621, @Bugagazavr]
* BUGFIX: Formatted messages work if params are `nil` [#625, @miyachik]
* BUGFIX: Backtrace logger on failed event send works with custom formatters [#627, @chulkilee]
* BUGFIX: Fix typo that caused Version headers to not be corrected [#628, @nateberkopec]
* BUGFIX: Faraday errors are more descriptive when no server response [#629, @drewish]
* BUGFIX: DelayedJob handler no longer truncates unneccessarily short [#633, @darrennix]
* BUGFIX: Fix several processors not working correctly w/async jobs stored in backends like Redis [#634, @nateberkopec]
2.3.0
-----
* CHANGE: Log levels of some messages have been changed. Raven logger is INFO level by default. [@nateberkopec]
* BUGFIX: Exception messages are now limited to 10,000 bytes. [#617, @mattrobenolt]
2.2.0
-----
* ENHANCEMENT: Sentry server errors now return some information about the response headers. [#585, @rafadc]
* BUGFIX/ENHANCEMENT: Frozen objects are no longer sanitized. This prevents some bugs, but you can now also freeze objects if you don't want them to be sanitized by the SanitizeData processor. [#594, @nateberkopec]
* ENHANCEMENT: The ability to use Raven::Instance alone is greatly improved. You can now call #capture_exception directly on an Instance (#595), give it it's own Logger (#599), and set it's own config which will be used when creating Events (#601). Thanks to
* ENHANCEMENT: You may now provide your own LineCache-like class to Raven. This is useful if you have source code which is not available on disk. [#606, @nateberkopec]
* BUGFIX: Raven no longer emits anything to STDOUT if a system command fails [#596, @nateberkopec]
* ENHANCEMENT: Raven now tells you exactly why it will not send an event in the logs [#602, @nateberkopec]
2.1.4
-----
* FIX: Remove `contexts` key, because it was disabling browser auto-tagging [#587, @nateberkopec]
2.1.3
-----
* Move `os` context key to `server_os` [@nateberkopec]
2.1.2
-----
* FIX: `sys_command` not falling back to Windows commands properly, logging output [@jmalves, @nateberkopec]
2.1.1
-----
* FIX: Message params should accept nil [@jmalves, #570]
2.1.0
-----
ENHANCEMENTS:
* Your client version is now included in all Events. [@nateberkopec, #559]
* OS and Ruby runtime information now included in all Events. [@nateberkopec, #560]
* Transport errors (like Sentry 4XX errors) now raise Sentry::Error, not Faraday errors. [@nateberkopec, #565]
* Sidekiq integration is streamlined and improved. Supports Sidekiq 3.x and up. [@nateberkopec, #555]
FIXES:
* Heroku release detection is improved and more accurate. You must `heroku labs:enable runtime-dyno-metadata` for it to work. [@nateberkopec, #566]
2.0.2
-----
* FIX: Don't set up Rack-Timeout middleware. [@janraasch, #558]
2.0.1
-----
* FIX: UUIDs were being rejected by Sentry as being too long [@nateberkopec]
2.0.0
-----
BREAKING CHANGES:
* The object passed to the `async` callback is now a JSON-compatible hash, not a Raven::Event. This fixes many bugs with backend job processors like DelayedJob. [@nateberkopec, #547]
* Several deprecated accessors have been removed [@nateberkopec, #543]
* You can no longer pass an object which cannot be called to `should_capture` [@nateberkopec, #542]
ENHANCEMENTS:
* Rack::Timeout exceptions are now fingerprinted by URL, making them more useful [@nateberkopec, #538]
* Added an HTTP header processor by default. We now scrub `Authorization` headers correctly. You can use `config.sanitize_http_headers` to add a list of HTTP headers you don't want sent to Sentry (e.g. ["Via", "Referer", "User-Agent", "Server", "From"]) [@nateberkopec]
FIXES:
* User/Event IP addresses are now set more accurately. This will fix many issues with local proxy setups (nginx, etc). [@nateberkopec, #546]
* We now generate a real UUID in the correct format for Event IDs [@nateberkopec, #549]
* If `async` sending fails, we retry with sync sending. [@nateberkopec, #548]
* Changed truncation approach - event messages and HTTP bodies now limited to the same amount of characters they're limited to at the Sentry server [@nateberkopec, #536]
OTHER:
* Codebase cleaned up with Rubocop [@nateberkopec, #544]
1.2.3
-----
* ENHANCEMENT: Send the current environment to Sentry [@dcramer, #530]
* BUGFIX: Fix all warnings emitted by Ruby verbose mode [@nateberkopec]
* BUGFIX: Fix compat with `log4r` [@nateberkopec, #535]
1.2.2
-----
* BUGFIX: NameError in DelayedJob integration. [janraasch, #525]
1.2.1
-----
* BUGFIX: Context clearing should now work properly in DelayedJob and Sidekiq. Also, we properly clear context if Sentry causes an exception. [nateberkopec, #520]
* BUGFIX: If Sentry will not send the event (due to environments or no DSN set), it will not attempt to "capture" (construct an event) [nateberkopec, #518]
1.2.0
-----
* FEATURE: Raven now supports Breadcrumbs, though they aren't on by default. Check the docs for how to enable. [dcramer, #497]
* FEATURE: Raven is no longer a singleton, you may have many `Raven::Instance`s. [phillbaker, #504]
* PERFORMANCE: Raven no longer uses a vendored JSON implementation. JSON processing and encoding should be up to 6x faster. [dcramer, #510]
* BUGFIX: silence_ready now works for Rails apps. [ream88, #512]
* BUGFIX: transport_failure_callback now works correctly [nateberkopec, #508]
1.1.0
-----
* The client exposes a ``last_event_id`` accessor at `Raven.last_event_id`. [dcramer, #493]
* PERFORMANCE: Skip identical backtraces from "re-raised" exceptions [databus23, #499]
* Support for ActionController::Live and Rails template streaming [nateberkopec, #486]
1.0.0
-----
We (i.e. @nateberkopec) decided that `raven-ruby` has been stable enough for some time that it's time for a 1.0.0 release!
BREAKING CHANGES:
- Dropped support for Ruby 1.8.7 [nateberkopec, #465]
- `raven-ruby` no longer reports form POST data or web cookies by default. To re-enable this behavior, remove the appropriate Processors from your config (see docs or PR) [nateberkopec, #466]
- UDP transport has been removed [dcramer, #472]
OTHER CHANGES:
- Improved performance [zanker]
- Deprecated `config.catch_debugged_exceptions`, replaced with `config.rails_report_rescued_exceptions`. `catch_debugged_exceptions` will be removed in 1.1. [nateberkopec, #483]
- Added `config.transport_failure_callback`. Provide a lambda or proc to this config setting, which will be `call`ed when Sentry returns a 4xx/5xx response. [nateberkopec, #484]
- JRuby builds fixed [RobinDaugherty]
- Fix problems with duplicate exceptions and `Exception.cause` [dcramer, #490]
- Added Exception Context. Any Exception class can define a `raven_context` instance variable, which will be merged into any Event's context which contains this exception. [nateberkopec, #491]
+ Documentation from shaneog, squirly, dcramer, ehfeng, nateberkopec.
0.15.6
------
- Fixed bug where return value of debug middleware was nil [eugeneius, #461]
- Fixed a bug in checking `catch_debugged_exceptions` [greysteil, #458]
- Fixed a deprecation warning for Rails 5 [Elektron1c97, #457]
0.15.5
------
- DelayedJob integration fixed when last_error not present [dcramer, #454]
- Release detection doesn't overwrite manual release setting in Rails [eugeneius, #450]
- Deal properly with Cap 3.0/3.1 revision logs [timcheadle, #449]
- Rails 5 support [nateberkopec, #423]
0.15.4
------
- DelayedJob integration now also truncates last_error to 100 characters [nateberkopec]
- Fix several issues with release detection - silence git log message, fix Capistrano detection [nateberkopec, kkumler]
0.15.3
------
- Double exception reporting in Rails FIXED! [nateberkopec, #422]
- Rails 3 users having issues with undefined runner fixed [nateberkopec, #428]
- Sidekiq integration works properly when ActiveJob enabled [mattrobenolt]
- Fix problems with invalid UTF-8 in exception messages [nateberkopec, #426]
- Backtraces now consider "exe" directories part of the app [nateberkopec, #420]
- Sinatra::NotFound now ignored by default [drcapulet, #383]
- Release versions now properly set. Support for Heroku, Capistrano, and Git. [iloveitaly #377, Sija #380]
- DelayedJob integration plays well with ActiveJob [kkumler, #378]
- DelayedJob handlers now truncated [nateberkopec, #431]
- Tons of code quality improvements [amatsuda, ddrmanxbxfr, pmbrent, cpizzaia, wdhorton, PepperTeasdale]
0.15.2
------
- Reverted ActiveJob support due to conflicts [#368]
0.15.1
------
- Fix ActiveJob support [greysteil, #367]
0.15.0
------
- Remove Certifi and use default Ruby SSL config [zanker, #352]
- Support for ``fingerprint`` [dcramer]
- Improved documentation and tests around various attributes [dcramer]
- Allow configurable integrations [cthornton]
- Prevent recursion with ``Exception.cause`` [dcramer, #357]
- Use empty hash if false-y value [GeekOnCoffee, #354]
- Correct some behavior with at_exit error capturing [kratob, #355]
- Sanitize matches whole words [alyssa, #361]
- Expose more debugging info to active_job integration [tonywok, #365]
- Capture exceptions swallowed by rails [robertclancy, #343]
- Sanitize the query string when the key is a symbol [jason-o-matic, #349]
- Moved documentation to docs.getsentry.com [mitsuhiko]
0.14.0
------
- Correct handling of JRuby stacktraces [dcramer]
- Better handling of unreachable file contexts [dcramer, #335]
- SSL is now default ON [dcramer, #338]
- Capture exceptions in runner tasks [eugeneius, #339]
- ActiveJob integration [lucasmazza, #327]
- Cleanup return values of async blocks [lucasmazza, #344]
- Better handling when sending NaN/Infinity JSON values [Alric, #345]
- Fix issues with digest/md5 namespace [lsb, #346]
0.13.3
------
- Fix a deprecation warning being shown in regular operation [ripta, #332]
0.13.2
------
- DelayedJob integration now includes the job id [javawizard, #321]
- Rails integration now works properly when you're not using all parts of Rails (e.g. just ActiveRecord) [lucasmazza, #323]
- Bugfix CLI tool when async config is on [if1live, #324]
- Fix and standardize tag hierarchies. Event tags > context tags > configuration tags in all cases. [JonathanBatten, #322 and eugeneius, #330]
- Using #send on Client, Base, and Transports is now deprecated. See [the commit](https://github.com/getsentry/raven-ruby/commit/9f482022a648ab662c22177ba24fd2e2b6794c34) (or the deprecation message) for their replacements. [nateberkopec, #326]
- You can now disable credit-card-like value filtering. [codekitchen, #329]
0.13.1
------
- Raven::Transports::HTTP#send returns the response now. [eagletmt, #317]
- Filenames now work a lot better when you vendor your gems. [eugeneius, #316]
- Fix raven:test issue when testing non-async configurations. [weynsee, #318]
- Fix blockless Raven#capture. [dinosaurjr, #320]
- Fix some log messages [eagletmt, #319]
0.13.0
------
- Support exception chaining [javawizard, #312]
- Add support for sending release version [eugeneius, #310]
- Better status reports on configuration [faber, #309]
- Client "send" method accepts an event in object or hash format - this will make it much easier to send Sentry events in a delayed job! [marclennox, #300]
- Fix duplicate fields in SanitizeData [wyattisimo, #294]
- Always preserve filename paths under project_root [eugeneius, #291]
- Truncate project root prefixes from filenames [eagletmt, #278]
- Renamed should_send callback to should_capture [nateberkopec, #270]
- Silencing the ready message now happens in the config as normal [nateberkopec, #260]
- Various internal refactorings [see here](https://github.com/getsentry/raven-ruby/compare/0-12-stable...master)
0.12.3
------
- URL query parameters are now sanitized for sensitive data [pcorliss, #275]
- Raven::Client can now use a proxy server when sending events to Sentry [dcramer, #277]
- Raven::Client will now use a timed backoff strategy if the server fails [codekitchen, #267]
- Automatic integration loading is now a lot less brittle [dcramer, handlers, #263, #264]
- Fixed some issues with prefixes and DSN strings [nateberkopec, #259]
- If Raven is initialized without a server config, it will no longer send events [nateberkopec, #258]
- Slightly nicer credit-card-like number scrubbing [nateberkopec, #254]
- Fix some exceptions not being caught by Sidekiq middleware [nateberkopec, #251]
- Uncommon types are now encoded correctly [nateberkopec, #249]
0.12.2
------
- Security fix where exponential numbers in specially crafted params could cause a CPU attack [dcramer, #262]
0.12.1
------
- Integrations (Sidekiq, DelayedJob, etc) now load independently of your Gemfile order. [nateberkopec, #236]
- Fixed bug where setting tags mutated your configuration [berg, #239]
- Fixed several issues with SanitizeData and UTF8 sanitization processors [nateberkopec, #238, #241, #244]
0.12.0
------
- You can now give additional fields to the SanitizeData processor. Values matched are replaced by the string mask (*********). Full documentation (and how to use with Rails config.filter_parameters) [here](https://docs.getsentry.com/hosted/clients/ruby/config/). [jamescway, #232]
- An additional processor has been added, though it isn't turned on by default: RemoveStacktrace. Use it to remove stacktraces from exception reports. [nateberkopec, #233]
- Dependency on `uuidtools` has been removed. [nateberkopec, #231]
0.11.2
------
- Fix some issues with the SanitizeData processor when processing strings that look like JSON
0.11.1
------
- Raven now captures exceptions in Rake tasks automatically. [nateberkopec, troelskn #222]
- There is now a configuration option called ```should_send``` that can be configured to use a Proc to determine whether or not an event should be sent to Sentry. This can be used to implement rate limiters, etc. [nateberkopec, #221]
- Raven now includes three event processors by default instead of one, which can be turned on and off independently. [nateberkopec, #223]
- Fixed bug with YAJL compatibility. [nateberkopec, #223]
0.10.1
------
- Updated to RSpec 3.
- Apply filters to encoded JSON data.
0.10.0
------
- Events are now sent to Sentry in all environments. To change this behavior, either unset ```SENTRY_DSN``` or explicitly configure it via ```Raven.configure```.
- gzip is now the default encoding
- Removed hashie dependency
0.9.0
-----
- Native support for Delayed::Job [pkuczynski, #176]
- Updated to Sentry protocol version 5
0.5.0
-----
- Rails 2 support [sluukonen, #45]
- Controller methods in Rails [jfirebaugh]
- Runs by default in any environment other than test, cucumber, or development. [#81]
raven-ruby-2.6.3/docs/ 0000775 0000000 0000000 00000000000 13142120705 0014537 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/docs/Makefile 0000664 0000000 0000000 00000010760 13142120705 0016203 0 ustar 00root root 0000000 0000000 # Makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = ./_build
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest
help:
@echo "Please use \`make ' where is one of"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " singlehtml to make a single large HTML file"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " devhelp to make HTML files and a Devhelp project"
@echo " epub to make an epub"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
@echo " text to make text files"
@echo " man to make manual pages"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
clean:
-rm -rf $(BUILDDIR)/*
html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
singlehtml:
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
pickle:
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."
json:
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."
htmlhelp:
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp."
qthelp:
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/Sentry.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Sentry.qhc"
devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@echo "To view the help file:"
@echo "# mkdir -p $$HOME/.local/share/devhelp/Sentry"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/Sentry"
@echo "# devhelp"
epub:
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
@echo
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
latex:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@echo "Run \`make' in that directory to run these through (pdf)latex" \
"(use \`make latexpdf' here to do that automatically)."
latexpdf:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through pdflatex..."
make -C $(BUILDDIR)/latex all-pdf
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
text:
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo
@echo "Build finished. The text files are in $(BUILDDIR)/text."
man:
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
@echo
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in $(BUILDDIR)/changes."
linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."
doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."
raven-ruby-2.6.3/docs/_sentryext/ 0000775 0000000 0000000 00000000000 13142120705 0016743 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/docs/breadcrumbs.rst 0000664 0000000 0000000 00000003053 13142120705 0017563 0 ustar 00root root 0000000 0000000 Breadcrumbs
===========
Breadcrumbs are a trail of events which happened prior to an issue. Often, these events are very similar to traditional logs, but Breadcrumbs also can record rich, structured data.
.. sourcecode:: ruby
Raven.breadcrumbs.record do |crumb|
crumb.data = data
crumb.category = name
# ...
end
The following attributes are available:
* ``category``: A String to label the event under. This will usually be the same as a logger name, and will let you more easily understand the area an event took place, such as "auth".
* ``data``: A Hash of metadata around the event. This is often used instead of message, but may also be used in addition.
* ``level``: The level may be any of ``error``, ``warn``, ``info``, or ``debug``.
* ``message``: A string describing the event. The most common vector, often used as a drop-in for a traditional log message.
* ``timestamp``: A Unix timestamp (seconds past epoch)
Appropriate places to inject Breadcrumbs may be places like your HTTP library:
.. sourcecode:: ruby
# Instrumenting Faraday with a middleware:
class RavenFaradayMiddleware
def call
# Add a breadcrumb every time we complete an HTTP request
@app.call(request_env).on_complete do |response_env|
Raven.breadcrumbs.record do |crumb|
crumb.data = { response_env: response_env }
crumb.category = "faraday"
crumb.timestamp = Time.now.to_i
crumb.message = "Completed request to #{request_env[:url]}"
end
end
end
end
raven-ruby-2.6.3/docs/conf.py 0000664 0000000 0000000 00000016310 13142120705 0016037 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
#
# Sentry documentation build configuration file, created by
# sphinx-quickstart on Wed Oct 20 16:21:42 2010.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import os
import sys
import datetime
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.'))
# -- General configuration -----------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
#extensions = ['sphinxtogithub']
extensions = ['sphinx.ext.intersphinx']
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix of source filenames.
source_suffix = '.rst'
# The encoding of source files.
#source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'Raven'
copyright = u'%s, Functional Software Inc.' % datetime.datetime.today().year
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = __import__('pkg_resources').get_distribution('raven').version
# The full version, including alpha/beta/rc tags.
release = version
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_build']
# The reST default role (used for this markup: `text`) to use for all documents.
#default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
intersphinx_mapping = {
}
# -- Options for HTML output ---------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'nature'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
# html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
html_theme_path = ['_themes']
# The name for this set of Sphinx documents. If None, it defaults to
# " v documentation".
#html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = "_static/logo.png"
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
# If false, no module index is generated.
#html_domain_indices = True
# If false, no index is generated.
#html_use_index = True
# If true, the index is split into individual pages for each letter.
#html_split_index = False
# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None
# Output file base name for HTML help builder.
htmlhelp_basename = 'Ravendoc'
# -- Options for LaTeX output --------------------------------------------------
# The paper size ('letter' or 'a4').
#latex_paper_size = 'letter'
# The font size ('10pt', '11pt' or '12pt').
#latex_font_size = '10pt'
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'Raven.tex', u'Raven Ruby Documentation',
u'David Cramer', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# If true, show page references after internal links.
#latex_show_pagerefs = False
# If true, show URL addresses after external links.
#latex_show_urls = False
# Additional stuff for the LaTeX preamble.
#latex_preamble = ''
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
#latex_domain_indices = True
# -- Options for manual page output --------------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'raven', u'Raven Ruby Documentation',
[u'Functional Software Inc.'], 1)
]
if os.environ.get('SENTRY_FEDERATED_DOCS') != '1':
sys.path.insert(0, os.path.abspath('_sentryext'))
import sentryext
sentryext.activate()
raven-ruby-2.6.3/docs/config.rst 0000664 0000000 0000000 00000022455 13142120705 0016546 0 ustar 00root root 0000000 0000000 Configuration
=============
Configuration is passed as part of the client initialization:
.. code-block:: javascript
Raven.configure do |config|
config.dsn = '___DSN___'
config.attr = 'value'
end
Optional settings
-----------------
.. describe:: async
When an error or message occurs, the notification is immediately sent to Sentry. Raven can be configured to send asynchronously:
.. code-block:: ruby
config.async = lambda { |event|
Thread.new { Raven.send_event(event) }
}
Using a thread to send events will be adequate for truly parallel Ruby platforms such as JRuby, though the benefit on MRI/CRuby will be limited. Threads also won't report any exceptions raised inside of them, so be careful!
If the async callback raises an exception, Raven will attempt to send synchronously.
We recommend creating a background job, using your background job processor, that will send Sentry notifications in the background. Rather than enqueuing an entire Raven::Event object, we recommend providing the Hash representation of an event as a job argument. Here's an example for ActiveJob:
.. code-block:: ruby
config.async = lambda { |event|
SentryJob.perform_later(event.to_hash)
}
.. code-block:: ruby
class SentryJob < ActiveJob::Base
queue_as :default
# Important! Otherwise, we can get caught in an infinite loop.
rescue_from(ActiveJob::DeserializationError) { |e| Rails.logger.error e }
def perform(event)
Raven.send_event(event)
end
end
.. describe:: encoding
While unlikely that you'll need to change it, by default Raven compresses outgoing messages with gzip. This has a slight impact on performance, but due to the size of many Ruby stacktrace it's required for the serve to accept the content.
To disable gzip, set the encoding to 'json':
.. code-block:: ruby
config.encoding = 'json'
.. describe:: environments
As of v0.10.0, events will be sent to Sentry in all environments. If you do not wish to send events in an environment, we suggest you unset the SENTRY_DSN variable in that environment.
Alternately, you can configure Raven to run only in certain environments by configuring the environments whitelist. For example, to only run Sentry in production:
.. code-block:: ruby
config.environments = %w[ production ]
Sentry automatically sets the current environment to RAILS_ENV, or if it is not present, RACK_ENV. If you are using Sentry outside of Rack or Rails, or wish to override environment detection, you'll need to set the current environment yourself:
.. code-block:: ruby
config.current_environment = 'my_cool_environment'
.. describe:: excluded_exceptions
If you never wish to be notified of certain exceptions, specify 'excluded_exceptions' in your config file.
In the example below, the exceptions Rails uses to generate 404 responses will be suppressed.
.. code-block:: ruby
config.excluded_exceptions += ['ActionController::RoutingError', 'ActiveRecord::RecordNotFound']
You can find the list of exceptions that are excluded by default in ``Raven::Configuration::IGNORE_DEFAULT``. It is suggested that you append to these defaults rather than overwrite them with ``=``.
.. describe:: logger
The logger used by Sentry. Default is an instance of Raven::Logger.
.. code-block:: ruby
config.logger = Raven::Logger.new(STDOUT)
Raven respects logger levels.
.. describe:: processors
If you need to sanitize or pre-process (before its sent to the server) data, you can do so using the Processors implementation. By default, a few processors are installed. The most important is ``Raven::Processor::SanitizeData``, which will attempt to sanitize keys that match various patterns (e.g. password) and values that resemble credit card numbers.
In your Sentry UI, data which has been sanitized will appear as "********" (or 0, if the value was an Integer).
To specify your own (or to remove the defaults), simply pass them with your configuration:
.. code-block:: ruby
config.processors = [MyOwnProcessor]
Check out ``Raven::Processor::SanitizeData`` to see how a Processor is implemented.
You can also specify values to be sanitized. Any strings matched will be replaced with the string mask (********). One good use for this is to copy Rails' filter_parameters:
.. code-block:: ruby
config.sanitize_fields = Rails.application.config.filter_parameters.map(&:to_s)
The client scrubs the HTTP "Authorization" header of requests before sending them to Sentry, to prevent sensitive credentials from being sent. You can specify additional HTTP headers to ignore:
You can also provide regex-like strings to the sanitizer:
.. code-block:: ruby
config.sanitize_fields = ["my_field", "foo(.*)?bar]
It's also possible to remove HTTP header values which match a list:
.. code-block:: ruby
config.sanitize_http_headers = ["Via", "Referer", "User-Agent", "Server", "From"]
For more information about HTTP headers which may contain sensitive information in your application, see `RFC 2616 `_.
By default, Sentry sends up a stacktrace with an exception. This stacktrace may contain data which you may consider to be sensitive, including lines of source code, line numbers, module names, and source paths. To wipe the stacktrace from all error reports, require and add the RemoveStacktrace processor:
.. code-block:: ruby
require 'raven/processor/removestacktrace'
Raven.configure do |config|
config.processors << Raven::Processor::RemoveStacktrace
end
By default, Sentry does not send POST data or cookies if present. To re-enable, remove the respective processor from the chain:
.. code-block:: ruby
Raven.configure do |config|
config.processors -= [Raven::Processor::PostData] # Do this to send POST data
config.processors -= [Raven::Processor::Cookies] # Do this to send cookies by default
end
.. describe:: proxy
A string with the URL of the HTTP proxy to be used.
.. code-block:: ruby
config.proxy = 'http://path.to.my.proxy.com'
.. describe:: rails_report_rescued_exceptions
Rails catches exceptions in the ActionDispatch::ShowExceptions or ActionDispatch::DebugExceptions middlewares, depending on the environment. When `rails_report_rescued_exceptions` is true (it is by default), Raven will report exceptions even when they are rescued by these middlewares.
If you are using a custom exceptions app, you may wish to disable this behavior:
.. code-block:: ruby
config.rails_report_rescued_exceptions = false
.. describe:: release
Track the version of your application in Sentry.
We guess the release intelligently in the following order of preference:
* Commit SHA of the last commit (git)
* Reading from the REVISION file in the app root
* Heroku's dyno metadata (must have enabled via Heroku Labs)
.. code-block:: ruby
config.release = '721e41770371db95eee98ca2707686226b993eda'
.. describe:: should_capture
By providing a proc or lambda, you can control what events are captured. Events are passed to the Proc or lambda you provide - returning false will stop the event from sending to Sentry:
.. code-block:: ruby
config.should_capture = Proc.new { |e| true unless e.contains_sensitive_info? }
.. describe:: silence_ready
Upon start, Raven will write the following message to the log at the INFO level:
``
** [out :: hostname.example.com] I, [2014-07-22T15:32:57.498368 #30897] INFO -- : ** [Raven] Raven 0.9.4 ready to catch errors"
``
You can turn off this message:
.. code-block:: ruby
config.silence_ready = true
.. describe:: ssl_verification
By default SSL certificate verification is enabled in the client. It can be disabled.
.. code-block:: ruby
config.ssl_verification = false
.. describe:: tags
Default tags to send with each event.
.. code-block:: ruby
config.tags = { foo: :bar }
.. describe:: transport_failure_callback
If the transport fails to send an event to Sentry for any reason (either the Sentry server has returned a 4XX or 5XX response), this Proc or lambda will be called.
.. code-block:: ruby
config.transport_failure_callback = lambda { |event|
AdminMailer.email_admins("Oh god, it's on fire!").deliver_later
}
Environment Variables
---------------------
.. describe:: SENTRY_DSN
After you complete setting up a project, you'll be given a value which we call a DSN, or Data Source Name. It looks a lot like a standard URL, but it's actually just a representation of the configuration required by Raven (the Sentry client). It consists of a few pieces, including the protocol, public and secret keys, the server address, and the project identifier.
With Raven, you may either set the SENTRY_DSN environment variable (recommended), or set your DSN manually in a config block:
.. code-block:: ruby
# in Rails, this might be in config/initializers/sentry.rb
Raven.configure do |config|
config.dsn = 'http://public:secret@example.com/project-id'
end
raven-ruby-2.6.3/docs/context.rst 0000664 0000000 0000000 00000006433 13142120705 0016763 0 ustar 00root root 0000000 0000000 Context
=======
Additional context can be passed to the capture methods. This allows you
to record extra information that could help you identify the root cause of
the issue or who the error happened for.
.. sourcecode:: ruby
Raven.capture_message 'My Event!',
logger: 'logger',
extra: {
my_custom_variable: 'value'
},
tags: {
foo: 'bar'
}
The following attributes are available:
* ``logger``: the logger name to record this event under
* ``level``: a string representing the level of this event (fatal, error,
warning, info, debug)
* ``server_name``: the hostname of the server
* ``tags``: a mapping of tags describing this event
* ``extra``: a mapping of arbitrary context
* ``user``: a mapping of user context
Providing Request Context
-------------------------
Most of the time you're not actually calling out to Raven directly, but
you still want to provide some additional context. This lifecycle
generally constists of something like the following:
* Set some context via a middleware (e.g. the logged in user)
* Send all given context with any events during the request lifecycle
* Cleanup context
There are three primary methods for providing request context.
User Context
~~~~~~~~~~~~
User context describes the current actor.
.. sourcecode:: ruby
# bind the logged in user
Raven.user_context(
# a unique ID which represents this user
id: current_user.id, # 1
# the actor's email address, if available
email: current_user.email, # "example@example.org"
# the actor's username, if available
username: current_user.username, # "foo"
# the actor's IP address, if available
ip_address: request.ip # '127.0.0.1'
)
When dealing with anonymous users you will still want to send basic user context to ensure Sentry can count them against the unique users:
.. sourcecode:: ruby
Raven.user_context(
# the actor's IP address, if available
ip_address: request.ip # '127.0.0.1'
)
Tags
~~~~
You can provide a set of key/value pairs called tags which Sentry will index and aggregate. This will help you understand the distribution of issues, as well as enabling easy lookup via search.
.. sourcecode:: ruby
# tag the request with something interesting
Raven.tags_context(
language: I18n.locale, # "en-us"
timezone: current_user.time_zone # "PST"
)
Additional Context
~~~~~~~~~~~~~~~~~~
In addition to the supported structured data of Sentry, you can provide additional context. This is a key/value mapping, where the values must be JSON compatible, but can be of a rich datatype.
.. sourcecode:: ruby
# provide a bit of additional context
Raven.extra_context(
happiness: 'very',
emoji: ['much']
)
Rack (HTTP) Context
~~~~~~~~~~~~~~~~~~~
Additionally, if you're using Rack (without the middleware), you can
easily provide context with the ``rack_context`` helper:
.. sourcecode:: ruby
Raven.rack_context(env)
If you're using the Rack middleware, we've already taken care of cleanup
for you, otherwise you'll need to ensure you perform it manually:
.. sourcecode:: ruby
Raven::Context.clear!
Note: the rack and user context will perform a set operation, whereas tags
and extra context will merge with any existing request context.
raven-ruby-2.6.3/docs/index.rst 0000664 0000000 0000000 00000005117 13142120705 0016404 0 ustar 00root root 0000000 0000000 .. sentry:edition:: self
Raven Ruby
==========
.. sentry:edition:: hosted, on-premise
.. class:: platform-ruby
Ruby
====
Raven for Ruby is a client and integration layer for the Sentry error
reporting API. It supports Ruby 1.9.3 and 2.x.
JRuby support is provided but experimental.
Installation
------------
Raven Ruby comes as a gem and is straightforward to install. If you are
using Bundler just add this to your ``Gemfile``:
.. sourcecode:: ruby
gem "sentry-raven"
For other means of installation see :doc:`install`.
Configuration
-------------
To use Raven Ruby all you need is your DSN. Like most Sentry libraries it
will honor the ``SENTRY_DSN`` environment variable. You can find it on
the project settings page under API Keys. You can either export it as
environment variable or manually configure it with ``Raven.configure``:
.. sourcecode:: ruby
Raven.configure do |config|
config.dsn = '___DSN___'
end
Reporting Failures
------------------
If you use Rails, Rake, Sidekiq, etc, you're already done - no more
configuration required! Check :doc:`integrations/index` for more details on
other gems Sentry integrates with automatically.
Rack requires a little more setup: :doc:`integrations/rack`
Otherwise, Raven supports two methods of capturing exceptions:
.. sourcecode:: ruby
Raven.capture do
# capture any exceptions which happen during execution of this block
1 / 0
end
begin
1 / 0
rescue ZeroDivisionError => exception
Raven.capture_exception(exception)
end
Additional Context
------------------
Much of the usefulness of Sentry comes from additional context data with
the events. Raven Ruby makes this very convenient by providing
methods to set thread local context data that is then submitted
automatically with all events.
There are three primary methods for providing request context:
.. sourcecode:: ruby
# bind the logged in user
Raven.user_context email: 'foo@example.com'
# tag the request with something interesting
Raven.tags_context interesting: 'yes'
# provide a bit of additional context
Raven.extra_context happiness: 'very'
For more information see :doc:`context`.
Deep Dive
---------
Want to know more? We have a detailed documentation about all parts of
the library and the client integrations.
.. toctree::
:maxdepth: 2
:titlesonly:
install
config
usage
breadcrumbs
context
integrations/index
Resources:
* `Bug Tracker `_
* `Github Project `_
raven-ruby-2.6.3/docs/install.rst 0000664 0000000 0000000 00000001674 13142120705 0016747 0 ustar 00root root 0000000 0000000 Installation
============
Raven Ruby comes as a gem and is straightforward to install. If you are
using Bundler just add this to your ``Gemfile``:
.. sourcecode:: ruby
gem "sentry-raven"
Development Version
-------------------
If you want to install the development version from github:
.. sourcecode:: ruby
gem "sentry-raven", :github => "getsentry/raven-ruby"
Without Integrations
--------------------
If you wish to activate integrations manually (or don't want them
activated by default), require "raven/base" instead of "raven" or
"sentry-raven". In that case disable the requiring in the ``Gemfile``:
.. sourcecode:: ruby
gem "sentry-raven", :require => false
And in your initialization code:
.. sourcecode:: ruby
require "raven/base"
require "raven/integrations/rails"
require "raven/integrations/delayed_job"
This stops you from calling ``Raven.inject``, which is where all this
integration loading occurs.
raven-ruby-2.6.3/docs/integrations/ 0000775 0000000 0000000 00000000000 13142120705 0017245 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/docs/integrations/heroku.rst 0000664 0000000 0000000 00000000315 13142120705 0021273 0 ustar 00root root 0000000 0000000 Heroku
======
Installation
------------
Enable the ``runtime-dyno-metadata`` Heroku Labs feature in order to enable automated release detection:
::
heroku labs:enable runtime-dyno-metadata -a myapp
raven-ruby-2.6.3/docs/integrations/index.rst 0000664 0000000 0000000 00000002336 13142120705 0021112 0 ustar 00root root 0000000 0000000 Integrations
============
For common environments and frameworks like Rails, Rake, Rack and others
Ruby Raven provides automatic integration for reporting. Most of the time
you don't need to change anything, although you can configure those
features if you want.
.. toctree::
:maxdepth: 1
rails
rack
puma
heroku
The following integrations are available:
* Sidekiq (``:sidekiq``)
* ``Delayed::Job`` (``:delayed_job``)
* Rake (``:rake``)
* Rack (``:rack``)
* Rails (``:railties``)
Manually using integrations
---------------------------
Integrations are automatically loaded by default. This can be problematic if
the default integration behavior doesn't suit your projects' needs.
To explicitly include integrations:
.. sourcecode:: ruby
require 'sentry-raven-without-integrations'
Raven.inject_only(:railties, :rack, :rake)
To blacklist integrations:
.. sourcecode:: ruby
require 'sentry-raven-without-integrations'
Raven.inject_without(:sidekiq, :delayed_job)
If you're using bundler, then in your gemfile:
.. sourcecode:: ruby
gem 'sentry-raven', require: 'sentry-raven-without-integrations'
And in some sort of initializer:
.. sourcecode:: ruby
Raven.inject_without(:sidekiq)
raven-ruby-2.6.3/docs/integrations/puma.rst 0000664 0000000 0000000 00000001271 13142120705 0020742 0 ustar 00root root 0000000 0000000 Puma
====
Installation
------------
Install the SDK via Rubygems by adding it to your ``Gemfile``:
.. sourcecode:: ruby
gem "sentry-raven"
Configuration
-------------
Puma provides a config option for handling low level errors.
.. sourcecode:: ruby
# in your puma.rb config
lowlevel_error_handler do |ex, env|
Raven.capture_exception(
ex,
:message => ex.message,
:extra => { :puma => env },
:culprit => "Puma"
)
# note the below is just a Rack response
[500, {}, ["An error has occurred, and engineers have been informed. Please reload the page. If you continue to have problems, contact support@example.com\n"]]
end
raven-ruby-2.6.3/docs/integrations/rack.rst 0000664 0000000 0000000 00000000705 13142120705 0020721 0 ustar 00root root 0000000 0000000 Rack (Sinatra etc.)
===================
Installation
------------
Install the SDK via Rubygems by adding it to your ``Gemfile``:
.. sourcecode:: ruby
gem "sentry-raven"
Configuration
-------------
Add ``use Raven::Rack`` to your ``config.ru`` or other rackup file (this is
automatically inserted in Rails):
.. sourcecode:: ruby
require 'raven'
Raven.configure do |config|
config.dsn = '___DSN___'
end
use Raven::Rack
raven-ruby-2.6.3/docs/integrations/rails.rst 0000664 0000000 0000000 00000003702 13142120705 0021113 0 ustar 00root root 0000000 0000000 Ruby on Rails
=============
In Rails, all uncaught exceptions will be automatically reported.
We support Rails 3 and newer.
Installation
------------
Install the SDK via Rubygems by adding it to your ``Gemfile``:
.. sourcecode:: ruby
gem "sentry-raven"
Configuration
-------------
Open up ``config/application.rb`` and configure the DSN, and any other :doc:`settings <../config>`
you need:
.. sourcecode:: ruby
Raven.configure do |config|
config.dsn = '___DSN___'
end
If you have added items to `Rails' log filtering
`_,
you can also make sure that those items are not sent to Sentry:
.. sourcecode:: ruby
# in your application.rb:
config.filter_parameters << :password
# in an initializer, like sentry.rb
Raven.configure do |config|
config.sanitize_fields = Rails.application.config.filter_parameters.map(&:to_s)
end
Params and sessions
-------------------
.. sourcecode:: ruby
class ApplicationController < ActionController::Base
before_action :set_raven_context
private
def set_raven_context
Raven.user_context(id: session[:current_user_id]) # or anything else in session
Raven.extra_context(params: params.to_unsafe_h, url: request.url)
end
end
Authlogic
---------
When using Authlogic for authentication, you can provide user context by
binding to session ``after_persisting`` and ``after_destroy`` events in
``user_session.rb``:
.. sourcecode:: ruby
class UserSession < Authlogic::Session::Base
# events binding
after_persisting :raven_set_user_context
after_destroy :raven_clear_user_context
def raven_set_user_context
Raven.user_context({
'id' => self.user.id,
'email' => self.user.email,
'username' => self.user.username
})
end
def raven_clear_user_context
Raven.user_context({})
end
end
raven-ruby-2.6.3/docs/make.bat 0000664 0000000 0000000 00000010012 13142120705 0016136 0 ustar 00root root 0000000 0000000 @ECHO OFF
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set BUILDDIR=_build
set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
if NOT "%PAPER%" == "" (
set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
)
if "%1" == "" goto help
if "%1" == "help" (
:help
echo.Please use `make ^` where ^ is one of
echo. html to make standalone HTML files
echo. dirhtml to make HTML files named index.html in directories
echo. singlehtml to make a single large HTML file
echo. pickle to make pickle files
echo. json to make JSON files
echo. htmlhelp to make HTML files and a HTML help project
echo. qthelp to make HTML files and a qthelp project
echo. devhelp to make HTML files and a Devhelp project
echo. epub to make an epub
echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter
echo. text to make text files
echo. man to make manual pages
echo. changes to make an overview over all changed/added/deprecated items
echo. linkcheck to check all external links for integrity
echo. doctest to run all doctests embedded in the documentation if enabled
goto end
)
if "%1" == "clean" (
for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
del /q /s %BUILDDIR%\*
goto end
)
if "%1" == "html" (
%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
echo.
echo.Build finished. The HTML pages are in %BUILDDIR%/html.
goto end
)
if "%1" == "dirhtml" (
%SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
echo.
echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
goto end
)
if "%1" == "singlehtml" (
%SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
echo.
echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
goto end
)
if "%1" == "pickle" (
%SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
echo.
echo.Build finished; now you can process the pickle files.
goto end
)
if "%1" == "json" (
%SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
echo.
echo.Build finished; now you can process the JSON files.
goto end
)
if "%1" == "htmlhelp" (
%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
echo.
echo.Build finished; now you can run HTML Help Workshop with the ^
.hhp project file in %BUILDDIR%/htmlhelp.
goto end
)
if "%1" == "qthelp" (
%SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
echo.
echo.Build finished; now you can run "qcollectiongenerator" with the ^
.qhcp project file in %BUILDDIR%/qthelp, like this:
echo.^> qcollectiongenerator %BUILDDIR%\qthelp\Sentry.qhcp
echo.To view the help file:
echo.^> assistant -collectionFile %BUILDDIR%\qthelp\Sentry.ghc
goto end
)
if "%1" == "devhelp" (
%SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp
echo.
echo.Build finished.
goto end
)
if "%1" == "epub" (
%SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub
echo.
echo.Build finished. The epub file is in %BUILDDIR%/epub.
goto end
)
if "%1" == "latex" (
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
echo.
echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
goto end
)
if "%1" == "text" (
%SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text
echo.
echo.Build finished. The text files are in %BUILDDIR%/text.
goto end
)
if "%1" == "man" (
%SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man
echo.
echo.Build finished. The manual pages are in %BUILDDIR%/man.
goto end
)
if "%1" == "changes" (
%SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
echo.
echo.The overview file is in %BUILDDIR%/changes.
goto end
)
if "%1" == "linkcheck" (
%SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
echo.
echo.Link check complete; look for any errors in the above output ^
or in %BUILDDIR%/linkcheck/output.txt.
goto end
)
if "%1" == "doctest" (
%SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
echo.
echo.Testing of doctests in the sources finished, look at the ^
results in %BUILDDIR%/doctest/output.txt.
goto end
)
:end
raven-ruby-2.6.3/docs/sentry-doc-config.json 0000664 0000000 0000000 00000001203 13142120705 0020760 0 ustar 00root root 0000000 0000000 {
"support_level": "production",
"platforms": {
"ruby": {
"name": "Ruby",
"type": "language",
"doc_link": "",
"wizard": [
"index#installation",
"index#configuration",
"index#reporting-failures"
]
},
"ruby.rack": {
"name": "Rack",
"type": "framework",
"doc_link": "integrations/rack/",
"wizard": [
"integrations/rack#rack-sinatra-etc"
]
},
"ruby.rails": {
"name": "Rails",
"type": "framework",
"doc_link": "integrations/rails/",
"wizard": [
"integrations/rails#ruby-on-rails"
]
}
}
}
raven-ruby-2.6.3/docs/usage.rst 0000664 0000000 0000000 00000007613 13142120705 0016404 0 ustar 00root root 0000000 0000000 Usage
=====
To use Raven Ruby all you need is your DSN. Like most Sentry libraries it
will honor the ``SENTRY_DSN`` environment variable. You can find it on
the project settings page under API Keys. You can either export it as
environment variable or manually configure it with ``Raven.configure``:
.. code-block:: ruby
Raven.configure do |config|
config.dsn = '___DSN___'
end
If you only want to send events to Sentry in certain environments, you
should set ``config.environments`` too:
.. code-block:: ruby
Raven.configure do |config|
config.dsn = '___DSN___'
config.environments = ['staging', 'production']
end
Reporting Failures
------------------
If you use Rails, Rake, Rack etc, you're already done - no more
configuration required! Check :doc:`integrations/index` for more details on
other gems Sentry integrates with automatically.
Otherwise, Raven supports two methods of capturing exceptions:
.. sourcecode:: ruby
Raven.capture do
# capture any exceptions which happen during execution of this block
1 / 0
end
begin
1 / 0
rescue ZeroDivisionError => exception
Raven.capture_exception(exception)
end
Reporting Messages
------------------
If you want to report a message rather than an exception you can use the
``capture_message`` method:
.. code-block:: ruby
Raven.capture_message("Something went very wrong")
Referencing Events
------------------
The client exposes a ``last_event_id`` accessor allowing you to easily
reference the last captured event. This is useful, for example, if you wanted
to show the user a reference on your error page:
.. code-block:: ruby
# somewhere deep in the stack
Raven.capture do
1 / 0
end
Now you can easily expose this to your error handler:
.. code-block:: ruby
class ErrorsController < ApplicationController
def internal_server_error
render(:status => 500, :sentry_event_id => Raven.last_event_id)
end
end
Optional Attributes
-------------------
With calls to ``capture_exception`` or ``capture_message`` additional data
can be supplied:
.. code-block:: ruby
Raven.capture_message("...", :attr => 'value')
.. describe:: extra
Additional context for this event. Must be a mapping. Children can be any native JSON type.
.. code-block:: ruby
{
:extra => {'key' => 'value'}
}
.. describe:: fingerprint
The fingerprint for grouping this event.
.. code-block:: ruby
{
:fingerprint => ['{{ default }}', 'other value']
}
.. describe:: level
The level of the event. Defaults to ``error``.
.. code-block:: ruby
{
:level => 'warning'
}
Sentry is aware of the following levels:
* debug (the least serious)
* info
* warning
* error
* fatal (the most serious)
.. describe:: logger
The logger name for the event.
.. code-block:: ruby
{
:logger => 'default'
}
.. describe:: tags
Tags to index with this event. Must be a mapping of strings.
.. code-block:: ruby
{
:tags => {'key' => 'value'}
}
.. describe:: user
The acting user.
.. code-block:: ruby
{
:user => {
'id' => 42,
'email' => 'clever-girl'
}
}
Many Instances
--------------
It is possible to have many different instances and configurations of the Raven
client running at once. See the delegation pattern in ``base.rb`` for more
information about how the ``Raven`` module delegates calls to the "main" instance.
.. code-block:: ruby
Raven.capture # capture, sent to the main instance
# You can create as many instances as you like. Provide a context and config.
instance = Raven::Instance.new(Raven::Context.new, Raven::Configuration.new)
Currently, all integrations use the "main" instance.
raven-ruby-2.6.3/examples/ 0000775 0000000 0000000 00000000000 13142120705 0015425 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/ 0000775 0000000 0000000 00000000000 13142120705 0017040 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/.gitignore 0000664 0000000 0000000 00000000732 13142120705 0021032 0 ustar 00root root 0000000 0000000 # See https://help.github.com/articles/ignoring-files for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile '~/.gitignore_global'
# Ignore bundler config.
/.bundle
# Ignore the default SQLite database.
/db/*.sqlite3
/db/*.sqlite3-journal
# Ignore all logfiles and tempfiles.
/log/*
!/log/.keep
/tmp
raven-ruby-2.6.3/examples/rails-4.2/Gemfile 0000664 0000000 0000000 00000003006 13142120705 0020332 0 ustar 00root root 0000000 0000000 source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.5.1'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'sentry-raven', :path => "../../"
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end
raven-ruby-2.6.3/examples/rails-4.2/README.rdoc 0000664 0000000 0000000 00000000736 13142120705 0020654 0 ustar 00root root 0000000 0000000 == README
This README would normally document whatever steps are necessary to get the
application up and running.
Things you may want to cover:
* Ruby version
* System dependencies
* Configuration
* Database creation
* Database initialization
* How to run the test suite
* Services (job queues, cache servers, search engines, etc.)
* Deployment instructions
* ...
Please feel free to use a different markup language if you do not plan to run
rake doc:app.
raven-ruby-2.6.3/examples/rails-4.2/Rakefile 0000664 0000000 0000000 00000000371 13142120705 0020506 0 ustar 00root root 0000000 0000000 # Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
Rails.application.load_tasks
raven-ruby-2.6.3/examples/rails-4.2/app/ 0000775 0000000 0000000 00000000000 13142120705 0017620 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/app/assets/ 0000775 0000000 0000000 00000000000 13142120705 0021122 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/app/assets/images/ 0000775 0000000 0000000 00000000000 13142120705 0022367 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/app/assets/images/.keep 0000664 0000000 0000000 00000000000 13142120705 0023302 0 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/app/assets/javascripts/ 0000775 0000000 0000000 00000000000 13142120705 0023453 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/app/assets/javascripts/application.js 0000664 0000000 0000000 00000001225 13142120705 0026314 0 ustar 00root root 0000000 0000000 // This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .
raven-ruby-2.6.3/examples/rails-4.2/app/assets/javascripts/welcome.coffee 0000664 0000000 0000000 00000000323 13142120705 0026255 0 ustar 00root root 0000000 0000000 # Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
raven-ruby-2.6.3/examples/rails-4.2/app/assets/stylesheets/ 0000775 0000000 0000000 00000000000 13142120705 0023476 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/app/assets/stylesheets/application.css 0000664 0000000 0000000 00000001256 13142120705 0026517 0 ustar 00root root 0000000 0000000 /*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any styles
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
* file per style scope.
*
*= require_tree .
*= require_self
*/
raven-ruby-2.6.3/examples/rails-4.2/app/assets/stylesheets/welcome.scss 0000664 0000000 0000000 00000000262 13142120705 0026026 0 ustar 00root root 0000000 0000000 // Place all the styles related to the welcome controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
raven-ruby-2.6.3/examples/rails-4.2/app/controllers/ 0000775 0000000 0000000 00000000000 13142120705 0022166 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/app/controllers/application_controller.rb 0000664 0000000 0000000 00000000625 13142120705 0027264 0 ustar 00root root 0000000 0000000 class ApplicationController < ActionController::Base
before_action :set_raven_context
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
private
def set_raven_context
# Raven.user_context(email: 'david@getsentry.com')
# Raven.extra_context(params: params.to_hash, url: request.url)
end
end
raven-ruby-2.6.3/examples/rails-4.2/app/controllers/concerns/ 0000775 0000000 0000000 00000000000 13142120705 0024000 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/app/controllers/concerns/.keep 0000664 0000000 0000000 00000000000 13142120705 0024713 0 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/app/controllers/errors_controller.rb 0000664 0000000 0000000 00000000233 13142120705 0026270 0 ustar 00root root 0000000 0000000 class ErrorsController < ApplicationController
def internal_server_error
@sentry_event_id = Raven.last_event_id
render(:status => 500)
end
end
raven-ruby-2.6.3/examples/rails-4.2/app/controllers/welcome_controller.rb 0000664 0000000 0000000 00000000167 13142120705 0026415 0 ustar 00root root 0000000 0000000 class WelcomeController < ApplicationController
def index
Rails.logger.info("zomg division")
1 / 0
end
end
raven-ruby-2.6.3/examples/rails-4.2/app/helpers/ 0000775 0000000 0000000 00000000000 13142120705 0021262 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/app/helpers/application_helper.rb 0000664 0000000 0000000 00000000035 13142120705 0025447 0 ustar 00root root 0000000 0000000 module ApplicationHelper
end
raven-ruby-2.6.3/examples/rails-4.2/app/helpers/welcome_helper.rb 0000664 0000000 0000000 00000000031 13142120705 0024573 0 ustar 00root root 0000000 0000000 module WelcomeHelper
end
raven-ruby-2.6.3/examples/rails-4.2/app/mailers/ 0000775 0000000 0000000 00000000000 13142120705 0021254 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/app/mailers/.keep 0000664 0000000 0000000 00000000000 13142120705 0022167 0 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/app/models/ 0000775 0000000 0000000 00000000000 13142120705 0021103 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/app/models/.keep 0000664 0000000 0000000 00000000000 13142120705 0022016 0 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/app/models/concerns/ 0000775 0000000 0000000 00000000000 13142120705 0022715 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/app/models/concerns/.keep 0000664 0000000 0000000 00000000000 13142120705 0023630 0 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/app/views/ 0000775 0000000 0000000 00000000000 13142120705 0020755 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/app/views/errors/ 0000775 0000000 0000000 00000000000 13142120705 0022271 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/app/views/errors/internal_server_error.html.erb 0000664 0000000 0000000 00000000574 13142120705 0030347 0 ustar 00root root 0000000 0000000
Internal Server Error
raven-ruby-2.6.3/examples/rails-4.2/bin/ 0000775 0000000 0000000 00000000000 13142120705 0017610 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/bin/bundle 0000775 0000000 0000000 00000000201 13142120705 0021000 0 ustar 00root root 0000000 0000000 #!/usr/bin/env ruby
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
load Gem.bin_path('bundler', 'bundle')
raven-ruby-2.6.3/examples/rails-4.2/bin/rails 0000775 0000000 0000000 00000000414 13142120705 0020647 0 ustar 00root root 0000000 0000000 #!/usr/bin/env ruby
begin
load File.expand_path('../spring', __FILE__)
rescue LoadError => e
raise unless e.message.include?('spring')
end
APP_PATH = File.expand_path('../../config/application', __FILE__)
require_relative '../config/boot'
require 'rails/commands'
raven-ruby-2.6.3/examples/rails-4.2/bin/rake 0000775 0000000 0000000 00000000325 13142120705 0020460 0 ustar 00root root 0000000 0000000 #!/usr/bin/env ruby
begin
load File.expand_path('../spring', __FILE__)
rescue LoadError => e
raise unless e.message.include?('spring')
end
require_relative '../config/boot'
require 'rake'
Rake.application.run
raven-ruby-2.6.3/examples/rails-4.2/bin/setup 0000775 0000000 0000000 00000001445 13142120705 0020702 0 ustar 00root root 0000000 0000000 #!/usr/bin/env ruby
require 'pathname'
# path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
Dir.chdir APP_ROOT do
# This script is a starting point to setup your application.
# Add necessary setup steps to this file:
puts "== Installing dependencies =="
system "gem install bundler --conservative"
system "bundle check || bundle install"
# puts "\n== Copying sample files =="
# unless File.exist?("config/database.yml")
# system "cp config/database.yml.sample config/database.yml"
# end
puts "\n== Preparing database =="
system "bin/rake db:setup"
puts "\n== Removing old logs and tempfiles =="
system "rm -f log/*"
system "rm -rf tmp/cache"
puts "\n== Restarting application server =="
system "touch tmp/restart.txt"
end
raven-ruby-2.6.3/examples/rails-4.2/bin/spring 0000775 0000000 0000000 00000000750 13142120705 0021042 0 ustar 00root root 0000000 0000000 #!/usr/bin/env ruby
# This file loads spring without using Bundler, in order to be fast.
# It gets overwritten when you run the `spring binstub` command.
unless defined?(Spring)
require 'rubygems'
require 'bundler'
if (match = Bundler.default_lockfile.read.match(/^GEM$.*?^ (?: )*spring \((.*?)\)$.*?^$/m))
Gem.paths = { 'GEM_PATH' => [Bundler.bundle_path.to_s, *Gem.path].uniq.join(Gem.path_separator) }
gem 'spring', match[1]
require 'spring/binstub'
end
end
raven-ruby-2.6.3/examples/rails-4.2/config.ru 0000664 0000000 0000000 00000000231 13142120705 0020651 0 ustar 00root root 0000000 0000000 # This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
run Rails.application
raven-ruby-2.6.3/examples/rails-4.2/config/ 0000775 0000000 0000000 00000000000 13142120705 0020305 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/config/application.rb 0000664 0000000 0000000 00000003237 13142120705 0023142 0 ustar 00root root 0000000 0000000 require File.expand_path('../boot', __FILE__)
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module Rails42
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
# Do not swallow errors in after_commit/after_rollback callbacks.
config.active_record.raise_in_transactional_callbacks = true
config.consider_all_requests_local = false
# https://github.com/getsentry/raven-ruby/issues/494
config.exceptions_app = self.routes
# With this enabled 'exceptions_app' isnt executed, so instead we
# set ``config.consider_all_requests_local = false`` in development.
# config.action_dispatch.show_exceptions = false
# Inject Sentry logger breadcrumbs
require 'raven/breadcrumbs/logger'
Raven.configure do |config|
config.dsn = 'https://6bca098db7ef423ab983e26e27255fe8:650b2fcf94f942fe9093f656b809a94e@app.getsentry.com/3825'
end
end
end
raven-ruby-2.6.3/examples/rails-4.2/config/boot.rb 0000664 0000000 0000000 00000000204 13142120705 0021571 0 ustar 00root root 0000000 0000000 ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
require 'bundler/setup' # Set up gems listed in the Gemfile.
raven-ruby-2.6.3/examples/rails-4.2/config/database.yml 0000664 0000000 0000000 00000001050 13142120705 0022570 0 ustar 00root root 0000000 0000000 # SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
#
default: &default
adapter: sqlite3
pool: 5
timeout: 5000
development:
<<: *default
database: db/development.sqlite3
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: db/test.sqlite3
production:
<<: *default
database: db/production.sqlite3
raven-ruby-2.6.3/examples/rails-4.2/config/environment.rb 0000664 0000000 0000000 00000000226 13142120705 0023176 0 ustar 00root root 0000000 0000000 # Load the Rails application.
require File.expand_path('../application', __FILE__)
# Initialize the Rails application.
Rails.application.initialize!
raven-ruby-2.6.3/examples/rails-4.2/config/environments/ 0000775 0000000 0000000 00000000000 13142120705 0023034 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/config/environments/development.rb 0000664 0000000 0000000 00000002735 13142120705 0025712 0 ustar 00root root 0000000 0000000 Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
# Do not eager load code on boot.
config.eager_load = false
config.action_controller.perform_caching = false
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
# Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load
# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = true
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
# yet still be able to expire them through the digest params.
config.assets.digest = true
# Adds additional error checking when serving assets at runtime.
# Checks for improperly declared sprockets dependencies.
# Raises helpful error messages.
config.assets.raise_runtime_errors = true
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
end
raven-ruby-2.6.3/examples/rails-4.2/config/environments/production.rb 0000664 0000000 0000000 00000006350 13142120705 0025553 0 ustar 00root root 0000000 0000000 Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true
# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Enable Rack::Cache to put a simple HTTP cache in front of your application
# Add `rack-cache` to your Gemfile before enabling this.
# For large-scale production use, consider using a caching reverse proxy like
# NGINX, varnish or squid.
# config.action_dispatch.rack_cache = true
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
# yet still be able to expire them through the digest params.
config.assets.digest = true
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
# Use the lowest log level to ensure availability of diagnostic information
# when problems arise.
config.log_level = :debug
# Prepend all log lines with the following tags.
# config.log_tags = [ :subdomain, :uuid ]
# Use a different logger for distributed setups.
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
end
raven-ruby-2.6.3/examples/rails-4.2/config/environments/test.rb 0000664 0000000 0000000 00000003333 13142120705 0024342 0 ustar 00root root 0000000 0000000 Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
config.cache_classes = true
# Do not eager load code on boot. This avoids loading your whole application
# just for the purpose of running a single test. If you are using a tool that
# preloads Rails for running tests, you may have to set it to true.
config.eager_load = false
# Configure static file server for tests with Cache-Control for performance.
config.serve_static_files = true
config.static_cache_control = 'public, max-age=3600'
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Raise exceptions instead of rendering exception templates.
config.action_dispatch.show_exceptions = false
# Disable request forgery protection in test environment.
config.action_controller.allow_forgery_protection = false
# Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
# Randomize the order test cases are executed.
config.active_support.test_order = :random
# Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
end
raven-ruby-2.6.3/examples/rails-4.2/config/initializers/ 0000775 0000000 0000000 00000000000 13142120705 0023013 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/config/initializers/assets.rb 0000664 0000000 0000000 00000000746 13142120705 0024651 0 ustar 00root root 0000000 0000000 # Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'
# Add additional assets to the asset load path
# Rails.application.config.assets.paths << Emoji.images_path
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
# Rails.application.config.assets.precompile += %w( search.js )
raven-ruby-2.6.3/examples/rails-4.2/config/initializers/backtrace_silencers.rb 0000664 0000000 0000000 00000000624 13142120705 0027330 0 ustar 00root root 0000000 0000000 # Be sure to restart your server when you modify this file.
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
# Rails.backtrace_cleaner.remove_silencers!
raven-ruby-2.6.3/examples/rails-4.2/config/initializers/cookies_serializer.rb 0000664 0000000 0000000 00000000201 13142120705 0027216 0 ustar 00root root 0000000 0000000 # Be sure to restart your server when you modify this file.
Rails.application.config.action_dispatch.cookies_serializer = :json
raven-ruby-2.6.3/examples/rails-4.2/config/initializers/filter_parameter_logging.rb 0000664 0000000 0000000 00000000302 13142120705 0030366 0 ustar 00root root 0000000 0000000 # Be sure to restart your server when you modify this file.
# Configure sensitive parameters which will be filtered from the log file.
Rails.application.config.filter_parameters += [:password]
raven-ruby-2.6.3/examples/rails-4.2/config/initializers/inflections.rb 0000664 0000000 0000000 00000001207 13142120705 0025655 0 ustar 00root root 0000000 0000000 # Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format. Inflections
# are locale specific, and you may define rules for as many different
# locales as you wish. All of these examples are active by default:
# ActiveSupport::Inflector.inflections(:en) do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', 'people'
# inflect.uncountable %w( fish sheep )
# end
# These inflection rules are supported but not enabled by default:
# ActiveSupport::Inflector.inflections(:en) do |inflect|
# inflect.acronym 'RESTful'
# end
raven-ruby-2.6.3/examples/rails-4.2/config/initializers/mime_types.rb 0000664 0000000 0000000 00000000234 13142120705 0025512 0 ustar 00root root 0000000 0000000 # Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
raven-ruby-2.6.3/examples/rails-4.2/config/initializers/session_store.rb 0000664 0000000 0000000 00000000215 13142120705 0026235 0 ustar 00root root 0000000 0000000 # Be sure to restart your server when you modify this file.
Rails.application.config.session_store :cookie_store, key: '_rails-4_2_session'
raven-ruby-2.6.3/examples/rails-4.2/config/initializers/wrap_parameters.rb 0000664 0000000 0000000 00000001005 13142120705 0026530 0 ustar 00root root 0000000 0000000 # Be sure to restart your server when you modify this file.
# This file contains settings for ActionController::ParamsWrapper which
# is enabled by default.
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) do
wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
end
# To enable root element in JSON for ActiveRecord objects.
# ActiveSupport.on_load(:active_record) do
# self.include_root_in_json = true
# end
raven-ruby-2.6.3/examples/rails-4.2/config/locales/ 0000775 0000000 0000000 00000000000 13142120705 0021727 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/config/locales/en.yml 0000664 0000000 0000000 00000001172 13142120705 0023055 0 ustar 00root root 0000000 0000000 # Files in the config/locales directory are used for internationalization
# and are automatically loaded by Rails. If you want to use locales other
# than English, add the necessary files in this directory.
#
# To use the locales, use `I18n.t`:
#
# I18n.t 'hello'
#
# In views, this is aliased to just `t`:
#
# <%= t('hello') %>
#
# To use a different locale, set it with `I18n.locale`:
#
# I18n.locale = :es
#
# This would use the information in config/locales/es.yml.
#
# To learn more, please read the Rails Internationalization guide
# available at http://guides.rubyonrails.org/i18n.html.
en:
hello: "Hello world"
raven-ruby-2.6.3/examples/rails-4.2/config/routes.rb 0000664 0000000 0000000 00000003212 13142120705 0022151 0 ustar 00root root 0000000 0000000 Rails.application.routes.draw do
get 'welcome/index'
get '500', :to => 'errors#internal_server_error'
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
root 'welcome#index'
# Example of regular route:
# get 'products/:id' => 'catalog#view'
# Example of named route that can be invoked with purchase_url(id: product.id)
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
# Example resource route (maps HTTP verbs to controller actions automatically):
# resources :products
# Example resource route with options:
# resources :products do
# member do
# get 'short'
# post 'toggle'
# end
#
# collection do
# get 'sold'
# end
# end
# Example resource route with sub-resources:
# resources :products do
# resources :comments, :sales
# resource :seller
# end
# Example resource route with more complex sub-resources:
# resources :products do
# resources :comments
# resources :sales do
# get 'recent', on: :collection
# end
# end
# Example resource route with concerns:
# concern :toggleable do
# post 'toggle'
# end
# resources :posts, concerns: :toggleable
# resources :photos, concerns: :toggleable
# Example resource route within a namespace:
# namespace :admin do
# # Directs /admin/products/* to Admin::ProductsController
# # (app/controllers/admin/products_controller.rb)
# resources :products
# end
end
raven-ruby-2.6.3/examples/rails-4.2/config/secrets.yml 0000664 0000000 0000000 00000001704 13142120705 0022502 0 ustar 00root root 0000000 0000000 # Be sure to restart your server when you modify this file.
# Your secret key is used for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
# You can use `rake secret` to generate a secure secret key.
# Make sure the secrets in this file are kept private
# if you're sharing your code publicly.
development:
secret_key_base: ccd93ed8f0d469aabac280ec20fc066c8a049c4c1e99228cc0cb0ed7eaeebec40096b5adcb58f05c4ee310d1cbb6917c37effdc3998b11731fcd7320ee78c9dc
test:
secret_key_base: e09744809a164613edb32e8eb22617d571c4516c43709e53f593ee54aa8861bc3f668b6d0def7ed077ecf2658eadbf66e84e6124cbd45801ea8b9cc3032885bc
# Do not keep production secrets in the repository,
# instead read values from the environment.
production:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
raven-ruby-2.6.3/examples/rails-4.2/db/ 0000775 0000000 0000000 00000000000 13142120705 0017425 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/db/seeds.rb 0000664 0000000 0000000 00000000527 13142120705 0021061 0 ustar 00root root 0000000 0000000 # This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
raven-ruby-2.6.3/examples/rails-4.2/lib/ 0000775 0000000 0000000 00000000000 13142120705 0017606 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/lib/assets/ 0000775 0000000 0000000 00000000000 13142120705 0021110 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/lib/assets/.keep 0000664 0000000 0000000 00000000000 13142120705 0022023 0 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/lib/tasks/ 0000775 0000000 0000000 00000000000 13142120705 0020733 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/lib/tasks/.keep 0000664 0000000 0000000 00000000000 13142120705 0021646 0 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/log/ 0000775 0000000 0000000 00000000000 13142120705 0017621 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/log/.keep 0000664 0000000 0000000 00000000000 13142120705 0020534 0 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/public/ 0000775 0000000 0000000 00000000000 13142120705 0020316 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/public/404.html 0000664 0000000 0000000 00000003034 13142120705 0021513 0 ustar 00root root 0000000 0000000
The page you were looking for doesn't exist (404)
The page you were looking for doesn't exist.
You may have mistyped the address or the page may have moved.
If you are the application owner check the logs for more information.
raven-ruby-2.6.3/examples/rails-4.2/public/422.html 0000664 0000000 0000000 00000003013 13142120705 0021510 0 ustar 00root root 0000000 0000000
The change you wanted was rejected (422)
The change you wanted was rejected.
Maybe you tried to change something you didn't have access to.
If you are the application owner check the logs for more information.
raven-ruby-2.6.3/examples/rails-4.2/public/favicon.ico 0000664 0000000 0000000 00000000000 13142120705 0022425 0 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/public/robots.txt 0000664 0000000 0000000 00000000312 13142120705 0022363 0 ustar 00root root 0000000 0000000 # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
#
# To ban all spiders from the entire site uncomment the next two lines:
# User-agent: *
# Disallow: /
raven-ruby-2.6.3/examples/rails-4.2/test/ 0000775 0000000 0000000 00000000000 13142120705 0020017 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/test/controllers/ 0000775 0000000 0000000 00000000000 13142120705 0022365 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/test/controllers/.keep 0000664 0000000 0000000 00000000000 13142120705 0023300 0 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/test/controllers/welcome_controller_test.rb 0000664 0000000 0000000 00000000244 13142120705 0027647 0 ustar 00root root 0000000 0000000 require 'test_helper'
class WelcomeControllerTest < ActionController::TestCase
test "should get index" do
get :index
assert_response :success
end
end
raven-ruby-2.6.3/examples/rails-4.2/test/fixtures/ 0000775 0000000 0000000 00000000000 13142120705 0021670 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/test/fixtures/.keep 0000664 0000000 0000000 00000000000 13142120705 0022603 0 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/test/helpers/ 0000775 0000000 0000000 00000000000 13142120705 0021461 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/test/helpers/.keep 0000664 0000000 0000000 00000000000 13142120705 0022374 0 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/test/integration/ 0000775 0000000 0000000 00000000000 13142120705 0022342 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/test/integration/.keep 0000664 0000000 0000000 00000000000 13142120705 0023255 0 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/test/mailers/ 0000775 0000000 0000000 00000000000 13142120705 0021453 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/test/mailers/.keep 0000664 0000000 0000000 00000000000 13142120705 0022366 0 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/test/models/ 0000775 0000000 0000000 00000000000 13142120705 0021302 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/test/models/.keep 0000664 0000000 0000000 00000000000 13142120705 0022215 0 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/test/test_helper.rb 0000664 0000000 0000000 00000000470 13142120705 0022663 0 ustar 00root root 0000000 0000000 ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
fixtures :all
# Add more helper methods to be used by all tests here...
end
raven-ruby-2.6.3/examples/rails-4.2/vendor/ 0000775 0000000 0000000 00000000000 13142120705 0020335 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/vendor/assets/ 0000775 0000000 0000000 00000000000 13142120705 0021637 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/vendor/assets/javascripts/ 0000775 0000000 0000000 00000000000 13142120705 0024170 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/vendor/assets/javascripts/.keep 0000664 0000000 0000000 00000000000 13142120705 0025103 0 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/vendor/assets/stylesheets/ 0000775 0000000 0000000 00000000000 13142120705 0024213 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-4.2/vendor/assets/stylesheets/.keep 0000664 0000000 0000000 00000000000 13142120705 0025126 0 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-5.0/ 0000775 0000000 0000000 00000000000 13142120705 0017037 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-5.0/.gitignore 0000664 0000000 0000000 00000001037 13142120705 0021030 0 ustar 00root root 0000000 0000000 # See https://help.github.com/articles/ignoring-files for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile '~/.gitignore_global'
# Ignore bundler config.
/.bundle
# Ignore the default SQLite database.
/db/*.sqlite3
/db/*.sqlite3-journal
# Ignore all logfiles and tempfiles.
/log/*
/tmp/*
!/log/.keep
!/tmp/.keep
# Ignore Byebug command history file.
.byebug_history
raven-ruby-2.6.3/examples/rails-5.0/Gemfile 0000664 0000000 0000000 00000003326 13142120705 0020336 0 ustar 00root root 0000000 0000000 source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.0'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use Puma as the app server
gem 'puma', '~> 3.0'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
gem 'sentry-raven', path: "../../"
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platform: :mri
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'web-console'
gem 'listen', '~> 3.0.5'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
raven-ruby-2.6.3/examples/rails-5.0/README.md 0000664 0000000 0000000 00000000566 13142120705 0020325 0 ustar 00root root 0000000 0000000 # README
This README would normally document whatever steps are necessary to get the
application up and running.
Things you may want to cover:
* Ruby version
* System dependencies
* Configuration
* Database creation
* Database initialization
* How to run the test suite
* Services (job queues, cache servers, search engines, etc.)
* Deployment instructions
* ...
raven-ruby-2.6.3/examples/rails-5.0/Rakefile 0000664 0000000 0000000 00000000343 13142120705 0020504 0 ustar 00root root 0000000 0000000 # Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require_relative 'config/application'
Rails.application.load_tasks
raven-ruby-2.6.3/examples/rails-5.0/app/ 0000775 0000000 0000000 00000000000 13142120705 0017617 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-5.0/app/channels/ 0000775 0000000 0000000 00000000000 13142120705 0021412 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-5.0/app/channels/application_cable/ 0000775 0000000 0000000 00000000000 13142120705 0025043 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-5.0/app/channels/application_cable/channel.rb 0000664 0000000 0000000 00000000117 13142120705 0026777 0 ustar 00root root 0000000 0000000 module ApplicationCable
class Channel < ActionCable::Channel::Base
end
end
raven-ruby-2.6.3/examples/rails-5.0/app/channels/application_cable/connection.rb 0000664 0000000 0000000 00000000125 13142120705 0027525 0 ustar 00root root 0000000 0000000 module ApplicationCable
class Connection < ActionCable::Connection::Base
end
end
raven-ruby-2.6.3/examples/rails-5.0/app/controllers/ 0000775 0000000 0000000 00000000000 13142120705 0022165 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-5.0/app/controllers/application_controller.rb 0000664 0000000 0000000 00000000451 13142120705 0027260 0 ustar 00root root 0000000 0000000 class ApplicationController < ActionController::Base
before_action :set_raven_context
protect_from_forgery with: :exception
private
def set_raven_context
# Raven.user_context(email: 'david@getsentry.com')
# Raven.extra_context(params: params.to_hash, url: request.url)
end
end
raven-ruby-2.6.3/examples/rails-5.0/app/controllers/concerns/ 0000775 0000000 0000000 00000000000 13142120705 0023777 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-5.0/app/controllers/concerns/.keep 0000664 0000000 0000000 00000000000 13142120705 0024712 0 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-5.0/app/controllers/welcome_controller.rb 0000664 0000000 0000000 00000000330 13142120705 0026404 0 ustar 00root root 0000000 0000000 class WelcomeController < ApplicationController
def index
Rails.logger.info("zomg division")
1 / 0
end
def report_demo
@sentry_event_id = Raven.last_event_id
render(:status => 500)
end
end
raven-ruby-2.6.3/examples/rails-5.0/app/jobs/ 0000775 0000000 0000000 00000000000 13142120705 0020554 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-5.0/app/jobs/application_job.rb 0000664 0000000 0000000 00000000053 13142120705 0024234 0 ustar 00root root 0000000 0000000 class ApplicationJob < ActiveJob::Base
end
raven-ruby-2.6.3/examples/rails-5.0/app/models/ 0000775 0000000 0000000 00000000000 13142120705 0021102 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-5.0/app/models/application_record.rb 0000664 0000000 0000000 00000000116 13142120705 0025266 0 ustar 00root root 0000000 0000000 class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end
raven-ruby-2.6.3/examples/rails-5.0/app/models/concerns/ 0000775 0000000 0000000 00000000000 13142120705 0022714 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-5.0/app/models/concerns/.keep 0000664 0000000 0000000 00000000000 13142120705 0023627 0 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-5.0/app/views/ 0000775 0000000 0000000 00000000000 13142120705 0020754 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-5.0/app/views/layouts/ 0000775 0000000 0000000 00000000000 13142120705 0022454 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-5.0/app/views/layouts/application.html.erb 0000664 0000000 0000000 00000000660 13142120705 0026416 0 ustar 00root root 0000000 0000000
Rails50
<%= csrf_meta_tags %>
<%= yield %>
raven-ruby-2.6.3/examples/rails-5.0/app/views/layouts/mailer.html.erb 0000664 0000000 0000000 00000000345 13142120705 0025364 0 ustar 00root root 0000000 0000000
<%= yield %>
raven-ruby-2.6.3/examples/rails-5.0/app/views/layouts/mailer.text.erb 0000664 0000000 0000000 00000000015 13142120705 0025376 0 ustar 00root root 0000000 0000000 <%= yield %>
raven-ruby-2.6.3/examples/rails-5.0/app/views/welcome/ 0000775 0000000 0000000 00000000000 13142120705 0022407 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-5.0/app/views/welcome/report_demo.html.erb 0000664 0000000 0000000 00000000574 13142120705 0026371 0 ustar 00root root 0000000 0000000
Internal Server Error
Internal Server Error
='(
<% if @sentry_event_id %>
<% end %>
raven-ruby-2.6.3/examples/rails-5.0/bin/ 0000775 0000000 0000000 00000000000 13142120705 0017607 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-5.0/bin/bundle 0000775 0000000 0000000 00000000201 13142120705 0020777 0 ustar 00root root 0000000 0000000 #!/usr/bin/env ruby
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
load Gem.bin_path('bundler', 'bundle')
raven-ruby-2.6.3/examples/rails-5.0/bin/rails 0000775 0000000 0000000 00000000410 13142120705 0020642 0 ustar 00root root 0000000 0000000 #!/usr/bin/env ruby
begin
load File.expand_path('../spring', __FILE__)
rescue LoadError => e
raise unless e.message.include?('spring')
end
APP_PATH = File.expand_path('../config/application', __dir__)
require_relative '../config/boot'
require 'rails/commands'
raven-ruby-2.6.3/examples/rails-5.0/bin/rake 0000775 0000000 0000000 00000000325 13142120705 0020457 0 ustar 00root root 0000000 0000000 #!/usr/bin/env ruby
begin
load File.expand_path('../spring', __FILE__)
rescue LoadError => e
raise unless e.message.include?('spring')
end
require_relative '../config/boot'
require 'rake'
Rake.application.run
raven-ruby-2.6.3/examples/rails-5.0/bin/setup 0000775 0000000 0000000 00000001630 13142120705 0020675 0 ustar 00root root 0000000 0000000 #!/usr/bin/env ruby
require 'pathname'
require 'fileutils'
include FileUtils
# path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end
chdir APP_ROOT do
# This script is a starting point to setup your application.
# Add necessary setup steps to this file.
puts '== Installing dependencies =='
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')
# puts "\n== Copying sample files =="
# unless File.exist?('config/database.yml')
# cp 'config/database.yml.sample', 'config/database.yml'
# end
puts "\n== Preparing database =="
system! 'bin/rails db:setup'
puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear'
puts "\n== Restarting application server =="
system! 'bin/rails restart'
end
raven-ruby-2.6.3/examples/rails-5.0/bin/spring 0000775 0000000 0000000 00000000750 13142120705 0021041 0 ustar 00root root 0000000 0000000 #!/usr/bin/env ruby
# This file loads spring without using Bundler, in order to be fast.
# It gets overwritten when you run the `spring binstub` command.
unless defined?(Spring)
require 'rubygems'
require 'bundler'
if (match = Bundler.default_lockfile.read.match(/^GEM$.*?^ (?: )*spring \((.*?)\)$.*?^$/m))
Gem.paths = { 'GEM_PATH' => [Bundler.bundle_path.to_s, *Gem.path].uniq.join(Gem.path_separator) }
gem 'spring', match[1]
require 'spring/binstub'
end
end
raven-ruby-2.6.3/examples/rails-5.0/bin/update 0000775 0000000 0000000 00000001416 13142120705 0021021 0 ustar 00root root 0000000 0000000 #!/usr/bin/env ruby
require 'pathname'
require 'fileutils'
include FileUtils
# path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end
chdir APP_ROOT do
# This script is a way to update your development environment automatically.
# Add necessary update steps to this file.
puts '== Installing dependencies =='
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')
puts "\n== Updating database =="
system! 'bin/rails db:migrate'
puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear'
puts "\n== Restarting application server =="
system! 'bin/rails restart'
end
raven-ruby-2.6.3/examples/rails-5.0/config.ru 0000664 0000000 0000000 00000000202 13142120705 0020646 0 ustar 00root root 0000000 0000000 # This file is used by Rack-based servers to start the application.
require_relative 'config/environment'
run Rails.application
raven-ruby-2.6.3/examples/rails-5.0/config/ 0000775 0000000 0000000 00000000000 13142120705 0020304 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-5.0/config/application.rb 0000664 0000000 0000000 00000001570 13142120705 0023137 0 ustar 00root root 0000000 0000000 require_relative 'boot'
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module Rails50
class Application < Rails::Application
config.consider_all_requests_local = false
config.rails_activesupport_breadcrumbs = true
# https://github.com/getsentry/raven-ruby/issues/494
config.exceptions_app = self.routes
# With this enabled 'exceptions_app' isnt executed, so instead we
# set ``config.consider_all_requests_local = false`` in development.
# config.action_dispatch.show_exceptions = false
# Inject Sentry logger breadcrumbs
require 'raven/breadcrumbs/logger'
Raven.configure do |config|
config.dsn = 'https://6bca098db7ef423ab983e26e27255fe8:650b2fcf94f942fe9093f656b809a94e@app.getsentry.com/3825'
end
end
end
raven-ruby-2.6.3/examples/rails-5.0/config/boot.rb 0000664 0000000 0000000 00000000200 13142120705 0021564 0 ustar 00root root 0000000 0000000 ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
require 'bundler/setup' # Set up gems listed in the Gemfile.
raven-ruby-2.6.3/examples/rails-5.0/config/cable.yml 0000664 0000000 0000000 00000000164 13142120705 0022076 0 ustar 00root root 0000000 0000000 development:
adapter: async
test:
adapter: async
production:
adapter: redis
url: redis://localhost:6379/1
raven-ruby-2.6.3/examples/rails-5.0/config/database.yml 0000664 0000000 0000000 00000001050 13142120705 0022567 0 ustar 00root root 0000000 0000000 # SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
#
default: &default
adapter: sqlite3
pool: 5
timeout: 5000
development:
<<: *default
database: db/development.sqlite3
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: db/test.sqlite3
production:
<<: *default
database: db/production.sqlite3
raven-ruby-2.6.3/examples/rails-5.0/config/environment.rb 0000664 0000000 0000000 00000000200 13142120705 0023165 0 ustar 00root root 0000000 0000000 # Load the Rails application.
require_relative 'application'
# Initialize the Rails application.
Rails.application.initialize!
raven-ruby-2.6.3/examples/rails-5.0/config/environments/ 0000775 0000000 0000000 00000000000 13142120705 0023033 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-5.0/config/environments/development.rb 0000664 0000000 0000000 00000003420 13142120705 0025701 0 ustar 00root root 0000000 0000000 Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
# Do not eager load code on boot.
config.eager_load = false
# Enable/disable caching. By default caching is disabled.
if Rails.root.join('tmp/caching-dev.txt').exist?
config.action_controller.perform_caching = true
config.cache_store = :memory_store
config.public_file_server.headers = {
'Cache-Control' => 'public, max-age=172800'
}
else
config.action_controller.perform_caching = false
config.cache_store = :null_store
end
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
config.action_mailer.perform_caching = false
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
# Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load
# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = true
# Suppress logger output for asset requests.
config.assets.quiet = true
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
end
raven-ruby-2.6.3/examples/rails-5.0/config/environments/production.rb 0000664 0000000 0000000 00000006776 13142120705 0025566 0 ustar 00root root 0000000 0000000 Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true
# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
# Mount Action Cable outside main process or domain
# config.action_cable.mount_path = nil
# config.action_cable.url = 'wss://example.com/cable'
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
# Use the lowest log level to ensure availability of diagnostic information
# when problems arise.
config.log_level = :debug
# Prepend all log lines with the following tags.
config.log_tags = [ :request_id ]
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
# Use a real queuing backend for Active Job (and separate queues per environment)
# config.active_job.queue_adapter = :resque
# config.active_job.queue_name_prefix = "rails-5_0_#{Rails.env}"
config.action_mailer.perform_caching = false
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
# Use a different logger for distributed setups.
# require 'syslog/logger'
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
end
raven-ruby-2.6.3/examples/rails-5.0/config/environments/test.rb 0000664 0000000 0000000 00000003324 13142120705 0024341 0 ustar 00root root 0000000 0000000 Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
config.cache_classes = true
# Do not eager load code on boot. This avoids loading your whole application
# just for the purpose of running a single test. If you are using a tool that
# preloads Rails for running tests, you may have to set it to true.
config.eager_load = false
# Configure public file server for tests with Cache-Control for performance.
config.public_file_server.enabled = true
config.public_file_server.headers = {
'Cache-Control' => 'public, max-age=3600'
}
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Raise exceptions instead of rendering exception templates.
config.action_dispatch.show_exceptions = false
# Disable request forgery protection in test environment.
config.action_controller.allow_forgery_protection = false
config.action_mailer.perform_caching = false
# Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
# Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
end
raven-ruby-2.6.3/examples/rails-5.0/config/initializers/ 0000775 0000000 0000000 00000000000 13142120705 0023012 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-5.0/config/initializers/application_controller_renderer.rb 0000664 0000000 0000000 00000000242 13142120705 0031771 0 ustar 00root root 0000000 0000000 # Be sure to restart your server when you modify this file.
# ApplicationController.renderer.defaults.merge!(
# http_host: 'example.org',
# https: false
# )
raven-ruby-2.6.3/examples/rails-5.0/config/initializers/assets.rb 0000664 0000000 0000000 00000000746 13142120705 0024650 0 ustar 00root root 0000000 0000000 # Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'
# Add additional assets to the asset load path
# Rails.application.config.assets.paths << Emoji.images_path
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
# Rails.application.config.assets.precompile += %w( search.js )
raven-ruby-2.6.3/examples/rails-5.0/config/initializers/backtrace_silencers.rb 0000664 0000000 0000000 00000000624 13142120705 0027327 0 ustar 00root root 0000000 0000000 # Be sure to restart your server when you modify this file.
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
# Rails.backtrace_cleaner.remove_silencers!
raven-ruby-2.6.3/examples/rails-5.0/config/initializers/cookies_serializer.rb 0000664 0000000 0000000 00000000364 13142120705 0027227 0 ustar 00root root 0000000 0000000 # Be sure to restart your server when you modify this file.
# Specify a serializer for the signed and encrypted cookie jars.
# Valid options are :json, :marshal, and :hybrid.
Rails.application.config.action_dispatch.cookies_serializer = :json
raven-ruby-2.6.3/examples/rails-5.0/config/initializers/filter_parameter_logging.rb 0000664 0000000 0000000 00000000302 13142120705 0030365 0 ustar 00root root 0000000 0000000 # Be sure to restart your server when you modify this file.
# Configure sensitive parameters which will be filtered from the log file.
Rails.application.config.filter_parameters += [:password]
raven-ruby-2.6.3/examples/rails-5.0/config/initializers/inflections.rb 0000664 0000000 0000000 00000001207 13142120705 0025654 0 ustar 00root root 0000000 0000000 # Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format. Inflections
# are locale specific, and you may define rules for as many different
# locales as you wish. All of these examples are active by default:
# ActiveSupport::Inflector.inflections(:en) do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', 'people'
# inflect.uncountable %w( fish sheep )
# end
# These inflection rules are supported but not enabled by default:
# ActiveSupport::Inflector.inflections(:en) do |inflect|
# inflect.acronym 'RESTful'
# end
raven-ruby-2.6.3/examples/rails-5.0/config/initializers/mime_types.rb 0000664 0000000 0000000 00000000234 13142120705 0025511 0 ustar 00root root 0000000 0000000 # Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
raven-ruby-2.6.3/examples/rails-5.0/config/initializers/new_framework_defaults.rb 0000664 0000000 0000000 00000002120 13142120705 0030067 0 ustar 00root root 0000000 0000000 # Be sure to restart your server when you modify this file.
#
# This file contains migration options to ease your Rails 5.0 upgrade.
#
# Read the Rails 5.0 release notes for more info on each option.
# Enable per-form CSRF tokens. Previous versions had false.
Rails.application.config.action_controller.per_form_csrf_tokens = true
# Enable origin-checking CSRF mitigation. Previous versions had false.
Rails.application.config.action_controller.forgery_protection_origin_check = true
# Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`.
# Previous versions had false.
ActiveSupport.to_time_preserves_timezone = true
# Require `belongs_to` associations by default. Previous versions had false.
Rails.application.config.active_record.belongs_to_required_by_default = true
# Do not halt callback chains when a callback returns false. Previous versions had true.
ActiveSupport.halt_callback_chains_on_return_false = false
# Configure SSL options to enable HSTS with subdomains. Previous versions had false.
Rails.application.config.ssl_options = { hsts: { subdomains: true } }
raven-ruby-2.6.3/examples/rails-5.0/config/initializers/session_store.rb 0000664 0000000 0000000 00000000215 13142120705 0026234 0 ustar 00root root 0000000 0000000 # Be sure to restart your server when you modify this file.
Rails.application.config.session_store :cookie_store, key: '_rails-5_0_session'
raven-ruby-2.6.3/examples/rails-5.0/config/initializers/wrap_parameters.rb 0000664 0000000 0000000 00000000745 13142120705 0026541 0 ustar 00root root 0000000 0000000 # Be sure to restart your server when you modify this file.
# This file contains settings for ActionController::ParamsWrapper which
# is enabled by default.
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) do
wrap_parameters format: [:json]
end
# To enable root element in JSON for ActiveRecord objects.
# ActiveSupport.on_load(:active_record) do
# self.include_root_in_json = true
# end
raven-ruby-2.6.3/examples/rails-5.0/config/locales/ 0000775 0000000 0000000 00000000000 13142120705 0021726 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-5.0/config/locales/en.yml 0000664 0000000 0000000 00000001172 13142120705 0023054 0 ustar 00root root 0000000 0000000 # Files in the config/locales directory are used for internationalization
# and are automatically loaded by Rails. If you want to use locales other
# than English, add the necessary files in this directory.
#
# To use the locales, use `I18n.t`:
#
# I18n.t 'hello'
#
# In views, this is aliased to just `t`:
#
# <%= t('hello') %>
#
# To use a different locale, set it with `I18n.locale`:
#
# I18n.locale = :es
#
# This would use the information in config/locales/es.yml.
#
# To learn more, please read the Rails Internationalization guide
# available at http://guides.rubyonrails.org/i18n.html.
en:
hello: "Hello world"
raven-ruby-2.6.3/examples/rails-5.0/config/puma.rb 0000664 0000000 0000000 00000003725 13142120705 0021602 0 ustar 00root root 0000000 0000000 # Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers a minimum and maximum.
# Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum, this matches the default thread size of Active Record.
#
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i
threads threads_count, threads_count
# Specifies the `port` that Puma will listen on to receive requests, default is 3000.
#
port ENV.fetch("PORT") { 3000 }
# Specifies the `environment` that Puma will run in.
#
environment ENV.fetch("RAILS_ENV") { "development" }
# Specifies the number of `workers` to boot in clustered mode.
# Workers are forked webserver processes. If using threads and workers together
# the concurrency of the application would be max `threads` * `workers`.
# Workers do not work on JRuby or Windows (both of which do not support
# processes).
#
# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
# Use the `preload_app!` method when specifying a `workers` number.
# This directive tells Puma to first boot the application and load code
# before forking the application. This takes advantage of Copy On Write
# process behavior so workers use less memory. If you use this option
# you need to make sure to reconnect any threads in the `on_worker_boot`
# block.
#
# preload_app!
# The code in the `on_worker_boot` will be called if you are using
# clustered mode by specifying a number of `workers`. After each worker
# process is booted this block will be run, if you are using `preload_app!`
# option you will want to use this block to reconnect to any threads
# or connections that may have been created at application boot, Ruby
# cannot share connections between processes.
#
# on_worker_boot do
# ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
# end
# Allow puma to be restarted by `rails restart` command.
plugin :tmp_restart
raven-ruby-2.6.3/examples/rails-5.0/config/routes.rb 0000664 0000000 0000000 00000000152 13142120705 0022150 0 ustar 00root root 0000000 0000000 Rails.application.routes.draw do
get '500', :to => 'welcome#report_demo'
root to: "welcome#index"
end
raven-ruby-2.6.3/examples/rails-5.0/config/secrets.yml 0000664 0000000 0000000 00000001705 13142120705 0022502 0 ustar 00root root 0000000 0000000 # Be sure to restart your server when you modify this file.
# Your secret key is used for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
# You can use `rails secret` to generate a secure secret key.
# Make sure the secrets in this file are kept private
# if you're sharing your code publicly.
development:
secret_key_base: d91733e434c05e6905d6a0db58f91befa539464342558770b43c8acb11959cd3749bb196869a98ac8e82feeb9faafe9d6d92b2462a9e8c0642a1c881f0bbe608
test:
secret_key_base: b35e5485b128e991295e7649d4ba0b466d56208414ca842de01e38908a55b53442c33753a02898949883743d68c82bb039ee5adede75a7c9d400b05b76746e47
# Do not keep production secrets in the repository,
# instead read values from the environment.
production:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
raven-ruby-2.6.3/examples/rails-5.0/config/spring.rb 0000664 0000000 0000000 00000000157 13142120705 0022136 0 ustar 00root root 0000000 0000000 %w(
.ruby-version
.rbenv-vars
tmp/restart.txt
tmp/caching-dev.txt
).each { |path| Spring.watch(path) }
raven-ruby-2.6.3/examples/rails-5.0/db/ 0000775 0000000 0000000 00000000000 13142120705 0017424 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-5.0/db/seeds.rb 0000664 0000000 0000000 00000000562 13142120705 0021057 0 ustar 00root root 0000000 0000000 # This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Character.create(name: 'Luke', movie: movies.first)
raven-ruby-2.6.3/examples/rails-5.0/log/ 0000775 0000000 0000000 00000000000 13142120705 0017620 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-5.0/log/.keep 0000664 0000000 0000000 00000000000 13142120705 0020533 0 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-5.0/public/ 0000775 0000000 0000000 00000000000 13142120705 0020315 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-5.0/public/404.html 0000664 0000000 0000000 00000003034 13142120705 0021512 0 ustar 00root root 0000000 0000000
The page you were looking for doesn't exist (404)
The page you were looking for doesn't exist.
You may have mistyped the address or the page may have moved.
If you are the application owner check the logs for more information.
raven-ruby-2.6.3/examples/rails-5.0/public/422.html 0000664 0000000 0000000 00000003013 13142120705 0021507 0 ustar 00root root 0000000 0000000
The change you wanted was rejected (422)
The change you wanted was rejected.
Maybe you tried to change something you didn't have access to.
If you are the application owner check the logs for more information.
raven-ruby-2.6.3/examples/rails-5.0/public/apple-touch-icon-precomposed.png 0000664 0000000 0000000 00000000000 13142120705 0026476 0 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-5.0/public/apple-touch-icon.png 0000664 0000000 0000000 00000000000 13142120705 0024160 0 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-5.0/public/favicon.ico 0000664 0000000 0000000 00000000000 13142120705 0022424 0 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-5.0/public/robots.txt 0000664 0000000 0000000 00000000312 13142120705 0022362 0 ustar 00root root 0000000 0000000 # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
#
# To ban all spiders from the entire site uncomment the next two lines:
# User-agent: *
# Disallow: /
raven-ruby-2.6.3/examples/rails-5.0/tmp/ 0000775 0000000 0000000 00000000000 13142120705 0017637 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/examples/rails-5.0/tmp/.keep 0000664 0000000 0000000 00000000000 13142120705 0020552 0 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/exe/ 0000775 0000000 0000000 00000000000 13142120705 0014370 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/exe/raven 0000775 0000000 0000000 00000001044 13142120705 0015430 0 ustar 00root root 0000000 0000000 #!/usr/bin/env ruby
require "raven"
require "raven/cli"
require "optparse"
parser = OptionParser.new do |opt|
opt.banner = "Usage: raven COMMAND [OPTIONS]"
opt.separator ""
opt.separator "Commands"
opt.separator " test: send a test event"
opt.separator ""
opt.separator "Options"
opt.on("-h", "--help", "help") do
puts parser
end
end
parser.parse!
case ARGV[0]
when "test"
dsn = ARGV[1] if ARGV.length > 1
if !dsn
puts "Usage: raven test "
else
Raven::CLI.test(dsn)
end
else
puts parser
end
raven-ruby-2.6.3/lib/ 0000775 0000000 0000000 00000000000 13142120705 0014355 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/lib/raven.rb 0000664 0000000 0000000 00000000043 13142120705 0016012 0 ustar 00root root 0000000 0000000 require 'raven/base'
Raven.inject
raven-ruby-2.6.3/lib/raven/ 0000775 0000000 0000000 00000000000 13142120705 0015470 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/lib/raven/backtrace.rb 0000664 0000000 0000000 00000006606 13142120705 0017744 0 ustar 00root root 0000000 0000000 ## Inspired by Rails' and Airbrake's backtrace parsers.
module Raven
# Front end to parsing the backtrace for each notice
class Backtrace
# Handles backtrace parsing line by line
class Line
# regexp (optional leading X: on windows, or JRuby9000 class-prefix)
RUBY_INPUT_FORMAT = /
^ \s* (?: [a-zA-Z]: | uri:classloader: )? ([^:]+ | <.*>):
(\d+)
(?: :in \s `([^']+)')?$
/x
# org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:170)
JAVA_INPUT_FORMAT = /^(.+)\.([^\.]+)\(([^\:]+)\:(\d+)\)$/
# The file portion of the line (such as app/models/user.rb)
attr_reader :file
# The line number portion of the line
attr_reader :number
# The method of the line (such as index)
attr_reader :method
# The module name (JRuby)
attr_reader :module_name
# Parses a single line of a given backtrace
# @param [String] unparsed_line The raw line from +caller+ or some backtrace
# @return [Line] The parsed backtrace line
def self.parse(unparsed_line)
ruby_match = unparsed_line.match(RUBY_INPUT_FORMAT)
if ruby_match
_, file, number, method = ruby_match.to_a
file.sub!(/\.class$/, ".rb")
module_name = nil
else
java_match = unparsed_line.match(JAVA_INPUT_FORMAT)
_, module_name, method, file, number = java_match.to_a
end
new(file, number, method, module_name)
end
def initialize(file, number, method, module_name)
self.file = file
self.module_name = module_name
self.number = number.to_i
self.method = method
end
def in_app
if file =~ self.class.in_app_pattern
true
else
false
end
end
# Reconstructs the line in a readable fashion
def to_s
"#{file}:#{number}:in `#{method}'"
end
def ==(other)
to_s == other.to_s
end
def inspect
""
end
def self.in_app_pattern
@in_app_pattern ||= begin
project_root = Raven.configuration.project_root && Raven.configuration.project_root.to_s
Regexp.new("^(#{project_root}/)?#{Raven.configuration.app_dirs_pattern || APP_DIRS_PATTERN}")
end
end
private
attr_writer :file, :number, :method, :module_name
end
APP_DIRS_PATTERN = /(bin|exe|app|config|lib|test)/
# holder for an Array of Backtrace::Line instances
attr_reader :lines
def self.parse(backtrace, opts = {})
ruby_lines = backtrace.is_a?(Array) ? backtrace : backtrace.split(/\n\s*/)
filters = opts[:filters] || []
filtered_lines = ruby_lines.to_a.map do |line|
filters.reduce(line) do |nested_line, proc|
proc.call(nested_line)
end
end.compact
lines = filtered_lines.map do |unparsed_line|
Line.parse(unparsed_line)
end
new(lines)
end
def initialize(lines)
self.lines = lines
end
def inspect
""
end
def to_s
content = []
lines.each do |line|
content << line
end
content.join("\n")
end
def ==(other)
if other.respond_to?(:lines)
lines == other.lines
else
false
end
end
private
attr_writer :lines
end
end
raven-ruby-2.6.3/lib/raven/base.rb 0000664 0000000 0000000 00000007171 13142120705 0016735 0 ustar 00root root 0000000 0000000 require 'raven/version'
require 'raven/backtrace'
require 'raven/breadcrumbs'
require 'raven/processor'
require 'raven/processor/sanitizedata'
require 'raven/processor/removecircularreferences'
require 'raven/processor/utf8conversion'
require 'raven/processor/cookies'
require 'raven/processor/post_data'
require 'raven/processor/http_headers'
require 'raven/configuration'
require 'raven/context'
require 'raven/client'
require 'raven/event'
require 'raven/logger'
require 'raven/interfaces/message'
require 'raven/interfaces/exception'
require 'raven/interfaces/single_exception'
require 'raven/interfaces/stack_trace'
require 'raven/interfaces/http'
require 'raven/utils/deep_merge'
require 'raven/utils/real_ip'
require 'raven/instance'
require 'forwardable'
require 'English'
module Raven
AVAILABLE_INTEGRATIONS = %w(delayed_job railties sidekiq rack rack-timeout rake).freeze
class << self
extend Forwardable
def instance
@instance ||= Raven::Instance.new
end
def_delegators :instance, :client=, :configuration=, :context, :logger, :configuration,
:client, :report_status, :configure, :send_event, :capture, :capture_type,
:last_event_id, :annotate_exception, :user_context,
:tags_context, :extra_context, :rack_context, :breadcrumbs
def_delegator :instance, :report_status, :report_ready
def_delegator :instance, :capture_type, :capture_message
def_delegator :instance, :capture_type, :capture_exception
# For cross-language compatibility
def_delegator :instance, :capture_type, :captureException
def_delegator :instance, :capture_type, :captureMessage
def_delegator :instance, :annotate_exception, :annotateException
def_delegator :instance, :annotate_exception, :annotate
# Injects various integrations. Default behavior: inject all available integrations
def inject
inject_only(*Raven::AVAILABLE_INTEGRATIONS)
end
def inject_without(*exclude_integrations)
include_integrations = Raven::AVAILABLE_INTEGRATIONS - exclude_integrations.map(&:to_s)
inject_only(*include_integrations)
end
def inject_only(*only_integrations)
only_integrations = only_integrations.map(&:to_s)
integrations_to_load = Raven::AVAILABLE_INTEGRATIONS & only_integrations
not_found_integrations = only_integrations - integrations_to_load
if not_found_integrations.any?
logger.warn "Integrations do not exist: #{not_found_integrations.join ', '}"
end
integrations_to_load &= Gem.loaded_specs.keys
# TODO(dcramer): integrations should have some additional checks baked-in
# or we should break them out into their own repos. Specifically both the
# rails and delayed_job checks are not always valid (i.e. Rails 2.3) and
# https://github.com/getsentry/raven-ruby/issues/180
integrations_to_load.each do |integration|
load_integration(integration)
end
end
def load_integration(integration)
require "raven/integrations/#{integration}"
rescue Exception => error
logger.warn "Unable to load raven/integrations/#{integration}: #{error}"
end
def safely_prepend(module_name, opts = {})
return if opts[:to].nil? || opts[:from].nil?
if opts[:to].respond_to?(:prepend, true)
opts[:to].send(:prepend, opts[:from].const_get(module_name))
else
opts[:to].send(:include, opts[:from].const_get("Old" + module_name))
end
end
def sys_command(command)
result = `#{command} 2>&1` rescue nil
return if result.nil? || result.empty? || $CHILD_STATUS.exitstatus != 0
result.strip
end
end
end
raven-ruby-2.6.3/lib/raven/breadcrumbs.rb 0000664 0000000 0000000 00000002360 13142120705 0020307 0 ustar 00root root 0000000 0000000 module Raven
class Breadcrumb
attr_accessor :category, :data, :message, :level, :timestamp, :type
def initialize
@category = nil
@data = {}
@level = nil
@message = nil
@timestamp = Time.now.to_i
@type = nil
end
def to_hash
{
:category => @category,
:data => @data,
:level => @level,
:message => @message,
:timestamp => @timestamp,
:type => @type
}
end
end
end
module Raven
class BreadcrumbBuffer
include Enumerable
attr_accessor :buffer
def self.current
Thread.current[:sentry_breadcrumbs] ||= new
end
def self.clear!
Thread.current[:sentry_breadcrumbs] = nil
end
def initialize(size = 100)
@buffer = Array.new(size)
end
def record(crumb = nil)
if block_given?
crumb = Breadcrumb.new if crumb.nil?
yield(crumb)
end
@buffer.slice!(0)
@buffer << crumb
end
def members
@buffer.compact
end
def peek
members.last
end
def each(&block)
members.each(&block)
end
def empty?
!members.any?
end
def to_hash
{
:values => members.map(&:to_hash)
}
end
end
end
raven-ruby-2.6.3/lib/raven/breadcrumbs/ 0000775 0000000 0000000 00000000000 13142120705 0017761 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/lib/raven/breadcrumbs/activesupport.rb 0000664 0000000 0000000 00000001017 13142120705 0023215 0 ustar 00root root 0000000 0000000 module Raven
module ActiveSupportBreadcrumbs
class << self
def add(name, started, _finished, _unique_id, data)
Raven.breadcrumbs.record do |crumb|
crumb.data = data
crumb.category = name
crumb.timestamp = started.to_i
end
end
def inject
ActiveSupport::Notifications.subscribe(/.*/) do |name, started, finished, unique_id, data|
add(name, started, finished, unique_id, data)
end
end
end
end
end
raven-ruby-2.6.3/lib/raven/breadcrumbs/logger.rb 0000664 0000000 0000000 00000004723 13142120705 0021573 0 ustar 00root root 0000000 0000000 require 'logger'
module Raven
module BreadcrumbLogger
LEVELS = {
::Logger::DEBUG => 'debug',
::Logger::INFO => 'info',
::Logger::WARN => 'warn',
::Logger::ERROR => 'error',
::Logger::FATAL => 'fatal'
}.freeze
EXC_FORMAT = /^([a-zA-Z0-9]+)\:\s(.*)$/
def self.parse_exception(message)
lines = message.split(/\n\s*/)
# TODO: wat
return nil unless lines.length > 2
match = lines[0].match(EXC_FORMAT)
return nil unless match
_, type, value = match.to_a
[type, value]
end
def add(*args)
add_breadcrumb(*args)
super
end
def add_breadcrumb(severity, message = nil, progname = nil)
message = progname if message.nil? # see Ruby's Logger docs for why
return if ignored_logger?(progname)
return if message.nil? || message == ""
# some loggers will add leading/trailing space as they (incorrectly, mind you)
# think of logging as a shortcut to std{out,err}
message = message.strip
last_crumb = Raven.breadcrumbs.peek
# try to avoid dupes from logger broadcasts
if last_crumb.nil? || last_crumb.message != message
error = Raven::BreadcrumbLogger.parse_exception(message)
# TODO(dcramer): we need to filter out the "currently captured error"
if error
Raven.breadcrumbs.record do |crumb|
crumb.level = Raven::BreadcrumbLogger::LEVELS.fetch(severity, nil)
crumb.category = progname || 'error'
crumb.type = 'error'
crumb.data = {
:type => error[0],
:value => error[1]
}
end
else
Raven.breadcrumbs.record do |crumb|
crumb.level = Raven::BreadcrumbLogger::LEVELS.fetch(severity, nil)
crumb.category = progname || 'logger'
crumb.message = message
end
end
end
end
private
def ignored_logger?(progname)
progname == "sentry" ||
Raven.configuration.exclude_loggers.include?(progname)
end
end
module OldBreadcrumbLogger
def self.included(base)
base.class_eval do
include Raven::BreadcrumbLogger
alias_method :add_without_raven, :add
alias_method :add, :add_with_raven
end
end
def add_with_raven(*args)
add_breadcrumb(*args)
add_without_raven(*args)
end
end
end
Raven.safely_prepend(
"BreadcrumbLogger",
:from => Raven,
:to => ::Logger
)
raven-ruby-2.6.3/lib/raven/cli.rb 0000664 0000000 0000000 00000003314 13142120705 0016565 0 ustar 00root root 0000000 0000000 module Raven
class CLI
def self.test(dsn = nil, silent = false, config = nil) # rubocop:disable all
config ||= Raven.configuration
config.logger = if silent
::Logger.new(nil)
else
logger = ::Logger.new(STDOUT)
logger.formatter = proc do |_severity, _datetime, _progname, msg|
"-> #{msg}\n"
end
logger
end
config.timeout = 5
config.dsn = dsn if dsn
# wipe out env settings to ensure we send the event
unless config.capture_allowed?
env_name = config.environments.pop || 'production'
config.current_environment = env_name
end
instance = Raven::Instance.new(nil, config)
instance.logger.debug "Sending a test event:"
instance.logger.debug ""
begin
1 / 0
rescue ZeroDivisionError => exception
evt = instance.capture_exception(exception)
end
if evt && !(evt.is_a? Thread)
if evt.is_a? Hash
instance.logger.debug "-> event ID: #{evt[:event_id]}"
else
instance.logger.debug "-> event ID: #{evt.id}"
end
elsif evt # async configuration
if evt.value.is_a? Hash
instance.logger.debug "-> event ID: #{evt.value[:event_id]}"
else
instance.logger.debug "-> event ID: #{evt.value.id}"
end
else
instance.logger.debug ""
instance.logger.debug "An error occurred while attempting to send the event."
exit 1
end
instance.logger.debug ""
instance.logger.debug "Done!"
true
end
end
end
raven-ruby-2.6.3/lib/raven/client.rb 0000664 0000000 0000000 00000006771 13142120705 0017306 0 ustar 00root root 0000000 0000000 # frozen_string_literal: true
require 'base64'
require 'json'
require 'zlib'
require 'raven/version'
require 'raven/transports/http'
module Raven
# Encodes events and sends them to the Sentry server.
class Client
PROTOCOL_VERSION = '5'.freeze
USER_AGENT = "raven-ruby/#{Raven::VERSION}".freeze
CONTENT_TYPE = 'application/json'.freeze
attr_accessor :configuration
def initialize(configuration)
@configuration = configuration
@processors = configuration.processors.map { |v| v.new(self) }
@state = ClientState.new
end
def send_event(event)
return false unless configuration.sending_allowed?(event)
# Convert to hash
event = event.to_hash
unless @state.should_try?
failed_send(nil, event)
return
end
configuration.logger.info "Sending event #{event[:event_id]} to Sentry"
content_type, encoded_data = encode(event)
begin
transport.send_event(generate_auth_header, encoded_data,
:content_type => content_type)
successful_send
rescue => e
failed_send(e, event)
return
end
event
end
def transport
@transport ||=
case configuration.scheme
when 'http', 'https'
Transports::HTTP.new(configuration)
when 'dummy'
Transports::Dummy.new(configuration)
else
fail "Unknown transport scheme '#{configuration.scheme}'"
end
end
private
def encode(event)
hash = @processors.reduce(event.to_hash) { |a, e| e.process(a) }
encoded = JSON.fast_generate(hash)
case configuration.encoding
when 'gzip'
['application/octet-stream', Base64.strict_encode64(Zlib::Deflate.deflate(encoded))]
else
['application/json', encoded]
end
end
def get_log_message(event)
(event && event[:message]) || ''
end
def generate_auth_header
now = Time.now.to_i.to_s
fields = {
'sentry_version' => PROTOCOL_VERSION,
'sentry_client' => USER_AGENT,
'sentry_timestamp' => now,
'sentry_key' => configuration.public_key,
'sentry_secret' => configuration.secret_key
}
'Sentry ' + fields.map { |key, value| "#{key}=#{value}" }.join(', ')
end
def successful_send
@state.success
end
def failed_send(e, event)
@state.failure
if e # exception was raised
configuration.logger.error "Unable to record event with remote Sentry server (#{e.class} - #{e.message}):\n#{e.backtrace[0..10].join("\n")}"
else
configuration.logger.error "Not sending event due to previous failure(s)."
end
configuration.logger.error("Failed to submit event: #{get_log_message(event)}")
configuration.transport_failure_callback.call(event) if configuration.transport_failure_callback
end
end
class ClientState
def initialize
reset
end
def should_try?
return true if @status == :online
interval = @retry_after || [@retry_number, 6].min**2
return true if Time.now - @last_check >= interval
false
end
def failure(retry_after = nil)
@status = :error
@retry_number += 1
@last_check = Time.now
@retry_after = retry_after
end
def success
reset
end
def reset
@status = :online
@retry_number = 0
@last_check = nil
@retry_after = nil
end
def failed?
@status == :error
end
end
end
raven-ruby-2.6.3/lib/raven/configuration.rb 0000664 0000000 0000000 00000030244 13142120705 0020667 0 ustar 00root root 0000000 0000000 require 'uri'
module Raven
class Configuration
# Directories to be recognized as part of your app. e.g. if you
# have an `engines` dir at the root of your project, you may want
# to set this to something like /(app|config|engines|lib)/
attr_accessor :app_dirs_pattern
# Provide an object that responds to `call` to send events asynchronously.
# E.g.: lambda { |event| Thread.new { Raven.send_event(event) } }
attr_reader :async
alias async? async
# Number of lines of code context to capture, or nil for none
attr_accessor :context_lines
# RACK_ENV by default.
attr_reader :current_environment
# Encoding type for event bodies. Must be :json or :gzip.
attr_reader :encoding
# Whitelist of environments that will send notifications to Sentry. Array of Strings.
attr_accessor :environments
# Logger 'progname's to exclude from breadcrumbs
attr_accessor :exclude_loggers
# Array of exception classes that should never be sent. See IGNORE_DEFAULT.
# You should probably append to this rather than overwrite it.
attr_accessor :excluded_exceptions
# DSN component - set automatically if DSN provided
attr_accessor :host
# The Faraday adapter to be used. Will default to Net::HTTP when not set.
attr_accessor :http_adapter
# A Proc yeilding the faraday builder allowing for further configuration
# of the faraday adapter
attr_accessor :faraday_builder
# You may provide your own LineCache for matching paths with source files.
# This may be useful if you need to get source code from places other than
# the disk. See Raven::LineCache for the required interface you must implement.
attr_accessor :linecache
# Logger used by Raven. In Rails, this is the Rails logger, otherwise
# Raven provides its own Raven::Logger.
attr_accessor :logger
# Timeout waiting for the Sentry server connection to open in seconds
attr_accessor :open_timeout
# DSN component - set automatically if DSN provided
attr_accessor :path
# DSN component - set automatically if DSN provided
attr_accessor :port
# Processors to run on data before sending upstream. See DEFAULT_PROCESSORS.
# You should probably append to this rather than overwrite it.
attr_accessor :processors
# Project ID number to send to the Sentry server
# If you provide a DSN, this will be set automatically.
attr_accessor :project_id
# Project directory root for in_app detection. Could be Rails root, etc.
# Set automatically for Rails.
attr_reader :project_root
# Proxy information to pass to the HTTP adapter (via Faraday)
attr_accessor :proxy
# Public key for authentication with the Sentry server
# If you provide a DSN, this will be set automatically.
attr_accessor :public_key
# Turns on ActiveSupport breadcrumbs integration
attr_accessor :rails_activesupport_breadcrumbs
# Rails catches exceptions in the ActionDispatch::ShowExceptions or
# ActionDispatch::DebugExceptions middlewares, depending on the environment.
# When `rails_report_rescued_exceptions` is true (it is by default), Raven
# will report exceptions even when they are rescued by these middlewares.
attr_accessor :rails_report_rescued_exceptions
# Release tag to be passed with every event sent to Sentry.
# We automatically try to set this to a git SHA or Capistrano release.
attr_accessor :release
# Boolean - sanitize values that look like credit card numbers
attr_accessor :sanitize_credit_cards
# By default, Sentry censors Hash values when their keys match things like
# "secret", "password", etc. Provide an array of Strings that, when matched in
# a hash key, will be censored and not sent to Sentry.
attr_accessor :sanitize_fields
# If you're sure you want to override the default sanitization values, you can
# add to them to an array of Strings here, e.g. %w(authorization password)
attr_accessor :sanitize_fields_excluded
# Sanitize additional HTTP headers - only Authorization is removed by default.
attr_accessor :sanitize_http_headers
# DSN component - set automatically if DSN provided.
# Otherwise, can be one of "http", "https", or "dummy"
attr_accessor :scheme
# Secret key for authentication with the Sentry server
# If you provide a DSN, this will be set automatically.
attr_accessor :secret_key
# Include module versions in reports - boolean.
attr_accessor :send_modules
# Simple server string - set this to the DSN found on your Sentry settings.
attr_reader :server
attr_accessor :server_name
# Provide a configurable callback to determine event capture.
# Note that the object passed into the block will be a String (messages) or
# an exception.
# e.g. lambda { |exc_or_msg| exc_or_msg.some_attr == false }
attr_accessor :should_capture
# Silences ready message when true.
attr_accessor :silence_ready
# SSL settings passed directly to Faraday's ssl option
attr_accessor :ssl
# The path to the SSL certificate file
attr_accessor :ssl_ca_file
# Should the SSL certificate of the server be verified?
attr_accessor :ssl_verification
# Default tags for events. Hash.
attr_accessor :tags
# Timeout when waiting for the server to return data in seconds.
attr_accessor :timeout
# Optional Proc, called when the Sentry server cannot be contacted for any reason
# E.g. lambda { |event| Thread.new { MyJobProcessor.send_email(event) } }
attr_reader :transport_failure_callback
# Errors object - an Array that contains error messages. See #
attr_reader :errors
IGNORE_DEFAULT = [
'AbstractController::ActionNotFound',
'ActionController::InvalidAuthenticityToken',
'ActionController::RoutingError',
'ActionController::UnknownAction',
'ActiveRecord::RecordNotFound',
'CGI::Session::CookieStore::TamperedWithCookie',
'Mongoid::Errors::DocumentNotFound',
'Sinatra::NotFound'
].freeze
# Note the order - we have to remove circular references and bad characters
# before passing to other processors.
DEFAULT_PROCESSORS = [
Raven::Processor::RemoveCircularReferences,
Raven::Processor::UTF8Conversion,
Raven::Processor::SanitizeData,
Raven::Processor::Cookies,
Raven::Processor::PostData,
Raven::Processor::HTTPHeaders
].freeze
LOG_PREFIX = "** [Raven] ".freeze
def initialize
self.async = false
self.context_lines = 3
self.current_environment = ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'default'
self.encoding = 'gzip'
self.environments = []
self.exclude_loggers = []
self.excluded_exceptions = IGNORE_DEFAULT.dup
self.linecache = ::Raven::LineCache.new
self.logger = ::Raven::Logger.new(STDOUT)
self.open_timeout = 1
self.processors = DEFAULT_PROCESSORS.dup
self.project_root = detect_project_root
self.proxy = nil
self.rails_activesupport_breadcrumbs = false
self.rails_report_rescued_exceptions = true
self.release = detect_release
self.sanitize_credit_cards = true
self.sanitize_fields = []
self.sanitize_fields_excluded = []
self.sanitize_http_headers = []
self.send_modules = true
self.server = ENV['SENTRY_DSN'] if ENV['SENTRY_DSN']
self.server_name = resolve_hostname
self.should_capture = false
self.ssl_verification = true
self.tags = {}
self.timeout = 2
self.transport_failure_callback = false
end
def server=(value)
uri = URI.parse(value)
uri_path = uri.path.split('/')
if uri.user
# DSN-style string
self.project_id = uri_path.pop
self.public_key = uri.user
self.secret_key = uri.password
end
self.scheme = uri.scheme
self.host = uri.host
self.port = uri.port if uri.port
self.path = uri_path.join('/')
# For anyone who wants to read the base server string
@server = "#{scheme}://#{host}"
@server << ":#{port}" unless port == { 'http' => 80, 'https' => 443 }[scheme]
@server << path
end
alias dsn= server=
def encoding=(encoding)
raise(Error, 'Unsupported encoding') unless %w(gzip json).include? encoding
@encoding = encoding
end
def async=(value)
unless value == false || value.respond_to?(:call)
raise(ArgumentError, "async must be callable (or false to disable)")
end
@async = value
end
def transport_failure_callback=(value)
unless value == false || value.respond_to?(:call)
raise(ArgumentError, "transport_failure_callback must be callable (or false to disable)")
end
@transport_failure_callback = value
end
def should_capture=(value)
unless value == false || value.respond_to?(:call)
raise ArgumentError, "should_capture must be callable (or false to disable)"
end
@should_capture = value
end
# Allows config options to be read like a hash
#
# @param [Symbol] option Key for a given attribute
def [](option)
public_send(option)
end
def current_environment=(environment)
@current_environment = environment.to_s
end
def capture_allowed?(message_or_exc = nil)
@errors = []
valid? &&
capture_in_current_environment? &&
capture_allowed_by_callback?(message_or_exc)
end
# If we cannot capture, we cannot send.
alias sending_allowed? capture_allowed?
def error_messages
@errors = [errors[0]] + errors[1..-1].map(&:downcase) # fix case of all but first
errors.join(", ")
end
def project_root=(root_dir)
@project_root = root_dir
Backtrace::Line.instance_variable_set(:@in_app_pattern, nil) # blow away cache
end
def detect_release
detect_release_from_git ||
detect_release_from_capistrano ||
detect_release_from_heroku
rescue => ex
logger.error "Error detecting release: #{ex.message}"
end
def detect_project_root
if defined? Rails.root # we are in a Rails application
Rails.root.to_s
else
Dir.pwd
end
end
private
def detect_release_from_heroku
return unless running_on_heroku?
logger.warn(heroku_dyno_metadata_message) && return unless ENV['HEROKU_SLUG_COMMIT']
ENV['HEROKU_SLUG_COMMIT']
end
def running_on_heroku?
File.directory?("/etc/heroku")
end
def heroku_dyno_metadata_message
"You are running on Heroku but haven't enabled Dyno Metadata. For Sentry's "\
"release detection to work correctly, please run `heroku labs:enable runtime-dyno-metadata`"
end
def detect_release_from_capistrano
revision_file = File.join(project_root, 'REVISION')
revision_log = File.join(project_root, '..', 'revisions.log')
if File.exist?(revision_file)
File.read(revision_file).strip
elsif File.exist?(revision_log)
File.open(revision_log).to_a.last.strip.sub(/.*as release ([0-9]+).*/, '\1')
end
end
def detect_release_from_git
`git rev-parse --short HEAD`.strip if File.directory?(".git") rescue nil
end
def capture_in_current_environment?
return true unless environments.any? && !environments.include?(current_environment)
@errors << "Not configured to send/capture in environment '#{current_environment}'"
false
end
def capture_allowed_by_callback?(message_or_exc)
return true if !should_capture || message_or_exc.nil? || should_capture.call(*[message_or_exc])
@errors << "should_capture returned false"
false
end
def valid?
return true if %w(server host path public_key secret_key project_id).all? { |k| public_send(k) }
if server
%w(server host path public_key secret_key project_id).map do |key|
@errors << "No #{key} specified" unless public_send(key)
end
else
@errors << "DSN not set"
end
false
end
# Try to resolve the hostname to an FQDN, but fall back to whatever
# the load name is.
def resolve_hostname
Socket.gethostname ||
Socket.gethostbyname(hostname).first rescue server_name
end
end
end
raven-ruby-2.6.3/lib/raven/context.rb 0000664 0000000 0000000 00000002124 13142120705 0017500 0 ustar 00root root 0000000 0000000 require 'rbconfig'
module Raven
class Context
def self.current
Thread.current[:sentry_context] ||= new
end
def self.clear!
Thread.current[:sentry_context] = nil
end
attr_accessor :extra, :server_os, :rack_env, :runtime, :tags, :user
def initialize
self.server_os = self.class.os_context
self.runtime = self.class.runtime_context
self.extra = { :server => { :os => server_os, :runtime => runtime } }
self.rack_env = nil
self.tags = {}
self.user = {}
end
class << self
def os_context
@os_context ||= {
:name => Raven.sys_command("uname -s") || RbConfig::CONFIG["host_os"],
:version => Raven.sys_command("uname -v"),
:build => Raven.sys_command("uname -r"),
:kernel_version => Raven.sys_command("uname -a") || Raven.sys_command("ver") # windows
}
end
def runtime_context
@runtime_context ||= {
:name => RbConfig::CONFIG["ruby_install_name"],
:version => Raven.sys_command("ruby -v")
}
end
end
end
end
raven-ruby-2.6.3/lib/raven/error.rb 0000664 0000000 0000000 00000000065 13142120705 0017147 0 ustar 00root root 0000000 0000000 module Raven
class Error < StandardError
end
end
raven-ruby-2.6.3/lib/raven/event.rb 0000664 0000000 0000000 00000024201 13142120705 0017135 0 ustar 00root root 0000000 0000000 # frozen_string_literal: true
require 'rubygems'
require 'socket'
require 'securerandom'
require 'digest/md5'
require 'raven/error'
require 'raven/linecache'
module Raven
class Event
LOG_LEVELS = {
"debug" => 10,
"info" => 20,
"warn" => 30,
"warning" => 30,
"error" => 40,
"fatal" => 50
}.freeze
BACKTRACE_RE = /^(.+?):(\d+)(?::in `(.+?)')?$/
# See Sentry server default limits at
# https://github.com/getsentry/sentry/blob/master/src/sentry/conf/server.py
MAX_MESSAGE_SIZE_IN_BYTES = 1024 * 8
PLATFORM = "ruby".freeze
SDK = { "name" => "raven-ruby", "version" => Raven::VERSION }.freeze
attr_accessor :id, :timestamp, :time_spent, :level, :logger,
:culprit, :server_name, :release, :modules, :extra, :tags,
:context, :configuration, :checksum, :fingerprint, :environment,
:server_os, :runtime, :breadcrumbs, :user, :backtrace, :linecache
def initialize(init = {})
@configuration = init[:configuration] || Raven.configuration
@interfaces = {}
@breadcrumbs = init[:breadcrumbs] || Raven.breadcrumbs
@context = init[:context] || Raven.context
@linecache = @configuration.linecache
@id = SecureRandom.uuid.delete("-")
@timestamp = Time.now.utc
@time_spent = nil
@level = :error
@logger = 'ruby'
@culprit = nil
@server_name = @configuration.server_name
@release = @configuration.release
@modules = list_gem_specs if @configuration.send_modules
@user = {} # TODO: contexts
@extra = {} # TODO: contexts
@server_os = {} # TODO: contexts
@runtime = {} # TODO: contexts
@tags = {} # TODO: contexts
@checksum = nil
@fingerprint = nil
@environment = @configuration.current_environment
yield self if block_given?
if !self[:http] && @context.rack_env
interface :http do |int|
int.from_rack(@context.rack_env)
end
end
if @context.rack_env # TODO: contexts
@context.user[:ip_address] = calculate_real_ip_from_rack
end
init.each_pair { |key, val| public_send(key.to_s + "=", val) }
@user = @context.user.merge(@user) # TODO: contexts
@extra = @context.extra.merge(@extra) # TODO: contexts
@tags = @configuration.tags.merge(@context.tags).merge(@tags) # TODO: contexts
# Some type coercion
@timestamp = @timestamp.strftime('%Y-%m-%dT%H:%M:%S') if @timestamp.is_a?(Time)
@time_spent = (@time_spent * 1000).to_i if @time_spent.is_a?(Float)
@level = LOG_LEVELS[@level.to_s.downcase] if @level.is_a?(String) || @level.is_a?(Symbol)
end
def message
@interfaces[:logentry] && @interfaces[:logentry].unformatted_message
end
def message=(args)
message, params = *args
interface(:message) do |int|
int.message = message
int.params = params
end
end
class << self
def from_exception(exc, options = {}, &block)
exception_context = get_exception_context(exc) || {}
options = Raven::Utils::DeepMergeHash.deep_merge(exception_context, options)
configuration = options[:configuration] || Raven.configuration
if exc.is_a?(Raven::Error)
# Try to prevent error reporting loops
configuration.logger.debug "Refusing to capture Raven error: #{exc.inspect}"
return nil
end
if configuration[:excluded_exceptions].any? { |x| get_exception_class(x) === exc }
configuration.logger.debug "User excluded error: #{exc.inspect}"
return nil
end
new(options) do |evt|
evt.configuration = configuration
evt.message = "#{exc.class}: #{exc.message}".byteslice(0...MAX_MESSAGE_SIZE_IN_BYTES) # Messages limited to 10kb
evt.level = options[:level] || :error
add_exception_interface(evt, exc)
yield evt if block
end
end
def from_message(message, options = {})
message = message.byteslice(0...MAX_MESSAGE_SIZE_IN_BYTES)
configuration = options[:configuration] || Raven.configuration
new(options) do |evt|
evt.configuration = configuration
evt.level = options[:level] || :error
evt.message = message, options[:message_params] || []
if options[:backtrace]
evt.interface(:stacktrace) do |int|
stacktrace_interface_from(int, evt, options[:backtrace])
end
end
end
end
private
def get_exception_class(x)
x.is_a?(Module) ? x : qualified_const_get(x)
end
# In Ruby <2.0 const_get can't lookup "SomeModule::SomeClass" in one go
def qualified_const_get(x)
x = x.to_s
parts = x.split("::")
parts.reject!(&:empty?)
if parts.size < 2
Object.const_get(x)
else
parts.inject(Object) { |a, e| a.const_get(e) }
end
rescue NameError # There's no way to safely ask if a constant exist for an unknown string
nil
end
def get_exception_context(exc)
if exc.instance_variable_defined?(:@__raven_context)
exc.instance_variable_get(:@__raven_context)
elsif exc.respond_to?(:raven_context)
exc.raven_context
end
end
def add_exception_interface(evt, exc)
evt.interface(:exception) do |exc_int|
exceptions = [exc]
context = Set.new [exc.object_id]
backtraces = Set.new
while exc.respond_to?(:cause) && exc.cause
exc = exc.cause
break if context.include?(exc.object_id)
exceptions << exc
context.add(exc.object_id)
end
exceptions.reverse!
exc_int.values = exceptions.map do |e|
SingleExceptionInterface.new do |int|
int.type = e.class.to_s
int.value = e.to_s
int.module = e.class.to_s.split('::')[0...-1].join('::')
int.stacktrace =
if e.backtrace && !backtraces.include?(e.backtrace.object_id)
backtraces << e.backtrace.object_id
StacktraceInterface.new do |stacktrace|
stacktrace_interface_from(stacktrace, evt, e.backtrace)
end
end
end
end
end
end
def stacktrace_interface_from(int, evt, backtrace)
backtrace = Backtrace.parse(backtrace)
int.frames = []
backtrace.lines.reverse_each do |line|
frame = StacktraceInterface::Frame.new
frame.abs_path = line.file if line.file
frame.function = line.method if line.method
frame.lineno = line.number
frame.in_app = line.in_app
frame.module = line.module_name if line.module_name
if evt.configuration[:context_lines] && frame.abs_path
frame.pre_context, frame.context_line, frame.post_context = \
evt.get_file_context(frame.abs_path, frame.lineno, evt.configuration[:context_lines])
end
int.frames << frame if frame.filename
end
evt.culprit = evt.get_culprit(int.frames)
end
end
def list_gem_specs
# Older versions of Rubygems don't support iterating over all specs
Hash[Gem::Specification.map { |spec| [spec.name, spec.version.to_s] }] if Gem::Specification.respond_to?(:map)
end
def interface(name, value = nil, &block)
int = Interface.registered[name]
raise(Error, "Unknown interface: #{name}") unless int
@interfaces[int.sentry_alias] = int.new(value, &block) if value || block
@interfaces[int.sentry_alias]
end
def [](key)
interface(key)
end
def []=(key, value)
interface(key, value)
end
def to_hash
data = {
:event_id => @id,
:timestamp => @timestamp,
:time_spent => @time_spent,
:level => @level,
:platform => PLATFORM,
:sdk => SDK
}
data[:logger] = @logger if @logger
data[:culprit] = @culprit if @culprit
data[:server_name] = @server_name if @server_name
data[:release] = @release if @release
data[:environment] = @environment if @environment
data[:fingerprint] = @fingerprint if @fingerprint
data[:modules] = @modules if @modules
data[:extra] = @extra if @extra
data[:tags] = @tags if @tags
data[:user] = @user if @user
data[:breadcrumbs] = @breadcrumbs.to_hash unless @breadcrumbs.empty?
data[:checksum] = @checksum if @checksum
@interfaces.each_pair do |name, int_data|
data[name.to_sym] = int_data.to_hash
end
data[:message] = message
data
end
def get_file_context(filename, lineno, context)
linecache.get_file_context(filename, lineno, context)
end
def get_culprit(frames)
lastframe = frames.reverse.find(&:in_app) || frames.last
"#{lastframe.filename} in #{lastframe.function} at line #{lastframe.lineno}" if lastframe
end
def to_json_compatible
cleaned_hash = async_json_processors.reduce(to_hash) { |a, e| e.process(a) }
JSON.parse(JSON.generate(cleaned_hash))
end
# For cross-language compat
class << self
alias captureException from_exception
alias captureMessage from_message
alias capture_exception from_exception
alias capture_message from_message
end
private
# When behind a proxy (or if the user is using a proxy), we can't use
# REMOTE_ADDR to determine the Event IP, and must use other headers instead.
def calculate_real_ip_from_rack
Utils::RealIp.new(
:remote_addr => context.rack_env["REMOTE_ADDR"],
:client_ip => context.rack_env["HTTP_CLIENT_IP"],
:real_ip => context.rack_env["HTTP_X_REAL_IP"],
:forwarded_for => context.rack_env["HTTP_X_FORWARDED_FOR"]
).calculate_ip
end
def async_json_processors
[
Raven::Processor::RemoveCircularReferences,
Raven::Processor::UTF8Conversion
].map { |v| v.new(self) }
end
end
end
raven-ruby-2.6.3/lib/raven/instance.rb 0000664 0000000 0000000 00000014173 13142120705 0017627 0 ustar 00root root 0000000 0000000 module Raven
# A copy of Raven's base module class methods, minus some of the integration
# and global hooks since it's meant to be used explicitly. Useful for
# sending errors to multiple sentry projects in a large application.
#
# @example
# class Foo
# def initialize
# @other_raven = Raven::Instance.new
# @other_raven.configure do |config|
# config.server = 'http://...'
# end
# end
#
# def foo
# # ...
# rescue => e
# @other_raven.capture_exception(e)
# end
# end
class Instance
# See Raven::Client.
attr_writer :client
# See Raven::Configuration.
attr_accessor :configuration
def initialize(context = nil, config = nil)
@context = @explicit_context = context
self.configuration = config || Configuration.new
end
def context
if @explicit_context
@context ||= Context.new
else
Context.current
end
end
def logger
configuration.logger
end
# The client object is responsible for delivering formatted data to the
# Sentry server.
def client
@client ||= Client.new(configuration)
end
# Tell the log that the client is good to go
def report_status
return if configuration.silence_ready
if configuration.capture_allowed?
logger.info "Raven #{VERSION} ready to catch errors"
else
logger.info "Raven #{VERSION} configured not to capture errors: #{configuration.error_messages}"
end
end
# Call this method to modify defaults in your initializers.
#
# @example
# Raven.configure do |config|
# config.server = 'http://...'
# end
def configure
yield(configuration) if block_given?
self.client = Client.new(configuration)
report_status
client
end
# Send an event to the configured Sentry server
#
# @example
# evt = Raven::Event.new(:message => "An error")
# Raven.send_event(evt)
def send_event(event)
client.send_event(event)
end
# Capture and process any exceptions from the given block.
#
# @example
# Raven.capture do
# MyApp.run
# end
def capture(options = {})
if block_given?
begin
yield
rescue Error
raise # Don't capture Raven errors
rescue Exception => e
capture_type(e, options)
raise
end
else
install_at_exit_hook(options)
end
end
def capture_type(obj, options = {})
unless configuration.capture_allowed?(obj)
logger.debug("#{obj} excluded from capture: #{configuration.error_messages}")
return false
end
message_or_exc = obj.is_a?(String) ? "message" : "exception"
options[:configuration] = configuration
options[:context] = context
if (evt = Event.send("from_" + message_or_exc, obj, options))
yield evt if block_given?
if configuration.async?
begin
# We have to convert to a JSON-like hash, because background job
# processors (esp ActiveJob) may not like weird types in the event hash
configuration.async.call(evt.to_json_compatible)
rescue => ex
logger.error("async event sending failed: #{ex.message}")
send_event(evt)
end
else
send_event(evt)
end
Thread.current["sentry_#{object_id}_last_event_id".to_sym] = evt.id
evt
end
end
alias capture_message capture_type
alias capture_exception capture_type
def last_event_id
Thread.current["sentry_#{object_id}_last_event_id".to_sym]
end
# Provides extra context to the exception prior to it being handled by
# Raven. An exception can have multiple annotations, which are merged
# together.
#
# The options (annotation) is treated the same as the ``options``
# parameter to ``capture_exception`` or ``Event.from_exception``, and
# can contain the same ``:user``, ``:tags``, etc. options as these
# methods.
#
# These will be merged with the ``options`` parameter to
# ``Event.from_exception`` at the top of execution.
#
# @example
# begin
# raise "Hello"
# rescue => exc
# Raven.annotate_exception(exc, :user => { 'id' => 1,
# 'email' => 'foo@example.com' })
# end
def annotate_exception(exc, options = {})
notes = (exc.instance_variable_defined?(:@__raven_context) && exc.instance_variable_get(:@__raven_context)) || {}
notes.merge!(options)
exc.instance_variable_set(:@__raven_context, notes)
exc
end
# Bind user context. Merges with existing context (if any).
#
# It is recommending that you send at least the ``id`` and ``email``
# values. All other values are arbitrary.
#
# @example
# Raven.user_context('id' => 1, 'email' => 'foo@example.com')
def user_context(options = nil)
context.user = options || {}
end
# Bind tags context. Merges with existing context (if any).
#
# Tags are key / value pairs which generally represent things like
# application version, environment, role, and server names.
#
# @example
# Raven.tags_context('my_custom_tag' => 'tag_value')
def tags_context(options = nil)
context.tags.merge!(options || {})
end
# Bind extra context. Merges with existing context (if any).
#
# Extra context shows up as Additional Data within Sentry, and is
# completely arbitrary.
#
# @example
# Raven.extra_context('my_custom_data' => 'value')
def extra_context(options = nil)
context.extra.merge!(options || {})
end
def rack_context(env)
env = nil if env.empty?
context.rack_env = env
end
def breadcrumbs
BreadcrumbBuffer.current
end
private
def install_at_exit_hook(options)
at_exit do
exception = $ERROR_INFO
if exception
logger.debug "Caught a post-mortem exception: #{exception.inspect}"
capture_type(exception, options)
end
end
end
end
end
raven-ruby-2.6.3/lib/raven/integrations/ 0000775 0000000 0000000 00000000000 13142120705 0020176 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/lib/raven/integrations/delayed_job.rb 0000664 0000000 0000000 00000004004 13142120705 0022762 0 ustar 00root root 0000000 0000000 require 'delayed_job'
module Delayed
module Plugins
class Raven < ::Delayed::Plugin
callbacks do |lifecycle|
lifecycle.around(:invoke_job) do |job, *args, &block|
begin
# Forward the call to the next callback in the callback chain
block.call(job, *args)
rescue Exception => exception
# Log error to Sentry
extra = {
:delayed_job => {
:id => job.id,
:priority => job.priority,
:attempts => job.attempts,
:run_at => job.run_at,
:locked_at => job.locked_at,
:locked_by => job.locked_by,
:queue => job.queue,
:created_at => job.created_at
}
}
# last_error can be nil
extra[:last_error] = job.last_error[0...1000] if job.last_error
# handlers are YAML objects in strings, we definitely can't
# report all of that or the event will get truncated randomly
extra[:handler] = job.handler[0...1000] if job.handler
if job.respond_to?('payload_object') && job.payload_object.respond_to?('job_data')
extra[:active_job] = job.payload_object.job_data
end
::Raven.capture_exception(exception,
:logger => 'delayed_job',
:tags => {
:delayed_job_queue => job.queue,
:delayed_job_id => job.id
},
:extra => extra)
# Make sure we propagate the failure!
raise exception
ensure
::Raven::Context.clear!
::Raven::BreadcrumbBuffer.clear!
end
end
end
end
end
end
##
# Register DelayedJob Raven plugin
#
Delayed::Worker.plugins << Delayed::Plugins::Raven
raven-ruby-2.6.3/lib/raven/integrations/rack-timeout.rb 0000664 0000000 0000000 00000001156 13142120705 0023132 0 ustar 00root root 0000000 0000000 # We need to do this because of the way integration loading works
require "rack/timeout/base" unless defined?(Rack::Timeout)
# This integration is a good example of how to change how exceptions
# get grouped by Sentry's UI. Simply override #raven_context in
# the exception class, and append something to the fingerprint
# that will distinguish exceptions in the way you desire.
module RackTimeoutExtensions
def raven_context
{ :fingerprint => ["{{ default }}", env["REQUEST_URI"]] }
end
end
Rack::Timeout::Error.include RackTimeoutExtensions
Rack::Timeout::RequestTimeoutException.include RackTimeoutExtensions
raven-ruby-2.6.3/lib/raven/integrations/rack.rb 0000664 0000000 0000000 00000010010 13142120705 0021433 0 ustar 00root root 0000000 0000000 require 'time'
require 'rack'
module Raven
# Middleware for Rack applications. Any errors raised by the upstream
# application will be delivered to Sentry and re-raised.
#
# Synopsis:
#
# require 'rack'
# require 'raven'
#
# Raven.configure do |config|
# config.server = 'http://my_dsn'
# end
#
# app = Rack::Builder.app do
# use Raven::Rack
# run lambda { |env| raise "Rack down" }
# end
#
# Use a standard Raven.configure call to configure your server credentials.
class Rack
def self.capture_type(exception, env, options = {})
if env['raven.requested_at']
options[:time_spent] = Time.now - env['raven.requested_at']
end
Raven.capture_type(exception, options) do |evt|
evt.interface :http do |int|
int.from_rack(env)
end
end
end
class << self
alias capture_message capture_type
alias capture_exception capture_type
end
def initialize(app)
@app = app
end
def call(env)
# store the current environment in our local context for arbitrary
# callers
env['raven.requested_at'] = Time.now
Raven.rack_context(env)
begin
response = @app.call(env)
rescue Error
raise # Don't capture Raven errors
rescue Exception => e
Raven::Rack.capture_exception(e, env)
raise
end
error = env['rack.exception'] || env['sinatra.error']
Raven::Rack.capture_exception(error, env) if error
response
ensure
Context.clear!
BreadcrumbBuffer.clear!
end
end
module RackInterface
def from_rack(env_hash)
req = ::Rack::Request.new(env_hash)
self.url = req.scheme && req.url.split('?').first
self.method = req.request_method
self.query_string = req.query_string
self.data = read_data_from(req)
self.headers = format_headers_for_sentry(env_hash)
self.env = format_env_for_sentry(env_hash)
end
private
# See Sentry server default limits at
# https://github.com/getsentry/sentry/blob/master/src/sentry/conf/server.py
def read_data_from(request)
if request.form_data?
request.POST
elsif request.body # JSON requests, etc
data = request.body.read(4096 * 4) # Sentry server limit
request.body.rewind
data
end
rescue IOError => ex
ex.message
end
def format_headers_for_sentry(env_hash)
env_hash.each_with_object({}) do |(key, value), memo|
begin
key = key.to_s # rack env can contain symbols
value = value.to_s
next unless key.upcase == key # Non-upper case stuff isn't either
# Rack adds in an incorrect HTTP_VERSION key, which causes downstream
# to think this is a Version header. Instead, this is mapped to
# env['SERVER_PROTOCOL']. But we don't want to ignore a valid header
# if the request has legitimately sent a Version header themselves.
# See: https://github.com/rack/rack/blob/028438f/lib/rack/handler/cgi.rb#L29
next if key == 'HTTP_VERSION' && value == env_hash['SERVER_PROTOCOL']
next unless key.start_with?('HTTP_') || %w(CONTENT_TYPE CONTENT_LENGTH).include?(key)
# Rack stores headers as HTTP_WHAT_EVER, we need What-Ever
key = key.gsub("HTTP_", "")
key = key.split('_').map(&:capitalize).join('-')
memo[key] = value
rescue StandardError => e
# Rails adds objects to the Rack env that can sometimes raise exceptions
# when `to_s` is called.
# See: https://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/middleware/remote_ip.rb#L134
Raven.logger.warn("Error raised while formatting headers: #{e.message}")
next
end
end
end
def format_env_for_sentry(env_hash)
env_hash.select do |k, _v|
%w(REMOTE_ADDR SERVER_NAME SERVER_PORT).include? k.to_s
end
end
end
class HttpInterface
include RackInterface
end
end
raven-ruby-2.6.3/lib/raven/integrations/rails.rb 0000664 0000000 0000000 00000004123 13142120705 0021635 0 ustar 00root root 0000000 0000000 require 'rails'
module Raven
class Rails < ::Rails::Railtie
require 'raven/integrations/rails/overrides/streaming_reporter'
require 'raven/integrations/rails/controller_methods'
initializer "raven.use_rack_middleware" do |app|
app.config.middleware.insert 0, Raven::Rack
end
initializer 'raven.action_controller' do
ActiveSupport.on_load :action_controller do
include Raven::Rails::ControllerMethods
if ::Rails::VERSION::STRING >= "4.0.0"
Raven.safely_prepend(
"StreamingReporter",
:from => Raven::Rails::Overrides,
:to => ActionController::Live
)
end
end
end
initializer 'raven.action_view' do
ActiveSupport.on_load :action_view do
Raven.safely_prepend(
"StreamingReporter",
:from => Raven::Rails::Overrides,
:to => ActionView::StreamingTemplateRenderer::Body
)
end
end
config.before_initialize do
Raven.configuration.logger = ::Rails.logger
end
config.after_initialize do
if Raven.configuration.rails_activesupport_breadcrumbs
require 'raven/breadcrumbs/activesupport'
Raven::ActiveSupportBreadcrumbs.inject
end
if Raven.configuration.rails_report_rescued_exceptions
require 'raven/integrations/rails/overrides/debug_exceptions_catcher'
if defined?(::ActionDispatch::DebugExceptions)
exceptions_class = ::ActionDispatch::DebugExceptions
elsif defined?(::ActionDispatch::ShowExceptions)
exceptions_class = ::ActionDispatch::ShowExceptions
end
Raven.safely_prepend(
"DebugExceptionsCatcher",
:from => Raven::Rails::Overrides,
:to => exceptions_class
)
end
end
initializer 'raven.active_job' do
ActiveSupport.on_load :active_job do
require 'raven/integrations/rails/active_job'
end
end
rake_tasks do
require 'raven/integrations/tasks'
end
if defined?(runner)
runner do
Raven.capture
end
end
end
end
raven-ruby-2.6.3/lib/raven/integrations/rails/ 0000775 0000000 0000000 00000000000 13142120705 0021310 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/lib/raven/integrations/rails/active_job.rb 0000664 0000000 0000000 00000002771 13142120705 0023751 0 ustar 00root root 0000000 0000000 module Raven
class Rails
module ActiveJobExtensions
ALREADY_SUPPORTED_SENTRY_ADAPTERS = %w(
ActiveJob::QueueAdapters::SidekiqAdapter
ActiveJob::QueueAdapters::DelayedJobAdapter
).freeze
def self.included(base)
base.class_eval do
around_perform do |job, block|
capture_and_reraise_with_sentry(job, block)
end
end
end
def capture_and_reraise_with_sentry(job, block)
block.call
rescue Exception => exception # rubocop:disable Lint/RescueException
return if rescue_with_handler(exception)
unless already_supported_by_specific_integration?(job)
Raven.capture_exception(exception, :extra => raven_context(job))
end
raise exception
ensure
Context.clear!
BreadcrumbBuffer.clear!
end
def already_supported_by_specific_integration?(job)
ALREADY_SUPPORTED_SENTRY_ADAPTERS.include?(job.class.queue_adapter.to_s)
end
def raven_context(job)
ctx = {
:active_job => job.class.name,
:arguments => job.arguments,
:scheduled_at => job.scheduled_at,
:job_id => job.job_id,
:locale => job.locale
}
# Add provider_job_id details if Rails 5
if job.respond_to?(:provider_job_id)
ctx[:provider_job_id] = job.provider_job_id
end
ctx
end
end
end
end
class ActiveJob::Base
include Raven::Rails::ActiveJobExtensions
end
raven-ruby-2.6.3/lib/raven/integrations/rails/controller_methods.rb 0000664 0000000 0000000 00000000517 13142120705 0025546 0 ustar 00root root 0000000 0000000 module Raven
class Rails
module ControllerMethods
def capture_message(message, options = {})
Raven::Rack.capture_message(message, request.env, options)
end
def capture_exception(exception, options = {})
Raven::Rack.capture_exception(exception, request.env, options)
end
end
end
end
raven-ruby-2.6.3/lib/raven/integrations/rails/overrides/ 0000775 0000000 0000000 00000000000 13142120705 0023312 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/lib/raven/integrations/rails/overrides/debug_exceptions_catcher.rb 0000664 0000000 0000000 00000001716 13142120705 0030664 0 ustar 00root root 0000000 0000000 module Raven
class Rails
module Overrides
module DebugExceptionsCatcher
def render_exception(env_or_request, exception)
begin
env = env_or_request.respond_to?(:env) ? env_or_request.env : env_or_request
Raven::Rack.capture_exception(exception, env)
rescue # rubocop:disable Lint/HandleExceptions
end
super
end
end
module OldDebugExceptionsCatcher
def self.included(base)
base.send(:alias_method_chain, :render_exception, :raven)
end
def render_exception_with_raven(env_or_request, exception)
begin
env = env_or_request.respond_to?(:env) ? env_or_request.env : env_or_request
Raven::Rack.capture_exception(exception, env)
rescue # rubocop:disable Lint/HandleExceptions
end
render_exception_without_raven(env_or_request, exception)
end
end
end
end
end
raven-ruby-2.6.3/lib/raven/integrations/rails/overrides/streaming_reporter.rb 0000664 0000000 0000000 00000000776 13142120705 0027564 0 ustar 00root root 0000000 0000000 module Raven
class Rails
module Overrides
module StreamingReporter
def log_error(exception)
Raven.capture_exception(exception)
super
end
end
module OldStreamingReporter
def self.included(base)
base.send(:alias_method_chain, :log_error, :raven)
end
def log_error_with_raven(exception)
Raven.capture_exception(exception)
log_error_without_raven(exception)
end
end
end
end
end
raven-ruby-2.6.3/lib/raven/integrations/railties.rb 0000664 0000000 0000000 00000000043 13142120705 0022334 0 ustar 00root root 0000000 0000000 require 'raven/integrations/rails'
raven-ruby-2.6.3/lib/raven/integrations/rake.rb 0000664 0000000 0000000 00000000550 13142120705 0021445 0 ustar 00root root 0000000 0000000 require 'rake'
require 'rake/task'
require 'raven/integrations/tasks'
module Rake
class Application
alias orig_display_error_messsage display_error_message
def display_error_message(ex)
Raven.capture_exception ex, :logger => 'rake', :tags => { 'rake_task' => top_level_tasks.join(' ') }
orig_display_error_messsage(ex)
end
end
end
raven-ruby-2.6.3/lib/raven/integrations/sidekiq.rb 0000664 0000000 0000000 00000003727 13142120705 0022165 0 ustar 00root root 0000000 0000000 require 'time'
require 'sidekiq'
module Raven
class SidekiqCleanupMiddleware
def call(_worker, _job, _queue)
yield
Context.clear!
BreadcrumbBuffer.clear!
end
end
class SidekiqErrorHandler
ACTIVEJOB_RESERVED_PREFIX = "_aj_".freeze
def call(ex, context)
context = filter_context(context)
Raven.capture_exception(
ex,
:message => ex.message,
:extra => { :sidekiq => context },
:culprit => culprit_from_context(context)
)
Context.clear!
BreadcrumbBuffer.clear!
end
private
# Once an ActiveJob is queued, ActiveRecord references get serialized into
# some internal reserved keys, such as _aj_globalid.
#
# The problem is, if this job in turn gets queued back into ActiveJob with
# these magic reserved keys, ActiveJob will throw up and error. We want to
# capture these and mutate the keys so we can sanely report it.
def filter_context(context)
case context
when Array
context.map { |arg| filter_context(arg) }
when Hash
Hash[context.map { |key, value| filter_context_hash(key, value) }]
else
context
end
end
def filter_context_hash(key, value)
(key = key[3..-1]) if key [0..3] == ACTIVEJOB_RESERVED_PREFIX
[key, filter_context(value)]
end
# this will change in the future:
# https://github.com/mperham/sidekiq/pull/3161
def culprit_from_context(context)
classname = (context["class"] || (context["job"] && (context["job"]["wrapped"] || context["job"]["class"])))
if classname
"Sidekiq/#{classname}"
elsif context["event"]
"Sidekiq/#{context['event']}"
else
"Sidekiq"
end
end
end
end
if Sidekiq::VERSION > '3'
Sidekiq.configure_server do |config|
config.error_handlers << Raven::SidekiqErrorHandler.new
config.server_middleware do |chain|
chain.add Raven::SidekiqCleanupMiddleware
end
end
end
raven-ruby-2.6.3/lib/raven/integrations/tasks.rb 0000664 0000000 0000000 00000000430 13142120705 0021645 0 ustar 00root root 0000000 0000000 require 'rake'
require 'raven/cli'
namespace :raven do
desc "Send a test event to the remote Sentry server"
task :test, [:dsn] do |_t, args|
Rake::Task["environment"].invoke if Rake::Task.tasks.map(&:to_s).include?("environment")
Raven::CLI.test(args.dsn)
end
end
raven-ruby-2.6.3/lib/raven/interface.rb 0000664 0000000 0000000 00000001124 13142120705 0017753 0 ustar 00root root 0000000 0000000 module Raven
class Interface
def initialize(attributes = nil)
attributes.each do |attr, value|
public_send "#{attr}=", value
end if attributes
yield self if block_given?
end
def self.inherited(klass)
name = klass.name.split("::").last.downcase.gsub("interface", "")
registered[name.to_sym] = klass
super
end
def self.registered
@@registered ||= {} # rubocop:disable Style/ClassVars
end
def to_hash
Hash[instance_variables.map { |name| [name[1..-1].to_sym, instance_variable_get(name)] }]
end
end
end
raven-ruby-2.6.3/lib/raven/interfaces/ 0000775 0000000 0000000 00000000000 13142120705 0017613 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/lib/raven/interfaces/exception.rb 0000664 0000000 0000000 00000000460 13142120705 0022136 0 ustar 00root root 0000000 0000000 require 'raven/interface'
module Raven
class ExceptionInterface < Interface
attr_accessor :values
def self.sentry_alias
:exception
end
def to_hash(*args)
data = super(*args)
data[:values] = data[:values].map(&:to_hash) if data[:values]
data
end
end
end
raven-ruby-2.6.3/lib/raven/interfaces/http.rb 0000664 0000000 0000000 00000000533 13142120705 0021120 0 ustar 00root root 0000000 0000000 require 'raven/interface'
module Raven
class HttpInterface < Interface
attr_accessor :url, :method, :data, :query_string, :cookies, :headers, :env
def initialize(*arguments)
self.headers = {}
self.env = {}
self.cookies = nil
super(*arguments)
end
def self.sentry_alias
:request
end
end
end
raven-ruby-2.6.3/lib/raven/interfaces/message.rb 0000664 0000000 0000000 00000000542 13142120705 0021565 0 ustar 00root root 0000000 0000000 require 'raven/interface'
module Raven
class MessageInterface < Interface
attr_accessor :message, :params
def initialize(*arguments)
self.params = []
super(*arguments)
end
def unformatted_message
Array(params).empty? ? message : message % params
end
def self.sentry_alias
:logentry
end
end
end
raven-ruby-2.6.3/lib/raven/interfaces/single_exception.rb 0000664 0000000 0000000 00000000526 13142120705 0023502 0 ustar 00root root 0000000 0000000 require 'raven/interface'
module Raven
class SingleExceptionInterface < Interface
attr_accessor :type
attr_accessor :value
attr_accessor :module
attr_accessor :stacktrace
def to_hash(*args)
data = super(*args)
data[:stacktrace] = data[:stacktrace].to_hash if data[:stacktrace]
data
end
end
end
raven-ruby-2.6.3/lib/raven/interfaces/stack_trace.rb 0000664 0000000 0000000 00000004051 13142120705 0022423 0 ustar 00root root 0000000 0000000 require 'raven/interface'
module Raven
class StacktraceInterface < Interface
attr_accessor :frames
def initialize(*arguments)
self.frames = []
super(*arguments)
end
def self.sentry_alias
:stacktrace
end
def to_hash(*args)
data = super(*args)
data[:frames] = data[:frames].map(&:to_hash)
data
end
# Not actually an interface, but I want to use the same style
class Frame < Interface
attr_accessor :abs_path
attr_accessor :function
attr_accessor :vars
attr_accessor :pre_context
attr_accessor :post_context
attr_accessor :context_line
attr_accessor :module
attr_accessor :lineno
attr_accessor :in_app
def initialize(*arguments)
self.vars, self.pre_context, self.post_context = [], [], []
super(*arguments)
end
def filename
return if abs_path.nil?
return @filename if @filename
prefix =
if under_project_root? && in_app
project_root
elsif under_project_root?
longest_load_path || project_root
else
longest_load_path
end
@filename = prefix ? abs_path[prefix.to_s.chomp(File::SEPARATOR).length + 1..-1] : abs_path
end
def to_hash(*args)
data = super(*args)
data[:filename] = filename
data.delete(:vars) unless vars && !vars.empty?
data.delete(:pre_context) unless pre_context && !pre_context.empty?
data.delete(:post_context) unless post_context && !post_context.empty?
data.delete(:context_line) unless context_line && !context_line.empty?
data
end
private
def under_project_root?
project_root && abs_path.start_with?(project_root)
end
def project_root
@project_root ||= Raven.configuration.project_root && Raven.configuration.project_root.to_s
end
def longest_load_path
$LOAD_PATH.select { |path| abs_path.start_with?(path.to_s) }.max_by(&:size)
end
end
end
end
raven-ruby-2.6.3/lib/raven/linecache.rb 0000664 0000000 0000000 00000002016 13142120705 0017727 0 ustar 00root root 0000000 0000000 module Raven
class LineCache
def initialize
@cache = {}
end
# Any linecache you provide to Raven must implement this method.
# Returns an Array of Strings representing the lines in the source
# file. The number of lines retrieved is (2 * context) + 1, the middle
# line should be the line requested by lineno. See specs for more information.
def get_file_context(filename, lineno, context)
return nil, nil, nil unless valid_path?(filename)
lines = Array.new(2 * context + 1) do |i|
getline(filename, lineno - context + i)
end
[lines[0..(context - 1)], lines[context], lines[(context + 1)..-1]]
end
private
def valid_path?(path)
lines = getlines(path)
!lines.nil?
end
def getlines(path)
@cache[path] ||= begin
IO.readlines(path)
rescue
nil
end
end
def getline(path, n)
return nil if n < 1
lines = getlines(path)
return nil if lines.nil?
lines[n - 1]
end
end
end
raven-ruby-2.6.3/lib/raven/logger.rb 0000664 0000000 0000000 00000000735 13142120705 0017301 0 ustar 00root root 0000000 0000000 # frozen_string_literal: true
require 'logger'
module Raven
class Logger < ::Logger
LOG_PREFIX = "** [Raven] ".freeze
PROGNAME = "sentry".freeze
def initialize(*)
super
@level = ::Logger::INFO
original_formatter = ::Logger::Formatter.new
@default_formatter = proc do |severity, datetime, _progname, msg|
msg = "#{LOG_PREFIX}#{msg}"
original_formatter.call(severity, datetime, PROGNAME, msg)
end
end
end
end
raven-ruby-2.6.3/lib/raven/processor.rb 0000664 0000000 0000000 00000000437 13142120705 0020040 0 ustar 00root root 0000000 0000000 module Raven
class Processor
STRING_MASK = '********'.freeze
INT_MASK = 0
REGEX_SPECIAL_CHARACTERS = %w(. $ ^ { [ ( | ) * + ?).freeze
def initialize(client = nil)
@client = client
end
def process(_data)
raise NotImplementedError
end
end
end
raven-ruby-2.6.3/lib/raven/processor/ 0000775 0000000 0000000 00000000000 13142120705 0017507 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/lib/raven/processor/cookies.rb 0000664 0000000 0000000 00000001356 13142120705 0021475 0 ustar 00root root 0000000 0000000 module Raven
class Processor::Cookies < Processor
def process(data)
process_if_symbol_keys(data) if data[:request]
process_if_string_keys(data) if data["request"]
data
end
private
def process_if_symbol_keys(data)
data[:request][:cookies] = STRING_MASK if data[:request][:cookies]
return unless data[:request][:headers] && data[:request][:headers]["Cookie"]
data[:request][:headers]["Cookie"] = STRING_MASK
end
def process_if_string_keys(data)
data["request"]["cookies"] = STRING_MASK if data["request"]["cookies"]
return unless data["request"]["headers"] && data["request"]["headers"]["Cookie"]
data["request"]["headers"]["Cookie"] = STRING_MASK
end
end
end
raven-ruby-2.6.3/lib/raven/processor/http_headers.rb 0000664 0000000 0000000 00000002550 13142120705 0022510 0 ustar 00root root 0000000 0000000 module Raven
class Processor::HTTPHeaders < Processor
DEFAULT_FIELDS = ["Authorization"].freeze
attr_accessor :sanitize_http_headers
def initialize(client)
super
self.sanitize_http_headers = client.configuration.sanitize_http_headers
end
def process(data)
process_if_symbol_keys(data) if data[:request]
process_if_string_keys(data) if data["request"]
data
end
private
def process_if_symbol_keys(data)
return unless data[:request][:headers]
data[:request][:headers].keys.select { |k| fields_re.match(k.to_s) }.each do |k|
data[:request][:headers][k] = STRING_MASK
end
end
def process_if_string_keys(data)
return unless data["request"]["headers"]
data["request"]["headers"].keys.select { |k| fields_re.match(k) }.each do |k|
data["request"]["headers"][k] = STRING_MASK
end
end
def matches_regexes?(k)
fields_re.match(k.to_s)
end
def fields_re
@fields_re ||= /#{(DEFAULT_FIELDS | sanitize_http_headers).map do |f|
use_boundary?(f) ? "\\b#{f}\\b" : f
end.join("|")}/i
end
def use_boundary?(string)
!DEFAULT_FIELDS.include?(string) && !special_characters?(string)
end
def special_characters?(string)
REGEX_SPECIAL_CHARACTERS.select { |r| string.include?(r) }.any?
end
end
end
raven-ruby-2.6.3/lib/raven/processor/post_data.rb 0000664 0000000 0000000 00000001001 13142120705 0022002 0 ustar 00root root 0000000 0000000 module Raven
class Processor::PostData < Processor
def process(data)
process_if_symbol_keys(data) if data[:request]
process_if_string_keys(data) if data["request"]
data
end
private
def process_if_symbol_keys(data)
return unless data[:request][:method] == "POST"
data[:request][:data] = STRING_MASK
end
def process_if_string_keys(data)
return unless data["request"]["method"] == "POST"
data["request"]["data"] = STRING_MASK
end
end
end
raven-ruby-2.6.3/lib/raven/processor/removecircularreferences.rb 0000664 0000000 0000000 00000001066 13142120705 0025123 0 ustar 00root root 0000000 0000000 module Raven
class Processor::RemoveCircularReferences < Processor
def process(value, visited = [])
return "(...)" if visited.include?(value.__id__)
visited << value.__id__ if value.is_a?(Array) || value.is_a?(Hash)
case value
when Hash
!value.frozen? ? value.merge!(value) { |_, v| process v, visited } : value.merge(value) { |_, v| process v, visited }
when Array
!value.frozen? ? value.map! { |v| process v, visited } : value.map { |v| process v, visited }
else
value
end
end
end
end
raven-ruby-2.6.3/lib/raven/processor/removestacktrace.rb 0000664 0000000 0000000 00000001161 13142120705 0023375 0 ustar 00root root 0000000 0000000 module Raven
class Processor::RemoveStacktrace < Processor
def process(data)
process_if_symbol_keys(data) if data[:exception]
process_if_string_keys(data) if data["exception"]
data
end
private
def process_if_symbol_keys(data)
data[:exception][:values].map do |single_exception|
single_exception.delete(:stacktrace) if single_exception[:stacktrace]
end
end
def process_if_string_keys(data)
data["exception"]["values"].map do |single_exception|
single_exception.delete("stacktrace") if single_exception["stacktrace"]
end
end
end
end
raven-ruby-2.6.3/lib/raven/processor/sanitizedata.rb 0000664 0000000 0000000 00000005302 13142120705 0022514 0 ustar 00root root 0000000 0000000 # frozen_string_literal: true
require 'json'
module Raven
class Processor::SanitizeData < Processor
DEFAULT_FIELDS = %w(authorization password passwd secret ssn social(.*)?sec).freeze
CREDIT_CARD_RE = /^(?:\d[ -]*?){13,16}$/
QUERY_STRING = ['query_string', :query_string].freeze
JSON_STARTS_WITH = ["[", "{"].freeze
attr_accessor :sanitize_fields, :sanitize_credit_cards, :sanitize_fields_excluded
def initialize(client)
super
self.sanitize_fields = client.configuration.sanitize_fields
self.sanitize_credit_cards = client.configuration.sanitize_credit_cards
self.sanitize_fields_excluded = client.configuration.sanitize_fields_excluded
end
def process(value, key = nil)
case value
when Hash
!value.frozen? ? value.merge!(value) { |k, v| process v, k } : value.merge(value) { |k, v| process v, k }
when Array
!value.frozen? ? value.map! { |v| process v, key } : value.map { |v| process v, key }
when Integer
matches_regexes?(key, value.to_s) ? INT_MASK : value
when String
if value =~ fields_re && (json = parse_json_or_nil(value))
# if this string is actually a json obj, convert and sanitize
process(json).to_json
elsif matches_regexes?(key, value)
STRING_MASK
elsif QUERY_STRING.include?(key)
sanitize_query_string(value)
else
value
end
else
value
end
end
private
# CGI.parse takes our nice UTF-8 strings and converts them back to ASCII,
# so we have to convert them back, again.
def utf8_processor
@utf8_processor ||= Processor::UTF8Conversion.new
end
def sanitize_query_string(query_string)
query_hash = CGI.parse(query_string)
sanitized = utf8_processor.process(query_hash)
processed_query_hash = process(sanitized)
URI.encode_www_form(processed_query_hash)
end
def matches_regexes?(k, v)
(sanitize_credit_cards && v =~ CREDIT_CARD_RE) ||
k =~ fields_re
end
def fields_re
return @fields_re if @fields_re
fields = DEFAULT_FIELDS | sanitize_fields
fields -= sanitize_fields_excluded
@fields_re = /#{fields.map do |f|
use_boundary?(f) ? "\\b#{f}\\b" : f
end.join("|")}/i
end
def use_boundary?(string)
!DEFAULT_FIELDS.include?(string) && !special_characters?(string)
end
def special_characters?(string)
REGEX_SPECIAL_CHARACTERS.select { |r| string.include?(r) }.any?
end
def parse_json_or_nil(string)
return unless string.start_with?(*JSON_STARTS_WITH)
JSON.parse(string)
rescue JSON::ParserError, NoMethodError
nil
end
end
end
raven-ruby-2.6.3/lib/raven/processor/utf8conversion.rb 0000664 0000000 0000000 00000003601 13142120705 0023030 0 ustar 00root root 0000000 0000000 module Raven
class Processor::UTF8Conversion < Processor
# Slightly misnamed - actually just removes any bytes with invalid encoding
# Previously, our JSON backend required UTF-8. Since we now use the built-in
# JSON, we can use any encoding, but it must be valid anyway so we can do
# things like call #match and #slice on strings
REPLACE = "".freeze
def process(value)
case value
when Hash
!value.frozen? ? value.merge!(value) { |_, v| process v } : value.merge(value) { |_, v| process v }
when Array
!value.frozen? ? value.map! { |v| process v } : value.map { |v| process v }
when Exception
return value if value.message.valid_encoding?
clean_exc = value.class.new(remove_invalid_bytes(value.message))
clean_exc.set_backtrace(value.backtrace)
clean_exc
when String
# Encoding::BINARY / Encoding::ASCII_8BIT is a special binary encoding.
# valid_encoding? will always return true because it contains all codepoints,
# so instead we check if it only contains actual ASCII codepoints, and if
# not we assume it's actually just UTF8 and scrub accordingly.
if value.encoding == Encoding::BINARY && !value.ascii_only?
value.force_encoding(Encoding::UTF_8)
end
return value if value.valid_encoding?
remove_invalid_bytes(value)
else
value
end
end
private
# Stolen from RSpec
# https://github.com/rspec/rspec-support/blob/f0af3fd74a94ff7bb700f6ba06dbdc67bba17fbf/lib/rspec/support/encoded_string.rb#L120-L139
if String.method_defined?(:scrub) # 2.1+
def remove_invalid_bytes(string)
string.scrub!(REPLACE)
end
else
def remove_invalid_bytes(string)
string.chars.map do |char|
char.valid_encoding? ? char : REPLACE
end.join
end
end
end
end
raven-ruby-2.6.3/lib/raven/transports.rb 0000664 0000000 0000000 00000000540 13142120705 0020233 0 ustar 00root root 0000000 0000000 require 'raven/error'
module Raven
module Transports
class Transport
attr_accessor :configuration
def initialize(configuration)
@configuration = configuration
end
def send_event # (auth_header, data, options = {})
raise NotImplementedError, 'Abstract method not implemented'
end
end
end
end
raven-ruby-2.6.3/lib/raven/transports/ 0000775 0000000 0000000 00000000000 13142120705 0017707 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/lib/raven/transports/dummy.rb 0000664 0000000 0000000 00000000442 13142120705 0021367 0 ustar 00root root 0000000 0000000 module Raven
module Transports
class Dummy < Transport
attr_accessor :events
def initialize(*)
super
@events = []
end
def send_event(auth_header, data, options = {})
@events << [auth_header, data, options]
end
end
end
end
raven-ruby-2.6.3/lib/raven/transports/http.rb 0000664 0000000 0000000 00000004044 13142120705 0021215 0 ustar 00root root 0000000 0000000 require 'faraday'
require 'raven/transports'
require 'raven/error'
module Raven
module Transports
class HTTP < Transport
attr_accessor :conn, :adapter
def initialize(*args)
super
self.adapter = configuration.http_adapter || Faraday.default_adapter
self.conn = set_conn
end
def send_event(auth_header, data, options = {})
unless configuration.sending_allowed?
logger.debug("Event not sent: #{configuration.error_messages}")
end
project_id = configuration[:project_id]
path = configuration[:path] + "/"
conn.post "#{path}api/#{project_id}/store/" do |req|
req.headers['Content-Type'] = options[:content_type]
req.headers['X-Sentry-Auth'] = auth_header
req.body = data
end
rescue Faraday::Error => ex
error_info = ex.message
if ex.response && ex.response[:headers]['x-sentry-error']
error_info += " Error in headers is: #{ex.response[:headers]['x-sentry-error']}"
end
raise Raven::Error, error_info
end
private
def set_conn
configuration.logger.debug "Raven HTTP Transport connecting to #{configuration.server}"
ssl_configuration = configuration.ssl || {}
ssl_configuration[:verify] = configuration.ssl_verification
ssl_configuration[:ca_file] = configuration.ssl_ca_file
conn = Faraday.new(
:url => configuration[:server],
:ssl => ssl_configuration
) do |builder|
configuration.faraday_builder.call(builder) if configuration.faraday_builder
builder.response :raise_error
builder.adapter(*adapter)
end
conn.headers[:user_agent] = "sentry-ruby/#{Raven::VERSION}"
conn.options[:proxy] = configuration.proxy if configuration.proxy
conn.options[:timeout] = configuration.timeout if configuration.timeout
conn.options[:open_timeout] = configuration.open_timeout if configuration.open_timeout
conn
end
end
end
end
raven-ruby-2.6.3/lib/raven/utils/ 0000775 0000000 0000000 00000000000 13142120705 0016630 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/lib/raven/utils/deep_merge.rb 0000664 0000000 0000000 00000001420 13142120705 0021246 0 ustar 00root root 0000000 0000000 # rubocop:disable all
module Raven
module Utils
# ported from ActiveSupport
module DeepMergeHash
def self.deep_merge(hash, other_hash, &block)
deep_merge!(hash, other_hash, &block)
end
def self.deep_merge!(hash, other_hash, &block)
other_hash.each_pair do |current_key, other_value|
this_value = hash[current_key]
hash[current_key] = if this_value.is_a?(Hash) && other_value.is_a?(Hash)
deep_merge(this_value, other_value, &block)
else
if block_given? && key?(current_key)
block.call(current_key, this_value, other_value)
else
other_value
end
end
end
hash
end
end
end
end
# rubocop:enable all
raven-ruby-2.6.3/lib/raven/utils/real_ip.rb 0000664 0000000 0000000 00000004211 13142120705 0020566 0 ustar 00root root 0000000 0000000 require 'ipaddr'
# Based on ActionDispatch::RemoteIp. All security-related precautions from that
# middleware have been removed, because the Event IP just needs to be accurate,
# and spoofing an IP here only makes data inaccurate, not insecure. Don't re-use
# this module if you have to *trust* the IP address.
module Raven
module Utils
class RealIp
LOCAL_ADDRESSES = [
"127.0.0.1", # localhost IPv4
"::1", # localhost IPv6
"fc00::/7", # private IPv6 range fc00::/7
"10.0.0.0/8", # private IPv4 range 10.x.x.x
"172.16.0.0/12", # private IPv4 range 172.16.0.0 .. 172.31.255.255
"192.168.0.0/16", # private IPv4 range 192.168.x.x
].map { |proxy| IPAddr.new(proxy) }
attr_accessor :ip, :ip_addresses
def initialize(ip_addresses)
self.ip_addresses = ip_addresses
end
def calculate_ip
# CGI environment variable set by Rack
remote_addr = ips_from(ip_addresses[:remote_addr]).last
# Could be a CSV list and/or repeated headers that were concatenated.
client_ips = ips_from(ip_addresses[:client_ip])
real_ips = ips_from(ip_addresses[:real_ip])
forwarded_ips = ips_from(ip_addresses[:forwarded_for])
ips = [client_ips, real_ips, forwarded_ips, remote_addr].flatten.compact
# If every single IP option is in the trusted list, just return REMOTE_ADDR
self.ip = filter_local_addresses(ips).first || remote_addr
end
protected
def ips_from(header)
# Split the comma-separated list into an array of strings
ips = header ? header.strip.split(/[,\s]+/) : []
ips.select do |ip|
begin
# Only return IPs that are valid according to the IPAddr#new method
range = IPAddr.new(ip).to_range
# we want to make sure nobody is sneaking a netmask in
range.begin == range.end
rescue ArgumentError
nil
end
end
end
def filter_local_addresses(ips)
ips.reject { |ip| LOCAL_ADDRESSES.any? { |proxy| proxy === ip } }
end
end
end
end
raven-ruby-2.6.3/lib/raven/version.rb 0000664 0000000 0000000 00000000226 13142120705 0017502 0 ustar 00root root 0000000 0000000 # frozen_string_literal: true
module Raven
# Freezing this constant breaks in 1.9.x
VERSION = "2.6.3" # rubocop:disable Style/MutableConstant
end
raven-ruby-2.6.3/lib/sentry-raven-without-integrations.rb 0000664 0000000 0000000 00000000025 13142120705 0023541 0 ustar 00root root 0000000 0000000 require 'raven/base'
raven-ruby-2.6.3/lib/sentry-raven.rb 0000664 0000000 0000000 00000000020 13142120705 0017327 0 ustar 00root root 0000000 0000000 require "raven"
raven-ruby-2.6.3/sentry-raven.gemspec 0000664 0000000 0000000 00000001411 13142120705 0017606 0 ustar 00root root 0000000 0000000 $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
require 'raven/version'
Gem::Specification.new do |gem|
gem.name = "sentry-raven"
gem.authors = ["Sentry Team"]
gem.description = gem.summary = "A gem that provides a client interface for the Sentry error logger"
gem.email = "getsentry@googlegroups.com"
gem.license = 'Apache-2.0'
gem.homepage = "https://github.com/getsentry/raven-ruby"
gem.version = Raven::VERSION
gem.platform = Gem::Platform::RUBY
gem.required_ruby_version = '>= 1.9.0'
gem.has_rdoc = true
gem.extra_rdoc_files = ["README.md", "LICENSE"]
gem.files = `git ls-files | grep -Ev '^(spec|benchmarks|examples)'`.split("\n")
gem.bindir = "exe"
gem.executables = "raven"
gem.add_dependency "faraday", ">= 0.7.6", "< 1.0"
end
raven-ruby-2.6.3/spec/ 0000775 0000000 0000000 00000000000 13142120705 0014541 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/spec/raven/ 0000775 0000000 0000000 00000000000 13142120705 0015654 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/spec/raven/backtrace_spec.rb 0000664 0000000 0000000 00000001017 13142120705 0021131 0 ustar 00root root 0000000 0000000 require 'spec_helper'
describe Raven::Backtrace do
before(:each) do
@backtrace = Raven::Backtrace.parse(Thread.current.backtrace)
end
it "#lines" do
expect(@backtrace.lines.first).to be_a(Raven::Backtrace::Line)
end
it "#inspect" do
expect(@backtrace.inspect).to match(/Backtrace: .*>$/)
end
it "#to_s" do
expect(@backtrace.to_s).to match(/backtrace_spec.rb:5/)
end
it "==" do
@backtrace2 = Raven::Backtrace.new(@backtrace.lines)
expect(@backtrace).to be == @backtrace2
end
end
raven-ruby-2.6.3/spec/raven/breadcrumbs_spec.rb 0000664 0000000 0000000 00000003353 13142120705 0021510 0 ustar 00root root 0000000 0000000 require 'spec_helper'
describe Raven::BreadcrumbBuffer do
before(:each) do
@breadcrumbs = Raven::BreadcrumbBuffer.new(10)
end
it "records breadcrumbs w/a block" do
expect(@breadcrumbs.empty?).to be true
@breadcrumbs.record do
Raven::Breadcrumb.new.tap { |b| b.message = "test" }
end
expect(@breadcrumbs.members.size).to eq(1)
expect(@breadcrumbs.empty?).to be false
end
it "records breadcrumbs w/o block" do
crumb = Raven::Breadcrumb.new.tap { |b| b.message = "test" }
@breadcrumbs.record(crumb)
expect(@breadcrumbs.members[0]).to eq(crumb)
end
it "allows peeking" do
expect(@breadcrumbs.peek).to eq(nil)
crumb = Raven::Breadcrumb.new.tap { |b| b.message = "test" }
@breadcrumbs.record(crumb)
expect(@breadcrumbs.peek).to eq(crumb)
end
it "is enumerable" do
(0..10).each do |i|
@breadcrumbs.record(Raven::Breadcrumb.new.tap { |b| b.message = i })
end
expect(@breadcrumbs.each).to be_a Enumerator
end
it "evicts when buffer exceeded" do
(0..10).each do |i|
@breadcrumbs.record(Raven::Breadcrumb.new.tap { |b| b.message = i })
end
expect(@breadcrumbs.members[0].message).to eq(1)
expect(@breadcrumbs.members[-1].message).to eq(10)
end
it "converts to a hash" do
expect(@breadcrumbs.peek).to eq(nil)
crumb = Raven::Breadcrumb.new.tap { |b| b.message = "test" }
@breadcrumbs.record(crumb)
expect(@breadcrumbs.to_hash[:values]).to eq([crumb.to_hash])
end
it "clears in a threaded context" do
crumb = Raven::Breadcrumb.new.tap { |b| b.message = "test" }
Raven::BreadcrumbBuffer.current.record(crumb)
Raven::BreadcrumbBuffer.clear!
expect(Raven::BreadcrumbBuffer.current.empty?).to be true
end
end
raven-ruby-2.6.3/spec/raven/cli_spec.rb 0000664 0000000 0000000 00000001747 13142120705 0017773 0 ustar 00root root 0000000 0000000 require 'spec_helper'
require 'raven/cli'
describe "CLI tests" do
let(:configuration) do
Raven::Configuration.new.tap do |config|
config.environments = ["test"]
config.current_environment = "test"
config.silence_ready = true
end
end
it "posting an exception" do
stubs = Faraday::Adapter::Test::Stubs.new do |stub|
stub.post('sentry/api/42/store/') { [200, {}, 'ok'] }
end
configuration.http_adapter = [:test, stubs]
dsn = 'http://12345:67890@sentry.localdomain/sentry/42'
Raven::CLI.test(dsn, true, configuration)
stubs.verify_stubbed_calls
end
it "posting an exception to a prefixed DSN" do
stubs = Faraday::Adapter::Test::Stubs.new do |stub|
stub.post('/prefix/sentry/api/42/store/') { [200, {}, 'ok'] }
end
configuration.http_adapter = [:test, stubs]
dsn = 'http://12345:67890@sentry.localdomain/prefix/sentry/42'
Raven::CLI.test(dsn, true, configuration)
stubs.verify_stubbed_calls
end
end
raven-ruby-2.6.3/spec/raven/client_state_spec.rb 0000664 0000000 0000000 00000002245 13142120705 0021674 0 ustar 00root root 0000000 0000000 require 'spec_helper'
require 'timecop'
describe Raven::ClientState do
let(:state) { Raven::ClientState.new }
it 'should try when online' do
expect(state.should_try?).to eq(true)
end
it 'should not try with a new error' do
state.failure
expect(state.should_try?).to eq(false)
end
it 'should try again after time passes' do
Timecop.freeze(-10) { state.failure }
expect(state.should_try?).to eq(true)
end
it 'should try again after success' do
state.failure
state.success
expect(state.should_try?).to eq(true)
end
it 'should try again after retry_after' do
Timecop.freeze(-2) { state.failure(1) }
expect(state.should_try?).to eq(true)
end
it 'should exponentially backoff' do
Timecop.freeze do
state.failure
Timecop.travel(2)
expect(state.should_try?).to eq(true)
state.failure
Timecop.travel(3)
expect(state.should_try?).to eq(false)
Timecop.travel(2)
expect(state.should_try?).to eq(true)
state.failure
Timecop.travel(8)
expect(state.should_try?).to eq(false)
Timecop.travel(2)
expect(state.should_try?).to eq(true)
end
end
end
raven-ruby-2.6.3/spec/raven/configuration_spec.rb 0000664 0000000 0000000 00000007015 13142120705 0022065 0 ustar 00root root 0000000 0000000 require 'spec_helper'
describe Raven::Configuration do
before do
# Make sure we reset the env in case something leaks in
ENV.delete('SENTRY_DSN')
ENV.delete('RAILS_ENV')
ENV.delete('RACK_ENV')
end
it "should set some attributes when server is set" do
subject.server = "http://12345:67890@sentry.localdomain:3000/sentry/42"
expect(subject.project_id).to eq("42")
expect(subject.public_key).to eq("12345")
expect(subject.secret_key).to eq("67890")
expect(subject.scheme).to eq("http")
expect(subject.host).to eq("sentry.localdomain")
expect(subject.port).to eq(3000)
expect(subject.path).to eq("/sentry")
expect(subject.server).to eq("http://sentry.localdomain:3000/sentry")
end
it "doesnt accept invalid encodings" do
expect { subject.encoding = "apple" }.to raise_error(Raven::Error, 'Unsupported encoding')
end
it "has hashlike attribute accessors" do
expect(subject.encoding).to eq("gzip")
expect(subject[:encoding]).to eq("gzip")
end
context 'configuring for async' do
it 'should be configurable to send events async' do
subject.async = ->(_e) { :ok }
expect(subject.async.call('event')).to eq(:ok)
end
it 'should raise when setting async to anything other than callable or false' do
subject.transport_failure_callback = -> {}
subject.transport_failure_callback = false
expect { subject.async = true }.to raise_error(ArgumentError)
end
end
it 'should raise when setting transport_failure_callback to anything other than callable or false' do
subject.transport_failure_callback = -> {}
subject.transport_failure_callback = false
expect { subject.transport_failure_callback = true }.to raise_error(ArgumentError)
end
it 'should raise when setting should_capture to anything other than callable or false' do
subject.should_capture = -> {}
subject.should_capture = false
expect { subject.should_capture = true }.to raise_error(ArgumentError)
end
context 'being initialized with a current environment' do
before(:each) do
subject.current_environment = 'test'
subject.server = 'http://12345:67890@sentry.localdomain:3000/sentry/42'
end
it 'should send events if test is whitelisted' do
subject.environments = %w(test)
subject.capture_allowed?
puts subject.errors
expect(subject.capture_allowed?).to eq(true)
end
it 'should not send events if test is not whitelisted' do
subject.environments = %w(not_test)
expect(subject.capture_allowed?).to eq(false)
expect(subject.errors).to eq(["Not configured to send/capture in environment 'test'"])
end
end
context 'with a should_capture callback configured' do
before(:each) do
subject.should_capture = ->(exc_or_msg) { exc_or_msg != "dont send me" }
subject.server = 'http://12345:67890@sentry.localdomain:3000/sentry/42'
end
it 'should not send events if should_capture returns false' do
expect(subject.capture_allowed?("dont send me")).to eq(false)
expect(subject.errors).to eq(["should_capture returned false"])
expect(subject.capture_allowed?("send me")).to eq(true)
end
end
context "with an invalid server" do
before(:each) do
subject.server = 'dummy://trololo'
end
it 'captured_allowed returns false' do
expect(subject.capture_allowed?).to eq(false)
expect(subject.errors).to eq(["No public_key specified", "No secret_key specified", "No project_id specified"])
end
end
end
raven-ruby-2.6.3/spec/raven/event_spec.rb 0000664 0000000 0000000 00000054414 13142120705 0020344 0 ustar 00root root 0000000 0000000 require 'spec_helper'
require 'raven/integrations/rack'
describe Raven::Event do
before do
Raven::Context.clear!
Raven::BreadcrumbBuffer.clear!
end
context 'a fully implemented event' do
let(:hash) do
Raven::Event.new(:message => 'test',
:level => 'warning',
:logger => 'foo',
:tags => {
'foo' => 'bar'
},
:extra => {
'my_custom_variable' => 'value'
},
:server_name => 'foo.local',
:release => '721e41770371db95eee98ca2707686226b993eda',
:environment => 'production').to_hash
end
it 'has message' do
expect(hash[:message]).to eq('test')
end
it 'has level' do
expect(hash[:level]).to eq(30)
end
it 'has logger' do
expect(hash[:logger]).to eq('foo')
end
it 'has server name' do
expect(hash[:server_name]).to eq('foo.local')
end
it 'has release' do
expect(hash[:release]).to eq('721e41770371db95eee98ca2707686226b993eda')
end
it 'has environment' do
expect(hash[:environment]).to eq('production')
end
it 'has tag data' do
expect(hash[:tags]).to eq('foo' => 'bar')
end
it 'has extra data' do
expect(hash[:extra]["my_custom_variable"]).to eq('value')
end
it 'has platform' do
expect(hash[:platform]).to eq('ruby')
end
it 'has SDK' do
expect(hash[:sdk]).to eq("name" => "raven-ruby", "version" => Raven::VERSION)
end
it 'has server os' do
expect(hash[:extra][:server][:os].keys).to eq([:name, :version, :build, :kernel_version])
end
it 'has runtime' do
expect(hash[:extra][:server][:runtime][:version]).to match(/ruby/)
end
end
context 'user context specified' do
let(:hash) do
Raven.user_context('id' => 'hello')
Raven::Event.new(:level => 'warning',
:logger => 'foo',
:tags => {
'foo' => 'bar'
},
:extra => {
'my_custom_variable' => 'value'
},
:server_name => 'foo.local').to_hash
end
it "adds user data" do
expect(hash[:user]).to eq('id' => 'hello')
end
end
context 'tags context specified' do
let(:hash) do
Raven.tags_context('key' => 'value')
Raven::Event.new(:level => 'warning',
:logger => 'foo',
:tags => {
'foo' => 'bar'
},
:extra => {
'my_custom_variable' => 'value'
},
:server_name => 'foo.local').to_hash
end
it "merges tags data" do
expect(hash[:tags]).to eq('key' => 'value',
'foo' => 'bar')
end
end
context 'extra context specified' do
let(:hash) do
Raven.extra_context('key' => 'value')
Raven::Event.new(:level => 'warning',
:logger => 'foo',
:tags => {
'foo' => 'bar'
},
:extra => {
'my_custom_variable' => 'value'
},
:server_name => 'foo.local').to_hash
end
it "merges extra data" do
expect(hash[:extra]['key']).to eq('value')
expect(hash[:extra]['my_custom_variable']).to eq('value')
end
end
context 'rack context specified' do
require 'stringio'
let(:hash) do
Raven.rack_context('REQUEST_METHOD' => 'POST',
'QUERY_STRING' => 'biz=baz',
'HTTP_HOST' => 'localhost',
'SERVER_NAME' => 'localhost',
'SERVER_PORT' => '80',
'HTTP_X_FORWARDED_FOR' => '1.1.1.1, 2.2.2.2',
'REMOTE_ADDR' => '192.168.1.1',
'PATH_INFO' => '/lol',
'rack.url_scheme' => 'http',
'rack.input' => StringIO.new('foo=bar'))
Raven::Event.new(:level => 'warning',
:logger => 'foo',
:tags => {
'foo' => 'bar'
},
:extra => {
'my_custom_variable' => 'value'
},
:server_name => 'foo.local').to_hash
end
it "adds http data" do
expect(hash[:request]).to eq(:data => { 'foo' => 'bar' },
:env => { 'SERVER_NAME' => 'localhost', 'SERVER_PORT' => '80', "REMOTE_ADDR" => "192.168.1.1" },
:headers => { 'Host' => 'localhost', "X-Forwarded-For" => "1.1.1.1, 2.2.2.2" },
:method => 'POST',
:query_string => 'biz=baz',
:url => 'http://localhost/lol',
:cookies => nil)
end
it "sets user context ip address correctly" do
expect(hash[:user][:ip_address]).to eq("1.1.1.1")
end
end
context "rack context, long body" do
let(:hash) do
Raven.rack_context('REQUEST_METHOD' => 'GET',
'rack.url_scheme' => 'http',
'rack.input' => StringIO.new('a' * 4096 * 5))
Raven::Event.new.to_hash
end
it "truncates http data" do
expect(hash[:request][:data]).to eq("a" * 4096 * 4)
end
end
context 'configuration tags specified' do
let(:hash) do
config = Raven::Configuration.new
config.tags = { 'key' => 'value' }
config.release = "custom"
config.current_environment = "custom"
Raven::Event.new(
:level => 'warning',
:logger => 'foo',
:tags => {
'foo' => 'bar'
},
:server_name => 'foo.local',
:configuration => config
).to_hash
end
it 'merges tags data' do
expect(hash[:tags]).to eq('key' => 'value',
'foo' => 'bar')
expect(hash[:release]).to eq("custom")
expect(hash[:environment]).to eq("custom")
end
end
context 'configuration tags unspecified' do
it 'should not persist tags between unrelated events' do
config = Raven::Configuration.new
config.logger = Logger.new(nil)
Raven::Event.new(
:level => 'warning',
:logger => 'foo',
:tags => {
'foo' => 'bar'
},
:server_name => 'foo.local',
:configuration => config
)
hash = Raven::Event.new(
:level => 'warning',
:logger => 'foo',
:server_name => 'foo.local',
:configuration => config
).to_hash
expect(hash[:tags]).to eq({})
end
end
context 'tags hierarchy respected' do
let(:hash) do
config = Raven::Configuration.new
config.logger = Logger.new(nil)
config.tags = {
'configuration_context_event_key' => 'configuration_value',
'configuration_context_key' => 'configuration_value',
'configuration_event_key' => 'configuration_value',
'configuration_key' => 'configuration_value'
}
Raven.tags_context('configuration_context_event_key' => 'context_value',
'configuration_context_key' => 'context_value',
'context_event_key' => 'context_value',
'context_key' => 'context_value')
Raven::Event.new(
:level => 'warning',
:logger => 'foo',
:tags => {
'configuration_context_event_key' => 'event_value',
'configuration_event_key' => 'event_value',
'context_event_key' => 'event_value',
'event_key' => 'event_value'
},
:server_name => 'foo.local',
:configuration => config
).to_hash
end
it 'merges tags data' do
expect(hash[:tags]).to eq('configuration_context_event_key' => 'event_value',
'configuration_context_key' => 'context_value',
'configuration_event_key' => 'event_value',
'context_event_key' => 'event_value',
'configuration_key' => 'configuration_value',
'context_key' => 'context_value',
'event_key' => 'event_value')
end
end
context 'merging user context' do
before do
Raven.user_context('context_event_key' => 'context_value',
'context_key' => 'context_value')
end
let(:hash) do
Raven::Event.new(:user => {
'context_event_key' => 'event_value',
'event_key' => 'event_value'
}).to_hash
end
it 'prioritizes event context over request context' do
expect(hash[:user]).to eq('context_event_key' => 'event_value',
'context_key' => 'context_value',
'event_key' => 'event_value')
end
end
context 'merging extra context' do
before do
Raven.extra_context('context_event_key' => 'context_value',
'context_key' => 'context_value')
end
let(:hash) do
Raven::Event.new(:extra => {
'context_event_key' => 'event_value',
'event_key' => 'event_value'
}).to_hash
end
it 'prioritizes event context over request context' do
expect(hash[:extra]['context_event_key']).to eq('event_value')
expect(hash[:extra]['context_key']).to eq('context_value')
expect(hash[:extra]['event_key']).to eq('event_value')
end
end
context 'merging exception context' do
class ExceptionWithContext < StandardError
def raven_context
{ :extra => {
'context_event_key' => 'context_value',
'context_key' => 'context_value'
} }
end
end
let(:hash) do
Raven::Event.from_exception(ExceptionWithContext.new, :extra => {
'context_event_key' => 'event_value',
'event_key' => 'event_value'
}).to_hash
end
it 'prioritizes event context over request context' do
expect(hash[:extra]['context_event_key']).to eq('event_value')
expect(hash[:extra]['context_key']).to eq('context_value')
expect(hash[:extra]['event_key']).to eq('event_value')
end
end
describe '.to_json_compatible' do
subject do
Raven::Event.new(:extra => {
'my_custom_variable' => 'value',
'date' => Time.utc(0),
'anonymous_module' => Class.new
})
end
it "should coerce non-JSON-compatible types" do
json = subject.to_json_compatible
expect(json["extra"]['my_custom_variable']).to eq('value')
expect(json["extra"]['date']).to be_a(String)
expect(json["extra"]['anonymous_module']).not_to be_a(Class)
end
context "with bad data" do
subject do
data = {}
data['data'] = data
data['ary'] = []
data['ary'].push('x' => data['ary'])
data['ary2'] = data['ary']
Raven::Event.new(:extra => {
:invalid => "invalid\255".force_encoding('UTF-8'),
:circular => data
})
end
it "should remove bad UTF-8" do
json = subject.to_json_compatible
expect(json["extra"]["invalid"]).to eq("invalid")
end
it "should remove circular references" do
json = subject.to_json_compatible
expect(json["extra"]["circular"]["ary2"]).to eq("(...)")
end
end
end
describe '.capture_message' do
let(:message) { 'This is a message' }
let(:hash) { Raven::Event.capture_message(message).to_hash }
context 'for a Message' do
it 'returns an event' do
expect(Raven::Event.capture_message(message)).to be_a(Raven::Event)
end
it "sets the message to the value passed" do
expect(hash[:message]).to eq(message)
end
it 'has level ERROR' do
expect(hash[:level]).to eq(40)
end
it 'accepts an options hash' do
expect(Raven::Event.capture_message(message, :logger => 'logger').logger).to eq('logger')
end
it 'accepts a stacktrace' do
backtrace = ["/path/to/some/file:22:in `function_name'",
"/some/other/path:1412:in `other_function'"]
evt = Raven::Event.capture_message(message, :backtrace => backtrace)
expect(evt[:stacktrace]).to be_a(Raven::StacktraceInterface)
frames = evt[:stacktrace].to_hash[:frames]
expect(frames.length).to eq(2)
expect(frames[0][:lineno]).to eq(1412)
expect(frames[0][:function]).to eq('other_function')
expect(frames[0][:filename]).to eq('/some/other/path')
expect(frames[1][:lineno]).to eq(22)
expect(frames[1][:function]).to eq('function_name')
expect(frames[1][:filename]).to eq('/path/to/some/file')
end
end
end
describe '.capture_exception' do
let(:message) { 'This is a message' }
let(:exception) { Exception.new(message) }
let(:hash) { Raven::Event.capture_exception(exception).to_hash }
context 'for an Exception' do
it 'returns an event' do
expect(Raven::Event.capture_exception(exception)).to be_a(Raven::Event)
end
it "sets the message to the exception's message and type" do
expect(hash[:message]).to eq("Exception: #{message}")
end
# sentry uses python's logging values; 40 is the value of logging.ERROR
it 'has level ERROR' do
expect(hash[:level]).to eq(40)
end
it 'uses the exception class name as the exception type' do
expect(hash[:exception][:values][0][:type]).to eq('Exception')
end
it 'uses the exception message as the exception value' do
expect(hash[:exception][:values][0][:value]).to eq(message)
end
it 'does not belong to a module' do
expect(hash[:exception][:values][0][:module]).to eq('')
end
end
context 'for a nested exception type' do
module Raven::Test
class Exception < RuntimeError; end
end
let(:exception) { Raven::Test::Exception.new(message) }
it 'sends the module name as part of the exception info' do
expect(hash[:exception][:values][0][:module]).to eq('Raven::Test')
end
end
context 'for a Raven::Error' do
let(:exception) { Raven::Error.new }
it 'does not create an event' do
expect(Raven::Event.capture_exception(exception)).to be_nil
end
end
context 'for an excluded exception type' do
module Raven::Test
class BaseExc < RuntimeError; end
class SubExc < BaseExc; end
module ExcTag; end
end
let(:config) do
config = Raven::Configuration.new
config.logger = Logger.new(nil)
config
end
context "invalid exclusion type" do
it 'returns Raven::Event' do
config.excluded_exceptions << nil
config.excluded_exceptions << 1
config.excluded_exceptions << {}
expect(Raven::Event.capture_exception(Raven::Test::BaseExc.new,
:configuration => config)).to be_a(Raven::Event)
end
end
context "defined by string type" do
it 'returns nil for a class match' do
config.excluded_exceptions << 'Raven::Test::BaseExc'
expect(Raven::Event.capture_exception(Raven::Test::BaseExc.new,
:configuration => config)).to be_nil
end
it 'returns nil for a top class match' do
config.excluded_exceptions << '::Raven::Test::BaseExc'
expect(Raven::Event.capture_exception(Raven::Test::BaseExc.new,
:configuration => config)).to be_nil
end
it 'returns nil for a sub class match' do
config.excluded_exceptions << 'Raven::Test::BaseExc'
expect(Raven::Event.capture_exception(Raven::Test::SubExc.new,
:configuration => config)).to be_nil
end
it 'returns nil for a tagged class match' do
config.excluded_exceptions << 'Raven::Test::ExcTag'
expect(Raven::Event.capture_exception(Raven::Test::SubExc.new.tap { |x| x.extend(Raven::Test::ExcTag) },
:configuration => config)).to be_nil
end
it 'returns Raven::Event for an undefined exception class' do
config.excluded_exceptions << 'Raven::Test::NonExistentExc'
expect(Raven::Event.capture_exception(Raven::Test::BaseExc.new,
:configuration => config)).to be_a(Raven::Event)
end
end
context "defined by class type" do
it 'returns nil for a class match' do
config.excluded_exceptions << Raven::Test::BaseExc
expect(Raven::Event.capture_exception(Raven::Test::BaseExc.new,
:configuration => config)).to be_nil
end
it 'returns nil for a sub class match' do
config.excluded_exceptions << Raven::Test::BaseExc
expect(Raven::Event.capture_exception(Raven::Test::SubExc.new,
:configuration => config)).to be_nil
end
it 'returns nil for a tagged class match' do
config.excluded_exceptions << Raven::Test::ExcTag
expect(Raven::Event.capture_exception(Raven::Test::SubExc.new.tap { |x| x.extend(Raven::Test::ExcTag) },
:configuration => config)).to be_nil
end
end
end
# Only check causes when they're supported
if Exception.new.respond_to? :cause
context 'when the exception has a cause' do
let(:exception) { build_exception_with_cause }
it 'captures the cause' do
expect(hash[:exception][:values].length).to eq(2)
end
end
context 'when the exception has nested causes' do
let(:exception) { build_exception_with_two_causes }
it 'captures nested causes' do
expect(hash[:exception][:values].length).to eq(3)
end
end
end
context 'when the exception has a recursive cause' do
let(:exception) { build_exception_with_recursive_cause }
it 'should handle it gracefully' do
expect(hash[:exception][:values].length).to eq(1)
end
end
if RUBY_PLATFORM == "java"
context 'when running under jRuby' do
let(:exception) do
begin
raise java.lang.OutOfMemoryError, "A Java error"
rescue Exception => e
return e
end
end
it 'should have a backtrace' do
frames = hash[:exception][:values][0][:stacktrace][:frames]
expect(frames.length).not_to eq(0)
end
end
end
context 'when the exception has a backtrace' do
let(:exception) do
e = Exception.new(message)
allow(e).to receive(:backtrace).and_return [
"/path/to/some/file:22:in `function_name'",
"/some/other/path:1412:in `other_function'"
]
e
end
it 'parses the backtrace' do
frames = hash[:exception][:values][0][:stacktrace][:frames]
expect(frames.length).to eq(2)
expect(frames[0][:lineno]).to eq(1412)
expect(frames[0][:function]).to eq('other_function')
expect(frames[0][:filename]).to eq('/some/other/path')
expect(frames[1][:lineno]).to eq(22)
expect(frames[1][:function]).to eq('function_name')
expect(frames[1][:filename]).to eq('/path/to/some/file')
end
context 'with internal backtrace' do
let(:exception) do
e = Exception.new(message)
allow(e).to receive(:backtrace).and_return([":10:in `synchronize'"])
e
end
it 'marks filename and in_app correctly' do
frames = hash[:exception][:values][0][:stacktrace][:frames]
expect(frames[0][:lineno]).to eq(10)
expect(frames[0][:function]).to eq("synchronize")
expect(frames[0][:filename]).to eq("")
end
end
it "sets the culprit" do
expect(hash[:culprit]).to eq("/path/to/some/file in function_name at line 22")
end
context 'when a path in the stack trace is on the load path' do
before do
$LOAD_PATH << '/some'
end
after do
$LOAD_PATH.delete('/some')
end
it 'strips prefixes in the load path from frame filenames' do
frames = hash[:exception][:values][0][:stacktrace][:frames]
expect(frames[0][:filename]).to eq('other/path')
end
end
end
describe "#get_file_context" do
it "delegates to the linecache" do
expect(subject.linecache).to receive(:get_file_context)
subject.get_file_context("this", 2, 10)
end
end
it 'accepts an options hash' do
expect(Raven::Event.capture_exception(exception, :logger => 'logger').logger).to eq('logger')
end
it 'uses an annotation if one exists' do
Raven.annotate_exception(exception, :logger => 'logger')
expect(Raven::Event.capture_exception(exception).logger).to eq('logger')
end
it 'accepts a checksum' do
expect(Raven::Event.capture_exception(exception, :checksum => 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa').checksum).to eq('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
end
it 'accepts a release' do
expect(Raven::Event.capture_exception(exception, :release => '1.0').release).to eq('1.0')
end
it 'accepts a fingerprint' do
expect(Raven::Event.capture_exception(exception, :fingerprint => ['{{ default }}', 'foo']).fingerprint).to eq(['{{ default }}', 'foo'])
end
it 'accepts a logger' do
expect(Raven::Event.capture_exception(exception, :logger => 'root').logger).to eq('root')
end
end
end
raven-ruby-2.6.3/spec/raven/instance_spec.rb 0000664 0000000 0000000 00000017346 13142120705 0021032 0 ustar 00root root 0000000 0000000 require 'spec_helper'
require 'raven/instance'
describe Raven::Instance do
let(:event) { Raven::Event.new(:id => "event_id") }
let(:options) { { :key => "value" } }
let(:context) { nil }
let(:configuration) do
config = Raven::Configuration.new
config.dsn = "dummy://12345:67890@sentry.localdomain:3000/sentry/42"
config.logger = Logger.new(nil)
config
end
subject { described_class.new(context, configuration) }
before do
allow(subject).to receive(:send_event)
allow(Raven::Event).to receive(:from_message) { event }
allow(Raven::Event).to receive(:from_exception) { event }
end
describe '#context' do
it 'is Raven.context by default' do
expect(subject.context).to equal(Raven.context)
end
context 'initialized with a context' do
let(:context) { :explicit }
it 'is not Raven.context' do
expect(subject.context).to_not equal(Raven.context)
end
end
end
describe '#capture_type' do
describe 'as #capture_message' do
let(:message) { "Test message" }
it 'sends the result of Event.capture_message' do
expect(Raven::Event).to receive(:from_message).with(message, options)
expect(subject).to receive(:send_event).with(event)
subject.capture_type(message, options)
end
it 'has an alias' do
expect(Raven::Event).to receive(:from_message).with(message, options)
expect(subject).to receive(:send_event).with(event)
subject.capture_message(message, options)
end
it 'yields the event to a passed block' do
expect { |b| subject.capture_type(message, options, &b) }.to yield_with_args(event)
end
end
describe 'as #capture_message when async' do
let(:message) { "Test message" }
around do |example|
prior_async = subject.configuration.async
subject.configuration.async = proc { :ok }
example.run
subject.configuration.async = prior_async
end
it 'sends the result of Event.capture_type' do
expect(Raven::Event).to receive(:from_message).with(message, options)
expect(subject).not_to receive(:send_event).with(event)
expect(subject.configuration.async).to receive(:call).with(event.to_json_compatible)
subject.capture_type(message, options)
end
it 'returns the generated event' do
returned = subject.capture_type(message, options)
expect(returned).to eq(event)
end
end
describe 'as #capture_exception' do
let(:exception) { build_exception }
it 'sends the result of Event.capture_exception' do
expect(Raven::Event).to receive(:from_exception).with(exception, options)
expect(subject).to receive(:send_event).with(event)
subject.capture_type(exception, options)
end
it 'has an alias' do
expect(Raven::Event).to receive(:from_exception).with(exception, options)
expect(subject).to receive(:send_event).with(event)
subject.capture_exception(exception, options)
end
it 'yields the event to a passed block' do
expect { |b| subject.capture_type(exception, options, &b) }.to yield_with_args(event)
end
end
describe 'as #capture_exception when async' do
let(:exception) { build_exception }
context "when correctly configured" do
around do |example|
prior_async = subject.configuration.async
subject.configuration.async = proc { :ok }
example.run
subject.configuration.async = prior_async
end
it 'sends the result of Event.capture_exception' do
expect(Raven::Event).to receive(:from_exception).with(exception, options)
expect(subject).not_to receive(:send_event).with(event)
expect(subject.configuration.async).to receive(:call).with(event.to_json_compatible)
subject.capture_type(exception, options)
end
it 'returns the generated event' do
returned = subject.capture_type(exception, options)
expect(returned).to eq(event)
end
end
context "when async raises an exception" do
around do |example|
prior_async = subject.configuration.async
subject.configuration.async = proc { raise TypeError }
example.run
subject.configuration.async = prior_async
end
it 'sends the result of Event.capture_exception via fallback' do
expect(Raven::Event).to receive(:from_exception).with(exception, options)
expect(subject.configuration.async).to receive(:call).with(event.to_json_compatible)
subject.capture_type(exception, options)
end
end
end
describe 'as #capture_exception with a should_capture callback' do
let(:exception) { build_exception }
it 'sends the result of Event.capture_exception according to the result of should_capture' do
expect(subject).not_to receive(:send_event).with(event)
subject.configuration.should_capture = proc { false }
expect(subject.configuration.should_capture).to receive(:call).with(exception)
expect(subject.capture_type(exception, options)).to be false
end
end
end
describe '#capture' do
context 'given a block' do
it 'yields to the given block' do
expect { |b| subject.capture(&b) }.to yield_with_no_args
end
end
it 'does not install an at_exit hook' do
expect(Kernel).not_to receive(:at_exit)
subject.capture {}
end
end
describe '#annotate_exception' do
let(:exception) { build_exception }
def ivars(object)
object.instance_variables.map(&:to_s)
end
it 'adds an annotation to the exception' do
expect(ivars(exception)).not_to include("@__raven_context")
subject.annotate_exception(exception, {})
expect(ivars(exception)).to include("@__raven_context")
expect(exception.instance_variable_get(:@__raven_context)).to \
be_kind_of Hash
end
end
describe '#report_status' do
let(:ready_message) do
"Raven #{Raven::VERSION} ready to catch errors"
end
let(:not_ready_message) do
"Raven #{Raven::VERSION} configured not to capture errors."
end
it 'logs a ready message when configured' do
subject.configuration.silence_ready = false
expect(subject.logger).to receive(:info).with(ready_message)
subject.report_status
end
it 'logs not ready message if the config does not send in current environment' do
subject.configuration.silence_ready = false
subject.configuration.environments = ["production"]
expect(subject.logger).to receive(:info).with(
"Raven #{Raven::VERSION} configured not to capture errors: Not configured to send/capture in environment 'default'"
)
subject.report_status
end
it 'logs nothing if "silence_ready" configuration is true' do
subject.configuration.silence_ready = true
expect(subject.logger).not_to receive(:info)
subject.report_status
end
end
describe '.last_event_id' do
let(:message) { "Test message" }
it 'sends the result of Event.capture_type' do
expect(subject).to receive(:send_event).with(event)
subject.capture_type("Test message", options)
expect(subject.last_event_id).to eq(event.id)
end
it 'yields the event to a passed block' do
expect { |b| subject.capture_type(message, options, &b) }.to yield_with_args(event)
end
end
describe "#rack_context" do
it "doesn't set anything if the context is empty" do
subject.rack_context({})
expect(subject.context.rack_env).to be_nil
end
it "sets arbitrary rack context" do
subject.rack_context(:foo => :bar)
expect(subject.context.rack_env[:foo]).to eq(:bar)
end
end
end
raven-ruby-2.6.3/spec/raven/integration_spec.rb 0000664 0000000 0000000 00000004011 13142120705 0021532 0 ustar 00root root 0000000 0000000 require 'spec_helper'
describe "Integration tests" do
before(:each) do
@io = StringIO.new
@logger = Logger.new(@io)
@instance = Raven::Instance.new
@stubs = Faraday::Adapter::Test::Stubs.new
@instance.configuration = Raven::Configuration.new.tap do |config|
config.server = 'http://12345:67890@sentry.localdomain/sentry/42'
config.http_adapter = [:test, @stubs]
config.logger = @logger
end
end
it "posting an exception" do
@stubs.post('sentry/api/42/store/') { [200, {}, 'ok'] }
@instance.capture_exception(build_exception)
@stubs.verify_stubbed_calls
expect(@io.string).to match(/Sending event [0-9a-f]+ to Sentry$/)
end
it "posting an exception to a prefixed DSN" do
@stubs.post('/prefix/sentry/api/42/store/') { [200, {}, 'ok'] }
@instance.configuration.server = 'http://12345:67890@sentry.localdomain/prefix/sentry/42'
@instance.capture_exception(build_exception)
@stubs.verify_stubbed_calls
end
it "hitting quota limit shouldn't swallow exception" do
@stubs.post('sentry/api/42/store/') { [403, {}, 'Creation of this event was blocked'] }
# sentry error and original error
expect(@logger).not_to receive(:error).twice
@instance.capture_exception(build_exception)
@stubs.verify_stubbed_calls
end
it "timed backoff should prevent sends" do
expect(@instance.client.transport).to receive(:send_event).exactly(1).times.and_raise(Faraday::Error::ConnectionFailed, "conn failed")
2.times { @instance.capture_exception(build_exception) }
expect(@io.string).to match(/Failed to submit event: ZeroDivisionError: divided by 0$/)
end
it "transport failure should call transport_failure_callback" do
@instance.configuration.transport_failure_callback = proc { |_e| @io.puts "OK!" }
expect(@instance.client.transport).to receive(:send_event).exactly(1).times.and_raise(Faraday::Error::ConnectionFailed, "conn failed")
@instance.capture_exception(build_exception)
expect(@io.string).to match(/OK!$/)
end
end
raven-ruby-2.6.3/spec/raven/integrations/ 0000775 0000000 0000000 00000000000 13142120705 0020362 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/spec/raven/integrations/rack_spec.rb 0000664 0000000 0000000 00000005710 13142120705 0022644 0 ustar 00root root 0000000 0000000 require 'spec_helper'
require 'raven/integrations/rack'
describe Raven::Rack do
it 'should capture exceptions' do
exception = build_exception
env = {}
expect(Raven::Rack).to receive(:capture_exception).with(exception, env)
app = ->(_e) { raise exception }
stack = Raven::Rack.new(app)
expect { stack.call(env) }.to raise_error(ZeroDivisionError)
end
it 'should capture rack.exception' do
exception = build_exception
env = {}
expect(Raven::Rack).to receive(:capture_exception).with(exception, env)
app = lambda do |e|
e['rack.exception'] = exception
[200, {}, ['okay']]
end
stack = Raven::Rack.new(app)
stack.call(env)
end
it 'should capture sinatra errors' do
exception = build_exception
env = {}
expect(Raven::Rack).to receive(:capture_exception).with(exception, env)
app = lambda do |e|
e['sinatra.error'] = exception
[200, {}, ['okay']]
end
stack = Raven::Rack.new(app)
stack.call(env)
end
it 'should clear context after app is called' do
Raven::Context.current.tags[:environment] = :test
app = ->(env) { ['response', {}, env] }
stack = Raven::Rack.new(app)
stack.call({})
expect(Raven::Context.current.tags).to eq({})
end
it 'should allow empty rack env in rspec tests' do
env = {} # the rack env is empty when running rails/rspec tests
Raven.rack_context(env)
Raven.capture_exception(build_exception)
end
it 'should bind request context' do
Raven::Context.current.rack_env = nil
app = lambda do |env|
expect(Raven::Context.current.rack_env).to eq(env)
['response', {}, env]
end
stack = Raven::Rack.new(app)
env = { :foo => :bar }
stack.call(env)
end
it 'transforms headers to conform with the interface' do
env = { "SERVER_PROTOCOL" => "HTTP/1.1", "HTTP_FOO" => "BAR", "HTTP_VERSION" => "HTTP/1.1" }
interface = Raven::HttpInterface.new
interface.from_rack(env)
expect(interface.headers["Foo"]).to eq("BAR")
expect(interface.headers["Version"]).to be_nil
end
it 'does not ignore version headers which do not match SERVER_PROTOCOL' do
env = { "SERVER_PROTOCOL" => "HTTP/1.1", "HTTP_VERSION" => "HTTP/2.0" }
interface = Raven::HttpInterface.new
interface.from_rack(env)
expect(interface.headers["Version"]).to eq("HTTP/2.0")
end
it 'does not fail if an object in the env cannot be cast to string' do
obj = Class.new do
def to_s
raise 'Could not stringify object!'
end
end.new
env = { "HTTP_FOO" => "BAR", "rails_object" => obj }
interface = Raven::HttpInterface.new
expect { interface.from_rack(env) }.to_not raise_error
end
it 'should pass rack/lint' do
env = Rack::MockRequest.env_for("/test")
app = proc do
[200, { 'Content-Type' => 'text/plain' }, ['OK']]
end
stack = Raven::Rack.new(Rack::Lint.new(app))
expect { stack.call(env) }.to_not raise_error
end
end
raven-ruby-2.6.3/spec/raven/integrations/rails/ 0000775 0000000 0000000 00000000000 13142120705 0021474 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/spec/raven/integrations/rails/activejob_spec.rb 0000664 0000000 0000000 00000004010 13142120705 0024774 0 ustar 00root root 0000000 0000000 require "spec_helper"
if defined? ActiveJob
class MyActiveJob < ActiveJob::Base
self.queue_adapter = :inline
self.logger = nil
class TestError < RuntimeError
end
def perform
raise TestError, "Boom!"
end
end
class RescuedActiveJob < MyActiveJob
rescue_from TestError, :with => :rescue_callback
def rescue_callback(error)
end
end
end
describe "ActiveJob integration", :rails => true do
before(:all) do
require "rspec/rails"
require "raven/integrations/rails"
require "raven/integrations/rails/active_job"
end
before(:each) do
Raven.client.transport.events = []
end
it "captures exceptions" do
job = MyActiveJob.new
expect { job.perform_now }.to raise_error(MyActiveJob::TestError)
expect(Raven.client.transport.events.size).to eq(1)
end
it "clears context" do
Raven.extra_context(:foo => :bar)
job = MyActiveJob.new
expect { job.perform_now }.to raise_error(MyActiveJob::TestError)
event = JSON.parse!(Raven.client.transport.events.first[1])
expect(event["extra"]["foo"]).to eq("bar")
Raven.client.transport.events = []
expect { job.perform_now }.to raise_error(MyActiveJob::TestError)
event = JSON.parse!(Raven.client.transport.events.first[1])
expect(event["extra"]["foo"]).to eq(nil)
end
context 'using rescue_from' do
it 'does not trigger Sentry' do
job = RescuedActiveJob.new
allow(job).to receive(:rescue_callback)
expect { job.perform_now }.not_to raise_error
expect(Raven.client.transport.events.size).to eq(0)
expect(job).to have_received(:rescue_callback).once
end
end
context "when we are using an adapter which has a specific integration" do
it "does not trigger sentry and re-raises" do
job = MyActiveJob.new
def job.already_supported_by_specific_integration?(*)
true
end
expect { job.perform_now }.to raise_error(MyActiveJob::TestError)
expect(Raven.client.transport.events.size).to eq(0)
end
end
end
raven-ruby-2.6.3/spec/raven/integrations/rails/controller_methods_spec.rb 0000664 0000000 0000000 00000001626 13142120705 0026746 0 ustar 00root root 0000000 0000000 require 'spec_helper'
describe "Raven::Rails::ControllerMethods", :rails => true do
include Raven::Rails::ControllerMethods if defined?(Rails)
before(:all) do
require 'raven/integrations/rails/controller_methods'
end
let(:env) { { "foo" => "bar" } }
let(:request) { double('request', :env => env) }
let(:options) { double('options') }
describe "#capture_message" do
let(:message) { double('message') }
it "captures a message with the request environment" do
expect(Raven::Rack).to receive(:capture_message).with(message, env, options)
capture_message(message, options)
end
end
describe "#capture_exception" do
let(:exception) { double('exception') }
it "captures a exception with the request environment" do
expect(Raven::Rack).to receive(:capture_exception).with(exception, env, options)
capture_exception(exception, options)
end
end
end
raven-ruby-2.6.3/spec/raven/integrations/rails/event_spec.rb 0000664 0000000 0000000 00000005566 13142120705 0024170 0 ustar 00root root 0000000 0000000 require 'spec_helper'
describe Raven::Event, :rails => true do
context 'in a rails environment' do
before do
Raven.configure do |config|
config.project_root ||= ::Rails.root
end
end
context 'with an application stacktrace' do
let(:exception) do
e = Exception.new("Oh no!")
allow(e).to receive(:backtrace).and_return [
"#{Rails.root}/vendor/bundle/cache/other_gem.rb:10:in `public_method'",
"vendor/bundle/some_gem.rb:10:in `a_method'",
"#{Rails.root}/app/models/user.rb:132:in `new_function'",
"/gem/lib/path:87:in `a_function'",
"/app/some/other/path:1412:in `other_function'",
"test/some/other/path:1412:in `other_function'"
]
e
end
let(:hash) { Raven::Event.capture_exception(exception).to_hash }
it 'marks in_app correctly' do
frames = hash[:exception][:values][0][:stacktrace][:frames]
expect(frames[0][:filename]).to eq("test/some/other/path")
expect(frames[0][:in_app]).to eq(true)
expect(frames[1][:filename]).to eq("/app/some/other/path")
expect(frames[1][:in_app]).to eq(false)
expect(frames[2][:filename]).to eq("/gem/lib/path")
expect(frames[2][:in_app]).to eq(false)
expect(frames[3][:filename]).to eq("app/models/user.rb")
expect(frames[3][:in_app]).to eq(true)
expect(frames[4][:filename]).to eq("vendor/bundle/some_gem.rb")
expect(frames[4][:in_app]).to eq(false)
expect(frames[5][:filename]).to eq("vendor/bundle/cache/other_gem.rb")
expect(frames[5][:in_app]).to eq(false)
end
context 'when an in_app path under project_root is on the load path' do
before do
$LOAD_PATH << "#{Rails.root}/app/models"
end
after do
$LOAD_PATH.delete("#{Rails.root}/app/models")
end
it 'normalizes the filename using project_root' do
frames = hash[:exception][:values][0][:stacktrace][:frames]
expect(frames[3][:filename]).to eq("app/models/user.rb")
end
end
context 'when a non-in_app path under project_root is on the load path' do
before do
$LOAD_PATH << "#{Rails.root}/vendor/bundle"
end
after do
$LOAD_PATH.delete("#{Rails.root}/vendor/bundle")
end
it 'normalizes the filename using the load path' do
frames = hash[:exception][:values][0][:stacktrace][:frames]
expect(frames[5][:filename]).to eq("cache/other_gem.rb")
end
end
context "when a non-in_app path under project_root isn't on the load path" do
it 'normalizes the filename using project_root' do
frames = hash[:exception][:values][0][:stacktrace][:frames]
expect(frames[5][:filename]).to eq("vendor/bundle/cache/other_gem.rb")
end
end
end
end
end
raven-ruby-2.6.3/spec/raven/integrations/rails/overrides/ 0000775 0000000 0000000 00000000000 13142120705 0023476 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/spec/raven/integrations/rails/overrides/debug_exceptions_catcher_spec.rb 0000664 0000000 0000000 00000004060 13142120705 0032055 0 ustar 00root root 0000000 0000000 require 'spec_helper'
describe "Raven::Rails::Overrides::DebugExceptionsCatcher", :rails => true do
before(:all) do
require 'raven/integrations/rails/overrides/debug_exceptions_catcher'
end
let(:middleware) do
Class.new do
def initialize(app)
@app = app
end
def call(env)
@app.call(env)
rescue => e
render_exception(env, e)
end
def render_exception(_, exception)
[500, exception.message, {}]
end
end
end
let(:app) do
lambda { |_| raise "app error" } # rubocop:disable Style/Lambda
end
let(:env) { {} }
if defined?(Rails) && Rails.version < "5.1.0"
context "using include" do
before do
middleware.send(:include, Raven::Rails::Overrides::OldDebugExceptionsCatcher)
end
it "shows the exception" do
expect(middleware.new(app).call(env)).to eq([500, "app error", {}])
end
it "captures the exception" do
expect(Raven::Rack).to receive(:capture_exception)
middleware.new(app).call(env)
end
context "when an error is raised" do
it "shows the original exception" do
allow(Raven::Rack).to receive(:capture_exception).and_raise("raven error")
expect(middleware.new(app).call(env)).to eq([500, "app error", {}])
end
end
end
end
context "using prepend" do
before do
skip "prepend not available" unless middleware.respond_to?(:prepend, true)
middleware.send(:prepend, Raven::Rails::Overrides::DebugExceptionsCatcher)
end
it "shows the exception" do
expect(middleware.new(app).call(env)).to eq([500, "app error", {}])
end
it "captures the exception" do
expect(Raven::Rack).to receive(:capture_exception)
middleware.new(app).call(env)
end
context "when an error is raised" do
it "shows the original exception" do
allow(Raven::Rack).to receive(:capture_exception).and_raise("raven error")
expect(middleware.new(app).call(env)).to eq([500, "app error", {}])
end
end
end
end
raven-ruby-2.6.3/spec/raven/integrations/rails_spec.rb 0000664 0000000 0000000 00000002336 13142120705 0023037 0 ustar 00root root 0000000 0000000 require "spec_helper"
describe "Rails Integration", :type => :request, :rails => true do
before(:all) do
require "rspec/rails"
require "raven/integrations/rack"
require "raven/integrations/rails"
Rails.logger = Logger.new(nil)
Rails.env = "production"
TestApp.initialize!
end
after(:each) do
Raven.client.transport.events = []
end
it "inserts middleware" do
expect(TestApp.middleware).to include(Raven::Rack)
end
it "should capture exceptions in production" do
get "/exception"
expect(response.status).to eq(500)
expect(Raven.client.transport.events.size).to eq(1)
end
it "should properly set the exception's URL" do
get "/exception"
event = Raven.client.transport.events.first
event = JSON.parse!(event[1])
expect(event['request']['url']).to eq("http://www.example.com/exception")
end
it "sets Raven.configuration.logger correctly" do
expect(Raven.configuration.logger).to eq(Rails.logger)
end
it "sets Raven.configuration.project_root correctly" do
expect(Raven.configuration.project_root).to eq(Rails.root.to_s)
end
it "doesn't clobber a manually configured release" do
expect(Raven.configuration.release).to eq('beta')
end
end
raven-ruby-2.6.3/spec/raven/integrations/rake_spec.rb 0000664 0000000 0000000 00000000567 13142120705 0022653 0 ustar 00root root 0000000 0000000 require 'spec_helper'
describe 'Rake tasks' do
it 'should bundle a CLI task which captures exceptions' do
expect(Raven::CLI.test("dummy://12345:67890@sentry.localdomain:3000/sentry/42", true)).to be true
end
it "should capture exceptions in Rake tasks" do
expect(`cd spec/support && bundle exec rake raise_exception 2>&1`).to match(/Sending event/)
end
end
raven-ruby-2.6.3/spec/raven/integrations/sidekiq_spec.rb 0000664 0000000 0000000 00000007533 13142120705 0023362 0 ustar 00root root 0000000 0000000 if RUBY_VERSION > '2.0'
require 'spec_helper'
require 'raven/integrations/sidekiq'
require 'sidekiq/processor'
describe "Raven::SidekiqErrorHandler" do
let(:context) do
{
"args" => [true, true],
"class" => "HardWorker",
"created_at" => 1_474_922_824.910579,
"enqueued_at" => 1_474_922_824.910665,
"error_class" => "RuntimeError",
"error_message" => "a wild exception appeared",
"failed_at" => 1_474_922_825.158953,
"jid" => "701ed9cfa51c84a763d56bc4",
"queue" => "default",
"retry" => true,
"retry_count" => 0
}
end
it "should capture exceptions based on Sidekiq context" do
exception = build_exception
expected_options = {
:message => exception.message,
:extra => { :sidekiq => context },
:culprit => "Sidekiq/HardWorker"
}
expect(Raven).to receive(:capture_exception).with(exception, expected_options)
Raven::SidekiqErrorHandler.new.call(exception, context)
end
it "filters out ActiveJob keys" do
exception = build_exception
aj_context = context
aj_context["_aj_globalid"] = "oh noes"
expected_context = aj_context
expected_context.delete("_aj_globalid")
expected_context["_globalid"] = "oh noes"
expected_options = {
:message => exception.message,
:extra => { :sidekiq => expected_context },
:culprit => "Sidekiq/HardWorker"
}
expect(Raven).to receive(:capture_exception).with(exception, expected_options)
Raven::SidekiqErrorHandler.new.call(exception, aj_context)
end
end
class HappyWorker
include Sidekiq::Worker
def perform
Raven.breadcrumbs.record do |crumb|
crumb.message = "I'm happy!"
end
Raven.tags_context :mood => 'happy'
end
end
class SadWorker
include Sidekiq::Worker
def perform
Raven.breadcrumbs.record do |crumb|
crumb.message = "I'm sad!"
end
Raven.tags_context :mood => 'sad'
raise "I'm sad!"
end
end
class VerySadWorker
include Sidekiq::Worker
def perform
Raven.breadcrumbs.record do |crumb|
crumb.message = "I'm very sad!"
end
Raven.tags_context :mood => 'very sad'
raise "I'm very sad!"
end
end
describe "Sidekiq full-stack integration" do
before(:all) do
Sidekiq.error_handlers << Raven::SidekiqErrorHandler.new
Sidekiq.server_middleware do |chain|
chain.add Raven::SidekiqCleanupMiddleware
end
Sidekiq.logger = Logger.new(nil)
end
before do
@mgr = double('manager')
allow(@mgr).to receive(:options).and_return(:queues => ['default'])
@processor = ::Sidekiq::Processor.new(@mgr)
end
def process_job(klass)
msg = Sidekiq.dump_json("class" => klass)
job = Sidekiq::BasicFetch::UnitOfWork.new('queue:default', msg)
@processor.instance_variable_set(:'@job', job)
@processor.send(:process, job)
rescue # rubocop:disable Lint/HandleExceptions
# do nothing
end
it "actually captures an exception" do
expect { process_job("SadWorker") }.to change { Raven.client.transport.events.size }.by(1)
end
it "clears context from other workers and captures its own" do
process_job("HappyWorker")
process_job("SadWorker")
event = JSON.parse(Raven.client.transport.events.last[1])
expect(event["tags"]).to eq("mood" => "sad")
expect(event["breadcrumbs"]["values"][0]["message"]).to eq("I'm sad!")
end
it "clears context after raising" do
process_job("SadWorker")
process_job("VerySadWorker")
event = JSON.parse(Raven.client.transport.events.last[1])
expect(event["tags"]).to eq("mood" => "very sad")
expect(event["breadcrumbs"]["values"][0]["message"]).to eq("I'm very sad!")
end
end
end
raven-ruby-2.6.3/spec/raven/interface_spec.rb 0000664 0000000 0000000 00000002270 13142120705 0021154 0 ustar 00root root 0000000 0000000 require 'spec_helper'
class TestInterface < Raven::Interface
attr_accessor :some_attr
end
describe Raven::Interface do
it "should register an interface when a new class is defined" do
expect(Raven::Interface.registered[:test]).to eq(TestInterface)
end
it "can be initialized with some attributes" do
interface = TestInterface.new(:some_attr => "test")
expect(interface.some_attr).to eq("test")
end
it "can initialize with a block" do
interface = TestInterface.new { |int| int.some_attr = "test" }
expect(interface.some_attr).to eq("test")
end
it "serializes to a Hash" do
interface = TestInterface.new(:some_attr => "test")
expect(interface.to_hash).to eq(:some_attr => "test")
end
end
describe Raven::MessageInterface do
it "supports invalid format string message when params is not defined" do
interface = Raven::MessageInterface.new(:params => nil, :message => "test '%'")
expect(interface.unformatted_message).to eq("test '%'")
end
it "supports invalid format string message when params is empty" do
interface = Raven::MessageInterface.new(:message => "test '%'")
expect(interface.unformatted_message).to eq("test '%'")
end
end
raven-ruby-2.6.3/spec/raven/interfaces/ 0000775 0000000 0000000 00000000000 13142120705 0017777 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/spec/raven/interfaces/stack_trace_spec.rb 0000664 0000000 0000000 00000000550 13142120705 0023621 0 ustar 00root root 0000000 0000000 require 'spec_helper'
describe Raven::StacktraceInterface::Frame do
it "should convert pathnames to strings" do
frame = Raven::StacktraceInterface::Frame.new
$LOAD_PATH.unshift Pathname.pwd # Oh no, a Pathname in the $LOAD_PATH!
frame.abs_path = __FILE__
expect(frame.filename).to match(/stack_trace_spec.rb/)
$LOAD_PATH.shift
end
end
raven-ruby-2.6.3/spec/raven/json_spec.rb 0000664 0000000 0000000 00000004723 13142120705 0020172 0 ustar 00root root 0000000 0000000 # Raven sometimes has to deal with some weird JSON. This makes sure whatever
# JSON impl we use handles it in the way that we expect.
require 'spec_helper'
describe JSON do
data = [
OpenStruct.new(:key => 'foo', :val => 'bar', :enc_key => '"foo"', :enc_val => '"bar"'),
OpenStruct.new(:key => :foo, :val => :bar, :enc_key => '"foo"', :enc_val => '"bar"'),
OpenStruct.new(:key => 1, :val => 1, :enc_key => '"1"', :enc_val => '1')
]
data.each do |obj|
it "works with #{obj.key.class} keys" do
expect(JSON.dump(obj.key => 'bar')).to eq "{#{obj.enc_key}:\"bar\"}"
end
it "works with #{obj.val.class} values" do
expect(JSON.dump('bar' => obj.val)).to eq "{\"bar\":#{obj.enc_val}}"
end
it "works with an array of #{obj.val.class}s" do
expect(JSON.dump('bar' => [obj.val])).to eq "{\"bar\":[#{obj.enc_val}]}"
end
it "works with a hash of #{obj.val.class}s" do
expect(JSON.dump('bar' => { obj.key => obj.val })).to eq "{\"bar\":{#{obj.enc_key}:#{obj.enc_val}}}"
end
end
it 'encodes anything that responds to to_s' do
data = [
:symbol,
1 / 0.0,
0 / 0.0
]
expect(JSON.dump(data)).to eq "[\"symbol\",Infinity,NaN]"
end
it 'resolves large numbers to Infinity' do
expect(JSON.parse("[123e090000000]")).to eq [+1.0 / 0.0]
end
if RUBY_VERSION.to_f >= 2.0 # 1.9 just hangs on this.
it 'it raises the correct error on strings that look like incomplete objects' do
expect { JSON.parse("{") }.to raise_error(JSON::ParserError)
expect { JSON.parse("[") }.to raise_error(JSON::ParserError)
end
it "accepts any encoding which is internally valid" do
expect do
JSON.parse(%({"example": "this is a utf8 or ASCII string"}))
end.not_to raise_error
expect do
JSON.parse(%({"example": "this is a utf8 or ASCII string"}).encode("utf-16"))
end.not_to raise_error
expect do
JSON.parse(%({"example": "this is a utf8 or ASCII string"}).encode("US-ASCII"))
end.not_to raise_error
end
it "blows up on circular references" do
data = {}
data['data'] = data
data['ary'] = []
data['ary'].push('x' => data['ary'])
data['ary2'] = data['ary']
data['leave intact'] = { 'not a circular reference' => true }
if RUBY_PLATFORM == 'java'
expect { JSON.dump(data) }.to raise_error
else
expect { JSON.dump(data) }.to raise_error(SystemStackError)
end
end
end
end
raven-ruby-2.6.3/spec/raven/linecache_spec.rb 0000664 0000000 0000000 00000002063 13142120705 0021127 0 ustar 00root root 0000000 0000000 require 'spec_helper'
# rubocop:disable Style/WordArray
describe Raven::LineCache do
describe "#get_file_context" do
it "returns an array of nils if the path is not valid" do
expect(subject.get_file_context("/nonexist", 1, 10)).to eq([nil, nil, nil])
end
it "returns a variable size depending on context" do
expect(subject.get_file_context("spec/support/linecache.txt", 3, 2)).to eq(
[
["foo\n", "bar\n"],
"baz\n",
["qux\n", "lorem\n"]
]
)
end
it "returns nil if line doesnt exist" do
expect(subject.get_file_context("spec/support/linecache.txt", 1, 2)).to eq(
[
[nil, nil],
"foo\n",
["bar\n", "baz\n"]
]
)
end
it "returns a different section of the file based on lineno" do
expect(subject.get_file_context("./spec/support/linecache.txt", 4, 2)).to eq(
[
["bar\n", "baz\n"],
"qux\n",
["lorem\n", "ipsum\n"]
]
)
end
end
end
# rubocop:enable Style/WordArray
raven-ruby-2.6.3/spec/raven/logger_spec.rb 0000664 0000000 0000000 00000000416 13142120705 0020473 0 ustar 00root root 0000000 0000000 require 'spec_helper'
describe Raven::Logger do
it "should log to a given IO" do
stringio = StringIO.new
log = Raven::Logger.new(stringio)
log.fatal("Oh noes!")
expect(stringio.string).to end_with("FATAL -- sentry: ** [Raven] Oh noes!\n")
end
end
raven-ruby-2.6.3/spec/raven/processors/ 0000775 0000000 0000000 00000000000 13142120705 0020056 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/spec/raven/processors/cookies_spec.rb 0000664 0000000 0000000 00000002740 13142120705 0023054 0 ustar 00root root 0000000 0000000 # Encoding: utf-8
require 'spec_helper'
describe Raven::Processor::Cookies do
before do
@client = double("client")
@processor = Raven::Processor::Cookies.new(@client)
end
it 'should remove cookies' do
test_data = {
:request => {
:headers => {
"Cookie" => "_sentry-testapp_session=SlRKVnNha2Z",
"AnotherHeader" => "still_here"
},
:cookies => "_sentry-testapp_session=SlRKVnNha2Z",
:some_other_data => "still_here"
}
}
result = @processor.process(test_data)
expect(result[:request][:cookies]).to eq("********")
expect(result[:request][:headers]["Cookie"]).to eq("********")
expect(result[:request][:some_other_data]).to eq("still_here")
expect(result[:request][:headers]["AnotherHeader"]).to eq("still_here")
end
it 'should remove cookies even if keys are strings' do
test_data = {
"request" => {
"headers" => {
"Cookie" => "_sentry-testapp_session=SlRKVnNha2Z",
"AnotherHeader" => "still_here"
},
"cookies" => "_sentry-testapp_session=SlRKVnNha2Z",
"some_other_data" => "still_here"
}
}
result = @processor.process(test_data)
expect(result["request"]["cookies"]).to eq("********")
expect(result["request"]["headers"]["Cookie"]).to eq("********")
expect(result["request"]["some_other_data"]).to eq("still_here")
expect(result["request"]["headers"]["AnotherHeader"]).to eq("still_here")
end
end
raven-ruby-2.6.3/spec/raven/processors/http_headers_spec.rb 0000664 0000000 0000000 00000002774 13142120705 0024101 0 ustar 00root root 0000000 0000000 require 'spec_helper'
describe Raven::Processor::HTTPHeaders do
before do
@client = double("client")
allow(@client).to receive_message_chain(:configuration, :sanitize_http_headers) { ['User-Defined-Header'] }
@processor = Raven::Processor::HTTPHeaders.new(@client)
end
it 'should remove HTTP headers we dont like' do
data = {
:request => {
:headers => {
"Authorization" => "dontseeme",
"AnotherHeader" => "still_here"
}
}
}
result = @processor.process(data)
expect(result[:request][:headers]["Authorization"]).to eq("********")
expect(result[:request][:headers]["AnotherHeader"]).to eq("still_here")
end
it 'should be configurable' do
data = {
:request => {
:headers => {
"User-Defined-Header" => "dontseeme",
"AnotherHeader" => "still_here"
}
}
}
result = @processor.process(data)
expect(result[:request][:headers]["User-Defined-Header"]).to eq("********")
expect(result[:request][:headers]["AnotherHeader"]).to eq("still_here")
end
it "should remove headers even if the keys are strings" do
data = {
"request" => {
"headers" => {
"Authorization" => "dontseeme",
"AnotherHeader" => "still_here"
}
}
}
result = @processor.process(data)
expect(result["request"]["headers"]["Authorization"]).to eq("********")
expect(result["request"]["headers"]["AnotherHeader"]).to eq("still_here")
end
end
raven-ruby-2.6.3/spec/raven/processors/post_data_spec.rb 0000664 0000000 0000000 00000002250 13142120705 0023372 0 ustar 00root root 0000000 0000000 # Encoding: utf-8
require 'spec_helper'
describe Raven::Processor::PostData do
before do
@client = double("client")
@processor = Raven::Processor::PostData.new(@client)
end
it 'should remove post data when HTTP method is POST' do
data = {
:request => {
:method => "POST",
:data => {
"sensitive_stuff" => "TOP_SECRET-GAMMA"
}
}
}
result = @processor.process(data)
expect(result[:request][:data]).to eq("********")
end
it 'should NOT remove post data when HTTP method is not POST' do
data = {
:request => {
:method => "GET",
:data => {
"sensitive_stuff" => "TOP_SECRET-GAMMA"
}
}
}
result = @processor.process(data)
expect(result[:request][:data]).to eq("sensitive_stuff" => "TOP_SECRET-GAMMA")
end
it 'should remove post data when HTTP method is POST and keys are strings' do
data = {
"request" => {
"method" => "POST",
"data" => {
"sensitive_stuff" => "TOP_SECRET-GAMMA"
}
}
}
result = @processor.process(data)
expect(result["request"]["data"]).to eq("********")
end
end
raven-ruby-2.6.3/spec/raven/processors/removecirculareferences_spec.rb 0000664 0000000 0000000 00000001324 13142120705 0026317 0 ustar 00root root 0000000 0000000 # Encoding: utf-8
require 'spec_helper'
describe Raven::Processor::RemoveCircularReferences do
before do
@client = double("client")
@processor = Raven::Processor::RemoveCircularReferences.new(@client)
end
it 'should cleanup circular references' do
data = {}
data['data'] = data
data['ary'] = []
data['ary'].push('x' => data['ary'])
data['ary2'] = data['ary']
data['leave intact'] = { 'not a circular reference' => true }
result = @processor.process(data)
expect(result['data']).to eq('(...)')
expect(result['ary'].first['x']).to eq('(...)')
expect(result['ary2']).to eq("(...)")
expect(result['leave intact']).to eq('not a circular reference' => true)
end
end
raven-ruby-2.6.3/spec/raven/processors/removestacktrace_spec.rb 0000664 0000000 0000000 00000004045 13142120705 0024762 0 ustar 00root root 0000000 0000000 require 'spec_helper'
require 'raven/processor/removestacktrace'
describe Raven::Processor::RemoveStacktrace do
before do
@client = double("client")
@processor = Raven::Processor::RemoveStacktrace.new(@client)
end
it 'should remove stacktraces' do
data = Raven::Event.capture_exception(build_exception).to_hash
expect(data[:exception][:values][0][:stacktrace]).to_not eq(nil)
result = @processor.process(data)
expect(result[:exception][:values][0][:stacktrace]).to eq(nil)
end
# Only check causes when they're supported
if Exception.new.respond_to? :cause
it 'should remove stacktraces from causes' do
data = Raven::Event.capture_exception(build_exception_with_cause).to_hash
expect(data[:exception][:values][0][:stacktrace]).to_not eq(nil)
expect(data[:exception][:values][1][:stacktrace]).to_not eq(nil)
result = @processor.process(data)
expect(result[:exception][:values][0][:stacktrace]).to eq(nil)
expect(result[:exception][:values][1][:stacktrace]).to eq(nil)
end
it 'should remove stacktraces from nested causes' do
data = Raven::Event.capture_exception(build_exception_with_two_causes).to_hash
expect(data[:exception][:values][0][:stacktrace]).to_not eq(nil)
expect(data[:exception][:values][1][:stacktrace]).to_not eq(nil)
expect(data[:exception][:values][2][:stacktrace]).to_not eq(nil)
result = @processor.process(data)
expect(result[:exception][:values][0][:stacktrace]).to eq(nil)
expect(result[:exception][:values][1][:stacktrace]).to eq(nil)
expect(result[:exception][:values][2][:stacktrace]).to eq(nil)
end
end
if defined?(Rails) # depends on activesupport
it 'should remove stacktraces even when keys are strings' do
data = Raven::Event.capture_exception(build_exception).to_hash.deep_stringify_keys
expect(data["exception"]["values"][0]["stacktrace"]).to_not eq(nil)
result = @processor.process(data)
expect(result["exception"]["values"][0]["stacktrace"]).to eq(nil)
end
end
end
raven-ruby-2.6.3/spec/raven/processors/sanitizedata_processor_spec.rb 0000664 0000000 0000000 00000017476 13142120705 0026213 0 ustar 00root root 0000000 0000000 require 'spec_helper'
describe Raven::Processor::SanitizeData do
before do
config = Struct.new(:sanitize_fields, :sanitize_credit_cards, :sanitize_fields_excluded).new([], true, [])
client = Struct.new(:configuration).new(config)
@processor = Raven::Processor::SanitizeData.new(client)
end
context 'configuration for sanitize fields' do
it 'should union default sanitize fields with user-defined sanitize fields' do
fields = Raven::Processor::SanitizeData::DEFAULT_FIELDS | %w(test monkeybutt)
@processor.sanitize_fields = fields
expected_fields_re = /authorization|password|passwd|secret|ssn|social(.*)?sec|\btest\b|\bmonkeybutt\b/i
expect(@processor.send(:fields_re)).to eq(expected_fields_re)
end
it 'should remove default fields if specified by sanitize_fields_excluded' do
@processor.sanitize_fields_excluded = %w(authorization)
expected_fields_re = /password|passwd|secret|ssn|social(.*)?sec/i
expect(@processor.send(:fields_re)).to eq(expected_fields_re)
end
it 'accepts regex-like strings' do
@processor.sanitize_fields = ["foo(.*)?bar"]
expected_fields_re = /authorization|password|passwd|secret|ssn|social(.*)?sec|foo(.*)?bar/i
expect(@processor.send(:fields_re)).to eq(expected_fields_re)
end
end
it 'should filter http data' do
@processor.sanitize_fields = ['user_field']
data = {
'sentry.interfaces.Http' => {
'data' => {
'foo' => 'bar',
'password' => 'hello',
'the_secret' => 'hello',
'a_password_here' => 'hello',
'mypasswd' => 'hello',
'test' => 1,
:ssn => '123-45-6789', # test symbol handling
'social_security_number' => 123456789,
'user_field' => 'user',
'user_field_foo' => 'hello',
'query_string' => 'foo=bar%E9' # test utf8 handling
}
}
}
result = @processor.process(data)
vars = result["sentry.interfaces.Http"]["data"]
expect(vars["foo"]).to eq("bar")
expect(vars["password"]).to eq(Raven::Processor::SanitizeData::STRING_MASK)
expect(vars["the_secret"]).to eq(Raven::Processor::SanitizeData::STRING_MASK)
expect(vars["a_password_here"]).to eq(Raven::Processor::SanitizeData::STRING_MASK)
expect(vars["mypasswd"]).to eq(Raven::Processor::SanitizeData::STRING_MASK)
expect(vars["test"]).to eq(1)
expect(vars[:ssn]).to eq(Raven::Processor::SanitizeData::STRING_MASK)
expect(vars["social_security_number"]).to eq(Raven::Processor::SanitizeData::INT_MASK)
expect(vars["user_field"]).to eq(Raven::Processor::SanitizeData::STRING_MASK)
expect(vars["user_field_foo"]).to eq('hello')
expect(vars["query_string"]).to match('foo=bar')
end
it 'should filter json data' do
@processor.sanitize_fields = ['user_field']
data_with_json = {
'json' => {
'foo' => 'bar',
'password' => 'hello',
'the_secret' => 'hello',
'a_password_here' => 'hello',
'mypasswd' => 'hello',
'test' => 1,
'ssn' => '123-45-6789',
'social_security_number' => 123456789,
'user_field' => 'user',
'user_field_foo' => 'hello'
}.to_json
}
result = JSON.parse(@processor.process(data_with_json)['json'])
vars = result
expect(vars["foo"]).to eq("bar")
expect(vars["password"]).to eq(Raven::Processor::SanitizeData::STRING_MASK)
expect(vars["the_secret"]).to eq(Raven::Processor::SanitizeData::STRING_MASK)
expect(vars["a_password_here"]).to eq(Raven::Processor::SanitizeData::STRING_MASK)
expect(vars["mypasswd"]).to eq(Raven::Processor::SanitizeData::STRING_MASK)
expect(vars["test"]).to eq(1)
expect(vars["ssn"]).to eq(Raven::Processor::SanitizeData::STRING_MASK)
expect(vars["social_security_number"]).to eq(Raven::Processor::SanitizeData::INT_MASK)
expect(vars["user_field"]).to eq(Raven::Processor::SanitizeData::STRING_MASK)
expect(vars["user_field_foo"]).to eq('hello')
end
it 'should filter json embedded in a ruby object' do
data_with_embedded_json = {
'data' => {
'json' => %w(foo bar).to_json,
'json_hash' => { 'foo' => 'bar' }.to_json,
'sensitive' => { 'password' => 'secret' }.to_json
}
}
result = @processor.process(data_with_embedded_json)
expect(JSON.parse(result["data"]["json"])).to eq(%w(foo bar))
expect(JSON.parse(result["data"]["json_hash"])).to eq('foo' => 'bar')
expect(JSON.parse(result["data"]["sensitive"])).to eq('password' => Raven::Processor::SanitizeData::STRING_MASK)
end
it 'should not fail when json is invalid' do
data_with_invalid_json = {
'data' => {
'invalid' => "{\r\n\"key\":\"value\",\r\n \"foo\":{\"bar\":\"baz\"}\r\n"
}
}
result = @processor.process(data_with_invalid_json)
expect { JSON.parse(result["data"]["invalid"]) }.to raise_exception(JSON::ParserError)
end
it 'should filter credit card values' do
data = {
'ccnumba' => '4242424242424242',
'ccnumba_13' => '4242424242424',
'ccnumba-dash' => '4242-4242-4242-4242',
'ccnumba_int' => 4242424242424242
}
result = @processor.process(data)
expect(result["ccnumba"]).to eq(Raven::Processor::SanitizeData::STRING_MASK)
expect(result["ccnumba_13"]).to eq(Raven::Processor::SanitizeData::STRING_MASK)
expect(result["ccnumba_int"]).to eq(Raven::Processor::SanitizeData::INT_MASK)
end
it 'should pass through credit card values if configured' do
@processor.sanitize_credit_cards = false
data = {
'ccnumba' => '4242424242424242',
'ccnumba_13' => '4242424242424',
'ccnumba-dash' => '4242-4242-4242-4242',
'ccnumba_int' => 4242424242424242
}
result = @processor.process(data)
expect(result["ccnumba"]).to eq('4242424242424242')
expect(result["ccnumba_13"]).to eq('4242424242424')
expect(result["ccnumba_int"]).to eq(4242424242424242)
end
it 'sanitizes hashes nested in arrays' do
data = {
"empty_array" => [],
"array" => [{ 'password' => 'secret' }]
}
result = @processor.process(data)
expect(result["array"][0]['password']).to eq(Raven::Processor::SanitizeData::STRING_MASK)
end
context "query strings" do
it 'sanitizes' do
data = {
'sentry.interfaces.Http' => {
'data' => {
'query_string' => 'foo=bar&password=secret'
}
}
}
result = @processor.process(data)
vars = result["sentry.interfaces.Http"]["data"]
expect(vars["query_string"]).to_not include("secret")
end
it 'handles :query_string as symbol' do
data = {
'sentry.interfaces.Http' => {
'data' => {
:query_string => 'foo=bar&password=secret'
}
}
}
result = @processor.process(data)
vars = result["sentry.interfaces.Http"]["data"]
expect(vars[:query_string]).to_not include("secret")
end
it 'handles multiple values for a key' do
data = {
'sentry.interfaces.Http' => {
'data' => {
'query_string' => 'foo=bar&foo=fubar&foo=barfoo'
}
}
}
result = @processor.process(data)
vars = result["sentry.interfaces.Http"]["data"]
query_string = vars["query_string"].split('&')
expect(query_string).to include("foo=bar")
expect(query_string).to include("foo=fubar")
expect(query_string).to include("foo=barfoo")
end
it 'handles url encoded keys and values' do
encoded_query_string = 'Bio+4%24=cA%24%7C-%7C+M%28%29n3%5E'
data = {
'sentry.interfaces.Http' => {
'data' => {
'query_string' => encoded_query_string
}
}
}
result = @processor.process(data)
vars = result["sentry.interfaces.Http"]["data"]
expect(vars["query_string"]).to eq(encoded_query_string)
end
end
end
raven-ruby-2.6.3/spec/raven/processors/utf8conversion_spec.rb 0000664 0000000 0000000 00000004332 13142120705 0024413 0 ustar 00root root 0000000 0000000 # Encoding: utf-8
require 'spec_helper'
describe Raven::Processor::UTF8Conversion do
before do
@client = double("client")
@processor = Raven::Processor::UTF8Conversion.new(@client)
@bad_utf8_string = "invalid utf8 string goes here\255".force_encoding('UTF-8')
end
it "has a utf8 fixture which is not valid utf-8" do
expect(@bad_utf8_string.valid_encoding?).to eq(false)
expect { @bad_utf8_string.match("") }.to raise_error(ArgumentError)
end
it 'should cleanup invalid UTF-8 bytes' do
data = {}
data['invalid'] = @bad_utf8_string
results = @processor.process(data)
expect(results['invalid']).to eq("invalid utf8 string goes here")
end
it "should cleanup invalid UTF-8 bytes in Exception messages" do
data = Exception.new(@bad_utf8_string)
results = @processor.process(data)
expect(results.message).to eq("invalid utf8 string goes here")
end
it 'should keep valid UTF-8 bytes after cleaning' do
data = {}
data['invalid'] = "한국, 中國, 日本(にっぽん)\255".force_encoding('UTF-8')
results = @processor.process(data)
expect(results['invalid']).to eq("한국, 中國, 日本(にっぽん)")
end
it 'should work recursively on hashes' do
data = { 'nested' => {} }
data['nested']['invalid'] = @bad_utf8_string
results = @processor.process(data)
expect(results['nested']['invalid']).to eq("invalid utf8 string goes here")
end
it 'should work recursively on arrays' do
data = ['good string', 'good string',
['good string', @bad_utf8_string]]
results = @processor.process(data)
expect(results[2][1]).to eq("invalid utf8 string goes here")
end
it 'should not blow up on symbols' do
data = { :key => :value }
results = @processor.process(data)
expect(results[:key]).to eq(:value)
end
it "deals with unicode hidden in ASCII_8BIT" do
data = ["\xE2\x9C\x89 Hello".force_encoding(Encoding::ASCII_8BIT)]
results = @processor.process(data)
# Calling JSON.generate here to simulate this value eventually being fed
# to JSON generator in the client for transport, we're looking to see
# if encoding errors are raised
expect(JSON.generate(results)).to eq("[\"✉ Hello\"]")
end
end
raven-ruby-2.6.3/spec/raven/raven_spec.rb 0000664 0000000 0000000 00000007172 13142120705 0020335 0 ustar 00root root 0000000 0000000 require 'spec_helper'
describe Raven do
let(:event) { Raven::Event.new(:id => "event_id") }
let(:options) { double("options") }
before do
allow(Raven.instance).to receive(:send_event)
allow(Raven::Event).to receive(:from_message) { event }
allow(Raven::Event).to receive(:from_exception) { event }
end
describe '.capture' do
context 'not given a block' do
let(:options) { { :key => 'value' } }
def capture_in_separate_process
pipe_in, pipe_out = IO.pipe
fork do
pipe_in.close
described_class.capture(options)
allow(Raven.instance).to receive(:capture_type) do |exception, _options|
pipe_out.puts exception.message
end
# silence process
$stderr.reopen('/dev/null', 'w')
$stdout.reopen('/dev/null', 'w')
yield
exit
end
pipe_out.close
captured_messages = pipe_in.read
pipe_in.close
# sometimes the at_exit hook was registered multiple times
captured_messages.split("\n").last
end
it 'does not yield' do
# As there is no yield matcher that does not require a probe (e.g. this
# is not valid: expect { |b| described_class.capture }.to_not yield_control),
# expect that a LocalJumpError, which is raised when yielding when no
# block is defined, is not raised.
described_class.capture
end
it 'installs an at exit hook that will capture exceptions' do
skip('fork not supported in jruby') if RUBY_PLATFORM == 'java'
captured_message = capture_in_separate_process { raise 'test error' }
expect(captured_message).to eq('test error')
end
end
end
describe '.inject_only' do
before do
allow(Gem.loaded_specs).to receive(:keys).and_return(%w(railties rack sidekiq))
end
it 'loads integrations when they are valid configurations' do
expect(Raven).to receive(:load_integration).once.with('railties')
expect(Raven).to receive(:load_integration).once.with('sidekiq')
Raven.inject_only(:railties, :sidekiq)
end
it 'skips any integrations that are not supported' do
expect(Raven).to receive(:load_integration).once.with('railties')
expect(Raven.logger).to receive(:warn).with('Integrations do not exist: doesnot, exist')
Raven.inject_only(:railties, :doesnot, :exist)
end
it 'skips any integrations that are not loaded in the gemspec' do
expect(Raven).to receive(:load_integration).once.with('railties')
Raven.inject_only(:railties, :delayed_job)
end
end
describe '.inject_without' do
before do
allow(Gem.loaded_specs).to receive(:keys).and_return(Raven::AVAILABLE_INTEGRATIONS)
end
it 'injects all integrations except those passed as an argument' do
expect(Raven).to receive(:load_integration).once.with('rake')
Raven.inject_without(:delayed_job, :logger, :railties, :sidekiq, :rack, :"rack-timeout")
end
end
describe "#sys_command" do
it "should execute system commands" do
expect(Raven.sys_command("echo 'Sentry'")).to eq("Sentry")
end
it "should return nil if a system command doesn't exist" do
expect(Raven.sys_command("asdasdasdsa")).to eq(nil)
end
it "should return nil if the process exits with a non-zero exit status" do
expect(Raven.sys_command("uname -c")).to eq(nil) # non-existent uname option
end
it "should not output to stdout on failure" do
expect { Raven.sys_command("asdasdasdsa") }.to_not output.to_stdout
expect { Raven.sys_command("uname -c") }.to_not output.to_stdout
end
end
end
raven-ruby-2.6.3/spec/raven/transports/ 0000775 0000000 0000000 00000000000 13142120705 0020073 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/spec/raven/transports/http_spec.rb 0000664 0000000 0000000 00000004016 13142120705 0022412 0 ustar 00root root 0000000 0000000 require 'spec_helper'
describe Raven::Transports::HTTP do
let(:config) { Raven::Configuration.new.tap { |c| c.dsn = 'http://12345:67890@sentry.localdomain/sentry/42' } }
let(:client) { Raven::Client.new(config) }
it 'should set a custom User-Agent' do
expect(client.send(:transport).conn.headers[:user_agent]).to eq("sentry-ruby/#{Raven::VERSION}")
end
it 'should raise an error on 4xx responses' do
stubs = Faraday::Adapter::Test::Stubs.new do |stub|
stub.post('sentry/api/42/store/') { [404, {}, 'not found'] }
end
client.configuration.http_adapter = [:test, stubs]
event = JSON.generate(Raven::Event.from_message("test").to_hash)
expect { client.send(:transport).send_event("test", event) }.to raise_error(Raven::Error)
stubs.verify_stubbed_calls
end
it 'should raise an error on 5xx responses' do
stubs = Faraday::Adapter::Test::Stubs.new do |stub|
stub.post('sentry/api/42/store/') { [500, {}, 'error'] }
end
client.configuration.http_adapter = [:test, stubs]
event = JSON.generate(Raven::Event.from_message("test").to_hash)
expect { client.send(:transport).send_event("test", event) }.to raise_error(Raven::Error)
stubs.verify_stubbed_calls
end
it 'should add header info message to the error' do
stubs = Faraday::Adapter::Test::Stubs.new do |stub|
stub.post('sentry/api/42/store/') { [400, { 'x-sentry-error' => 'error_in_header' }, 'error'] }
end
client.configuration.http_adapter = [:test, stubs]
event = JSON.generate(Raven::Event.from_message("test").to_hash)
expect { client.send(:transport).send_event("test", event) }.to raise_error(Raven::Error, /error_in_header/)
stubs.verify_stubbed_calls
end
it 'allows to customise faraday' do
builder = spy('faraday_builder')
expect(Faraday).to receive(:new).and_yield(builder)
client.configuration.faraday_builder = proc { |b| b.request :instrumentation }
client.send(:transport)
expect(builder).to have_received(:request).with(:instrumentation)
end
end
raven-ruby-2.6.3/spec/raven/utils/ 0000775 0000000 0000000 00000000000 13142120705 0017014 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/spec/raven/utils/real_ip_spec.rb 0000664 0000000 0000000 00000003735 13142120705 0021776 0 ustar 00root root 0000000 0000000 require 'spec_helper'
describe Raven::Utils::RealIp do
context "when no ip addresses are provided other than REMOTE_ADDR" do
subject { Raven::Utils::RealIp.new(:remote_addr => "1.1.1.1") }
it "should return the remote_addr" do
expect(subject.calculate_ip).to eq("1.1.1.1")
end
end
context "when a list of x-forwarded-for ips is provided" do
subject do
Raven::Utils::RealIp.new(
:forwarded_for => "192.168.0.2, 2.2.2.2, 3.3.3.3, 4.4.4.4",
:remote_addr => "192.168.0.1"
)
end
it "should return the oldest ancestor that is not a local IP" do
expect(subject.calculate_ip).to eq("2.2.2.2")
end
end
context "when client/real ips are provided" do
subject do
Raven::Utils::RealIp.new(
:forwarded_for => "2.2.2.2",
:real_ip => "4.4.4.4",
:client_ip => "3.3.3.3",
:remote_addr => "192.168.0.1"
)
end
it "should return the oldest ancestor, preferring client/real ips first" do
expect(subject.calculate_ip).to eq("3.3.3.3")
end
end
context "all provided ip addresses are actually local addresses" do
subject do
Raven::Utils::RealIp.new(
:forwarded_for => "127.0.0.1, ::1, 10.0.0.0",
:remote_addr => "192.168.0.1"
)
end
it "should return REMOTE_ADDR" do
expect(subject.calculate_ip).to eq("192.168.0.1")
end
end
context "when an invalid IP is provided" do
subject do
Raven::Utils::RealIp.new(
:forwarded_for => "4.4.4.4.4, 2.2.2.2",
:remote_addr => "192.168.0.1"
)
end
it "return the eldest valid IP" do
expect(subject.calculate_ip).to eq("2.2.2.2")
end
end
context "with IPv6 ips" do
subject do
Raven::Utils::RealIp.new(
:forwarded_for => "2001:db8:a0b:12f0::1",
:remote_addr => "192.168.0.1"
)
end
it "return the eldest valid IP" do
expect(subject.calculate_ip).to eq("2001:db8:a0b:12f0::1")
end
end
end
raven-ruby-2.6.3/spec/spec_helper.rb 0000664 0000000 0000000 00000002622 13142120705 0017361 0 ustar 00root root 0000000 0000000 require 'sentry-raven-without-integrations'
require 'raven/transports/dummy'
Raven.configure do |config|
config.dsn = "dummy://12345:67890@sentry.localdomain/sentry/42"
config.encoding = "json"
config.silence_ready = true
config.logger = Logger.new(nil)
end
if ENV["RAILS_VERSION"] && (ENV["RAILS_VERSION"].to_i == 0)
RSpec.configure do |config|
config.filter_run_excluding :rails => true
end
else
require File.dirname(__FILE__) + "/support/test_rails_app/app.rb"
require "rspec/rails"
end
RSpec.configure do |config|
config.mock_with(:rspec) { |mocks| mocks.verify_partial_doubles = true }
config.raise_errors_for_deprecations!
end
def build_exception
1 / 0
rescue ZeroDivisionError => exception
return exception
end
def build_exception_with_cause
begin
raise "exception a"
rescue
raise "exception b"
end
rescue RuntimeError => exception
return exception
end
def build_exception_with_two_causes
begin
begin
raise "exception a"
rescue
raise "exception b"
end
rescue
raise "exception c"
end
rescue RuntimeError => exception
return exception
end
def build_exception_with_recursive_cause
backtrace = []
exception = double("Exception")
allow(exception).to receive(:cause).and_return(exception)
allow(exception).to receive(:message).and_return("example")
allow(exception).to receive(:backtrace).and_return(backtrace)
exception
end
raven-ruby-2.6.3/spec/support/ 0000775 0000000 0000000 00000000000 13142120705 0016255 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/spec/support/Rakefile 0000664 0000000 0000000 00000000273 13142120705 0017724 0 ustar 00root root 0000000 0000000 require 'rake'
require 'rubygems'
require 'raven'
Raven.configure do |config|
config.dsn = 'dummy://12345:67890@sentry.localdomain/sentry/42'
end
task :raise_exception do
1 / 0
end
raven-ruby-2.6.3/spec/support/linecache.txt 0000664 0000000 0000000 00000000034 13142120705 0020726 0 ustar 00root root 0000000 0000000 foo
bar
baz
qux
lorem
ipsum
raven-ruby-2.6.3/spec/support/test_rails_app/ 0000775 0000000 0000000 00000000000 13142120705 0021266 5 ustar 00root root 0000000 0000000 raven-ruby-2.6.3/spec/support/test_rails_app/app.rb 0000664 0000000 0000000 00000001712 13142120705 0022374 0 ustar 00root root 0000000 0000000 require 'rails'
# require "active_record/railtie"
require "action_view/railtie"
require "action_controller/railtie"
# require "action_mailer/railtie"
require "active_job/railtie"
# require "action_cable/engine"
# require "sprockets/railtie"
# require "rails/test_unit/railtie"
require 'raven/integrations/rails'
ActiveSupport::Deprecation.silenced = true
class TestApp < Rails::Application
config.secret_key_base = "test"
# Usually set for us in production.rb
config.eager_load = true
config.cache_classes = true
config.serve_static_files = false
routes.append do
get "/exception", :to => "hello#exception"
root :to => "hello#world"
end
initializer :configure_release do
Raven.configure do |config|
config.release = 'beta'
end
end
end
class HelloController < ActionController::Base
def exception
raise "An unhandled exception!"
end
def world
render :text => "Hello World!"
end
end
Rails.env = "production"