diff --git a/lib/lab/dynagen_driver.rb b/lib/lab/dynagen_driver.rb index 1246ed7004..7357a8f021 100644 --- a/lib/lab/dynagen_driver.rb +++ b/lib/lab/dynagen_driver.rb @@ -17,8 +17,9 @@ module Drivers attr_accessor :location def initialize(vmid,location,platform) - @vmid = filter_input(vmid) - @location = filter_input(location) + + @vmid = filter_command(vmid) + @location = filter_command(location) if !File.exist?(location) raise ArgumentError,"Couldn't find: " + location @@ -26,7 +27,7 @@ module Drivers @type = "dynagen" @running = false - @platform = filter_input(platform) + @platform = filter_command(platform) @credentials = [] end diff --git a/lib/lab/remote_esx_driver.rb b/lib/lab/remote_esx_driver.rb index 8fb234eeee..6201574d35 100644 --- a/lib/lab/remote_esx_driver.rb +++ b/lib/lab/remote_esx_driver.rb @@ -20,10 +20,10 @@ class RemoteEsxDriver < VmDriver unless user then raise ArgumentError, "Must provide a username" end unless host then raise ArgumentError, "Must provide a hostname" end - @vmid = filter_input(vmid) - @location = filter_input(location) - @user = filter_input(user) - @host = filter_input(host) + @vmid = filter_command(vmid) + @location = filter_command(location) + @user = filter_command(user) + @host = filter_command(host) @credentials = credentials # individually filtered @tools = tools # not used in command lines, no filter @os = os # not used in command lines, no filter diff --git a/lib/lab/remote_workstation_driver.rb b/lib/lab/remote_workstation_driver.rb index a7a4dcd6b9..59c492c1f7 100644 --- a/lib/lab/remote_workstation_driver.rb +++ b/lib/lab/remote_workstation_driver.rb @@ -17,10 +17,10 @@ class RemoteWorkstationDriver < VmDriver unless user then raise ArgumentError, "Must provide a username" end unless host then raise ArgumentError, "Must provide a hostname" end - @vmid = filter_input(vmid) - @location = filter_input(location) - @user = filter_input(user) - @host = filter_input(host) + @vmid = filter_command(vmid) + @location = filter_command(location) + @user = filter_command(user) + @host = filter_command(host) @credentials = credentials # individually filtered @tools = tools # not used in command lines, no filter @os = os # not used in command lines, no filter diff --git a/lib/lab/virtualbox_driver.rb b/lib/lab/virtualbox_driver.rb index cfe4fca07f..852dc7464c 100644 --- a/lib/lab/virtualbox_driver.rb +++ b/lib/lab/virtualbox_driver.rb @@ -12,8 +12,9 @@ module Drivers def initialize(vmid, location=nil, credentials=nil) - @vmid = filter_input(vmid) - @location = filter_input(location) + @vmid = filter_command(vmid) + @location = filter_command(location) + ## Check to see if we already know this vm, if not, go on location vmid_list = ::Lab::Controllers::VirtualBoxController::config_list diff --git a/lib/lab/vm_driver.rb b/lib/lab/vm_driver.rb index a0dcab5063..1e27714bd3 100644 --- a/lib/lab/vm_driver.rb +++ b/lib/lab/vm_driver.rb @@ -146,6 +146,16 @@ private string end + + def filter_command(string) + return "" unless string + + if !(string =~ /^[\w\s\[\]\{\}\/\\\.\-\"\(\)]*$/) + raise "WARNING! Invalid character in: #{string}" + end + + string + end def system_command(command) begin diff --git a/lib/lab/workstation_driver.rb b/lib/lab/workstation_driver.rb index e88018d696..93c35cef69 100644 --- a/lib/lab/workstation_driver.rb +++ b/lib/lab/workstation_driver.rb @@ -13,8 +13,9 @@ class WorkstationDriver < VmDriver attr_accessor :location def initialize(vmid, location, os=nil, tools=false, credentials=nil) - @vmid = filter_input(vmid) - @location = filter_input(location) + @vmid = filter_command(vmid) + @location = filter_command(location) + if !File.exist?(@location) raise ArgumentError,"Couldn't find: " + @location end diff --git a/lib/lab/workstation_vixr_driver.rb b/lib/lab/workstation_vixr_driver.rb index dd4c2c3d5e..d5dc73c516 100644 --- a/lib/lab/workstation_vixr_driver.rb +++ b/lib/lab/workstation_vixr_driver.rb @@ -22,8 +22,9 @@ class WorkstationVixrDriver < VmDriver raise "Oops, no vixr installed. Consider using the regular workstation driver." end - @vmid = filter_input(vmid) - @location = filter_input(location) + @vmid = filter_command(vmid) + @location = filter_command(location) + if !File.exist?(@location) raise ArgumentError,"Couldn't find: " + location end