change reporting usage of handlebars to @kbn/handlebars#217778
change reporting usage of handlebars to @kbn/handlebars#217778pmuellr merged 5 commits intoelastic:mainfrom
handlebars to @kbn/handlebars#217778Conversation
|
Pinging @elastic/response-ops (Team:ResponseOps) |
| async function compileTemplate<T>(pathToTemplate: string): Promise<TemplateDelegate<T>> { | ||
| const contentsBuffer = await fs.readFile(pathToTemplate); | ||
| return Handlebars.compile(contentsBuffer.toString()); | ||
| return Handlebars.compileAST(contentsBuffer.toString()); |
There was a problem hiding this comment.
question: can we limit helpers in this context?
return Handlebars.compileAST(contentsBuffer.toString(), { knownHelpersOnly: true });and maybe even?
return Handlebars.compileAST(contentsBuffer.toString(), { knownHelpers: { set all not needed built-in helpers to `false`}, knownHelpersOnly: true });There was a problem hiding this comment.
I suspect we can, since the HB usage here is pretty simple. Simple variable usage, and and #if block/section.
I'm unfamiliar with these options though, so ... any advice?
There was a problem hiding this comment.
Just committed this - 69dd2d7 - locking down everything but #if - and it seems to do everything correctly.
|
I tested PNG, PDF, and PDF "for print" - there's a problem with PDF "for print" which I suspect is unrelated. (it is a known problem: https://github.com/elastic/response-ops-team/issues/310 ) The other two, the titles work fine, and for PDF setting the footer image in Advanced Settings works fine - renders the image and the "Powered by Elastic" copy. |
|
/ci |
|
@elasticmachine merge upstream |
azasypkin
left a comment
There was a problem hiding this comment.
Looks good from a security perspective, thanks for tightening down Handlebars compile options!
tsullivan
left a comment
There was a problem hiding this comment.
LGTM
Tested the code using a Docker container, no regressions.
|
@elasticmachine merge upstream |
|
@elasticmachine merge upstream |
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]
History
|
|
Starting backport for target branches: 7.17, 8.17, 8.18, 8.19, 9.0 https://github.com/elastic/kibana/actions/runs/14730841139 |
…217778) Change reporting's usage of `handlebars` to `@kbn/handlebars`. Also added a test to ensure user input is HTML escaped (it always has been, this just tests it). There should be no change to the final rendered output, at all. These changes only affect PDF and PNG reports, not CSV reports. (cherry picked from commit 3b5e96a)
…217778) Change reporting's usage of `handlebars` to `@kbn/handlebars`. Also added a test to ensure user input is HTML escaped (it always has been, this just tests it). There should be no change to the final rendered output, at all. These changes only affect PDF and PNG reports, not CSV reports. (cherry picked from commit 3b5e96a)
…217778) Change reporting's usage of `handlebars` to `@kbn/handlebars`. Also added a test to ensure user input is HTML escaped (it always has been, this just tests it). There should be no change to the final rendered output, at all. These changes only affect PDF and PNG reports, not CSV reports. (cherry picked from commit 3b5e96a)
💔 Some backports could not be created
Note: Successful backport PRs will be merged automatically after passing CI. Manual backportTo create the backport manually run: Questions ?Please refer to the Backport tool documentation |
…217778) Change reporting's usage of `handlebars` to `@kbn/handlebars`. Also added a test to ensure user input is HTML escaped (it always has been, this just tests it). There should be no change to the final rendered output, at all. These changes only affect PDF and PNG reports, not CSV reports. (cherry picked from commit 3b5e96a) # Conflicts: # x-pack/plugins/screenshotting/server/browsers/chromium/templates/index.test.ts
…217778) Change reporting's usage of `handlebars` to `@kbn/handlebars`. Also added a test to ensure user input is HTML escaped (it always has been, this just tests it). There should be no change to the final rendered output, at all. These changes only affect PDF and PNG reports, not CSV reports. (cherry picked from commit 3b5e96a) # Conflicts: # x-pack/platform/plugins/shared/screenshotting/server/browsers/chromium/templates/index.ts # x-pack/platform/plugins/shared/screenshotting/tsconfig.json
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…217778) (#219527) # Backport This will backport the following commits from `main` to `8.19`: - [change reporting usage of `handlebars` to `@kbn/handlebars` (#217778)](#217778) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Patrick Mueller","email":"patrick.mueller@elastic.co"},"sourceCommit":{"committedDate":"2025-04-29T12:08:28Z","message":"change reporting usage of `handlebars` to `@kbn/handlebars` (#217778)\n\nChange reporting's usage of `handlebars` to `@kbn/handlebars`. Also\nadded a test to ensure user input is HTML escaped (it always has been,\nthis just tests it).\n\nThere should be no change to the final rendered output, at all. These\nchanges only affect PDF and PNG reports, not CSV reports.","sha":"3b5e96a4b8dc3d2741de658ea9ad7981617fe3db","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:ResponseOps","backport:all-open","ci:cloud-deploy","Feature:Reporting:Framework","Feature:Reporting:Screenshot","v9.1.0"],"title":"change reporting usage of `handlebars` to `@kbn/handlebars`","number":217778,"url":"https://github.com/elastic/kibana/pull/217778","mergeCommit":{"message":"change reporting usage of `handlebars` to `@kbn/handlebars` (#217778)\n\nChange reporting's usage of `handlebars` to `@kbn/handlebars`. Also\nadded a test to ensure user input is HTML escaped (it always has been,\nthis just tests it).\n\nThere should be no change to the final rendered output, at all. These\nchanges only affect PDF and PNG reports, not CSV reports.","sha":"3b5e96a4b8dc3d2741de658ea9ad7981617fe3db"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/217778","number":217778,"mergeCommit":{"message":"change reporting usage of `handlebars` to `@kbn/handlebars` (#217778)\n\nChange reporting's usage of `handlebars` to `@kbn/handlebars`. Also\nadded a test to ensure user input is HTML escaped (it always has been,\nthis just tests it).\n\nThere should be no change to the final rendered output, at all. These\nchanges only affect PDF and PNG reports, not CSV reports.","sha":"3b5e96a4b8dc3d2741de658ea9ad7981617fe3db"}}]}] BACKPORT--> Co-authored-by: Patrick Mueller <patrick.mueller@elastic.co>
…17778) (#219528) # Backport This will backport the following commits from `main` to `9.0`: - [change reporting usage of `handlebars` to `@kbn/handlebars` (#217778)](#217778) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Patrick Mueller","email":"patrick.mueller@elastic.co"},"sourceCommit":{"committedDate":"2025-04-29T12:08:28Z","message":"change reporting usage of `handlebars` to `@kbn/handlebars` (#217778)\n\nChange reporting's usage of `handlebars` to `@kbn/handlebars`. Also\nadded a test to ensure user input is HTML escaped (it always has been,\nthis just tests it).\n\nThere should be no change to the final rendered output, at all. These\nchanges only affect PDF and PNG reports, not CSV reports.","sha":"3b5e96a4b8dc3d2741de658ea9ad7981617fe3db","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:ResponseOps","backport:all-open","ci:cloud-deploy","Feature:Reporting:Framework","Feature:Reporting:Screenshot","v9.1.0"],"title":"change reporting usage of `handlebars` to `@kbn/handlebars`","number":217778,"url":"https://github.com/elastic/kibana/pull/217778","mergeCommit":{"message":"change reporting usage of `handlebars` to `@kbn/handlebars` (#217778)\n\nChange reporting's usage of `handlebars` to `@kbn/handlebars`. Also\nadded a test to ensure user input is HTML escaped (it always has been,\nthis just tests it).\n\nThere should be no change to the final rendered output, at all. These\nchanges only affect PDF and PNG reports, not CSV reports.","sha":"3b5e96a4b8dc3d2741de658ea9ad7981617fe3db"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/217778","number":217778,"mergeCommit":{"message":"change reporting usage of `handlebars` to `@kbn/handlebars` (#217778)\n\nChange reporting's usage of `handlebars` to `@kbn/handlebars`. Also\nadded a test to ensure user input is HTML escaped (it always has been,\nthis just tests it).\n\nThere should be no change to the final rendered output, at all. These\nchanges only affect PDF and PNG reports, not CSV reports.","sha":"3b5e96a4b8dc3d2741de658ea9ad7981617fe3db"}}]}] BACKPORT--> Co-authored-by: Patrick Mueller <patrick.mueller@elastic.co>
…217778) (#219526) # Backport This will backport the following commits from `main` to `8.18`: - [change reporting usage of `handlebars` to `@kbn/handlebars` (#217778)](#217778) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Patrick Mueller","email":"patrick.mueller@elastic.co"},"sourceCommit":{"committedDate":"2025-04-29T12:08:28Z","message":"change reporting usage of `handlebars` to `@kbn/handlebars` (#217778)\n\nChange reporting's usage of `handlebars` to `@kbn/handlebars`. Also\nadded a test to ensure user input is HTML escaped (it always has been,\nthis just tests it).\n\nThere should be no change to the final rendered output, at all. These\nchanges only affect PDF and PNG reports, not CSV reports.","sha":"3b5e96a4b8dc3d2741de658ea9ad7981617fe3db","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:ResponseOps","backport:all-open","ci:cloud-deploy","Feature:Reporting:Framework","Feature:Reporting:Screenshot","v9.1.0"],"title":"change reporting usage of `handlebars` to `@kbn/handlebars`","number":217778,"url":"https://github.com/elastic/kibana/pull/217778","mergeCommit":{"message":"change reporting usage of `handlebars` to `@kbn/handlebars` (#217778)\n\nChange reporting's usage of `handlebars` to `@kbn/handlebars`. Also\nadded a test to ensure user input is HTML escaped (it always has been,\nthis just tests it).\n\nThere should be no change to the final rendered output, at all. These\nchanges only affect PDF and PNG reports, not CSV reports.","sha":"3b5e96a4b8dc3d2741de658ea9ad7981617fe3db"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/217778","number":217778,"mergeCommit":{"message":"change reporting usage of `handlebars` to `@kbn/handlebars` (#217778)\n\nChange reporting's usage of `handlebars` to `@kbn/handlebars`. Also\nadded a test to ensure user input is HTML escaped (it always has been,\nthis just tests it).\n\nThere should be no change to the final rendered output, at all. These\nchanges only affect PDF and PNG reports, not CSV reports.","sha":"3b5e96a4b8dc3d2741de658ea9ad7981617fe3db"}}]}] BACKPORT--> Co-authored-by: Patrick Mueller <patrick.mueller@elastic.co>
…217778) (#219543) # Backport This will backport the following commits from `main` to `8.17`: - [change reporting usage of `handlebars` to `@kbn/handlebars` (#217778)](#217778) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Patrick Mueller","email":"patrick.mueller@elastic.co"},"sourceCommit":{"committedDate":"2025-04-29T12:08:28Z","message":"change reporting usage of `handlebars` to `@kbn/handlebars` (#217778)\n\nChange reporting's usage of `handlebars` to `@kbn/handlebars`. Also\nadded a test to ensure user input is HTML escaped (it always has been,\nthis just tests it).\n\nThere should be no change to the final rendered output, at all. These\nchanges only affect PDF and PNG reports, not CSV reports.","sha":"3b5e96a4b8dc3d2741de658ea9ad7981617fe3db","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:ResponseOps","backport:all-open","ci:cloud-deploy","Feature:Reporting:Framework","Feature:Reporting:Screenshot","v9.1.0"],"title":"change reporting usage of `handlebars` to `@kbn/handlebars`","number":217778,"url":"https://github.com/elastic/kibana/pull/217778","mergeCommit":{"message":"change reporting usage of `handlebars` to `@kbn/handlebars` (#217778)\n\nChange reporting's usage of `handlebars` to `@kbn/handlebars`. Also\nadded a test to ensure user input is HTML escaped (it always has been,\nthis just tests it).\n\nThere should be no change to the final rendered output, at all. These\nchanges only affect PDF and PNG reports, not CSV reports.","sha":"3b5e96a4b8dc3d2741de658ea9ad7981617fe3db"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/217778","number":217778,"mergeCommit":{"message":"change reporting usage of `handlebars` to `@kbn/handlebars` (#217778)\n\nChange reporting's usage of `handlebars` to `@kbn/handlebars`. Also\nadded a test to ensure user input is HTML escaped (it always has been,\nthis just tests it).\n\nThere should be no change to the final rendered output, at all. These\nchanges only affect PDF and PNG reports, not CSV reports.","sha":"3b5e96a4b8dc3d2741de658ea9ad7981617fe3db"}},{"url":"https://github.com/elastic/kibana/pull/219526","number":219526,"branch":"8.18","state":"OPEN"},{"url":"https://github.com/elastic/kibana/pull/219527","number":219527,"branch":"8.19","state":"OPEN"},{"url":"https://github.com/elastic/kibana/pull/219528","number":219528,"branch":"9.0","state":"OPEN"}]}] BACKPORT-->
…217778) Change reporting's usage of `handlebars` to `@kbn/handlebars`. Also added a test to ensure user input is HTML escaped (it always has been, this just tests it). There should be no change to the final rendered output, at all. These changes only affect PDF and PNG reports, not CSV reports.
…217778) Change reporting's usage of `handlebars` to `@kbn/handlebars`. Also added a test to ensure user input is HTML escaped (it always has been, this just tests it). There should be no change to the final rendered output, at all. These changes only affect PDF and PNG reports, not CSV reports.
…217778) Change reporting's usage of `handlebars` to `@kbn/handlebars`. Also added a test to ensure user input is HTML escaped (it always has been, this just tests it). There should be no change to the final rendered output, at all. These changes only affect PDF and PNG reports, not CSV reports.
Summary
Change reporting's usage of
handlebarsto@kbn/handlebars. Also added a test to ensure user input is HTML escaped (it always has been, this just tests it).There should be no change to the final rendered output, at all. These changes only affect PDF and PNG reports, not CSV reports.
Checklist
Check the PR satisfies following conditions.
Powered by Elasticbeneath itPowered by Elasticwill not be rendered.Reviewers should verify this PR satisfies this list as well.