From ebad1141e86925320db2370ee49ce316c73226f5 Mon Sep 17 00:00:00 2001 From: An-Cheng Huang Date: Fri, 12 Jun 2009 18:56:15 -0700 Subject: add validation for bash special characters --- lib/Vyatta/TypeChecker.pm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/Vyatta/TypeChecker.pm b/lib/Vyatta/TypeChecker.pm index e436e0c..27d9e03 100755 --- a/lib/Vyatta/TypeChecker.pm +++ b/lib/Vyatta/TypeChecker.pm @@ -68,7 +68,8 @@ my %type_handler = ( 'hex16' => \&validate_hex_16_bits, 'hex32' => \&validate_hex_32_bits, 'ipv6_addr_param' => \&validate_ipv6_addr_param, - 'restrictive_filename' => \&validate_restrictive_filename + 'restrictive_filename' => \&validate_restrictive_filename, + 'no_bash_special' => \&validate_no_bash_special ); sub validate_ipv4 { @@ -274,6 +275,12 @@ sub validate_restrictive_filename { return (($value =~ /^[-_.a-zA-Z0-9]+$/) ? 1 : 0); } +# validate that a string does not contain bash special chars +sub validate_no_bash_special { + my $value = shift; + return (($value =~ /[;&"'`!\$><|]/) ? 0 : 1); +} + sub validateType { my ($type, $value, $quiet) = @_; if (!defined($type) || !defined($value)) { -- cgit v1.2.3