[ZBX-9458] discovery macros are not quoted correctly in calculated item expressions Created: 2015 Apr 07  Updated: 2019 Mar 11  Resolved: 2016 Jan 19

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Server (S)
Affects Version/s: 2.4.4
Fix Version/s: 2.0.17rc1, 2.2.12rc1, 2.4.8rc1, 3.0.0alpha5

Type: Incident report Priority: Minor
Reporter: Aleksandrs Saveljevs Assignee: Unassigned
Resolution: Fixed Votes: 1
Labels: calculateditems, escaping, lld, macros, quoting
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File some_tests_after_fix.txt    
Issue Links:
Causes
causes ZBX-15788 crash in poller in substitute_lld_macros Closed
Duplicate
is duplicated by ZBX-9890 LLD is not correctly processing speci... Closed

 Description   

Suppose we have the following item prototype:

echo[{#VALUE}]

If the value of {#VALUE} macro is "quoted" (quotes are part of the value), then in the discovered item key the expanded macro is quoted correctly:

echo["\"quoted\""]

However, suppose we have a calculated item prototype with the following expression:

strlen(echo[{#VALUE}])

In this case, expression of the discovered calculated item will be the following, which is not correct:

strlen(echo["quoted"])


 Comments   
Comment by Jason McIntosh [ 2015 Apr 23 ]

Affects 2.2.3 as well as 2.4 as I hit this myself with JDBC pool names in tomcat.

Comment by Andris Zeila [ 2015 Oct 27 ]

Fixed in development branch svn://svn.zabbix.com/branches/dev/ZBX-9458

Comment by Sandis Neilands (Inactive) [ 2015 Dec 10 ]

(1) Added few comments and minor changes in r57130 (RESOLVED). Please review.

wiper Thanks, CLOSED

Comment by Sandis Neilands (Inactive) [ 2015 Dec 10 ]

(2) Having no complete specification of our expression language it is quite difficult to tell which cases are correct and which are not, especially regarding unquoted strings. Please take a look at some_tests_after_fix.txt. Maybe you can find some cases that you think are not correct. In any case it is strongly recommended that the users always quote item keys in functions (for calculated items).

wiper While looking at tests found a bug in function parameter quoting.The quoting was enforced if the parameter was originally quoted or the new value contained ',' and ')' characters. However it should be also quoted if it starts with ' ' or '"' characters.

RESOLVED in r57202

sandis.neilands CLOSED with minor edits of comments in r57220.

Comment by Sandis Neilands (Inactive) [ 2015 Dec 10 ]

(3) Considering that currently this correction is targeted to minor releases as far back as 2.0 and it contains "interface" changes I would like our support team to look at it and comment on the acceptable risks.

These changes definitely break backwards compatibility of how calculated item formulas are created from discovery item prototypes.

  • The workarounds for this particular issue will definitely break;
  • I will be very surprised if this correction (basically - writing expression lexer/parser from scratch by hand) doesn't introduce other subtle changes.

Few questions that might be relevant...
1. Is there a way to detect pro-actively if formulas in item prototypes need to be updated manually due to this correction (when importing older templates or just after the upgrade)?
2, Is there a way to detect after-the-fact that some calculated items created from LLD stopped working due to this correction?
3. What do we do if there is an unintended backwards compatibility issue? Sure, we'll fix it but the users will have to wait till the next release. Does it make sense to implement configurable fall-back to the current behaviour?

wiper As we don't know what lld data could be processed - we can't tell if the generated item would be ok or not. Regarding any compatibility issues - we will document it in upgrade notes. I don't think we should provide any configurable option to have it working incorrectly.

sandis.neilands OK, CLOSED.

Comment by Andris Zeila [ 2015 Dec 17 ]

Released in:

  • pre-2.0.17rc1 r57270
  • pre-2.2.12rc1 r57271
  • pre-2.4.8rc1 r57272
  • pre-3.0.0alpha5 r57273
Comment by Andris Zeila [ 2015 Dec 17 ]

Documentation:

sasha It must be rephrased. I think that the word "illegal" is not good here.

The double quote (") also must be in this list.

REOPENED

wiper double quote and space belong to another list, RESOLVED

sasha CLOSED

Generated at Thu Mar 28 18:59:58 EET 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.