sentry-ruby 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.craft.yml +18 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +6 -0
- data/CHANGELOG.md +10 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +11 -0
- data/LICENSE.txt +21 -0
- data/README.md +44 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/sentry.rb +97 -0
- data/lib/sentry/backtrace.rb +128 -0
- data/lib/sentry/breadcrumb.rb +25 -0
- data/lib/sentry/breadcrumb/sentry_logger.rb +103 -0
- data/lib/sentry/breadcrumb_buffer.rb +50 -0
- data/lib/sentry/client.rb +85 -0
- data/lib/sentry/configuration.rb +401 -0
- data/lib/sentry/core_ext/object/deep_dup.rb +57 -0
- data/lib/sentry/core_ext/object/duplicable.rb +153 -0
- data/lib/sentry/dsn.rb +45 -0
- data/lib/sentry/event.rb +175 -0
- data/lib/sentry/event/options.rb +31 -0
- data/lib/sentry/hub.rb +126 -0
- data/lib/sentry/interface.rb +22 -0
- data/lib/sentry/interfaces/exception.rb +11 -0
- data/lib/sentry/interfaces/request.rb +104 -0
- data/lib/sentry/interfaces/single_exception.rb +14 -0
- data/lib/sentry/interfaces/stacktrace.rb +57 -0
- data/lib/sentry/linecache.rb +44 -0
- data/lib/sentry/logger.rb +20 -0
- data/lib/sentry/rack.rb +4 -0
- data/lib/sentry/rack/capture_exception.rb +45 -0
- data/lib/sentry/ruby.rb +1 -0
- data/lib/sentry/scope.rb +192 -0
- data/lib/sentry/transport.rb +110 -0
- data/lib/sentry/transport/configuration.rb +28 -0
- data/lib/sentry/transport/dummy_transport.rb +14 -0
- data/lib/sentry/transport/http_transport.rb +62 -0
- data/lib/sentry/transport/state.rb +40 -0
- data/lib/sentry/utils/deep_merge.rb +22 -0
- data/lib/sentry/utils/exception_cause_chain.rb +20 -0
- data/lib/sentry/utils/real_ip.rb +70 -0
- data/lib/sentry/version.rb +3 -0
- data/sentry-ruby.gemspec +26 -0
- metadata +107 -0
| @@ -0,0 +1,22 @@ | |
| 1 | 
            +
            module Sentry
         | 
| 2 | 
            +
              module Utils
         | 
| 3 | 
            +
                # ported from ActiveSupport
         | 
| 4 | 
            +
                module DeepMergeHash
         | 
| 5 | 
            +
                  def self.deep_merge(hash, other_hash, &block)
         | 
| 6 | 
            +
                    deep_merge!(hash, other_hash, &block)
         | 
| 7 | 
            +
                  end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                  def self.deep_merge!(hash, other_hash, &block)
         | 
| 10 | 
            +
                    hash.merge!(other_hash) do |key, this_val, other_val|
         | 
| 11 | 
            +
                      if this_val.is_a?(Hash) && other_val.is_a?(Hash)
         | 
| 12 | 
            +
                        deep_merge(this_val, other_val, &block)
         | 
| 13 | 
            +
                      elsif block_given?
         | 
| 14 | 
            +
                        block.call(key, this_val, other_val)
         | 
| 15 | 
            +
                      else
         | 
| 16 | 
            +
                        other_val
         | 
| 17 | 
            +
                      end
         | 
| 18 | 
            +
                    end
         | 
| 19 | 
            +
                  end
         | 
| 20 | 
            +
                end
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
            end
         | 
| @@ -0,0 +1,20 @@ | |
| 1 | 
            +
            module Sentry
         | 
| 2 | 
            +
              module Utils
         | 
| 3 | 
            +
                module ExceptionCauseChain
         | 
| 4 | 
            +
                  def self.exception_to_array(exception)
         | 
| 5 | 
            +
                    if exception.respond_to?(:cause) && exception.cause
         | 
| 6 | 
            +
                      exceptions = [exception]
         | 
| 7 | 
            +
                      while exception.cause
         | 
| 8 | 
            +
                        exception = exception.cause
         | 
| 9 | 
            +
                        break if exceptions.any? { |e| e.object_id == exception.object_id }
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                        exceptions << exception
         | 
