wazuh / wazuh-dashboard-plugins

Plugins for Wazuh Dashboard
https://wazuh.com/
GNU General Public License v2.0
427 stars 176 forks source link

Generate PDF report button doesn't work in Firefox #6900

Closed asteriscos closed 1 month ago

asteriscos commented 1 month ago
Wazuh Rev Browser
4.9.0 06 Firefox

Description When using a Firefox browser the create PDF report doesn't work, and throws an error.

Preconditions

  1. Use Firefox

Steps to reproduce

  1. Navigate to any dashboard
  2. Click on Generate report
  3. See the error

Screenshots

Peek 2024-08-06 21-21

image

Desvelao commented 1 month ago

Research

The error is caused by a problem getting the screenshots of the visualizations. Editing the source code to display the error on console:

Image

A recent pull request https://github.com/wazuh/wazuh-dashboard-plugins/pull/6558/files#diff-09c83b245d7d7757479c6f6bce9a14e1e15823a12d4e827885ed2b584d69f06dR480-R482 for 4.9.0 added a fix for the dom-to-image dependency library.

I tried to remove the fix, and this avoids the error reported on the issue, but the logic to get the visualization screenshots seems to enter into a loop and the report can not be generated. This behavior happens on Firefox and Google Chrome.

Desvelao commented 1 month ago

I tried to replace the embedded dom-to-image dependency by https://www.npmjs.com/package/dom-to-image-more and this seems to fix the problem related to the loop.

```console yarn add dom-to-image-more ``` It installed the `v3.3.1`.

But it seems on Firefox, some images are cropped. Related issue: https://github.com/1904labs/dom-to-image-more/issues/160

Desvelao commented 1 month ago

Solution

I added a embedded dom-to-image-more dependency because I wanted to remove the font fetching logic that was customized on the dom-to-image library.

I applied a fix to solve the problem related to cropped images on Firefox.

@yenienserrano and me were reviewing the generation of reports on Safari and Firefox too.

I created the following pull request with the proposed solution: https://github.com/wazuh/wazuh-dashboard-plugins/pull/6902

Desvelao commented 1 month ago

Changes