X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=plugins%2Fmcollective%2Fvalidator%2Fshellsafe_validator.rb;fp=plugins%2Fmcollective%2Fvalidator%2Fshellsafe_validator.rb;h=d03e4201ae463334283d2b63c69b6b1e12fc9846;hb=b87d2f4e68281062df1913440ca5753ae63314a9;hp=0000000000000000000000000000000000000000;hpb=ab0ea530b8ac956091f17b104ab2311336cfc250;p=packages%2Fprecise%2Fmcollective.git diff --git a/plugins/mcollective/validator/shellsafe_validator.rb b/plugins/mcollective/validator/shellsafe_validator.rb new file mode 100644 index 0000000..d03e420 --- /dev/null +++ b/plugins/mcollective/validator/shellsafe_validator.rb @@ -0,0 +1,13 @@ +module MCollective + module Validator + class ShellsafeValidator + def self.validate(validator) + raise ValidatorError, "value should be a String" unless validator.is_a?(String) + + ['`', '$', ';', '|', '&&', '>', '<'].each do |chr| + raise ValidatorError, "value should not have #{chr} in it" if validator.match(Regexp.escape(chr)) + end + end + end + end +end