| 12 | 
            +
                      end
         | 
| 13 | 
            +
                      exceptions
         | 
| 14 | 
            +
                    else
         | 
| 15 | 
            +
                      [exception]
         | 
| 16 | 
            +
                    end
         | 
| 17 | 
            +
                  end
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
            end
         | 
| @@ -0,0 +1,70 @@ | |
| 1 | 
            +
            require 'ipaddr'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            # Based on ActionDispatch::RemoteIp. All security-related precautions from that
         | 
| 4 | 
            +
            # middleware have been removed, because the Event IP just needs to be accurate,
         | 
| 5 | 
            +
            # and spoofing an IP here only makes data inaccurate, not insecure. Don't re-use
         | 
| 6 | 
            +
            # this module if you have to *trust* the IP address.
         | 
| 7 | 
            +
            module Sentry
         | 
| 8 | 
            +
              module Utils
         | 
| 9 | 
            +
                class RealIp
         | 
| 10 | 
            +
                  LOCAL_ADDRESSES = [
         | 
| 11 | 
            +
                    "127.0.0.1",      # localhost IPv4
         | 
| 12 | 
            +
                    "::1",            # localhost IPv6
         | 
| 13 | 
            +
                    "fc00::/7",       # private IPv6 range fc00::/7
         | 
| 14 | 
            +
                    "10.0.0.0/8",     # private IPv4 range 10.x.x.x
         | 
| 15 | 
            +
                    "172.16.0.0/12",  # private IPv4 range 172.16.0.0 .. 172.31.255.255
         | 
| 16 | 
            +
                    "192.168.0.0/16" # private IPv4 range 192.168.x.x
         | 
| 17 | 
            +
                  ].map { |proxy| IPAddr.new(proxy) }
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                  attr_reader :ip
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                  def initialize(
         | 
| 22 | 
            +
                    remote_addr: nil,
         | 
| 23 | 
            +
                    client_ip: nil,
         | 
| 24 | 
            +
                    real_ip: nil,
         | 
| 25 | 
            +
                    forwarded_for: nil
         | 
| 26 | 
            +
                  )
         | 
| 27 | 
            +
                    @remote_addr = remote_addr
         | 
| 28 | 
            +
                    @client_ip = client_ip
         | 
| 29 | 
            +
                    @real_ip = real_ip
         | 
| 30 | 
            +
                    @forwarded_for = forwarded_for
         | 
| 31 | 
            +
                  end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                  def calculate_ip
         | 
| 34 | 
            +
                    # CGI environment variable set by Rack
         | 
| 35 | 
            +
                    remote_addr = ips_from(@remote_addr).last
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                    # Could be a CSV list and/or repeated headers that were concatenated.
         | 
| 38 | 
            +
                    client_ips    = ips_from(@client_ip)
         | 
| 39 | 
            +
                    real_ips      = ips_from(@real_ip)
         | 
| 40 | 
            +
                    forwarded_ips = ips_from(@forwarded_for)
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                    ips = [client_ips, real_ips, forwarded_ips, remote_addr].flatten.compact
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                    # If every single IP option is in the trusted list, just return REMOTE_ADDR
         | 
| 45 | 
            +
                    @ip = filter_local_addresses(ips).first || remote_addr
         | 
| 46 | 
            +
                  end
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                  protected
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                  def ips_from(header)
         | 
| 51 | 
            +
                    # Split the comma-separated list into an array of strings
         | 
| 52 | 
            +
                    ips = header ? header.strip.split(/[,\s]+/) : []
         | 
| 53 | 
            +
                    ips.select do |ip|
         | 
| 54 | 
            +
                      begin
         | 
| 55 | 
            +
                        # Only return IPs that are valid according to the IPAddr#new method
         | 
| 56 | 
            +
                        range = IPAddr.new(ip).to_range
         | 
| 57 | 
            +
                        # we want to make sure nobody is sneaking a netmask in
         | 
| 58 | 
            +
                        range.begin == range.end
         | 
| 59 | 
            +
                      rescue ArgumentError
         | 
| 60 | 
            +
                        nil
         | 
| 61 | 
            +
                      end
         | 
| 62 | 
            +
                    end
         | 
| 63 | 
            +
                  end
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                  def filter_local_addresses(ips)
         | 
