-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Fleet] add escapeMultilineString Handlebar helper #195159
[Fleet] add escapeMultilineString Handlebar helper #195159
Conversation
Pinging @elastic/fleet (Team:Fleet) |
💚 Build Succeeded
Metrics [docs]
To update your PR or re-run it, just comment with: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add test coverage on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call @juliaElastic, I added it!
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]
History
|
Starting backport for target branches: 8.x |
💔 All backports failed
Manual backportTo create the backport manually run:
Questions ?Please refer to the Backport tool documentation |
## Summary Adding a handlebar helper to escape multiline strings. It has the same function as `escapeStringHelper`, but does not wrap strings in single quotes, allowing concatenation of escaped variables in the `hbs` template such as this example: ```hbs audit_rules: "{{escape_multiline_string audit_rules}} {{escape_multiline_string " # Session data audit rules -a always,exit -F arch=b64 -S execve,execveat -k exec -a always,exit -F arch=b64 -S exit_group -a always,exit -F arch=b64 -S setsid"}}" {{else}} {{#if audit_rules}} audit_rules: {{escape_string audit_rules}} {{/if}} {{/if}} ``` The above would not be possible using only `escape_string` as `audit_rules` would be wrapped in single quotes. ## Screenshots The example above illustrates how this option allows the Auditd manager integration to append Session data audit rules to the `audit_rules` field when Session data is enabled in the integration ([PR](elastic/integrations#11336)). <img width="872" alt="image" src="https://github.com/user-attachments/assets/325d784d-26a4-4dfe-9d0e-54d51c3ed060"> <img width="801" alt="image" src="https://github.com/user-attachments/assets/ebd521c0-4471-48f9-ba8d-94630ea0efd2"> (cherry picked from commit 407137a)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
## Summary Adding a handlebar helper to escape multiline strings. It has the same function as `escapeStringHelper`, but does not wrap strings in single quotes, allowing concatenation of escaped variables in the `hbs` template such as this example: ```hbs audit_rules: "{{escape_multiline_string audit_rules}} {{escape_multiline_string " # Session data audit rules -a always,exit -F arch=b64 -S execve,execveat -k exec -a always,exit -F arch=b64 -S exit_group -a always,exit -F arch=b64 -S setsid"}}" {{else}} {{#if audit_rules}} audit_rules: {{escape_string audit_rules}} {{/if}} {{/if}} ``` The above would not be possible using only `escape_string` as `audit_rules` would be wrapped in single quotes. ## Screenshots The example above illustrates how this option allows the Auditd manager integration to append Session data audit rules to the `audit_rules` field when Session data is enabled in the integration ([PR](elastic/integrations#11336)). <img width="872" alt="image" src="https://github.com/user-attachments/assets/325d784d-26a4-4dfe-9d0e-54d51c3ed060"> <img width="801" alt="image" src="https://github.com/user-attachments/assets/ebd521c0-4471-48f9-ba8d-94630ea0efd2"> (cherry picked from commit 407137a)
…195497) # Backport This will backport the following commits from `main` to `8.x`: - [[Fleet] add escapeMultilineString Handlebar helper (#195159)](#195159) <!--- Backport version: 8.9.8 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Paulo Silva","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-08T18:56:08Z","message":"[Fleet] add escapeMultilineString Handlebar helper (#195159)\n\n## Summary\r\n\r\nAdding a handlebar helper to escape multiline strings. It has the same\r\nfunction as `escapeStringHelper`, but does not wrap strings in single\r\nquotes, allowing concatenation of escaped variables in the `hbs`\r\ntemplate such as this example:\r\n\r\n```hbs\r\naudit_rules: \"{{escape_multiline_string audit_rules}}\r\n {{escape_multiline_string \"\r\n # Session data audit rules\r\n -a always,exit -F arch=b64 -S execve,execveat -k exec\r\n -a always,exit -F arch=b64 -S exit_group\r\n -a always,exit -F arch=b64 -S setsid\"}}\"\r\n{{else}}\r\n {{#if audit_rules}}\r\naudit_rules: {{escape_string audit_rules}}\r\n {{/if}}\r\n{{/if}}\r\n```\r\n\r\nThe above would not be possible using only `escape_string` as\r\n`audit_rules` would be wrapped in single quotes.\r\n\r\n## Screenshots\r\n\r\nThe example above illustrates how this option allows the Auditd manager\r\nintegration to append Session data audit rules to the `audit_rules`\r\nfield when Session data is enabled in the integration\r\n([PR](https://github.com/elastic/integrations/pull/11336)).\r\n\r\n<img width=\"872\" alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/325d784d-26a4-4dfe-9d0e-54d51c3ed060\">\r\n\r\n<img width=\"801\" alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/ebd521c0-4471-48f9-ba8d-94630ea0efd2\">","sha":"407137a6befb38f34cb11f6a3b6a741a27977031","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Fleet","v9.0.0","v8.16.0","backport:version"],"number":195159,"url":"https://github.com/elastic/kibana/pull/195159","mergeCommit":{"message":"[Fleet] add escapeMultilineString Handlebar helper (#195159)\n\n## Summary\r\n\r\nAdding a handlebar helper to escape multiline strings. It has the same\r\nfunction as `escapeStringHelper`, but does not wrap strings in single\r\nquotes, allowing concatenation of escaped variables in the `hbs`\r\ntemplate such as this example:\r\n\r\n```hbs\r\naudit_rules: \"{{escape_multiline_string audit_rules}}\r\n {{escape_multiline_string \"\r\n # Session data audit rules\r\n -a always,exit -F arch=b64 -S execve,execveat -k exec\r\n -a always,exit -F arch=b64 -S exit_group\r\n -a always,exit -F arch=b64 -S setsid\"}}\"\r\n{{else}}\r\n {{#if audit_rules}}\r\naudit_rules: {{escape_string audit_rules}}\r\n {{/if}}\r\n{{/if}}\r\n```\r\n\r\nThe above would not be possible using only `escape_string` as\r\n`audit_rules` would be wrapped in single quotes.\r\n\r\n## Screenshots\r\n\r\nThe example above illustrates how this option allows the Auditd manager\r\nintegration to append Session data audit rules to the `audit_rules`\r\nfield when Session data is enabled in the integration\r\n([PR](https://github.com/elastic/integrations/pull/11336)).\r\n\r\n<img width=\"872\" alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/325d784d-26a4-4dfe-9d0e-54d51c3ed060\">\r\n\r\n<img width=\"801\" alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/ebd521c0-4471-48f9-ba8d-94630ea0efd2\">","sha":"407137a6befb38f34cb11f6a3b6a741a27977031"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/195159","number":195159,"mergeCommit":{"message":"[Fleet] add escapeMultilineString Handlebar helper (#195159)\n\n## Summary\r\n\r\nAdding a handlebar helper to escape multiline strings. It has the same\r\nfunction as `escapeStringHelper`, but does not wrap strings in single\r\nquotes, allowing concatenation of escaped variables in the `hbs`\r\ntemplate such as this example:\r\n\r\n```hbs\r\naudit_rules: \"{{escape_multiline_string audit_rules}}\r\n {{escape_multiline_string \"\r\n # Session data audit rules\r\n -a always,exit -F arch=b64 -S execve,execveat -k exec\r\n -a always,exit -F arch=b64 -S exit_group\r\n -a always,exit -F arch=b64 -S setsid\"}}\"\r\n{{else}}\r\n {{#if audit_rules}}\r\naudit_rules: {{escape_string audit_rules}}\r\n {{/if}}\r\n{{/if}}\r\n```\r\n\r\nThe above would not be possible using only `escape_string` as\r\n`audit_rules` would be wrapped in single quotes.\r\n\r\n## Screenshots\r\n\r\nThe example above illustrates how this option allows the Auditd manager\r\nintegration to append Session data audit rules to the `audit_rules`\r\nfield when Session data is enabled in the integration\r\n([PR](https://github.com/elastic/integrations/pull/11336)).\r\n\r\n<img width=\"872\" alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/325d784d-26a4-4dfe-9d0e-54d51c3ed060\">\r\n\r\n<img width=\"801\" alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/ebd521c0-4471-48f9-ba8d-94630ea0efd2\">","sha":"407137a6befb38f34cb11f6a3b6a741a27977031"}},{"branch":"8.x","label":"v8.16.0","labelRegex":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT-->
Summary
Adding a handlebar helper to escape multiline strings. It has the same function as
escapeStringHelper
, but does not wrap strings in single quotes, allowing concatenation of escaped variables in thehbs
template such as this example:The above would not be possible using only
escape_string
asaudit_rules
would be wrapped in single quotes.Screenshots
The example above illustrates how this option allows the Auditd manager integration to append Session data audit rules to the
audit_rules
field when Session data is enabled in the integration (PR).