sinatra 4.0.1 → 4.1.0
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/CHANGELOG.md +17 -28
- data/README.md +30 -10
- data/VERSION +1 -1
- data/lib/sinatra/base.rb +32 -11
- data/lib/sinatra/indifferent_hash.rb +1 -1
- data/lib/sinatra/version.rb +1 -1
- data/sinatra.gemspec +1 -2
- metadata +9 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a487551e0b40831dadeffd669ae0a8fb408fc5880825f2257105beec8be727ec
|
4
|
+
data.tar.gz: f7999f252d7d1c2192a3c909911ff5879075a811a8c742c89a2d700bf1db8b82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 611bf8733959bae4110a357e22be091cd3c044a5f810d133a9833993c84e2ae7a3b2c3999fd13991338c44e72ac5ab6b9b3af8bc9d4667384fd97b7715c086d2
|
7
|
+
data.tar.gz: 824f4f37c5cc5fde671bdf286c63cd67672566c10fadcf80b841eddc9685f92b88a9032ee8b711a2b859a5529afc082fe11f09ac1204f8b04659501f13a03747
|
data/CHANGELOG.md
CHANGED
@@ -1,29 +1,18 @@
|
|
1
|
-
## 4.0
|
2
|
-
|
3
|
-
*
|
4
|
-
|
5
|
-
*
|
6
|
-
|
7
|
-
*
|
8
|
-
|
9
|
-
* Fix
|
10
|
-
|
11
|
-
* Declare missing dependencies for Ruby 3.5 ([#2032])
|
12
|
-
|
13
|
-
* Fix
|
14
|
-
|
15
|
-
*
|
16
|
-
|
17
|
-
* Address URI depreciation ([#2060])
|
18
|
-
|
19
|
-
[#2035]: https://github.com/sinatra/sinatra/pull/2035
|
20
|
-
[#2081]: https://github.com/sinatra/sinatra/pull/2081
|
21
|
-
[#2078]: https://github.com/sinatra/sinatra/pull/2078
|
22
|
-
[#2033]: https://github.com/sinatra/sinatra/pull/2033
|
23
|
-
[#2032]: https://github.com/sinatra/sinatra/pull/2032
|
24
|
-
[#2028]: https://github.com/sinatra/sinatra/pull/2028
|
25
|
-
[#2050]: https://github.com/sinatra/sinatra/pull/2050
|
26
|
-
[#2060]: https://github.com/sinatra/sinatra/pull/2060
|
1
|
+
## 4.1.0 / 2024-11-18
|
2
|
+
|
3
|
+
* New: Add `host_authorization` setting ([#2053](https://github.com/sinatra/sinatra/pull/2053))
|
4
|
+
* Defaults to `.localhost`, `.test` and any IP address in development mode.
|
5
|
+
* Security: addresses [CVE-2018-11627](https://github.com/advisories/GHSA-hxx2-7vcw-mqr3).
|
6
|
+
* Fix: Return an instance of `Sinatra::IndifferentHash` when calling `#except` ([#2044](https://github.com/sinatra/sinatra/pull/2044))
|
7
|
+
* Fix: Address warning from `URI` for Ruby 3.4 ([#2060](https://github.com/sinatra/sinatra/pull/2060))
|
8
|
+
* Fix: `rackup` no longer depends on WEBrick, recommend Puma instead ([`4a558503`](https://github.com/sinatra/sinatra/commit/4a558503a0ee41f26d4ebc07b478340e8a8a5ed6))
|
9
|
+
* Fix: Zeitwerk 2.7.0+ compatibility ([#2050](https://github.com/sinatra/sinatra/pull/2050))
|
10
|
+
* Fix: Address warning about Hash construction for Ruby 3.4 ([#2028](https://github.com/sinatra/sinatra/pull/2028))
|
11
|
+
* Fix: Declare missing dependencies for Ruby 3.5 ([#2032](https://github.com/sinatra/sinatra/pull/2032))
|
12
|
+
* Fix: Compatibility with `--enable-frozen-string-literal` ([#2033](https://github.com/sinatra/sinatra/pull/2033))
|
13
|
+
* Fix: Rack 3.1 compatibility ([#2035](https://github.com/sinatra/sinatra/pull/2035))
|
14
|
+
* Don't depend on `Rack::Logger`
|
15
|
+
* Don't delete `content-length` header when `Rack::Files` is used
|
27
16
|
|
28
17
|
## 4.0.0. / 2024-01-19
|
29
18
|
|
@@ -270,7 +259,7 @@
|
|
270
259
|
|
271
260
|
* Fix issue with passed routes and provides Fixes [#1095](https://github.com/sinatra/sinatra/pull/1095) [#1606](https://github.com/sinatra/sinatra/pull/1606) by Mike Pastore, Jordan Owens
|
272
261
|
|
273
|
-
* Add QuietLogger that excludes
|
262
|
+
* Add QuietLogger that excludes paths from Rack::CommonLogger [1250](https://github.com/sinatra/sinatra/pull/1250) by Christoph Wagner
|
274
263
|
|
275
264
|
* Sinatra::Contrib dependency updates. Fixes [#1207](https://github.com/sinatra/sinatra/pull/1207) [#1411](https://github.com/sinatra/sinatra/pull/1411) by Mike Pastore
|
276
265
|
|
@@ -1636,7 +1625,7 @@ the 1.0 release:
|
|
1636
1625
|
Hash structure. e.g., "post[title]=Hello&post[body]=World" yields
|
1637
1626
|
params: {'post' => {'title' => 'Hello', 'body' => 'World'}}.
|
1638
1627
|
|
1639
|
-
* Regular expressions may now be used in route
|
1628
|
+
* Regular expressions may now be used in route patterns; captures are
|
1640
1629
|
available at "params[:captures]".
|
1641
1630
|
|
1642
1631
|
* New ":provides" route condition takes an array of mime types and
|
data/README.md
CHANGED
@@ -15,11 +15,10 @@ get '/' do
|
|
15
15
|
end
|
16
16
|
```
|
17
17
|
|
18
|
-
Install the
|
18
|
+
Install the gems needed:
|
19
19
|
|
20
20
|
```shell
|
21
|
-
gem install sinatra
|
22
|
-
gem install puma # or any other server
|
21
|
+
gem install sinatra rackup puma
|
23
22
|
```
|
24
23
|
|
25
24
|
And run with:
|
@@ -1993,6 +1992,31 @@ set :protection, :session => true
|
|
1993
1992
|
<tt>"development"</tt> if not available.
|
1994
1993
|
</dd>
|
1995
1994
|
|
1995
|
+
<dt>host_authorization</dt>
|
1996
|
+
<dd>
|
1997
|
+
You can pass a hash of options to <tt>host_authorization</tt>,
|
1998
|
+
to be used by the <tt>Rack::Protection::HostAuthorization</tt> middleware.
|
1999
|
+
<dd>
|
2000
|
+
<dd>
|
2001
|
+
The middleware can block requests with unrecognized hostnames, to prevent DNS rebinding
|
2002
|
+
and other host header attacks. It checks the <tt>Host</tt>, <tt>X-Forwarded-Host</tt>
|
2003
|
+
and <tt>Forwarded</tt> headers.
|
2004
|
+
</dd>
|
2005
|
+
<dd>
|
2006
|
+
Useful options are:
|
2007
|
+
<ul>
|
2008
|
+
<li><tt>permitted_hosts</tt> – an array of hostnames (and <tt>IPAddr</tt> objects) your app recognizes
|
2009
|
+
<ul>
|
2010
|
+
<li>in the <tt>development</tt> environment, it is set to <tt>.localhost</tt>, <tt>.test</tt> and any IPv4/IPv6 address</li>
|
2011
|
+
<li>if empty, any hostname is permitted (the default for any other environment)</li>
|
2012
|
+
</ul>
|
2013
|
+
</li>
|
2014
|
+
<li><tt>status</tt> – the HTTP status code used in the response when a request is blocked (defaults to <tt>403</tt>)</li>
|
2015
|
+
<li><tt>message</tt> – the body used in the response when a request is blocked (defaults to <tt>Host not permitted</tt>)</li>
|
2016
|
+
<li><tt>allow_if</tt> – supply a <tt>Proc</tt> to use custom allow/deny logic, the proc is passed the request environment</li>
|
2017
|
+
</ul>
|
2018
|
+
</dd>
|
2019
|
+
|
1996
2020
|
<dt>logging</dt>
|
1997
2021
|
<dd>Use the logger.</dd>
|
1998
2022
|
|
@@ -2086,12 +2110,8 @@ set :protection, :session => true
|
|
2086
2110
|
|
2087
2111
|
<dt>server_settings</dt>
|
2088
2112
|
<dd>
|
2089
|
-
|
2090
|
-
|
2091
|
-
such as <tt>SSLEnable</tt> or <tt>SSLVerifyClient</tt>. However, web
|
2092
|
-
servers such as Puma do not support this, so you can set
|
2093
|
-
<tt>server_settings</tt> by defining it as a method when you call
|
2094
|
-
<tt>configure</tt>.
|
2113
|
+
You can pass a hash of options to <tt>server_settings</tt>,
|
2114
|
+
such as <tt>Host</tt> or <tt>Port</tt>.
|
2095
2115
|
</dd>
|
2096
2116
|
|
2097
2117
|
<dt>sessions</dt>
|
@@ -2812,7 +2832,7 @@ _Paraphrasing from
|
|
2812
2832
|
by Konstantin_
|
2813
2833
|
|
2814
2834
|
Sinatra doesn't impose any concurrency model but leaves that to the
|
2815
|
-
underlying Rack handler (server) like Puma or
|
2835
|
+
underlying Rack handler (server) like Puma or Falcon. Sinatra
|
2816
2836
|
itself is thread-safe, so there won't be any problem if the Rack handler
|
2817
2837
|
uses a threaded model of concurrency.
|
2818
2838
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
4.0
|
1
|
+
4.1.0
|
data/lib/sinatra/base.rb
CHANGED
@@ -14,6 +14,7 @@ require 'mustermann/sinatra'
|
|
14
14
|
require 'mustermann/regular'
|
15
15
|
|
16
16
|
# stdlib dependencies
|
17
|
+
require 'ipaddr'
|
17
18
|
require 'time'
|
18
19
|
require 'uri'
|
19
20
|
|
@@ -63,7 +64,7 @@ module Sinatra
|
|
63
64
|
alias secure? ssl?
|
64
65
|
|
65
66
|
def forwarded?
|
66
|
-
|
67
|
+
!forwarded_authority.nil?
|
67
68
|
end
|
68
69
|
|
69
70
|
def safe?
|
@@ -395,11 +396,11 @@ module Sinatra
|
|
395
396
|
end
|
396
397
|
params.delete :charset if mime_type.include? 'charset'
|
397
398
|
unless params.empty?
|
398
|
-
mime_type << ';'
|
399
|
+
mime_type << (mime_type.include?(';') ? ', ' : ';')
|
399
400
|
mime_type << params.map do |key, val|
|
400
|
-
val = val.inspect if val
|
401
|
+
val = val.inspect if val =~ /[";,]/
|
401
402
|
"#{key}=#{val}"
|
402
|
-
end.join('
|
403
|
+
end.join(', ')
|
403
404
|
end
|
404
405
|
response['content-type'] = mime_type
|
405
406
|
end
|
@@ -1600,20 +1601,20 @@ module Sinatra
|
|
1600
1601
|
alias stop! quit!
|
1601
1602
|
|
1602
1603
|
# Run the Sinatra app as a self-hosted server using
|
1603
|
-
# Puma, Falcon
|
1604
|
+
# Puma, Falcon (in that order). If given a block, will call
|
1604
1605
|
# with the constructed handler once we have taken the stage.
|
1605
1606
|
def run!(options = {}, &block)
|
1606
1607
|
unless defined?(Rackup::Handler)
|
1607
1608
|
rackup_warning = <<~MISSING_RACKUP
|
1608
|
-
Sinatra could not start, the
|
1609
|
+
Sinatra could not start, the required gems weren't found!
|
1609
1610
|
|
1610
|
-
Add
|
1611
|
+
Add them to your bundle with:
|
1611
1612
|
|
1612
|
-
bundle add rackup
|
1613
|
+
bundle add rackup puma
|
1613
1614
|
|
1614
|
-
or install
|
1615
|
+
or install them with:
|
1615
1616
|
|
1616
|
-
gem install rackup
|
1617
|
+
gem install rackup puma
|
1617
1618
|
|
1618
1619
|
MISSING_RACKUP
|
1619
1620
|
warn rackup_warning
|
@@ -1821,6 +1822,7 @@ module Sinatra
|
|
1821
1822
|
setup_logging builder
|
1822
1823
|
setup_sessions builder
|
1823
1824
|
setup_protection builder
|
1825
|
+
setup_host_authorization builder
|
1824
1826
|
end
|
1825
1827
|
|
1826
1828
|
def setup_middleware(builder)
|
@@ -1869,6 +1871,10 @@ module Sinatra
|
|
1869
1871
|
builder.use Rack::Protection, options
|
1870
1872
|
end
|
1871
1873
|
|
1874
|
+
def setup_host_authorization(builder)
|
1875
|
+
builder.use Rack::Protection::HostAuthorization, host_authorization
|
1876
|
+
end
|
1877
|
+
|
1872
1878
|
def setup_sessions(builder)
|
1873
1879
|
return unless sessions?
|
1874
1880
|
|
@@ -1963,10 +1969,25 @@ module Sinatra
|
|
1963
1969
|
set :running_server, nil
|
1964
1970
|
set :handler_name, nil
|
1965
1971
|
set :traps, true
|
1966
|
-
set :server, %w[
|
1972
|
+
set :server, %w[]
|
1967
1973
|
set :bind, proc { development? ? 'localhost' : '0.0.0.0' }
|
1968
1974
|
set :port, Integer(ENV['PORT'] && !ENV['PORT'].empty? ? ENV['PORT'] : 4567)
|
1969
1975
|
set :quiet, false
|
1976
|
+
set :host_authorization, ->() do
|
1977
|
+
if development?
|
1978
|
+
{
|
1979
|
+
permitted_hosts: [
|
1980
|
+
"localhost",
|
1981
|
+
".localhost",
|
1982
|
+
".test",
|
1983
|
+
IPAddr.new("0.0.0.0/0"),
|
1984
|
+
IPAddr.new("::/0"),
|
1985
|
+
]
|
1986
|
+
}
|
1987
|
+
else
|
1988
|
+
{}
|
1989
|
+
end
|
1990
|
+
end
|
1970
1991
|
|
1971
1992
|
ruby_engine = defined?(RUBY_ENGINE) && RUBY_ENGINE
|
1972
1993
|
|
data/lib/sinatra/version.rb
CHANGED
data/sinatra.gemspec
CHANGED
@@ -40,8 +40,7 @@ RubyGems 2.0 or newer is required to protect against public gem pushes. You can
|
|
40
40
|
'homepage_uri' => 'http://sinatrarb.com/',
|
41
41
|
'bug_tracker_uri' => 'https://github.com/sinatra/sinatra/issues',
|
42
42
|
'mailing_list_uri' => 'http://groups.google.com/group/sinatrarb',
|
43
|
-
'documentation_uri' => 'https://www.rubydoc.info/gems/sinatra'
|
44
|
-
'rubygems_mfa_required' => 'true',
|
43
|
+
'documentation_uri' => 'https://www.rubydoc.info/gems/sinatra'
|
45
44
|
}
|
46
45
|
|
47
46
|
s.required_ruby_version = '>= 2.7.8'
|
metadata
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0
|
4
|
+
version: 4.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Blake Mizerany
|
8
8
|
- Ryan Tomayko
|
9
9
|
- Simon Rozet
|
10
10
|
- Konstantin Haase
|
11
|
+
autorequire:
|
11
12
|
bindir: bin
|
12
13
|
cert_chain: []
|
13
|
-
date:
|
14
|
+
date: 2024-11-18 00:00:00.000000000 Z
|
14
15
|
dependencies:
|
15
16
|
- !ruby/object:Gem::Dependency
|
16
17
|
name: logger
|
@@ -66,14 +67,14 @@ dependencies:
|
|
66
67
|
requirements:
|
67
68
|
- - '='
|
68
69
|
- !ruby/object:Gem::Version
|
69
|
-
version: 4.0
|
70
|
+
version: 4.1.0
|
70
71
|
type: :runtime
|
71
72
|
prerelease: false
|
72
73
|
version_requirements: !ruby/object:Gem::Requirement
|
73
74
|
requirements:
|
74
75
|
- - '='
|
75
76
|
- !ruby/object:Gem::Version
|
76
|
-
version: 4.0
|
77
|
+
version: 4.1.0
|
77
78
|
- !ruby/object:Gem::Dependency
|
78
79
|
name: rack-session
|
79
80
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,8 +115,8 @@ email: sinatrarb@googlegroups.com
|
|
114
115
|
executables: []
|
115
116
|
extensions: []
|
116
117
|
extra_rdoc_files:
|
117
|
-
- LICENSE
|
118
118
|
- README.md
|
119
|
+
- LICENSE
|
119
120
|
files:
|
120
121
|
- ".yardopts"
|
121
122
|
- AUTHORS.md
|
@@ -152,7 +153,7 @@ metadata:
|
|
152
153
|
bug_tracker_uri: https://github.com/sinatra/sinatra/issues
|
153
154
|
mailing_list_uri: http://groups.google.com/group/sinatrarb
|
154
155
|
documentation_uri: https://www.rubydoc.info/gems/sinatra
|
155
|
-
|
156
|
+
post_install_message:
|
156
157
|
rdoc_options:
|
157
158
|
- "--line-numbers"
|
158
159
|
- "--title"
|
@@ -173,7 +174,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
173
174
|
- !ruby/object:Gem::Version
|
174
175
|
version: '0'
|
175
176
|
requirements: []
|
176
|
-
rubygems_version: 3.
|
177
|
+
rubygems_version: 3.5.22
|
178
|
+
signing_key:
|
177
179
|
specification_version: 4
|
178
180
|
summary: Classy web-development dressed in a DSL
|
179
181
|
test_files: []
|