| 66 | 
            +
                    ips.reject { |ip| LOCAL_ADDRESSES.any? { |proxy| proxy === ip } }
         | 
| 67 | 
            +
                  end
         | 
| 68 | 
            +
                end
         | 
| 69 | 
            +
              end
         | 
| 70 | 
            +
            end
         | 
    
        data/sentry-ruby.gemspec
    ADDED
    
    | @@ -0,0 +1,26 @@ | |
| 1 | 
            +
            require_relative "lib/sentry/version"
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Gem::Specification.new do |spec|
         | 
| 4 | 
            +
              spec.name          = "sentry-ruby"
         | 
| 5 | 
            +
              spec.version       = Sentry::VERSION
         | 
| 6 | 
            +
              spec.authors = ["Sentry Team"]
         | 
| 7 | 
            +
              spec.description = spec.summary = "A gem that provides a client interface for the Sentry error logger"
         | 
| 8 | 
            +
              spec.email = "accounts@sentry.io"
         | 
| 9 | 
            +
              spec.license = 'Apache-2.0'
         | 
| 10 | 
            +
              spec.homepage = "https://github.com/getsentry/raven-ruby"
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              spec.platform = Gem::Platform::RUBY
         | 
| 13 | 
            +
              spec.required_ruby_version = '>= 2.4'
         | 
| 14 | 
            +
              spec.extra_rdoc_files = ["README.md", "LICENSE.txt"]
         | 
| 15 | 
            +
              spec.files = `git ls-files | grep -Ev '^(spec|benchmarks|examples)'`.split("\n")
         | 
| 16 | 
            +
             | 
| 17 | 
            +
              spec.metadata["homepage_uri"] = spec.homepage
         | 
| 18 | 
            +
              spec.metadata["source_code_uri"] = spec.homepage
         | 
| 19 | 
            +
              spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/master/CHANGELOG.md"
         | 
| 20 | 
            +
             | 
| 21 | 
            +
              spec.bindir        = "exe"
         | 
| 22 | 
            +
              spec.executables   = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
         | 
| 23 | 
            +
              spec.require_paths = ["lib"]
         | 
| 24 | 
            +
             | 
| 25 | 
            +
              spec.add_dependency "faraday", ">= 1.0"
         | 
| 26 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,107 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: sentry-ruby
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.1.1
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Sentry Team
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: exe
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2020-11-06 00:00:00.000000000 Z
         | 
| 12 | 
            +
            dependencies:
         | 
| 13 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            +
              name: faraday
         | 
| 15 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 | 
            +
                requirements:
         | 
| 17 | 
            +
                - - ">="
         | 
| 18 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            +
                    version: '1.0'
         | 
| 20 | 
            +
              type: :runtime
         | 
| 21 | 
            +
              prerelease: false
         | 
| 22 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 | 
            +
                requirements:
         | 
| 24 | 
            +
                - - ">="
         | 
| 25 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            +
                    version: '1.0'
         | 
| 27 | 
            +
            description: A gem that provides a client interface for the Sentry error logger
         | 
| 28 | 
            +
            email: accounts@sentry.io
         | 
| 29 | 
            +
            executables: []
         | 
| 30 | 
            +
            extensions: []
         | 
| 31 | 
            +
            extra_rdoc_files:
         | 
| 32 | 
            +
            - README.md
         | 
| 33 | 
            +
            - LICENSE.txt
         | 
| 34 | 
            +
            files:
         | 
| 35 | 
            +
            - ".craft.yml"
         | 
| 36 | 
            +
            - ".gitignore"
         | 
| 37 | 
            +
            - ".rspec"
         | 
| 38 | 
            +
            - ".travis.yml"
         | 
| 39 | 
            +
            - CHANGELOG.md
         | 
| 40 | 
            +
            - CODE_OF_CONDUCT.md
         | 
| 41 | 
            +
            - Gemfile
         | 
| 42 | 
            +
            - LICENSE.txt
         | 
| 43 | 
            +
            - README.md
         | 
| 44 | 
            +
            - Rakefile
         | 
| 45 | 
            +
            - bin/console
         | 
| 46 | 
            +
            - bin/setup
         | 
| 47 | 
            +
            - lib/sentry.rb
         | 
| 48 | 
            +
            - lib/sentry/backtrace.rb
         | 
