sinatra-contrib 4.2.1 → 4.2.2
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 +4 -4
- data/lib/sinatra/contrib/version.rb +1 -1
- data/lib/sinatra/quiet_logger.rb +20 -1
- data/sinatra-contrib.gemspec +3 -1
- metadata +6 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6cebaa00078a2b2de2591b9d59c57a8e9b4397bdb9b7407e7fab6b121b8084b3
|
|
4
|
+
data.tar.gz: 202e01d903046c7e6ca1876a36101c1e91029413fcd5a3bfca34682260bfe7a0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dc42d2b959a979d389c0c752da0104172dfc802dcb5a4da01b373c71571dbbb97a7fca2c6d49e766bd5ca2c7f2e29658daa63faf6e465373c543b72b791b9fad
|
|
7
|
+
data.tar.gz: 8113ec07d11aff659a1c9e9276f16f8c773b52b716f874b0dbfddab0ef541c26a311e876469018487545bfd70eac23728d55964997e88f32960ab33b61d5414e
|
data/lib/sinatra/quiet_logger.rb
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'rack/protection'
|
|
4
|
+
|
|
3
5
|
module Sinatra
|
|
4
6
|
# = Sinatra::QuietLogger
|
|
5
7
|
#
|
|
@@ -34,6 +36,8 @@ module Sinatra
|
|
|
34
36
|
# end
|
|
35
37
|
#
|
|
36
38
|
module QuietLogger
|
|
39
|
+
PATH_TRAVERSAL = ::Rack::Protection::PathTraversal.new(nil)
|
|
40
|
+
|
|
37
41
|
def self.registered(app)
|
|
38
42
|
quiet_logger_prefixes = begin
|
|
39
43
|
app.settings.quiet_logger_prefixes.join('|')
|
|
@@ -42,14 +46,29 @@ module Sinatra
|
|
|
42
46
|
end
|
|
43
47
|
return warn('You need to specify the paths you wish to exclude from logging via `set :quiet_logger_prefixes, %w(images css fonts)`') if quiet_logger_prefixes.empty?
|
|
44
48
|
|
|
49
|
+
@app = app
|
|
45
50
|
const_set('QUIET_LOGGER_REGEX', %r(\A/{0,2}(?:#{quiet_logger_prefixes})))
|
|
46
51
|
::Rack::CommonLogger.prepend(
|
|
47
52
|
::Module.new do
|
|
48
53
|
def log(env, *)
|
|
49
|
-
super unless env['PATH_INFO'] =~ QUIET_LOGGER_REGEX
|
|
54
|
+
super unless QuietLogger.routed_path(env['PATH_INFO'].to_s) =~ QUIET_LOGGER_REGEX
|
|
50
55
|
end
|
|
51
56
|
end
|
|
52
57
|
)
|
|
53
58
|
end
|
|
59
|
+
|
|
60
|
+
# The path the app matched its routes on. Rack::Protection::PathTraversal
|
|
61
|
+
# cleans the path for the app only, when the request is logged PATH_INFO
|
|
62
|
+
# is back to what the client sent.
|
|
63
|
+
def self.routed_path(path)
|
|
64
|
+
path_traversal? ? PATH_TRAVERSAL.cleanup(path) : path
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# Checked for each request, protection can be set after registering
|
|
68
|
+
def self.path_traversal?
|
|
69
|
+
protection = @app.protection
|
|
70
|
+
except = protection[:except] if protection.is_a?(Hash)
|
|
71
|
+
@app.protection? && !Array(except).include?(:path_traversal)
|
|
72
|
+
end
|
|
54
73
|
end
|
|
55
74
|
end
|
data/sinatra-contrib.gemspec
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sinatra-contrib
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.2.
|
|
4
|
+
version: 4.2.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- https://github.com/sinatra/sinatra/graphs/contributors
|
|
@@ -43,28 +43,28 @@ dependencies:
|
|
|
43
43
|
requirements:
|
|
44
44
|
- - '='
|
|
45
45
|
- !ruby/object:Gem::Version
|
|
46
|
-
version: 4.2.
|
|
46
|
+
version: 4.2.2
|
|
47
47
|
type: :runtime
|
|
48
48
|
prerelease: false
|
|
49
49
|
version_requirements: !ruby/object:Gem::Requirement
|
|
50
50
|
requirements:
|
|
51
51
|
- - '='
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
|
-
version: 4.2.
|
|
53
|
+
version: 4.2.2
|
|
54
54
|
- !ruby/object:Gem::Dependency
|
|
55
55
|
name: sinatra
|
|
56
56
|
requirement: !ruby/object:Gem::Requirement
|
|
57
57
|
requirements:
|
|
58
58
|
- - '='
|
|
59
59
|
- !ruby/object:Gem::Version
|
|
60
|
-
version: 4.2.
|
|
60
|
+
version: 4.2.2
|
|
61
61
|
type: :runtime
|
|
62
62
|
prerelease: false
|
|
63
63
|
version_requirements: !ruby/object:Gem::Requirement
|
|
64
64
|
requirements:
|
|
65
65
|
- - '='
|
|
66
66
|
- !ruby/object:Gem::Version
|
|
67
|
-
version: 4.2.
|
|
67
|
+
version: 4.2.2
|
|
68
68
|
- !ruby/object:Gem::Dependency
|
|
69
69
|
name: tilt
|
|
70
70
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
136
136
|
- !ruby/object:Gem::Version
|
|
137
137
|
version: '0'
|
|
138
138
|
requirements: []
|
|
139
|
-
rubygems_version:
|
|
139
|
+
rubygems_version: 4.0.20
|
|
140
140
|
specification_version: 4
|
|
141
141
|
summary: Collection of useful Sinatra extensions.
|
|
142
142
|
test_files: []
|