webrick 1.6.1 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of webrick might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +0 -2
- data/lib/webrick.rb +7 -2
- data/lib/webrick/httpauth/authenticator.rb +1 -1
- data/lib/webrick/httpproxy.rb +6 -2
- data/lib/webrick/httprequest.rb +9 -4
- data/lib/webrick/httpservlet/filehandler.rb +15 -4
- data/lib/webrick/httputils.rb +1 -0
- data/lib/webrick/server.rb +3 -0
- data/lib/webrick/ssl.rb +2 -2
- data/lib/webrick/utils.rb +1 -6
- data/lib/webrick/version.rb +1 -1
- data/webrick.gemspec +3 -5
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 800e0427bf3a5f03799b0615f21888ef4827fde35a89663bcf90c055bf4e2221
|
4
|
+
data.tar.gz: ea2b6bdee1ae775c2946e6b16e73a3dbcd18ab27d910cc11eeb72f6eafdc3242
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d5511564c5ea1ff1eaf936af515acdaff9b157b767093b13e873a38596470bc42cab4a6be97770856e87d91b069ee05716e73dfea88d165a435737e332fb0f4
|
7
|
+
data.tar.gz: a2eaabfc8c4e16303a59cf45de503aaf71577824a8fb92dc2ad60cc4f5fc2478e707635062ed9abc138e260fbc7bea0cc999f8033e5a0f59deeb0e697ec47c1a
|
data/README.md
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# Webrick
|
2
2
|
|
3
|
-
[![Build Status](https://travis-ci.org/ruby/webrick.svg?branch=master)](https://travis-ci.org/ruby/webrick)
|
4
|
-
|
5
3
|
WEBrick is an HTTP server toolkit that can be configured as an HTTPS server, a proxy server, and a virtual-host server.
|
6
4
|
|
7
5
|
WEBrick features complete logging of both server operations and HTTP access.
|
data/lib/webrick.rb
CHANGED
@@ -15,6 +15,11 @@
|
|
15
15
|
# WEBrick also includes tools for daemonizing a process and starting a process
|
16
16
|
# at a higher privilege level and dropping permissions.
|
17
17
|
#
|
18
|
+
# == Security
|
19
|
+
#
|
20
|
+
# *Warning:* WEBrick is not recommended for production. It only implements
|
21
|
+
# basic security checks.
|
22
|
+
#
|
18
23
|
# == Starting an HTTP server
|
19
24
|
#
|
20
25
|
# To create a new WEBrick::HTTPServer that will listen to connections on port
|
@@ -139,9 +144,9 @@
|
|
139
144
|
# servers. See WEBrick::HTTPAuth, WEBrick::HTTPAuth::BasicAuth and
|
140
145
|
# WEBrick::HTTPAuth::DigestAuth.
|
141
146
|
#
|
142
|
-
# == WEBrick as a
|
147
|
+
# == WEBrick as a daemonized Web Server
|
143
148
|
#
|
144
|
-
# WEBrick can be run as a
|
149
|
+
# WEBrick can be run as a daemonized server for small loads.
|
145
150
|
#
|
146
151
|
# === Daemonizing
|
147
152
|
#
|
data/lib/webrick/httpproxy.rb
CHANGED
@@ -115,7 +115,7 @@ module WEBrick
|
|
115
115
|
proxy_auth(req, res)
|
116
116
|
|
117
117
|
begin
|
118
|
-
|
118
|
+
public_send("do_#{req.request_method}", req, res)
|
119
119
|
rescue NoMethodError
|
120
120
|
raise HTTPStatus::MethodNotAllowed,
|
121
121
|
"unsupported method `#{req.request_method}'."
|
@@ -295,6 +295,10 @@ module WEBrick
|
|
295
295
|
return FakeProxyURI
|
296
296
|
end
|
297
297
|
|
298
|
+
def create_net_http(uri, upstream)
|
299
|
+
Net::HTTP.new(uri.host, uri.port, upstream.host, upstream.port)
|
300
|
+
end
|
301
|
+
|
298
302
|
def perform_proxy_request(req, res, req_class, body_stream = nil)
|
299
303
|
uri = req.request_uri
|
300
304
|
path = uri.path.dup
|
@@ -303,7 +307,7 @@ module WEBrick
|
|
303
307
|
upstream = setup_upstream_proxy_authentication(req, res, header)
|
304
308
|
|
305
309
|
body_tmp = []
|
306
|
-
http =
|
310
|
+
http = create_net_http(uri, upstream)
|
307
311
|
req_fib = Fiber.new do
|
308
312
|
http.start do
|
309
313
|
if @config[:ProxyTimeout]
|
data/lib/webrick/httprequest.rb
CHANGED
@@ -9,6 +9,7 @@
|
|
9
9
|
#
|
10
10
|
# $IPR: httprequest.rb,v 1.64 2003/07/13 17:18:22 gotoyuzo Exp $
|
11
11
|
|
12
|
+
require 'fiber'
|
12
13
|
require 'uri'
|
13
14
|
require_relative 'httpversion'
|
14
15
|
require_relative 'httpstatus'
|
@@ -273,13 +274,17 @@ module WEBrick
|
|
273
274
|
self
|
274
275
|
end
|
275
276
|
|
276
|
-
# for IO.copy_stream.
|
277
|
-
# here; but IO.copy_stream does not care.
|
277
|
+
# for IO.copy_stream.
|
278
278
|
def readpartial(size, buf = ''.b) # :nodoc
|
279
279
|
res = @body_tmp.shift or raise EOFError, 'end of file reached'
|
280
|
+
if res.length > size
|
281
|
+
@body_tmp.unshift(res[size..-1])
|
282
|
+
res = res[0..size - 1]
|
283
|
+
end
|
280
284
|
buf.replace(res)
|
281
285
|
res.clear
|
282
|
-
|
286
|
+
# get more chunks - check alive? because we can take a partial chunk
|
287
|
+
@body_rd.resume if @body_rd.alive?
|
283
288
|
buf
|
284
289
|
end
|
285
290
|
|
@@ -517,7 +522,7 @@ module WEBrick
|
|
517
522
|
if @remaining_size > 0 && @socket.eof?
|
518
523
|
raise HTTPStatus::BadRequest, "invalid body size."
|
519
524
|
end
|
520
|
-
elsif BODY_CONTAINABLE_METHODS.member?(@request_method)
|
525
|
+
elsif BODY_CONTAINABLE_METHODS.member?(@request_method) && !@socket.eof
|
521
526
|
raise HTTPStatus::LengthRequired
|
522
527
|
end
|
523
528
|
return @body
|
@@ -212,9 +212,18 @@ module WEBrick
|
|
212
212
|
|
213
213
|
# :stopdoc:
|
214
214
|
|
215
|
+
def set_filesystem_encoding(str)
|
216
|
+
enc = Encoding.find('filesystem')
|
217
|
+
if enc == Encoding::US_ASCII
|
218
|
+
str.b
|
219
|
+
else
|
220
|
+
str.dup.force_encoding(enc)
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
215
224
|
def service(req, res)
|
216
225
|
# if this class is mounted on "/" and /~username is requested.
|
217
|
-
# we're going to override path
|
226
|
+
# we're going to override path information before invoking service.
|
218
227
|
if defined?(Etc) && @options[:UserDir] && req.script_name.empty?
|
219
228
|
if %r|^(/~([^/]+))| =~ req.path_info
|
220
229
|
script_name, user = $1, $2
|
@@ -298,7 +307,7 @@ module WEBrick
|
|
298
307
|
end
|
299
308
|
|
300
309
|
def exec_handler(req, res)
|
301
|
-
raise HTTPStatus::NotFound, "`#{req.path}' not found" unless @root
|
310
|
+
raise HTTPStatus::NotFound, "`#{req.path}' not found." unless @root
|
302
311
|
if set_filename(req, res)
|
303
312
|
handler = get_handler(req, res)
|
304
313
|
call_callback(:HandlerCallback, req, res)
|
@@ -324,11 +333,12 @@ module WEBrick
|
|
324
333
|
end
|
325
334
|
|
326
335
|
def set_filename(req, res)
|
327
|
-
res.filename = @root
|
336
|
+
res.filename = @root
|
328
337
|
path_info = req.path_info.scan(%r|/[^/]*|)
|
329
338
|
|
330
339
|
path_info.unshift("") # dummy for checking @root dir
|
331
340
|
while base = path_info.first
|
341
|
+
base = set_filesystem_encoding(base)
|
332
342
|
break if base == "/"
|
333
343
|
break unless File.directory?(File.expand_path(res.filename + base))
|
334
344
|
shift_path_info(req, res, path_info)
|
@@ -336,6 +346,7 @@ module WEBrick
|
|
336
346
|
end
|
337
347
|
|
338
348
|
if base = path_info.first
|
349
|
+
base = set_filesystem_encoding(base)
|
339
350
|
if base == "/"
|
340
351
|
if file = search_index_file(req, res)
|
341
352
|
shift_path_info(req, res, path_info, file)
|
@@ -364,7 +375,7 @@ module WEBrick
|
|
364
375
|
|
365
376
|
def shift_path_info(req, res, path_info, base=nil)
|
366
377
|
tmp = path_info.shift
|
367
|
-
base = base || tmp
|
378
|
+
base = base || set_filesystem_encoding(tmp)
|
368
379
|
req.path_info = path_info.join
|
369
380
|
req.script_name << base
|
370
381
|
res.filename = File.expand_path(res.filename + base)
|
data/lib/webrick/httputils.rb
CHANGED
data/lib/webrick/server.rb
CHANGED
@@ -102,6 +102,9 @@ module WEBrick
|
|
102
102
|
@listeners = []
|
103
103
|
@shutdown_pipe = nil
|
104
104
|
unless @config[:DoNotListen]
|
105
|
+
raise ArgumentError, "Port must an integer" unless @config[:Port].to_s == @config[:Port].to_i.to_s
|
106
|
+
|
107
|
+
@config[:Port] = @config[:Port].to_i
|
105
108
|
if @config[:Listen]
|
106
109
|
warn(":Listen option is deprecated; use GenericServer#listen", uplevel: 1)
|
107
110
|
end
|
data/lib/webrick/ssl.rb
CHANGED
@@ -122,7 +122,7 @@ module WEBrick
|
|
122
122
|
ef.issuer_certificate = cert
|
123
123
|
cert.extensions = [
|
124
124
|
ef.create_extension("basicConstraints","CA:FALSE"),
|
125
|
-
ef.create_extension("keyUsage", "keyEncipherment"),
|
125
|
+
ef.create_extension("keyUsage", "keyEncipherment, digitalSignature, keyAgreement, dataEncipherment"),
|
126
126
|
ef.create_extension("subjectKeyIdentifier", "hash"),
|
127
127
|
ef.create_extension("extendedKeyUsage", "serverAuth"),
|
128
128
|
ef.create_extension("nsComment", comment),
|
@@ -130,7 +130,7 @@ module WEBrick
|
|
130
130
|
aki = ef.create_extension("authorityKeyIdentifier",
|
131
131
|
"keyid:always,issuer:always")
|
132
132
|
cert.add_extension(aki)
|
133
|
-
cert.sign(rsa,
|
133
|
+
cert.sign(rsa, "SHA256")
|
134
134
|
|
135
135
|
return [ cert, rsa ]
|
136
136
|
end
|
data/lib/webrick/utils.rb
CHANGED
data/lib/webrick/version.rb
CHANGED
data/webrick.gemspec
CHANGED
@@ -61,14 +61,12 @@ Gem::Specification.new do |s|
|
|
61
61
|
|
62
62
|
s.authors = ["TAKAHASHI Masayoshi", "GOTOU YUUZOU", "Eric Wong"]
|
63
63
|
s.email = [nil, nil, 'normal@ruby-lang.org']
|
64
|
-
s.homepage = "https://
|
65
|
-
s.
|
64
|
+
s.homepage = "https://github.com/ruby/webrick"
|
65
|
+
s.licenses = ["Ruby", "BSD-2-Clause"]
|
66
66
|
|
67
67
|
if s.respond_to?(:metadata=)
|
68
68
|
s.metadata = {
|
69
|
-
"bug_tracker_uri" => "https://
|
70
|
-
"homepage_uri" => "https://www.ruby-lang.org",
|
71
|
-
"source_code_uri" => "https://git.ruby-lang.org/ruby.git/"
|
69
|
+
"bug_tracker_uri" => "https://github.com/ruby/webrick/issues",
|
72
70
|
}
|
73
71
|
end
|
74
72
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webrick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TAKAHASHI Masayoshi
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2020-
|
13
|
+
date: 2020-12-11 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|
@@ -78,13 +78,12 @@ files:
|
|
78
78
|
- lib/webrick/utils.rb
|
79
79
|
- lib/webrick/version.rb
|
80
80
|
- webrick.gemspec
|
81
|
-
homepage: https://
|
81
|
+
homepage: https://github.com/ruby/webrick
|
82
82
|
licenses:
|
83
|
+
- Ruby
|
83
84
|
- BSD-2-Clause
|
84
85
|
metadata:
|
85
|
-
bug_tracker_uri: https://
|
86
|
-
homepage_uri: https://www.ruby-lang.org
|
87
|
-
source_code_uri: https://git.ruby-lang.org/ruby.git/
|
86
|
+
bug_tracker_uri: https://github.com/ruby/webrick/issues
|
88
87
|
post_install_message:
|
89
88
|
rdoc_options: []
|
90
89
|
require_paths:
|
@@ -100,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
99
|
- !ruby/object:Gem::Version
|
101
100
|
version: '0'
|
102
101
|
requirements: []
|
103
|
-
rubygems_version: 3.2.0
|
102
|
+
rubygems_version: 3.2.0
|
104
103
|
signing_key:
|
105
104
|
specification_version: 4
|
106
105
|
summary: HTTP server toolkit
|