Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-19381

Macro values are not correctly escaped when testing items in web interface

XMLWordPrintable

    • Sprint 88 (May 2022)
    • 0.5

      Problem
      If a macro is used in an item key parameter, and that item key parameter is a quoted string, on item execution double quotes in macro value are additionally escaped by Zabbix server before the item is sent to the agent.

      This doesn't seem to be documented, but works that way at least from version 2.4 and is very convenient as macro value is always the same regardless whether the parameter containing it is quoted or not.

      When testing an item using Test button in Zabbix web interface in item configuration form, double quotes in macro values used there (which by default are the same as actually used ones) are not additionally escaped and thus test result and actual item run result may differ.

      Steps to reproduce

      1. Create an item on some host of type Zabbix agent, type of information Text, with key: system.run["{$V}"].
      2. Create a macro {$V} with the value:
        echo 'a " b \" c \\" d'
        
      3. Test the item in web interface, observe the test returns an error: Invalid item key format. (There is an unescaped double quote in the key.)
      4. Observe the value is actually collected by the host agent with no error, it should be:
        " b \" c \\" d
        

      In case the parameter containing a macro is unquoted both the test and the collected value concur:

      1. Create another item of the same type with key: system.run[{$V}].
      2. Test the item in web interface, observe the test is now successful and returns
        " b \" c \\" d
        
      3. Observe the value collected by the host agent, which should be the same.

      Expected result
      Tests coincide with actual item runs in all cases.

            tolups Tomass Olups (Inactive)
            btmc Arthur Tokarchuk
            Team C
            Votes:
            1 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: