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

Allow disabling pyppeteer sandbox #1516

Merged
merged 1 commit into from
Feb 3, 2021
Merged
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
18 changes: 18 additions & 0 deletions nbconvert/exporters/webpdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,22 @@ class WebPDFExporter(HTMLExporter):
"""
).tag(config=True)

disable_sandbox = Bool(
False,
help="""
Disable chromium security sandbox when converting to PDF.

WARNING: This could cause arbitrary code execution in specific circumstances,
where JS in your notebook can execute serverside code! Please use with
caution.

https://github.com/puppeteer/puppeteer/blob/main@%7B2020-12-14T17:22:24Z%7D/docs/troubleshooting.md#setting-up-chrome-linux-sandbox
has more information.

This is required for webpdf to work inside most container environments.
"""
).tag(config=True)

def _check_launch_reqs(self):
try:
from pyppeteer import launch
Expand All @@ -50,10 +66,12 @@ def run_pyppeteer(self, html):
"""Run pyppeteer."""

async def main():
args = ['--no-sandbox'] if self.disable_sandbox else []
browser = await self._check_launch_reqs()(
handleSIGINT=False,
handleSIGTERM=False,
handleSIGHUP=False,
args=args
)
page = await browser.newPage()
await page.waitFor(100)
Expand Down