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

Safely output strings into the package manifest #1

Closed
wants to merge 3 commits into from

Conversation

ilyannn
Copy link
Owner

@ilyannn ilyannn commented Sep 7, 2024

Summary

Previously the multiline output or special symbols in the user-provided strings, like description, were breaking YAML structure of the package manifest. Especially unfortunate was that this was happening during the last step, after all the work of generating the integration was completed.

We implement a method to safely output a string into a YAML template and apply it to all user-provided strings in the package manifest. As a result, strings are correctly saved.

The method consists in us using the safeDump from js-yaml to render the following YAML structure:

a:
    b: <user-provided string>

and then removing the preamble, keeping only the string. The resulting string will be a correctly formatted YAML string; it will be quoted as necessary, like this:

abc
"1.0"
"string \t with \t tabs"

For multiline strings, the typical output would rely on the | symbol, e.g.

|
    multiline
    string

When outputting such a string, care needs to be taken: it will work in the context of

key: {{ rendered_string }}

but it will break in the context of

key: 
  another:
    one_more: 
       yet_another: {{ rendered_string }}

because it will be rendered as this incorrect YAML:

key: 
  another:
    one_more: 
       yet_another: |
    multiline
    string

Therefore the documentation of renderYAMLString notes that it is only safe to use this function in the files that do not have indents in excess of MaxManifestNestedIndent. Our package manifest is safe in that regard.

We add tests to verify the correctness of generated manifests.

Checklist

Delete any items that are not applicable to this PR.

Risk Matrix

Delete this section if it is not applicable to this PR.

Before closing this PR, invite QA, stakeholders, and other developers to identify risks that should be tested prior to the change/feature release.

When forming the risk matrix, consider some of the following examples and how they may potentially impact the change:

Risk Probability Severity Mitigation/Notes
Multiple Spaces—unexpected behavior in non-default Kibana Space. Low High Integration tests will verify that all features are still supported in non-default Kibana Space and when user switches between spaces.
Multiple nodes—Elasticsearch polling might have race conditions when multiple Kibana nodes are polling for the same tasks. High Low Tasks are idempotent, so executing them multiple times will not result in logical error, but will degrade performance. To test for this case we add plenty of unit tests around this logic and document manual testing procedure.
Code should gracefully handle cases when feature X or plugin Y are disabled. Medium High Unit tests will verify that any feature flag or plugin combination still results in our service operational.
See more potential risk examples

For maintainers

@ilyannn ilyannn closed this Sep 7, 2024
@ilyannn
Copy link
Owner Author

ilyannn commented Sep 7, 2024

Obsoleted by elastic#192316

ilyannn pushed a commit that referenced this pull request Sep 30, 2024
Connected to elastic#188187

## Summary

- Changed the cases `Settings` button and icon
- Changed the the `Additional fields` title to `Custom fields` for
consistency

<img width="1728" alt="Screenshot 2024-09-09 at 20 15 39"
src="https://github.com/user-attachments/assets/1fb1232a-f958-4d4d-8694-f85cc8872237">
<img width="1443" alt="Screenshot 2024-09-09 at 20 34 27"
src="https://github.com/user-attachments/assets/0fbdae02-65a6-4128-adc7-39f51cc2d5e6">
<img width="1370" alt="Screenshot 2024-09-09 at 20 34 57"
src="https://github.com/user-attachments/assets/c216407a-ac13-4579-8007-531c79d52de7">
ilyannn pushed a commit that referenced this pull request Oct 29, 2024
…95375)

## Summary

Follow-up of elastic#195367
As part of the Sustainable Kibana Architecture initiative, this PR
leverages the mechanisms and concepts introduced in
elastic#194810, updating plugins that
were considered to be solution-specific in Luke's
[PoC](elastic#179710).

This might trigger linting rule violations in CI, and help uncover
conflicts related to forbidden dependencies.
As soon as they are resolved, we can proceed to classify solutions'
plugins.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant