geminabox 3.1.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/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 +6 -2
- data/lib/geminabox/version.rb +1 -1
- 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/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
|
@@ -144,8 +144,9 @@ module Geminabox
|
|
|
144
144
|
error_response(403, 'Gem deletion is disabled - see https://github.com/geminabox/geminabox/issues/115')
|
|
145
145
|
end
|
|
146
146
|
|
|
147
|
+
path = file_path
|
|
147
148
|
serialize_update do
|
|
148
|
-
File.delete
|
|
149
|
+
File.delete path if File.exist? path
|
|
149
150
|
self.class.reindex(:force_rebuild)
|
|
150
151
|
redirect url("/")
|
|
151
152
|
end
|
|
@@ -255,7 +256,10 @@ HTML
|
|
|
255
256
|
end
|
|
256
257
|
|
|
257
258
|
def file_path
|
|
258
|
-
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
|
|
259
263
|
end
|
|
260
264
|
|
|
261
265
|
def dependency_cache
|
data/lib/geminabox/version.rb
CHANGED