geminabox 3.0.0 → 3.1.1
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/README.md +8 -0
- data/lib/geminabox/hostess.rb +4 -1
- data/lib/geminabox/incoming_gem.rb +5 -1
- data/lib/geminabox/proxy/file_handler.rb +5 -0
- data/lib/geminabox/proxy/hostess.rb +11 -4
- data/lib/geminabox/server.rb +7 -2
- data/lib/geminabox/version.rb +1 -1
- data/lib/geminabox.rb +11 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4da5997cf6f07bf5f5c18308b50ddabae4e3acad3c59b5e725555632c94338ec
|
|
4
|
+
data.tar.gz: 27a3b1392251204e9f210b9efd1b2dbb0e081e851381fce830385f1eb9db4c28
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 74b98e66ccc6112d37fb694189c216297cbdfedaeaf1570ce2c0682db24722cb59c1ea5f513f7068743beb7b607969c6eca404f47d72aac822d99a066e9c07be
|
|
7
|
+
data.tar.gz: 4c818745e2edf7e128e4c6849d07a01f54b29cc851eaa57d5ffb9f101076b28db02f2c45ec49cc8c2bb25500f8e0ad1c67930b54b851122b4041e0f42fac8591
|
data/README.md
CHANGED
|
@@ -43,6 +43,12 @@ Start your gem server with 'rackup' to run WEBrick or hook up the config.ru as y
|
|
|
43
43
|
|
|
44
44
|
## RubyGems Proxy
|
|
45
45
|
|
|
46
|
+
> **Deprecated.** The RubyGems proxy is unmaintained and **will be removed in
|
|
47
|
+
> Geminabox 4.0.** It depends on the RubyGems.org Dependency API
|
|
48
|
+
> (`/api/v1/dependencies`), which was [sunset on 2023-05-24](https://blog.rubygems.org/2023/02/22/dependency-api-deprecation.html)
|
|
49
|
+
> in favour of the Compact Index API, so proxy mode no longer functions.
|
|
50
|
+
> Enabling it now emits a deprecation warning. Do not rely on this feature.
|
|
51
|
+
|
|
46
52
|
Geminabox can be configured to pull gems, it does not currently have, from rubygems.org. To enable this mode you can either:
|
|
47
53
|
|
|
48
54
|
Set RUBYGEM_PROXY to true in the environment:
|
|
@@ -180,6 +186,8 @@ Your Gemfile only needs:
|
|
|
180
186
|
source 'https://rubygems.org'
|
|
181
187
|
|
|
182
188
|
gem 'geminabox'
|
|
189
|
+
gem 'rackup'
|
|
190
|
+
gem 'webrick' # or other server you prefer
|
|
183
191
|
```
|
|
184
192
|
|
|
185
193
|
From there
|
data/lib/geminabox/hostess.rb
CHANGED
|
@@ -9,7 +9,10 @@ module Geminabox
|
|
|
9
9
|
|
|
10
10
|
def serve
|
|
11
11
|
headers["Cache-Control"] = 'no-transform'
|
|
12
|
-
|
|
12
|
+
path = File.expand_path(File.join(Geminabox.data, *request.path_info))
|
|
13
|
+
# Rack::Protection normally strips ".." first; this holds without it.
|
|
14
|
+
halt 404 unless path.start_with?(File.expand_path(Geminabox.data) + File::SEPARATOR)
|
|
15
|
+
send_file(path, :type => response['Content-Type'])
|
|
13
16
|
end
|
|
14
17
|
|
|
15
18
|
%w[/specs.4.8.gz
|
|
@@ -26,8 +26,12 @@ module Geminabox
|
|
|
26
26
|
File.open(@tempfile.path, "rb")
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
+
# spec comes from the uploaded archive and RubyGems does not validate it on
|
|
30
|
+
# read, so the name must be checked before it becomes part of a path.
|
|
29
31
|
def valid?
|
|
30
|
-
spec && spec.name && spec.version
|
|
32
|
+
spec && spec.name && spec.version &&
|
|
33
|
+
spec.name.match?(Gem::Specification::VALID_NAME_PATTERN) &&
|
|
34
|
+
File.basename(name) == name
|
|
31
35
|
rescue Gem::Package::Error
|
|
32
36
|
false
|
|
33
37
|
end
|
|
@@ -8,6 +8,11 @@ module Geminabox
|
|
|
8
8
|
|
|
9
9
|
def initialize(file_name)
|
|
10
10
|
@file_name = file_name
|
|
11
|
+
# file_name comes from the request path; both paths get mkdir_p and writes.
|
|
12
|
+
root = File.expand_path(root_path) + File::SEPARATOR
|
|
13
|
+
unless local_path.start_with?(root) && proxy_path.start_with?(root)
|
|
14
|
+
raise ArgumentError, "#{file_name} resolves outside #{root_path}"
|
|
15
|
+
end
|
|
11
16
|
ensure_destination_exists
|
|
12
17
|
end
|
|
13
18
|
|
|
@@ -14,7 +14,7 @@ module Geminabox
|
|
|
14
14
|
if file_handler
|
|
15
15
|
send_file file_handler.proxy_path
|
|
16
16
|
else
|
|
17
|
-
send_file(
|
|
17
|
+
send_file(data_path, :type => response['Content-Type'])
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
20
|
|
|
@@ -53,9 +53,7 @@ module Geminabox
|
|
|
53
53
|
private
|
|
54
54
|
def get_from_rubygems_if_not_local
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
unless File.exist?(file)
|
|
56
|
+
unless File.exist?(data_path)
|
|
59
57
|
ruby_gems_url = Geminabox.ruby_gems_url
|
|
60
58
|
path = File.join(ruby_gems_url, *request.path_info)
|
|
61
59
|
content = Geminabox.http_adapter.get_content(path)
|
|
@@ -70,6 +68,15 @@ module Geminabox
|
|
|
70
68
|
|
|
71
69
|
def copy_file(file_name)
|
|
72
70
|
self.file_handler = Copier.copy(file_name)
|
|
71
|
+
rescue ArgumentError
|
|
72
|
+
halt 404
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# Rack::Protection normally strips ".." first; this holds without it.
|
|
76
|
+
def data_path
|
|
77
|
+
path = File.expand_path(File.join(Geminabox.data, *request.path_info))
|
|
78
|
+
halt 404 unless path.start_with?(File.expand_path(Geminabox.data) + File::SEPARATOR)
|
|
79
|
+
path
|
|
73
80
|
end
|
|
74
81
|
|
|
75
82
|
|
data/lib/geminabox/server.rb
CHANGED
|
@@ -12,6 +12,7 @@ module Geminabox
|
|
|
12
12
|
set :host_authorization, { permitted_hosts: [] }
|
|
13
13
|
|
|
14
14
|
if Geminabox.rubygems_proxy
|
|
15
|
+
Geminabox.warn_rubygems_proxy_deprecation
|
|
15
16
|
use Proxy::Hostess
|
|
16
17
|
else
|
|
17
18
|
use Hostess
|
|
@@ -143,8 +144,9 @@ module Geminabox
|
|
|
143
144
|
error_response(403, 'Gem deletion is disabled - see https://github.com/geminabox/geminabox/issues/115')
|
|
144
145
|
end
|
|
145
146
|
|
|
147
|
+
path = file_path
|
|
146
148
|
serialize_update do
|
|
147
|
-
File.delete
|
|
149
|
+
File.delete path if File.exist? path
|
|
148
150
|
self.class.reindex(:force_rebuild)
|
|
149
151
|
redirect url("/")
|
|
150
152
|
end
|
|
@@ -254,7 +256,10 @@ HTML
|
|
|
254
256
|
end
|
|
255
257
|
|
|
256
258
|
def file_path
|
|
257
|
-
File.expand_path(File.join(Geminabox.data, *request.path_info))
|
|
259
|
+
path = File.expand_path(File.join(Geminabox.data, *request.path_info))
|
|
260
|
+
# Rack::Protection normally strips ".." first; this holds without it.
|
|
261
|
+
halt 404 unless path.start_with?(File.expand_path(Geminabox.data) + File::SEPARATOR)
|
|
262
|
+
path
|
|
258
263
|
end
|
|
259
264
|
|
|
260
265
|
def dependency_cache
|
data/lib/geminabox/version.rb
CHANGED
data/lib/geminabox.rb
CHANGED
|
@@ -68,6 +68,17 @@ module Geminabox
|
|
|
68
68
|
Server.settings
|
|
69
69
|
end
|
|
70
70
|
|
|
71
|
+
# Deprecated: the RubyGems proxy is unmaintained and will be removed in
|
|
72
|
+
# Geminabox 4.0. It depends on the RubyGems.org Dependency API
|
|
73
|
+
# (/api/v1/dependencies), which was sunset on 2023-05-24, so proxy mode no
|
|
74
|
+
# longer functions.
|
|
75
|
+
def warn_rubygems_proxy_deprecation
|
|
76
|
+
warn '[DEPRECATION] Geminabox RubyGems proxy is deprecated and will be ' \
|
|
77
|
+
'removed in Geminabox 4.0. It depends on the RubyGems.org ' \
|
|
78
|
+
'Dependency API (/api/v1/dependencies), which was sunset on ' \
|
|
79
|
+
'2023-05-24, so proxy mode no longer functions.'
|
|
80
|
+
end
|
|
81
|
+
|
|
71
82
|
def call(env)
|
|
72
83
|
Server.call env
|
|
73
84
|
end
|