Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dev.icinga.com #13195] Semicolons in plugin output are converted to colon #4785

Closed
icinga-migration opened this issue Nov 15, 2016 · 4 comments · Fixed by #5901
Closed

[dev.icinga.com #13195] Semicolons in plugin output are converted to colon #4785

icinga-migration opened this issue Nov 15, 2016 · 4 comments · Fixed by #5901
Assignees
Labels
area/compat Deprecated features from 1.x bug Something isn't working
Milestone

Comments

@icinga-migration
Copy link

This issue has been migrated from Redmine: https://dev.icinga.com/issues/13195

Created by elippmann on 2016-11-15 09:30:47 +00:00

Assignee: (none)
Status: New
Target Version: (none)
Last Update: 2016-11-15 10:10:57 +00:00 (in Redmine)

Icinga Version: 2.5.4
Backport?: Not yet backported
Include in Changelog: 1

For example one can't use HTML entities in the plugin output.

@icinga-migration
Copy link
Author

Updated by gbeutner on 2016-11-15 10:10:57 +00:00

CompatUtility::GetCheckResultOutput seems to be the culprit here. According to Michael this was added to improve compatibility with how Icinga 1.x handles this. The rationale being that shell scripts would have to replace semi-colons with colon when using macro values in external commands. We should probably discuss whether to change this behavior.

String CompatUtility::GetCheckResultOutput(const CheckResult::Ptr& cr)
{
        if (!cr)
                return Empty;

        String output;

        String raw_output = cr->GetOutput();

        /*
         * replace semi-colons with colons in output
         * semi-colon is used as delimiter in various interfaces
         */
        boost::algorithm::replace_all(raw_output, ";", ":");

        size_t line_end = raw_output.Find("\n");

        return raw_output.SubStr(0, line_end);
}

@icinga-migration icinga-migration added bug Something isn't working area/compat Deprecated features from 1.x labels Jan 17, 2017
@dnsmichi dnsmichi added this to the 2.7.0 milestone Feb 7, 2017
@dnsmichi dnsmichi self-assigned this Feb 7, 2017
@dnsmichi
Copy link
Contributor

dnsmichi commented Feb 8, 2017

Guess we can only change that for DB IDO, all other interfaces might break (esp. Livestatus and statusdata)

michi@mbmif ~/coding/icinga/icinga2 (master=) $ grep -r GetCheckResultOutput lib/
lib//compat/compatlogger.cpp:		output = CompatUtility::GetCheckResultOutput(cr);
lib//compat/compatlogger.cpp:		output = CompatUtility::GetCheckResultOutput(cr);
lib//compat/compatlogger.cpp:			output = CompatUtility::GetCheckResultOutput(cr);
lib//compat/compatlogger.cpp:			output = CompatUtility::GetCheckResultOutput(cr);
lib//compat/statusdatawriter.cpp:	      "\t" "plugin_output=" << CompatUtility::GetCheckResultOutput(cr) << "\n"
lib//db_ido/dbevents.cpp:		fields1->Set("output", CompatUtility::GetCheckResultOutput(cr));
lib//db_ido/dbevents.cpp:		fields1->Set("output", CompatUtility::GetCheckResultOutput(cr));
lib//db_ido/dbevents.cpp:		output = CompatUtility::GetCheckResultOutput(cr);
lib//db_ido/dbevents.cpp:		output = CompatUtility::GetCheckResultOutput(cr);
lib//db_ido/dbevents.cpp:	fields1->Set("output", CompatUtility::GetCheckResultOutput(cr));
lib//db_ido/hostdbobject.cpp:		fields->Set("output", CompatUtility::GetCheckResultOutput(cr));
lib//db_ido/servicedbobject.cpp:		fields->Set("output", CompatUtility::GetCheckResultOutput(cr));
lib//icinga/compatutility.cpp:String CompatUtility::GetCheckResultOutput(const CheckResult::Ptr& cr)
lib//icinga/compatutility.hpp:	static String GetCheckResultOutput(const CheckResult::Ptr& cr);
lib//livestatus/hoststable.cpp:		output = CompatUtility::GetCheckResultOutput(cr);
lib//livestatus/hoststable.cpp:			output = CompatUtility::GetCheckResultOutput(cr);
lib//livestatus/servicestable.cpp:		output = CompatUtility::GetCheckResultOutput(cr);
lib//perfdata/gelfwriter.cpp:		fields->Set("short_message", CompatUtility::GetCheckResultOutput(cr));
lib//perfdata/gelfwriter.cpp:		output = CompatUtility::GetCheckResultOutput(cr);
lib//perfdata/gelfwriter.cpp:		fields->Set("short_message", CompatUtility::GetCheckResultOutput(cr));

@dnsmichi dnsmichi removed this from the 2.7.0 milestone Mar 28, 2017
@dnsmichi
Copy link
Contributor

Consider it for a new backend, and partially adopt features like GelfWriter.

@dnsmichi dnsmichi added this to the 2.9.0 milestone Dec 21, 2017
@dnsmichi
Copy link
Contributor

The only real problem lies with using the output and passing it into the command pipe again. Tools should already have a safety mechanism for user inputs with colons either. I'll fix that for 2.9.

dnsmichi pushed a commit that referenced this issue Dec 21, 2017
This affects all interfaces which are using the CompatUtility class
format helpers for short and long output.

fixes #4785
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/compat Deprecated features from 1.x bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants