d03e4201ae463334283d2b63c69b6b1e12fc9846
[packages/precise/mcollective.git] / plugins / mcollective / validator / shellsafe_validator.rb
1 module MCollective
2   module Validator
3     class ShellsafeValidator
4       def self.validate(validator)
5         raise ValidatorError, "value should be a String" unless validator.is_a?(String)
6
7         ['`', '$', ';', '|', '&&', '>', '<'].each do |chr|
8           raise ValidatorError, "value should not have #{chr} in it" if validator.match(Regexp.escape(chr))
9         end
10       end
11     end
12   end
13 end