From e759df11a08fc98beb3ef4878dad3543d69abe6e Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 6 Jul 2015 10:36:41 -0600 Subject: [PATCH] core: fix crash for missing options [GH-5550] --- CHANGELOG.md | 1 + lib/vagrant/plugin/v2/command.rb | 2 +- test/unit/vagrant/plugin/v2/command_test.rb | 11 +++++++++++ vagrant.gemspec | 2 +- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ef8516e9..0e4064fd1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ BUG FIXES: - core: do not report plugins as installed when plugins are disabled [GH-5698, GH-5430] - core: Only take files when packaging a box to avoid duplicates [GH-5658, GH-5657] - core: escape curl urls and authentication [GH-5677] + - core: fix crash if a value is missing for CLI arguments [GH-5550] - core/cli: fix box checksum validation [GH-4665, GH-5221] - core/windows: allow Windows UNC paths to allow more than 256 characters [GH-4815] diff --git a/lib/vagrant/plugin/v2/command.rb b/lib/vagrant/plugin/v2/command.rb index 24b2230d4..eeb580a29 100644 --- a/lib/vagrant/plugin/v2/command.rb +++ b/lib/vagrant/plugin/v2/command.rb @@ -58,7 +58,7 @@ module Vagrant opts.parse!(argv) return argv - rescue OptionParser::InvalidOption + rescue OptionParser::InvalidOption, OptionParser::MissingArgument raise Errors::CLIInvalidOptions, help: opts.help.chomp end diff --git a/test/unit/vagrant/plugin/v2/command_test.rb b/test/unit/vagrant/plugin/v2/command_test.rb index a6ac5d318..7b42f2345 100644 --- a/test/unit/vagrant/plugin/v2/command_test.rb +++ b/test/unit/vagrant/plugin/v2/command_test.rb @@ -45,6 +45,17 @@ describe Vagrant::Plugin::V2::Command do expect { instance.parse_options(OptionParser.new) }. to raise_error(Vagrant::Errors::CLIInvalidOptions) end + + it "raises an error if options without a value are given" do + opts = OptionParser.new do |o| + o.on("--provision-with x,y,z", Array, "Example") { |f| } + end + + + instance = klass.new(["--provision-with"], nil) + expect { instance.parse_options(opts) }. + to raise_error(Vagrant::Errors::CLIInvalidOptions) + end end describe "target VMs" do diff --git a/vagrant.gemspec b/vagrant.gemspec index 00b5ebb4c..415885270 100644 --- a/vagrant.gemspec +++ b/vagrant.gemspec @@ -15,7 +15,7 @@ Gem::Specification.new do |s| s.required_rubygems_version = ">= 1.3.6" s.rubyforge_project = "vagrant" - s.add_dependency "bundler", ">= 1.5.2", "< 1.8.0" + s.add_dependency "bundler", ">= 1.5.2", "<= 1.9.4" s.add_dependency "childprocess", "~> 0.5.0" s.add_dependency "erubis", "~> 2.7.0" s.add_dependency "i18n", ">= 0.6.0", "<= 0.8.0"