| 49 | 
            +
            - lib/sentry/breadcrumb.rb
         | 
| 50 | 
            +
            - lib/sentry/breadcrumb/sentry_logger.rb
         | 
| 51 | 
            +
            - lib/sentry/breadcrumb_buffer.rb
         | 
| 52 | 
            +
            - lib/sentry/client.rb
         | 
| 53 | 
            +
            - lib/sentry/configuration.rb
         | 
| 54 | 
            +
            - lib/sentry/core_ext/object/deep_dup.rb
         | 
| 55 | 
            +
            - lib/sentry/core_ext/object/duplicable.rb
         | 
| 56 | 
            +
            - lib/sentry/dsn.rb
         | 
| 57 | 
            +
            - lib/sentry/event.rb
         | 
| 58 | 
            +
            - lib/sentry/event/options.rb
         | 
| 59 | 
            +
            - lib/sentry/hub.rb
         | 
| 60 | 
            +
            - lib/sentry/interface.rb
         | 
| 61 | 
            +
            - lib/sentry/interfaces/exception.rb
         | 
| 62 | 
            +
            - lib/sentry/interfaces/request.rb
         | 
| 63 | 
            +
            - lib/sentry/interfaces/single_exception.rb
         | 
| 64 | 
            +
            - lib/sentry/interfaces/stacktrace.rb
         | 
| 65 | 
            +
            - lib/sentry/linecache.rb
         | 
| 66 | 
            +
            - lib/sentry/logger.rb
         | 
| 67 | 
            +
            - lib/sentry/rack.rb
         | 
| 68 | 
            +
            - lib/sentry/rack/capture_exception.rb
         | 
| 69 | 
            +
            - lib/sentry/ruby.rb
         | 
| 70 | 
            +
            - lib/sentry/scope.rb
         | 
| 71 | 
            +
            - lib/sentry/transport.rb
         | 
| 72 | 
            +
            - lib/sentry/transport/configuration.rb
         | 
| 73 | 
            +
            - lib/sentry/transport/dummy_transport.rb
         | 
| 74 | 
            +
            - lib/sentry/transport/http_transport.rb
         | 
| 75 | 
            +
            - lib/sentry/transport/state.rb
         | 
| 76 | 
            +
            - lib/sentry/utils/deep_merge.rb
         | 
| 77 | 
            +
            - lib/sentry/utils/exception_cause_chain.rb
         | 
| 78 | 
            +
            - lib/sentry/utils/real_ip.rb
         | 
| 79 | 
            +
            - lib/sentry/version.rb
         | 
| 80 | 
            +
            - sentry-ruby.gemspec
         | 
| 81 | 
            +
            homepage: https://github.com/getsentry/raven-ruby
         | 
| 82 | 
            +
            licenses:
         | 
| 83 | 
            +
            - Apache-2.0
         | 
| 84 | 
            +
            metadata:
         | 
| 85 | 
            +
              homepage_uri: https://github.com/getsentry/raven-ruby
         | 
| 86 | 
            +
              source_code_uri: https://github.com/getsentry/raven-ruby
         | 
| 87 | 
            +
              changelog_uri: https://github.com/getsentry/raven-ruby/blob/master/CHANGELOG.md
         | 
| 88 | 
            +
            post_install_message: 
         | 
| 89 | 
            +
            rdoc_options: []
         | 
| 90 | 
            +
            require_paths:
         | 
| 91 | 
            +
            - lib
         | 
| 92 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 93 | 
            +
              requirements:
         | 
| 94 | 
            +
              - - ">="
         | 
| 95 | 
            +
                - !ruby/object:Gem::Version
         | 
| 96 | 
            +
                  version: '2.4'
         | 
| 97 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 98 | 
            +
              requirements:
         | 
| 99 | 
            +
              - - ">="
         | 
| 100 | 
            +
                - !ruby/object:Gem::Version
         | 
| 101 | 
            +
                  version: '0'
         | 
| 102 | 
            +
            requirements: []
         | 
| 103 | 
            +
            rubygems_version: 3.0.3
         | 
| 104 | 
            +
            signing_key: 
         | 
| 105 | 
            +
            specification_version: 4
         | 
| 106 | 
            +
            summary: A gem that provides a client interface for the Sentry error logger
         | 
| 107 | 
            +
            test_files: []
         |