Icinga / icingaweb2-module-director

The Director aims to be your new favourite Icinga config deployment tool. Director is designed for those who want to automate their configuration deployment and those who want to grant their “point & click” users easy access to the configuration.
https://icinga.com/docs/director/latest
GNU General Public License v2.0
413 stars 203 forks source link

Import Source Modifier won't reject row if new line character is in cell of .xlsx #2813

Open danopt opened 1 year ago

danopt commented 1 year ago

Expected Behavior

Reject a row of a .xlsx file if it matches a simple match with wildcard and new line characters within cell

Current Behavior

Row won't be rejected if there is a new line character in cell

Possible Solution

Steps to Reproduce (for bugs)

  1. Create a .xlsx file with row and a cell that includes a new line character that has to be rejected.
  2. Create modifier: grafik
  3. Import it and the line does not get rejected. Cells without a new line character do get rejected: grafik

Your Environment

Icinga Web 2 Version | 2.12.0 8.1.2-1ubuntu2.14 2023-09-21 Icinga Web 2 Version 2.12.0 Git commit 7cd79a5c7ff66a6a67ecd55875c214ba4b2c7db4 PHP Version 8.1.2-1ubuntu2.14 Git commit date 2023-09-21

Loaded Libraries icinga/icinga-php-thirdparty 0.12.0 icinga/icinga-php-library 0.13.0 Loaded Modules director 1.10.2 fileshipper 1.2.0 icingadb 1.1.0
incubator 0.20.0
pdfexport 0.10.2

danopt commented 1 year ago

ref/NC/796361

Thomas-Gelf commented 1 year ago

Could you please provide some sample data allowing me to reproduce this? A related/anonymized snippet of the Import Source preview/JSON download should suffice.

Thomas-Gelf commented 1 year ago

Update: I found the problem, it's in Icinga\Data\Filter\FilterExpression on this line: https://github.com/Icinga/icingaweb2/blob/main/library/Icinga/Data/Filter/FilterExpression.php#L200

Please give the following patch a try, and open a related issue in the Icinga Web Issue Tracker:

-         $pattern = '/^' . implode('.*', $parts) . '$/';
+         $pattern = '/^' . implode('.*', $parts) . '$/s';

Cheers, Thomas

Thomas-Gelf commented 1 year ago

(update: fixed the patch)

danopt commented 1 year ago

Patch works @Thomas-Gelf ! 👍 I will open a related issue.

danopt commented 1 year ago

https://github.com/Icinga/icingaweb2-module-director/issues/2834