Icinga / icinga2

The core of our monitoring platform with a powerful configuration language and REST API.
https://icinga.com/docs/icinga2/latest
GNU General Public License v2.0
2.03k stars 579 forks source link

Invalid Unicode escape error on strings contains backslash character "\" #8951

Closed ulyszk closed 3 years ago

ulyszk commented 3 years ago

Describe the bug

A clear and concise description of what the bug is.

Please ensure to read https://github.com/Icinga/icinga2/blob/master/doc/15-troubleshooting.md first. Formatting tips: GitHub supports Markdown: https://guides.github.com/features/mastering-markdown/

To Reproduce

Upgrading to 2.12.5 and 2.13.0 from 2.12.4 causes "invalid Unicode escape" error and non working IDO PosgreSQL connection.

Relevant logfiles (icinga2.log): 2021-08-04 14:27:55 +0200] critical/IdoPgsqlConnection: Error "ERROR: invalid Unicode escape LINE 1: ...LUES (E'1', 1, E'0', 13703, E'file_age_file', E'C:\Users\rob... ^ HINT: Unicode escapes must be \uXXXX or \UXXXXXXXX. " when executing query "INSERT INTO icinga_customvariables (config_type, instance_id, is_json, object_id, varname, varvalue) VALUES (E'1', 1, E'0', 13703, E'file_age_file', E'C:\Users\flexi\Logs\LastRun\CalendarUpdate.log' )" [2021-08-04 14:27:55 +0200] warning/IdoPgsqlConnection: Exception during database operation: Verify that your database is operational!

Downgrading back to 2.12.4 solves the problem.

  1. I am not sure if this is the root cause, but any parameter contains \ backslash character in configuration can cause error like file_age_file = "C:\Users\felxi" vars.ilo4_password = "MTsk3499cv\!f"
  2. Downgrading to older version solves the problem.

Expected behavior

Proper handling of Unicode.

Your Environment

Include as many relevant details about the environment you experienced the problem in

Copyright (c) 2012-2021 Icinga GmbH (https://icinga.com/) License GPLv2+: GNU GPL version 2 or later http://gnu.org/licenses/gpl2.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.

System information: Platform: CentOS Linux Platform version: 7 (Core) Kernel: Linux Kernel version: 3.10.0-1127.8.2.el7.x86_64 Architecture: x86_64

Build information: Compiler: GNU 4.8.5 Build host: runner-hh8q3bz2-project-322-concurrent-0 OpenSSL version: OpenSSL 1.0.2k-fips 26 Jan 2017

Application information:

General paths: Config directory: /etc/icinga2 Data directory: /var/lib/icinga2 Log directory: /var/log/icinga2 Cache directory: /var/cache/icinga2 Spool directory: /var/spool/icinga2 Run directory: /run/icinga2

Old paths (deprecated): Installation root: /usr Sysconf directory: /etc Run directory (base): /run Local state directory: /var

Internal paths: Package data directory: /usr/share/icinga2 State path: /var/lib/icinga2/icinga2.state Modified attributes path: /var/lib/icinga2/modified-attributes.conf Objects path: /var/cache/icinga2/icinga2.debug Vars path: /var/cache/icinga2/icinga2.vars PID path: /run/icinga2/icinga2.pid

Disabled features: compatlog elasticsearch graphite icingadb influxdb2 livestatus opentsdb perfdata Enabled features: api checker command debuglog gelf ido-pgsql influxdb mainlog notification statusdata syslog

Configuration is valid

julianbrost commented 3 years ago

Upgrading to 2.12.5 and 2.13.0 from 2.12.4 causes "invalid Unicode escape" error and non working IDO PosgreSQL connection.

Are you sure this is broken in 2.12.5 but was working in 2.12.4? The only change to PostgreSQL between these versions is 843353ab69f79b3abfeb38ac249b05e1944369ab, but that doesn't have an effect on the actual connection to the database.

I suspect this might be due to #8123, but that's only in 2.13.0.

julianbrost commented 3 years ago

Anyways, I was able to reproduce this with 2.13.0. And looks like reverting #8123 indeed fixes this.

ulyszk commented 3 years ago

@julianbrost You are right, 2.12.5 is also OK for me. Thank you for the confirmation.