geminabox 4.0.0 → 4.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 758c29c033252b87dc6fbe24ee015340f6f0c365ecc01aed02b7809e15ff3a6e
4
- data.tar.gz: 321199cded3cc8b60cf4ecf7f9b04c2a14ec5cc5246a0f072e3d4d12307106cd
3
+ metadata.gz: a7be0ebee3d899057907a90084837978a25915b3a82683e8ea74e0d1227d3125
4
+ data.tar.gz: 12a531294faf2cb0745b44ac1c9191a759f0d82ba05acabfa33d05637e4d551f
5
5
  SHA512:
6
- metadata.gz: b726d61fe2807fb6c2d0d19544c9e52d8b3cef10be0dd8d772e72f866d286017609034e54ff15ac222cb5bca6fac9394e57b964ae8cb939c7a4e34bc73431f89
7
- data.tar.gz: 0d84ea5560b6cc1bd32de94dd0b6952256f820e98ca5fdfbda9656c47eea1fecac25c8f3177518fc6ca59ba2fc293f072f75c18154f69d1e50cb70131208c05a
6
+ metadata.gz: 149594466d61a7637ec9e308aba64b4b076588f9e01523fac0cded7465f7bfeb257a9ea6b051e17a408580775f64210201b87d1fc5a81bb1d9555b28caab978d
7
+ data.tar.gz: c9ff3b58f3c76ca47330a9949ad6d01c98a88a5970d06eb06c0e0c417122315e3fadefc9b69e6e777c5b4adfc5a53b6675b014a53c2d9849cf455a547051fe6d
@@ -9,7 +9,10 @@ module Geminabox
9
9
 
10
10
  def serve
11
11
  headers["Cache-Control"] = 'no-transform'
12
- send_file(File.expand_path(File.join(Geminabox.data, *request.path_info)), :type => response['Content-Type'])
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
@@ -174,8 +174,9 @@ module Geminabox
174
174
  error_response(403, 'Gem deletion is disabled - see https://github.com/geminabox/geminabox/issues/115')
175
175
  end
176
176
 
177
+ path = file_path
177
178
  serialize_update do
178
- File.delete file_path if File.exist? file_path
179
+ File.delete path if File.exist? path
179
180
  self.class.reindex(:force_rebuild)
180
181
  redirect url("/")
181
182
  end
@@ -309,7 +310,10 @@ HTML
309
310
  end
310
311
 
311
312
  def file_path
312
- File.expand_path(File.join(Geminabox.data, *request.path_info))
313
+ path = File.expand_path(File.join(Geminabox.data, *request.path_info))
314
+ # Rack::Protection normally strips ".." first; this holds without it.
315
+ halt 404 unless path.start_with?(File.expand_path(Geminabox.data) + File::SEPARATOR)
316
+ path
313
317
  end
314
318
 
315
319
  def dependency_cache
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Geminabox
4
- VERSION = '4.0.0' unless defined? VERSION
4
+ VERSION = '4.0.1' unless defined? VERSION
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geminabox
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Lea