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 +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/sqreen/dependency/detector.rb +13 -0
- data/lib/sqreen/dependency/sinatra.rb +54 -0
- data/lib/sqreen/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b146b5b2fc5e830ab98c049eb17c576a943899035226300157eb88ab9db8fad5
|
4
|
+
data.tar.gz: 6a3ec0498bd1f1eac06caef917708a837fc06d83b6931e139f2da7890a2cc59a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c357bbd375005220b136be93496689df76d883cce643dda9c8260024393b2fc82173aa3f7ebd76e12fbe7d62309df9d5f009e7d304e38c2db548f40cd1fee6d2
|
7
|
+
data.tar.gz: 2606d78d949c24784f04fc71fab61d964a323cbbbe04580750c5dda4f954b3e07d95f9f34b15efb0e7a09ed2b1ee008cbd22d2a470cc03f84c1f3963fe111189
|
data/CHANGELOG.md
CHANGED
@@ -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
|
data/lib/sqreen/version.rb
CHANGED
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.
|
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-
|
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
|