Skip to content

Commit 81dd50b

Browse files
committed
Specs for new RubyGems CVEs
1 parent 3a8b2c2 commit 81dd50b

9 files changed

+124
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
require_relative '../spec_helper'
2+
3+
require 'rubygems'
4+
require 'rubygems/user_interaction'
5+
6+
describe "CVE-2019-8321 is resisted by" do
7+
it "sanitising verbose messages" do
8+
ui = Class.new {
9+
include Gem::UserInteraction
10+
}.new
11+
ui.should_receive(:say).with(".]2;nyan.")
12+
verbose_before = Gem.configuration.verbose
13+
begin
14+
Gem.configuration.verbose = :really_verbose
15+
ui.verbose("\e]2;nyan\a")
16+
ensure
17+
Gem.configuration.verbose = verbose_before
18+
end
19+
end
20+
end
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
require_relative '../spec_helper'
2+
3+
require 'yaml'
4+
require 'rubygems'
5+
require 'rubygems/safe_yaml'
6+
require 'rubygems/commands/owner_command'
7+
8+
describe "CVE-2019-8322 is resisted by" do
9+
it "sanitising owner names" do
10+
command = Gem::Commands::OwnerCommand.new
11+
def command.rubygems_api_request(*args)
12+
Struct.new(:body).new("---\n- email: \"\e]2;nyan\a\"\n handle: handle\n id: id\n")
13+
end
14+
def command.with_response(response)
15+
yield response
16+
end
17+
command.should_receive(:say).with("Owners for gem: name")
18+
command.should_receive(:say).with("- .]2;nyan.")
19+
command.show_owners "name"
20+
end
21+
end
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
require_relative '../spec_helper'
2+
3+
require 'optparse'
4+
5+
require 'rubygems'
6+
require 'rubygems/gemcutter_utilities'
7+
8+
describe "CVE-2019-8323 is resisted by" do
9+
describe "sanitising the body" do
10+
it "for success codes" do
11+
cutter = Class.new {
12+
include Gem::GemcutterUtilities
13+
}.new
14+
response = Net::HTTPSuccess.new(nil, nil, nil)
15+
def response.body
16+
"\e]2;nyan\a"
17+
end
18+
cutter.should_receive(:say).with(".]2;nyan.")
19+
cutter.with_response response
20+
end
21+
22+
it "for error codes" do
23+
cutter = Class.new {
24+
include Gem::GemcutterUtilities
25+
}.new
26+
def cutter.terminate_interaction(n)
27+
end
28+
response = Net::HTTPNotFound.new(nil, nil, nil)
29+
def response.body
30+
"\e]2;nyan\a"
31+
end
32+
cutter.should_receive(:say).with(".]2;nyan.")
33+
cutter.with_response response
34+
end
35+
end
36+
end
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
require_relative '../spec_helper'
2+
3+
require 'rubygems'
4+
require 'rubygems/command_manager'
5+
6+
describe "CVE-2019-8325 is resisted by" do
7+
describe "sanitising error message components" do
8+
it "for the 'while executing' message" do
9+
manager = Gem::CommandManager.new
10+
def manager.process_args(args, build_args)
11+
raise StandardError, "\e]2;nyan\a"
12+
end
13+
def manager.terminate_interaction(n)
14+
end
15+
manager.should_receive(:alert_error).with("While executing gem ... (StandardError)\n .]2;nyan.")
16+
manager.run nil, nil
17+
end
18+
19+
it "for the 'invalid option' message" do
20+
manager = Gem::CommandManager.new
21+
def manager.terminate_interaction(n)
22+
end
23+
manager.should_receive(:alert_error).with("Invalid option: --.]2;nyan.. See 'gem --help'.")
24+
manager.process_args ["--\e]2;nyan\a"], nil
25+
end
26+
27+
it "for the 'loading command' message" do
28+
manager = Gem::CommandManager.new
29+
def manager.require(x)
30+
raise 'foo'
31+
end
32+
manager.should_receive(:alert_error).with("Loading command: .]2;nyan. (RuntimeError)\n\tfoo")
33+
manager.send :load_and_instantiate, "\e]2;nyan\a"
34+
end
35+
end
36+
end
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fails:CVE-2019-8321 is resisted by sanitising verbose messages
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fails:CVE-2019-8322 is resisted by sanitising owner names
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
fails:CVE-2019-8323 is resisted by sanitising the body for success codes
2+
fails:CVE-2019-8323 is resisted by sanitising the body for error codes
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fails:CVE-2019-8325 is resisted by sanitising error message components for the 'while executing' message
2+
fails:CVE-2019-8325 is resisted by sanitising error message components for the 'invalid option' message
3+
fails:CVE-2019-8325 is resisted by sanitising error message components for the 'loading command' message

spec/truffle.mspec

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ class MSpecScript
3838
spec/ruby/library/yaml
3939
spec/ruby/library/zlib
4040
spec/ruby/security/cve_2017_17742_spec.rb
41+
spec/ruby/security/cve_2019_8321_spec.rb
42+
spec/ruby/security/cve_2019_8322_spec.rb
43+
spec/ruby/security/cve_2019_8323_spec.rb
44+
spec/ruby/security/cve_2019_8325_spec.rb
4145
]
4246

4347
set :command_line, [

0 commit comments

Comments
 (0)