sentry-ruby-core 4.6.5 → 4.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4440f6ad3a4fd52dc9bd94c15a64e239a6957aca9adc7a410e8bd787d124bcae
4
- data.tar.gz: c6736aba5112331695e81adc496f3c6ee5581ae2ee419ba880c912eb20cedde9
3
+ metadata.gz: '08bb1e6f6c55f8f9a206aabcb008ac4e8322652831108a0ec5145b69ed741c1d'
4
+ data.tar.gz: 7d699edbb8b0a1e05c44b0d039f2e9ea79cba7355961488f1bc9311e8a92cb14
5
5
  SHA512:
6
- metadata.gz: e38a7ad731a84ee1886c341f8e6484c2019ad328b0a7c3bd93583d1f3056088f5f8e050bf0d0b764a5938c80ca7e704608aa2a107e6b9f915f76cb6dc701e1dc
7
- data.tar.gz: fd137796bb363205ba78929c987b1cb1e3f7f494058e9fb8a31348ef29dd071994ec30a816b7de3befcdc018f91bc437cfade282fa65aa57952ac0e863580291
6
+ metadata.gz: ff6528918de5664c632d44c48cc04536cd41537e7fb2e5bc372c5794834cc4450b9d6aff82ba6ba4ad0a822ee5f96bc74a165ae6c1164299585019a187c63aad
7
+ data.tar.gz: 9cf4dcecb8d81ec03048d22ffc75a0d4647b70a4bf037e9183ff794ef044f1ece661218a4ca22aef89cdbb4992361b1c9829a5aeeab0179430afc420c2d8a01f
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2020 st0012
3
+ Copyright (c) 2020 getsentry
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/lib/sentry/client.rb CHANGED
@@ -57,10 +57,10 @@ module Sentry
57
57
  end
58
58
  end
59
59
 
60
- def event_from_message(message, hint = {})
60
+ def event_from_message(message, hint = {}, backtrace: nil)
61
61
  integration_meta = Sentry.integrations[hint[:integration]]
62
62
  event = Event.new(configuration: configuration, integration_meta: integration_meta, message: message)
63
- event.add_threads_interface(backtrace: caller)
63
+ event.add_threads_interface(backtrace: backtrace || caller)
64
64
  event
65
65
  end
66
66
 
@@ -324,6 +324,15 @@ module Sentry
324
324
  log_error("Error detecting release", e, debug: debug)
325
325
  end
326
326
 
327
+ def csp_report_uri
328
+ if dsn && dsn.valid?
329
+ uri = dsn.csp_report_uri
330
+ uri += "&sentry_release=#{CGI.escape(release)}" if release && !release.empty?
331
+ uri += "&sentry_environment=#{CGI.escape(environment)}" if environment && !environment.empty?
332
+ uri
333
+ end
334
+ end
335
+
327
336
  private
328
337
 
329
338
  def excluded_exception?(incoming_exception)
data/lib/sentry/dsn.rb CHANGED
@@ -40,6 +40,10 @@ module Sentry
40
40
  server
41
41
  end
42
42
 
43
+ def csp_report_uri
44
+ "#{server}/api/#{project_id}/security/?sentry_key=#{public_key}"
45
+ end
46
+
43
47
  def envelope_endpoint
44
48
  "#{path}/api/#{project_id}/envelope/"
45
49
  end
data/lib/sentry/hub.rb CHANGED
@@ -108,7 +108,8 @@ module Sentry
108
108
 
109
109
  options[:hint] ||= {}
110
110
  options[:hint][:message] = message
111
- event = current_client.event_from_message(message, options[:hint])
111
+ backtrace = options.delete(:backtrace)
112
+ event = current_client.event_from_message(message, options[:hint], backtrace: backtrace)
112
113
  capture_event(event, **options, &block)
113
114
  end
114
115
 
@@ -135,6 +136,8 @@ module Sentry
135
136
  end
136
137
 
137
138
  def add_breadcrumb(breadcrumb, hint: {})
139
+ return unless configuration.enabled_in_current_env?
140
+
138
141
  if before_breadcrumb = current_client.configuration.before_breadcrumb
139
142
  breadcrumb = before_breadcrumb.call(breadcrumb, hint)
140
143
  end
@@ -57,7 +57,7 @@ module Sentry
57
57
  request.POST
58
58
  elsif request.body # JSON requests, etc
59
59
  data = request.body.read(MAX_BODY_LIMIT)
60
- data = data.force_encoding(Encoding::UTF_8) if data.respond_to?(:force_encoding)
60
+ data = encode_to_utf_8(data.to_s)
61
61
  request.body.rewind
