From b59e4d00e795c05b421675128c5e17b3eaacd993 Mon Sep 17 00:00:00 2001 From: "Eyo O. Eyo" <7893459+eokoneyo@users.noreply.github.com> Date: Wed, 18 Sep 2024 22:26:44 +0200 Subject: [PATCH] [Reporting] update puppeteer to version 23.3.1 (#192345) ## Summary Update for puppeteer, the following changeset updates puppeteer to version `23.3.1`. The chromium version required for this version of puppeteer is `128.0.6613.137` from revision `1331488`, as such the chromium binary included for windows and darwin platforms either match or were the closest revision to the expectation. The linux headless binary was built from commit `fe621c5aa2d6b987e964fb1b5066833da5fb613d` of the same revision. _**N.B.**_ Puppeteer 23.0.0 is earmarked as containing breaking changes see [here](https://github.com/puppeteer/puppeteer/blob/abda5dcc9912f4fa2c5a566403108db783f48538/packages/puppeteer-core/CHANGELOG.md#2300-2024-08-07), this PR considers the outlined changes and makes relevant adjustments so reporting continues working as is. ### How to verify linux headless build - clone the following repo https://github.com/tsullivan/kibana-dev-docker - pull this particular PR - follow the steps outlined in the repo, replacing any occurrence of `kibana--SNAPSHOT-linux-aarch64.tar.gz` from the repo above's step with the output of running build on this changeset. - before running step 4, modify the `kibana.yml` file from the `kibana-dev-docker` repo and include the following so we might be able to verify the version of chromium running; ```yaml logging.loggers: - name: plugins.reporting level: debug ``` - complete the steps outlined in the README, you'll have a linux distro of kibana running on port `5601` - Attempt creating exports of PDF and PNG reports, in dashboard, canvas, and visualizations, on report creation attempt we would see a log output that prints out the chromium version exactly matching this; Screenshot 2024-09-18 at 14 50 19 --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Elastic Machine (cherry picked from commit 91ca8ab95c01f88ea2d79779f3670c88bf269da0) # Conflicts: # yarn.lock --- package.json | 2 +- .../kbn-screenshotting-server/src/paths.ts | 34 ++++----- x-pack/build_chromium/linux/args.gn | 2 +- .../server/browsers/chromium/driver.ts | 25 +++--- .../browsers/chromium/driver_factory/index.ts | 2 +- yarn.lock | 76 ++++++++++--------- 6 files changed, 76 insertions(+), 65 deletions(-) diff --git a/package.json b/package.json index 963f620f58277..30c35e4f08de4 100644 --- a/package.json +++ b/package.json @@ -1131,7 +1131,7 @@ "pretty-ms": "6.0.0", "prop-types": "^15.8.1", "proxy-from-env": "1.0.0", - "puppeteer": "22.13.1", + "puppeteer": "23.3.1", "query-string": "^6.13.2", "rbush": "^3.0.1", "re-resizable": "^6.9.9", diff --git a/packages/kbn-screenshotting-server/src/paths.ts b/packages/kbn-screenshotting-server/src/paths.ts index e5b958ddc1fc0..bfbfab186019d 100644 --- a/packages/kbn-screenshotting-server/src/paths.ts +++ b/packages/kbn-screenshotting-server/src/paths.ts @@ -45,10 +45,10 @@ export class ChromiumArchivePaths { platform: 'darwin', architecture: 'x64', archiveFilename: 'chrome-mac.zip', - archiveChecksum: 'fa8004f3c8c5574c089c901e48429d1b01720bf3dd25e05ac56c41d0ab470c10', - binaryChecksum: '56f25cb6881e5c2b1aac0d8e87630517d1af8effdc9319d35f872add048df1ca', + archiveChecksum: '0a3d18efd00b3406f66139a673616b4b2b4b00323776678cb82295996f5a6733', + binaryChecksum: '8bcdaa973ee11110f6b70eaac2418fda3bb64446cf37f964fce331cdc8907a20', binaryRelativePath: 'chrome-mac/Chromium.app/Contents/MacOS/Chromium', - revision: 1300317, // 1300313 is not available for Mac_x64 + revision: 1331485, // 1331488 is not available for Mac_x64 location: 'common', archivePath: 'Mac', isPreInstalled: false, @@ -57,10 +57,10 @@ export class ChromiumArchivePaths { platform: 'darwin', architecture: 'arm64', archiveFilename: 'chrome-mac.zip', - archiveChecksum: 'bea49fd3ccd6aaccd7cdc4df38306f002a2934aaa2c044f3b5a3272b31ec77ca', - binaryChecksum: '4c55d9e47deb1179c377c9785afdcdb5f3d3f351bff62b414d43e32ff195bd55', + archiveChecksum: '426eddf16acb88b9446a91de53cc4364c7d487414248f33e30f68cf488cea0c0', + binaryChecksum: '827931739bfdd2b6790a81d5ade8886c159cd051581d79b84d1ede447293e9cf', binaryRelativePath: 'chrome-mac/Chromium.app/Contents/MacOS/Chromium', - revision: 1300314, // 1300313 is not available for Mac_Arm + revision: 1331488, location: 'common', archivePath: 'Mac_Arm', isPreInstalled: false, @@ -68,22 +68,22 @@ export class ChromiumArchivePaths { { platform: 'linux', architecture: 'x64', - archiveFilename: 'chromium-5b5d829-locales-linux_x64.zip', - archiveChecksum: '799e8fd5f47ea70b8a3972d39b2617c9cbebc7fc433a89251dae312a7c77534b', - binaryChecksum: '216b8f7ff9b41e985397342c2df54e4f8e07a01a3b8a929f39b9a10931d26ff5', + archiveFilename: 'chromium-fe621c5-locales-linux_x64.zip', + archiveChecksum: '12ce2e0eac184072dfcbc7a267328e3eb7fbe10a682997f4111c0378f2397341', + binaryChecksum: '670481cfa8db209401106cd23051009d390c03608724d0822a12c8c0a92b4c25', binaryRelativePath: 'headless_shell-linux_x64/headless_shell', - revision: 1300313, + revision: 1331488, location: 'custom', isPreInstalled: true, }, { platform: 'linux', architecture: 'arm64', - archiveFilename: 'chromium-5b5d829-locales-linux_arm64.zip', - archiveChecksum: '961e20c45c61f8e948efdc4128bb17c23217bbcb28537f270ccf5bf0826981e7', - binaryChecksum: 'fc4027fb6b1c96bef9374d5d9f791097fae2ec2ddc4e0134167075bd52d1458f', + archiveFilename: 'chromium-fe621c5-locales-linux_arm64.zip', + archiveChecksum: 'f7333eaff5235046c8775f0c1a0b7395b7ebc2e054ea638710cf511c4b6f9daf', + binaryChecksum: '8a3a3371b3d04f4b0880b137a3611c223e0d8e65a218943cb7be1ec4a91f5e35', binaryRelativePath: 'headless_shell-linux_arm64/headless_shell', - revision: 1300313, + revision: 1331488, location: 'custom', isPreInstalled: true, }, @@ -91,10 +91,10 @@ export class ChromiumArchivePaths { platform: 'win32', architecture: 'x64', archiveFilename: 'chrome-win.zip', - archiveChecksum: '27a2ed1473cefc6f48ff5665faa1fbcc69ef5be47ee21777a60e87c8379fdd93', - binaryChecksum: 'd603401a5e6f8bd734b329876e4221a4d24a1999f14df6e32eeb5e6a72520d96', + archiveChecksum: 'fa62be702f55f37e455bab4291c59ceb40e81e1922d30cf9453a4ee176b909bc', + binaryChecksum: '1345e66583bad1a1f16885f381d1173de8bf931487da9ba155e1b58bf23b2c66', binaryRelativePath: path.join('chrome-win', 'chrome.exe'), - revision: 1300320, // 1300313 is not available for win32 + revision: 1331487, // 1331488 is not available for win32 location: 'common', archivePath: 'Win', isPreInstalled: true, diff --git a/x-pack/build_chromium/linux/args.gn b/x-pack/build_chromium/linux/args.gn index 01af3bf766f7b..a7d5713b92cd0 100644 --- a/x-pack/build_chromium/linux/args.gn +++ b/x-pack/build_chromium/linux/args.gn @@ -17,7 +17,7 @@ v8_symbol_level = 0 enable_ink = false rtc_build_examples = false angle_build_tests = false -enable_screen_ai_service = false +use_fake_screen_ai = true enable_vr = false # Please, consult @elastic/kibana-security before changing/removing this option. diff --git a/x-pack/plugins/screenshotting/server/browsers/chromium/driver.ts b/x-pack/plugins/screenshotting/server/browsers/chromium/driver.ts index 02d611f9ca00f..3c199b2916b30 100644 --- a/x-pack/plugins/screenshotting/server/browsers/chromium/driver.ts +++ b/x-pack/plugins/screenshotting/server/browsers/chromium/driver.ts @@ -244,15 +244,17 @@ export class HeadlessChromiumDriver { if (error) { await this.injectScreenshottingErrorHeader(error, getPrintLayoutSelectors().screenshot); } - return this.page.pdf({ - format: 'a4', - preferCSSPageSize: true, - scale: 1, - landscape: false, - displayHeaderFooter: true, - headerTemplate: await getHeaderTemplate({ title }), - footerTemplate: await getFooterTemplate({ logo }), - }); + return Buffer.from( + await this.page.pdf({ + format: 'a4', + preferCSSPageSize: true, + scale: 1, + landscape: false, + displayHeaderFooter: true, + headerTemplate: await getHeaderTemplate({ title }), + footerTemplate: await getFooterTemplate({ logo }), + }) + ); } /* @@ -272,6 +274,7 @@ export class HeadlessChromiumDriver { } const { boundingClientRect, scroll } = elementPosition; + const screenshot = await this.page.screenshot({ clip: { x: boundingClientRect.left + scroll.x, @@ -282,8 +285,8 @@ export class HeadlessChromiumDriver { captureBeyondViewport: false, // workaround for an internal resize. See: https://github.com/puppeteer/puppeteer/issues/7043 }); - if (Buffer.isBuffer(screenshot)) { - return screenshot; + if (screenshot.byteLength) { + return Buffer.from(screenshot); } if (typeof screenshot === 'string') { diff --git a/x-pack/plugins/screenshotting/server/browsers/chromium/driver_factory/index.ts b/x-pack/plugins/screenshotting/server/browsers/chromium/driver_factory/index.ts index f6015c319cc0a..d8503b70ad963 100644 --- a/x-pack/plugins/screenshotting/server/browsers/chromium/driver_factory/index.ts +++ b/x-pack/plugins/screenshotting/server/browsers/chromium/driver_factory/index.ts @@ -150,7 +150,7 @@ export class HeadlessChromiumDriverFactory { pipe: !this.config.browser.chromium.inspect, userDataDir: this.userDataDir, executablePath: this.binaryPath, - ignoreHTTPSErrors: true, + acceptInsecureCerts: true, handleSIGHUP: false, args: chromiumArgs, defaultViewport: viewport, diff --git a/yarn.lock b/yarn.lock index 83a5b41f58b32..4ae3fdeeec549 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8087,16 +8087,16 @@ resolved "https://registry.yarnpkg.com/@protobufjs/utf8/-/utf8-1.1.0.tgz#a777360b5b39a1a2e5106f8e858f2fd2d060c570" integrity sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA= -"@puppeteer/browsers@2.2.4": - version "2.2.4" - resolved "https://registry.yarnpkg.com/@puppeteer/browsers/-/browsers-2.2.4.tgz#4307245d881aa5a79743050be66568bad0f6ffbb" - integrity sha512-BdG2qiI1dn89OTUUsx2GZSpUzW+DRffR1wlMJyKxVHYrhnKoELSDxDd+2XImUkuWPEKk76H5FcM/gPFrEK1Tfw== +"@puppeteer/browsers@2.4.0": + version "2.4.0" + resolved "https://registry.yarnpkg.com/@puppeteer/browsers/-/browsers-2.4.0.tgz#a0dd0f4e381e53f509109ae83b891db5972750f5" + integrity sha512-x8J1csfIygOwf6D6qUAZ0ASk3z63zPb7wkNeHRerCMh82qWKUrOgkuP005AJC8lDL6/evtXETGEJVcwykKT4/g== dependencies: - debug "^4.3.5" + debug "^4.3.6" extract-zip "^2.0.1" progress "^2.0.3" proxy-agent "^6.4.0" - semver "^7.6.2" + semver "^7.6.3" tar-fs "^3.0.6" unbzip2-stream "^1.4.3" yargs "^17.7.2" @@ -14021,10 +14021,10 @@ chromedriver@^128.0.1: proxy-from-env "^1.1.0" tcp-port-used "^1.0.2" -chromium-bidi@0.6.1: - version "0.6.1" - resolved "https://registry.yarnpkg.com/chromium-bidi/-/chromium-bidi-0.6.1.tgz#533612dd166b7b36a8ba8b90685ad2fa0c98d064" - integrity sha512-kSxJRj0VgtUKz6nmzc2JPfyfJGzwzt65u7PqhPHtgGQUZLF5oG+ST6l6e5ONfStUMAlhSutFCjaGKllXZa16jA== +chromium-bidi@0.6.5: + version "0.6.5" + resolved "https://registry.yarnpkg.com/chromium-bidi/-/chromium-bidi-0.6.5.tgz#31be98f9ee5c93fa99d240c680518c9293d8c6bb" + integrity sha512-RuLrmzYrxSb0s9SgpB+QN5jJucPduZQ/9SIe76MDxYJuecPW5mxMdacJ1f4EtgiV+R0p3sCkznTMvH0MPGFqjA== dependencies: mitt "3.0.1" urlpattern-polyfill "10.0.0" @@ -15559,12 +15559,12 @@ debug@2.6.9, debug@^2.2.0, debug@^2.3.3, debug@^2.6.0, debug@^2.6.9: dependencies: ms "2.0.0" -debug@4, debug@^4.0.0, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2, debug@^4.3.3, debug@^4.3.4, debug@^4.3.5: - version "4.3.6" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.6.tgz#2ab2c38fbaffebf8aa95fdfe6d88438c7a13c52b" - integrity sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg== +debug@4, debug@^4.0.0, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2, debug@^4.3.3, debug@^4.3.4, debug@^4.3.5, debug@^4.3.6, debug@^4.3.7: + version "4.3.7" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.7.tgz#87945b4151a011d76d95a198d7111c865c360a52" + integrity sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ== dependencies: - ms "2.1.2" + ms "^2.1.3" debug@4.3.1: version "4.3.1" @@ -16020,10 +16020,10 @@ detective@^5.0.2: defined "^1.0.0" minimist "^1.1.1" -devtools-protocol@0.0.1299070: - version "0.0.1299070" - resolved "https://registry.yarnpkg.com/devtools-protocol/-/devtools-protocol-0.0.1299070.tgz#b3e4cf0b678a46f0f907ae6e07e03ad3a53c00df" - integrity sha512-+qtL3eX50qsJ7c+qVyagqi7AWMoQCBGNfoyJZMwm/NSXVqLYbuitrWEEIzxfUmTNy7//Xe8yhMmQ+elj3uAqSg== +devtools-protocol@0.0.1330662: + version "0.0.1330662" + resolved "https://registry.yarnpkg.com/devtools-protocol/-/devtools-protocol-0.0.1330662.tgz#400fe703c2820d6b2d9ebdd1785934310152373e" + integrity sha512-pzh6YQ8zZfz3iKlCvgzVCu22NdpZ8hNmwU6WnQjNVquh0A9iVosPtNLWDwaWVGyrntQlltPFztTMK5Cg6lfCuw== dezalgo@^1.0.0, dezalgo@^1.0.4: version "1.0.4" @@ -26043,26 +26043,29 @@ pupa@^3.1.0: dependencies: escape-goat "^4.0.0" -puppeteer-core@22.13.1: - version "22.13.1" - resolved "https://registry.yarnpkg.com/puppeteer-core/-/puppeteer-core-22.13.1.tgz#3ba03e5ebd98bbbd86e465864cf00314e07309de" - integrity sha512-NmhnASYp51QPRCAf9n0OPxuPMmzkKd8+2sB9Q+BjwwCG25gz6iuNc3LQDWa+cH2tyivmJppLhNNFt6Q3HmoOpw== +puppeteer-core@23.3.1: + version "23.3.1" + resolved "https://registry.yarnpkg.com/puppeteer-core/-/puppeteer-core-23.3.1.tgz#b93d825e586f5f7dc268128a31a31c62bbe378ae" + integrity sha512-m5gTpITEqqpSgAvPUI/Ch9igh5sNJV+BVVbqQMzqirRDVHDCkLGHaydEQZx2NZvSXdwCFrIV///cpSlX/uD0Sg== dependencies: - "@puppeteer/browsers" "2.2.4" - chromium-bidi "0.6.1" - debug "^4.3.5" - devtools-protocol "0.0.1299070" + "@puppeteer/browsers" "2.4.0" + chromium-bidi "0.6.5" + debug "^4.3.7" + devtools-protocol "0.0.1330662" + typed-query-selector "^2.12.0" ws "^8.18.0" -puppeteer@22.13.1: - version "22.13.1" - resolved "https://registry.yarnpkg.com/puppeteer/-/puppeteer-22.13.1.tgz#f8e4217919b438f18adb754e9d8414fef58fb3de" - integrity sha512-PwXLDQK5u83Fm5A7TGMq+9BR7iHDJ8a3h21PSsh/E6VfhxiKYkU7+tvGZNSCap6k3pCNDd9oNteVBEctcBalmQ== +puppeteer@23.3.1: + version "23.3.1" + resolved "https://registry.yarnpkg.com/puppeteer/-/puppeteer-23.3.1.tgz#830ac4b2c264ae4a610b79be77aff23bb13efa2c" + integrity sha512-BxkuJyCv46ZKW8KEHiVMHgHEC89jKK9FffReWjbw1IfBUmNx+6JIZyqOtaJeSwyolTdVqqb5fiPiXflKeH3dKQ== dependencies: - "@puppeteer/browsers" "2.2.4" + "@puppeteer/browsers" "2.4.0" + chromium-bidi "0.6.5" cosmiconfig "^9.0.0" - devtools-protocol "0.0.1299070" - puppeteer-core "22.13.1" + devtools-protocol "0.0.1330662" + puppeteer-core "23.3.1" + typed-query-selector "^2.12.0" pure-rand@^6.0.0: version "6.0.2" @@ -30600,6 +30603,11 @@ typed-array-length@^1.0.6: is-typed-array "^1.1.13" possible-typed-array-names "^1.0.0" +typed-query-selector@^2.12.0: + version "2.12.0" + resolved "https://registry.yarnpkg.com/typed-query-selector/-/typed-query-selector-2.12.0.tgz#92b65dbc0a42655fccf4aeb1a08b1dddce8af5f2" + integrity sha512-SbklCd1F0EiZOyPiW192rrHZzZ5sBijB6xM+cpmrwDqObvdtunOHHIk9fCGsoK5JVIYXoyEp4iEdE3upFH3PAg== + typedarray-to-buffer@^3.1.5: version "3.1.5" resolved "https://registry.yarnpkg.com/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz#a97ee7a9ff42691b9f783ff1bc5112fe3fca9080"