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

EuiCodeEditor XML parse errors #4816

Closed
2 of 3 tasks
Tracked by #5039
asteriscos opened this issue Nov 7, 2022 · 2 comments
Closed
2 of 3 tasks
Tracked by #5039

EuiCodeEditor XML parse errors #4816

asteriscos opened this issue Nov 7, 2022 · 2 comments
Labels
level/task Task issue type/enhancement Enhancement issue

Comments

@asteriscos
Copy link
Member

asteriscos commented Nov 7, 2022

Introduction

Elastic UI Code editor renders XML parsing errors:

  • when a user escapes < characters
  • The error line number is wrong

error

Investigation

After debugging the EuiCodeEditor Wazuh implementation, we realized this error is produced regardless of how the component is implemented. EuiCodeEditor wraps a react Ace editor:
https://github.com/elastic/eui/blob/v29.3.2/src/components/code_editor/code_editor.tsx#L22

We checked if we could replicate the issue in their code editor online demo. We could replicate both the XML escaped < character error and the issue indicating a wrong error line number.

Screenshot from 2022-11-07 16-40-51

Additional information

Elastic UI component library has already deprecated the EuiCodeEditor component in version 41.0.0. Not only is no longer supported, but also since Kibana 8.1.0 uses "@elastic/eui": "46.1.1" and we cannot be compatible as long as we use EuiCodeEditor.

Since the component is deprecated, Elastic UI uses Microsoft Monaco code editor and recommends using their implementation @kbn/monaco.
elastic/eui#4683

On the other hand, Opensearch Dashboard 2.3 uses their fork of the Elastic UI repository V34.0.0 which still has EuiCodeEditor.
https://github.com/opensearch-project/OpenSearch-Dashboards/blob/2.3.0/package.json#L111

Strategy

In order to be compatible with both platforms, it seems our own implementation of a code editor is the most logical path. Also, Elastic UI has already researched how to solve its code editor issues and made the choice to replace it with Microsoft Monaco editor. This makes Microsoft Monaco editor a good candidate to make our own implementations.

Pros: Compatible with all platforms regardless of the UI repository and version.
Cons: Possible new bugs and code to maintain.

Related issues:

@asteriscos asteriscos added type/bug Bug issue type/enhancement Enhancement issue and removed type/bug Bug issue labels Nov 7, 2022
@gdiazlo gdiazlo added the level/task Task issue label Mar 16, 2023
@Desvelao
Copy link
Member

The code editor is using the highlighting for xml syntax. The current definition of rules or decoders is using an xml-based language. This causes escaping < character to display an error. This error is managed internally by the code editor related to the selected language xml.

@yenienserrano figured out OpenSearch has a customized editor based in Monaco #5039 (comment). He saw the customized editor only has a subset of languages. Moreover, we can add the language modifying the customized package (it would be possible in Wazuh dashboard). Another approach commented on by @yenienserrano would be adding our own Monaco editor, but he commented on he had some problems when using due to the imports conflicting with the customized by OpenSearch Dashboards.

@gdiazlo
Copy link
Member

gdiazlo commented Jul 13, 2023

We will revisit this in the future as OpenSearch is changing the editor, and we're changing the syntax of the decoders and rules.

@gdiazlo gdiazlo closed this as not planned Won't fix, can't repro, duplicate, stale Jul 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
level/task Task issue type/enhancement Enhancement issue
Projects
None yet
Development

No branches or pull requests

4 participants