[icinga-checkins] icinga.org: icinga2-migration/master: Escape $ARGn$ service/object vars

git at icinga.org git at icinga.org
Tue Jun 10 23:10:31 CEST 2014


Module: icinga2-migration
Branch: master
Commit: cf6d71a4ccb0c1f329be14b97d5adf8846e1f9c8
URL:    https://git.icinga.org/?p=icinga2-migration.git;a=commit;h=cf6d71a4ccb0c1f329be14b97d5adf8846e1f9c8

Author: Michael Friedrich <michael.friedrich at gmail.com>
Date:   Tue Jun 10 19:11:36 2014 +0200

Escape $ARGn$ service/object vars

---

 modules/conftool/library/Conftool/Icinga2/Icinga2Command.php     |    6 ++----
 .../library/Conftool/Icinga2/Icinga2ObjectDefinition.php         |    2 +-
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/modules/conftool/library/Conftool/Icinga2/Icinga2Command.php b/modules/conftool/library/Conftool/Icinga2/Icinga2Command.php
index a669c0d..87725ae 100644
--- a/modules/conftool/library/Conftool/Icinga2/Icinga2Command.php
+++ b/modules/conftool/library/Conftool/Icinga2/Icinga2Command.php
@@ -11,11 +11,9 @@ class Icinga2Command extends Icinga2ObjectDefinition
     );
 
     protected function convertCommand_line($line) {
-        //TODO migrate changed runtime macros
-
+	//escape double quotes
         $line = addslashes($line);
 
-        //TODO
         $patterns = array (
             //user
             "\$CONTACTNAME\$" => "\$user.name\$",
@@ -109,7 +107,7 @@ class Icinga2Command extends Icinga2ObjectDefinition
             $line = str_replace($match, $replace, $line);
         }
 
-        //TODO same for $_HOSTFOO$ and $_SERVICEBAR$ as $host.vars.FOO$ and $service.vars.BAR$
+        //same for $_HOSTFOO$ and $_SERVICEBAR$ as $host.vars.FOO$ and $service.vars.BAR$
         $line = preg_replace('/\$_HOST(\w+)\$/', '\$host.vars.$1\$', $line);
         $line = preg_replace('/\$_SERVICE(\w+)\$/', '\service.vars.$1\$', $line);
 
diff --git a/modules/conftool/library/Conftool/Icinga2/Icinga2ObjectDefinition.php b/modules/conftool/library/Conftool/Icinga2/Icinga2ObjectDefinition.php
index 3b23053..85336fd 100644
--- a/modules/conftool/library/Conftool/Icinga2/Icinga2ObjectDefinition.php
+++ b/modules/conftool/library/Conftool/Icinga2/Icinga2ObjectDefinition.php
@@ -93,7 +93,7 @@ class Icinga2ObjectDefinition
 
                 for($i = 1; $i < count($command_arr); $i++) {
                     $varname = "ARG".$i;
-                    $varvalue = $command_arr[$i];
+                    $varvalue = addslashes($command_arr[$i]); //escape the string 
                     //TODO check against legacy macros and replace them
                     $this->vars($varname, $varvalue);
                 }



More information about the icinga-checkins mailing list