Skip to content

Commit

Permalink
feat(preview-service): remove SYS_ADMIN capability requirement (#2414)
Browse files Browse the repository at this point in the history
* fix(preview-service): avoid SYS_ADMIN capabilities
  • Loading branch information
iainsproat authored Jun 20, 2024
1 parent d4f90a8 commit 69757fb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
8 changes: 4 additions & 4 deletions packages/preview-service/routes/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ async function getScreenshot(objectUrl, boundLogger = logger) {
headless: shouldBeHeadless,
userDataDir: '/tmp/puppeteer',
executablePath: '/usr/bin/google-chrome-stable',
args: ['--disable-dev-shm-usage']
// we trust the web content that is running, so can disable the sandbox
// disabling the sandbox allows us to run the docker image without linux kernel privileges
args: ['--no-sandbox', '--disable-setuid-sandbox', '--disable-dev-shm-usage']
}
// if ( process.env.PUPPETEER_SKIP_CHROMIUM_DOWNLOAD === 'true' ) {
// launchParams.executablePath = 'chromium'
// }

const browser = await puppeteer.launch(launchParams)
const page = await browser.newPage()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,8 @@ spec:
capabilities:
drop:
- ALL
add:
- SYS_ADMIN #TODO remove this and replace with sec comp profile: https://stackoverflow.com/a/53975412
privileged: false
# readOnlyRootFilesystem: true # this breaks chromium
# readOnlyRootFilesystem: true #FIXME this currently breaks chromium. Need to identify which directories should be mounted.
runAsNonRoot: true
runAsUser: 800

Expand Down Expand Up @@ -101,8 +99,8 @@ spec:
fsGroup: 25000
fsGroupChangePolicy: OnRootMismatch
runAsGroup: 30000
# seccompProfile:
# type: RuntimeDefault #TODO: uncomment this when we have a profile for chromium
seccompProfile:
type: RuntimeDefault

# Should be > preview generation time ( 1 hour for good measure )
terminationGracePeriodSeconds: 3600
Expand Down

0 comments on commit 69757fb

Please sign in to comment.