62
62
  data
63
63
  end
@@ -76,7 +76,8 @@ module Sentry
76
76
  # Rack stores headers as HTTP_WHAT_EVER, we need What-Ever
77
77
  key = key.sub(/^HTTP_/, "")
78
78
  key = key.split('_').map(&:capitalize).join('-')
79
- memo[key] = value.to_s
79
+
80
+ memo[key] = encode_to_utf_8(value.to_s)
80
81
  rescue StandardError => e
81
82
  # Rails adds objects to the Rack env that can sometimes raise exceptions
82
83
  # when `to_s` is called.
@@ -87,6 +88,18 @@ module Sentry
87
88
  end
88
89
  end
89
90
 
91
+ def encode_to_utf_8(value)
92
+ if value.encoding != Encoding::UTF_8 && value.respond_to?(:force_encoding)
93
+ value = value.dup.force_encoding(Encoding::UTF_8)
94
+ end
95
+
96
+ if !value.valid_encoding?
97
+ value = value.scrub
98
+ end
99
+
100
+ value
101
+ end
102
+
90
103
  def is_skippable_header?(key)
91
104
  key.upcase != key || # lower-case envs aren't real http headers
92
105
  key == "HTTP_COOKIE" || # Cookies don't go here, they go somewhere else
data/lib/sentry/scope.rb CHANGED
@@ -23,6 +23,7 @@ module Sentry
23
23
  event.user = user.merge(event.user)
24
24
  event.extra = extra.merge(event.extra)
25
25
  event.contexts = contexts.merge(event.contexts)
26
+ event.transaction = transaction_name if transaction_name
26
27
 
27
28
  if span
28
29
  event.contexts[:trace] = span.get_trace_context
@@ -30,7 +31,6 @@ module Sentry
30
31
 
31
32
  event.fingerprint = fingerprint
32
33
  event.level = level
33
- event.transaction = transaction_names.last
34
34
  event.breadcrumbs = breadcrumbs
35
35
  event.rack_env = rack_env if rack_env
36
36
 
@@ -1,3 +1,3 @@
1
1
  module Sentry
2
- VERSION = "4.6.5"
2
+ VERSION = "4.7.0"
3
3
  end
data/lib/sentry-ruby.rb CHANGED
@@ -90,6 +90,18 @@ module Sentry
90
90
  @background_worker = Sentry::BackgroundWorker.new(config)
91
91
  end
92
92
 
93
+ # Returns an uri for security policy reporting that's generated from the given DSN
94
+ # (To learn more about security policy reporting: https://docs.sentry.io/product/security-policy-reporting/)
95
+ #
96
+ # It returns nil if
97
+ #
98
+ # 1. The SDK is not initialized yet.
99
+ # 2. The DSN is not provided or is invalid.
100
+ def csp_report_uri
101
+ return unless initialized?
102
+ configuration.csp_report_uri
103
+ end
104
+
93
105
  # Returns the main thread's active hub.
94
106
  def get_main_hub
95
107
  @main_hub
@@ -6,7 +6,7 @@ Gem::Specification.new do |spec|
6
6
  spec.authors = ["Sentry Team"]
7
7
  spec.description = spec.summary = "A gem that provides a client interface for the Sentry error logger"
8
8
  spec.email = "accounts@sentry.io"
9
- spec.license = 'Apache-2.0'
9
+ spec.license = 'MIT'
10
10
  spec.homepage = "https://github.com/getsentry/sentry-ruby"
11
11
 
12
12
  spec.platform = Gem::Platform::RUBY
data/sentry-ruby.gemspec CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |spec|
6
6
  spec.authors = ["Sentry Team"]
7
7
  spec.description = spec.summary = "A gem that provides a client interface for the Sentry error logger"
8
8
  spec.email = "accounts@sentry.io"
9
- spec.license = 'Apache-2.0'
9
+ spec.license = 'MIT'
10
10
  spec.homepage = "https://github.com/getsentry/sentry-ruby"
11
11
 
12
12
  spec.platform = Gem::Platform::RUBY
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sentry-ruby-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.6.5
4
+ version: 4.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sentry Team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-08-12 00:00:00.000000000 Z
11
+ date: 2021-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -103,7 +103,7 @@ files:
103
103
  - sentry-ruby.gemspec
104
104
  homepage: https://github.com/getsentry/sentry-ruby
105
105
  licenses:
106
- - Apache-2.0
106
+ - MIT
107
107
  metadata:
108
108
  homepage_uri: https://github.com/getsentry/sentry-ruby
109
109
  source_code_uri: https://github.com/getsentry/sentry-ruby