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

refactor: remove unused setup code to connect to remote debugger #196979

Merged
merged 5 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1188,7 +1188,6 @@
"object-path-immutable": "^3.1.1",
"openai": "^4.24.1",
"openpgp": "5.10.1",
"opn": "^5.5.0",
"ora": "^4.0.4",
"p-limit": "^3.0.1",
"p-map": "^4.0.0",
Expand Down Expand Up @@ -1601,7 +1600,6 @@
"@types/normalize-path": "^3.0.0",
"@types/nunjucks": "^3.2.6",
"@types/object-hash": "^1.3.0",
"@types/opn": "^5.1.0",
"@types/ora": "^1.3.5",
"@types/papaparse": "^5.0.3",
"@types/pbf": "3.0.2",
Expand Down
5 changes: 0 additions & 5 deletions packages/kbn-screenshotting-server/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ export const config: PluginConfigDescriptor<ConfigType> = {
'xpack.screenshotting.browser.autoDownload',
{ level: 'warning' }
),
renameFromRoot(
'xpack.reporting.capture.browser.chromium.inspect',
'xpack.screenshotting.browser.chromium.inspect',
{ level: 'warning' }
),
renameFromRoot(
'xpack.reporting.capture.browser.chromium.disableSandbox',
'xpack.screenshotting.browser.chromium.disableSandbox',
Expand Down
6 changes: 0 additions & 6 deletions packages/kbn-screenshotting-server/src/config/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,6 @@ export const ConfigSchema = schema.object({
schema.boolean({ defaultValue: true })
),
chromium: schema.object({
inspect: schema.conditional(
schema.contextRef('dist'),
true,
schema.boolean({ defaultValue: false }),
schema.maybe(schema.never())
),
disableSandbox: schema.maybe(schema.boolean()), // default value is dynamic in createConfig
proxy: schema.object({
enabled: schema.boolean({ defaultValue: false }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,6 @@ kibana_vars=(
xpack.observability.unsafe.thresholdRule.enabled
xpack.reporting.capture.browser.autoDownload
xpack.reporting.capture.browser.chromium.disableSandbox
xpack.reporting.capture.browser.chromium.inspect
xpack.reporting.capture.browser.chromium.maxScreenshotDimension
xpack.reporting.capture.browser.chromium.proxy.bypass
xpack.reporting.capture.browser.chromium.proxy.enabled
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/screenshotting/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ Option | Default | Description
`xpack.screenshotting.networkPolicy.enabled` | `true` | Capturing a screenshot from a Kibana page involves sending out requests for all the linked web assets. For example, a Markdown visualization can show an image from a remote server.
`xpack.screenshotting.networkPolicy.rules` | Allow http, https, ws, wss, and data. | A policy is specified as an array of objects that describe what to allow or deny based on a host or protocol. If a host or protocol is not specified, the rule matches any host or protocol.
`xpack.screenshotting.browser.autoDownload` | Depends on the `dist` parameter. | Flag to automatically download chromium distribution.
`xpack.screenshotting.browser.chromium.inspect` | Depends on the `dist` parameter. | Connects to the browser over a pipe instead of a WebSocket. See [puppeteer](https://github.com/puppeteer/puppeteer/blob/main/docs/api.md#puppeteerlaunchoptions) documentation.
`xpack.screenshotting.browser.chromium.disableSandbox` | Defaults to `false` for all operating systems except Debian and Red Hat Linux, which use `true`. | It is recommended that you research the feasibility of enabling unprivileged user namespaces. An exception is if you are running Kibana in Docker because the container runs in a user namespace with the built-in seccomp/bpf filters. For more information, refer to [Chromium sandbox](https://chromium.googlesource.com/chromium/src/+/HEAD/docs/linux/sandboxing.md).
`xpack.screenshotting.browser.chromium.proxy.enabled` | `false` | Enables the proxy for Chromium to use.
`xpack.screenshotting.browser.chromium.proxy.server` | _none_ | The uri for the proxy server. Providing the username and password for the proxy server via the uri is not supported.
Expand Down
25 changes: 0 additions & 25 deletions x-pack/plugins/screenshotting/server/browsers/chromium/driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
} from '@kbn/screenshot-mode-plugin/server';
import { ConfigType } from '@kbn/screenshotting-server';
import { truncate } from 'lodash';
import open from 'opn';
import { ElementHandle, EvaluateFunc, HTTPResponse, Page } from 'puppeteer';
import { Subject } from 'rxjs';
import { parse as parseUrl } from 'url';
Expand Down Expand Up @@ -140,10 +139,6 @@ export class HeadlessChromiumDriver {
this.registerListeners(url, headers, logger);
await this.page.goto(url, { waitUntil: 'domcontentloaded' });

if (this.config.browser.chromium.inspect) {
await this.launchDebugger();
}

await this.waitForSelector(
pageLoadSelector,
{ timeout },
Expand Down Expand Up @@ -452,26 +447,6 @@ export class HeadlessChromiumDriver {
this.listenersAttached = true;
}

private async launchDebugger() {
// In order to pause on execution we have to reach more deeply into Chromiums Devtools Protocol,
// and more specifically, for the page being used. _client is per-page.
// In order to get the inspector running, we have to know the page's internal ID (again, private)
// in order to construct the final debugging URL.

const client = this.page._client();
const target = this.page.target();
const targetId = target._targetId;

await client.send('Debugger.enable');
await client.send('Debugger.pause');
const wsEndpoint = this.page.browser().wsEndpoint();
const { port } = parseUrl(wsEndpoint);

await open(
`http://localhost:${port}/devtools/inspector.html?ws=localhost:${port}/devtools/page/${targetId}`
);
}

private _shouldUseCustomHeaders(sourceUrl: string, targetUrl: string) {
const {
hostname: sourceHostname,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export class HeadlessChromiumDriverFactory {
let browser: Browser | undefined;
try {
browser = await puppeteer.launch({
pipe: !this.config.browser.chromium.inspect,
pipe: true,
userDataDir: this.userDataDir,
executablePath: this.binaryPath,
acceptInsecureCerts: true,
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/screenshotting/server/config/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ describe('ConfigSchema', () => {
"browser": Object {
"autoDownload": false,
"chromium": Object {
"inspect": false,
"proxy": Object {
"enabled": false,
},
Expand Down
14 changes: 0 additions & 14 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11023,13 +11023,6 @@
dependencies:
"@types/node" "*"

"@types/opn@^5.1.0":
version "5.1.0"
resolved "https://registry.yarnpkg.com/@types/opn/-/opn-5.1.0.tgz#bff7bc371677f4bdbb37884400e03fd81f743927"
integrity sha512-TNPrB7Y1xl06zDI0aGyqkgxjhIev3oJ+cdqlZ52MTAHauWpEL/gIUdHebIfRHFZk9IqSBpE2ci1DT48iZH81yg==
dependencies:
"@types/node" "*"

"@types/ora@^1.3.5":
version "1.3.5"
resolved "https://registry.yarnpkg.com/@types/ora/-/ora-1.3.5.tgz#1a08bf64902c1473d3d47de58549a49e07140f1c"
Expand Down Expand Up @@ -24773,13 +24766,6 @@ opentracing@^0.14.3:
resolved "https://registry.yarnpkg.com/opentracing/-/opentracing-0.14.4.tgz#a113408ea740da3a90fde5b3b0011a375c2e4268"
integrity sha512-nNnZDkUNExBwEpb7LZaeMeQgvrlO8l4bgY/LvGNZCR0xG/dGWqHqjKrAmR5GUoYo0FIz38kxasvA1aevxWs2CA==

opn@^5.5.0:
version "5.5.0"
resolved "https://registry.yarnpkg.com/opn/-/opn-5.5.0.tgz#fc7164fab56d235904c51c3b27da6758ca3b9bfc"
integrity sha512-PqHpggC9bLV0VeWcdKhkpxY+3JTzetLSqTCWL/z/tFIbI6G8JCjondXklT1JinczLz2Xib62sSp0T/gKT4KksA==
dependencies:
is-wsl "^1.1.0"

optional-js@^2.0.0:
version "2.1.1"
resolved "https://registry.yarnpkg.com/optional-js/-/optional-js-2.1.1.tgz#c2dc519ad119648510b4d241dbb60b1167c36a46"
Expand Down