sqreen 1.17.2.beta1 → 1.17.2.beta2

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: 3862ecef24ba42830b6570cc6bf05902a40e605b467339a62499f929ff6ed953
4
- data.tar.gz: 7aa4b16b8b80f5cbdeba29393aeef199c466e9148f6ad6a67fd522e8e5bf09d8
3
+ metadata.gz: b146b5b2fc5e830ab98c049eb17c576a943899035226300157eb88ab9db8fad5
4
+ data.tar.gz: 6a3ec0498bd1f1eac06caef917708a837fc06d83b6931e139f2da7890a2cc59a
5
5
  SHA512:
6
- metadata.gz: f51c35e5537404e214faf6686b771882d40eda98c2850105f3067a82e56756666cb52b188651db8e26a832df5f02971dc0d2f9aa30a8a300a486f93390333345
7
- data.tar.gz: 9c538573202337981c7b1daa6f369bb8e7115a280904a6d5f2040b4b2978526a90c52e0ab0762c5fe17a12fbfeb035aa08a001f51422c5dd4195836efab07c8e
6
+ metadata.gz: c357bbd375005220b136be93496689df76d883cce643dda9c8260024393b2fc82173aa3f7ebd76e12fbe7d62309df9d5f009e7d304e38c2db548f40cd1fee6d2
7
+ data.tar.gz: 2606d78d949c24784f04fc71fab61d964a323cbbbe04580750c5dda4f954b3e07d95f9f34b15efb0e7a09ed2b1ee008cbd22d2a470cc03f84c1f3963fe111189
@@ -1,3 +1,8 @@
1
+ ## 1.17.2.beta2
2
+
3
+ * Important note: this beta release supports Ruby 2.2 or above only
4
+ * Add support for Sinatra 2.0
5
+
1
6
  ## 1.17.2.beta1
2
7
 
3
8
  * Important note: this beta release supports Rails only, and notably excludes Sinatra support
@@ -3,6 +3,7 @@
3
3
 
4
4
  require 'sqreen/dependency/hook'
5
5
  require 'sqreen/dependency/rails'
6
+ require 'sqreen/dependency/sinatra'
6
7
  require 'sqreen/dependency/rack'
7
8
  require 'sqreen/dependency/sentry'
8
9
  require 'sqreen/dependency/new_relic'
@@ -37,6 +38,18 @@ module Sqreen
37
38
  end
38
39
  end if Sqreen::Dependency::Rails.required?
39
40
 
41
+ Sqreen::Dependency::Hook.add('Sinatra::Base.setup_default_middleware') do
42
+ after do |_, _, _, args|
43
+ Sqreen::Dependency::Sinatra.insert_sqreen_middlewares(args.first)
44
+ end
45
+ end.install if Sqreen::Dependency::Sinatra.required?
46
+
47
+ Sqreen::Dependency::Hook.add('Rack::Builder#to_app') do
48
+ after do |_, builder|
49
+ Sqreen::Dependency::Sinatra.inspect_middlewares(builder)
50
+ end
51
+ end if Sqreen::Dependency::Sinatra.required?
52
+
40
53
  # ensure startup of thread in request handling processes
41
54
 
42
55
  Sqreen::Dependency::Hook.add('Rack::Builder#to_app') do
@@ -0,0 +1,54 @@
1
+ # Copyright (c) 2015 Sqreen. All Rights Reserved.
2
+ # Please refer to our terms for more information: https://www.sqreen.io/terms.html
3
+
4
+ module Sqreen
5
+ module Dependency
6
+ module Sinatra
7
+ module_function
8
+
9
+ def required?
10
+ Sqreen::Dependency.const_exist?('Sinatra::Base')
11
+ end
12
+
13
+ def insert_sqreen_middlewares(builder, *args, &block)
14
+ Sqreen.log.debug { 'Inserting Sqreen middlewares for Sinatra' }
15
+ middleware = Sqreen::ErrorHandlingMiddleware
16
+ use = builder.instance_variable_get('@use')
17
+
18
+ p = proc { |app| middleware.new(app, *args, &block) }
19
+
20
+ return if middlewares(builder).include?(middleware)
21
+
22
+ if middlewares(builder).include?(::Sinatra::ShowExceptions)
23
+ Sqreen.log.warn('Sinatra :show_exceptions detected: Sinatra exception handling may prevent the Sqreen error page to display on attacks.')
24
+ end
25
+
26
+ if (i = middlewares(builder).index(::Rack::Head))
27
+ use.insert(i, p)
28
+ elsif (i = middlewares(builder).index(::Rack::MethodOverride))
29
+ use.insert(i + 1, p)
30
+ elsif (i = middlewares(builder).index(::Sinatra::ExtendedRack))
31
+ use.insert(i + 1, p)
32
+ else
33
+ use.insert(0, p)
34
+ end
35
+ end
36
+
37
+ def inspect_middlewares(builder)
38
+ Sqreen.log.debug do
39
+ "Middlewares: " << middlewares(builder).map(&:inspect).inspect
40
+ end
41
+ end
42
+
43
+ def middlewares(builder)
44
+ builder.instance_variable_get(:@use).map do |p|
45
+ unless p.respond_to?(:binding) && p.binding.local_variable_defined?(:middleware)
46
+ next :unknown
47
+ end
48
+
49
+ p.binding.local_variable_get(:middleware)
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -1,5 +1,5 @@
1
1
  # Copyright (c) 2015 Sqreen. All Rights Reserved.
2
2
  # Please refer to our terms for more information: https://www.sqreen.io/terms.html
3
3
  module Sqreen
4
- VERSION = '1.17.2.beta1'.freeze
4
+ VERSION = '1.17.2.beta2'.freeze
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sqreen
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.17.2.beta1
4
+ version: 1.17.2.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sqreen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-03 00:00:00.000000000 Z
11
+ date: 2019-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sq_mini_racer
@@ -61,6 +61,7 @@ files:
61
61
  - lib/sqreen/dependency/rack.rb
62
62
  - lib/sqreen/dependency/rails.rb
63
63
  - lib/sqreen/dependency/sentry.rb
64
+ - lib/sqreen/dependency/sinatra.rb
64
65
  - lib/sqreen/event.rb
65
66
  - lib/sqreen/events/attack.rb
66
67
  - lib/sqreen/events/remote_exception.rb