docs/Security/Sandboxes/vscode/README.md
Related files at this repo .vscode at this commit.
Install Debian with username wekan, so that WeKan repo here, only directory where VSCode will have access:
/home/wekan/repos/wekan
sudo apt install flatpak
sudo apt install gnome-software-plugin-flatpak
flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
sudo reboot
flatpak install flathub com.visualstudio.code
nano ~/.local/share/applications/wekan-vscode.desktop
Content:
[Desktop Entry]
Name=VS Code - WeKan
Comment=Open the WeKan project with Flatpak
Exec=flatpak run com.visualstudio.code /home/wekan/repos/wekan
Icon=com.visualstudio.code
Terminal=false
Type=Application
Categories=Development;IDE;
StartupWMClass=code
This setting is also added as git commit to VSCode settings.
This is the most important step. If this is "native", it will use the operating system window that sees everything.
Ctrl + , (options).Files: Simple Dialog setting to on (check the box).Run these two commands (the first clears everything, the second sets limits):
# Reset previous attempts
sudo flatpak override --reset com.visualstudio.code
# Block EVERYTHING except the display and the wekan folder
sudo flatpak override com.visualstudio.code \
--nofilesystem=home \
--nofilesystem=host \
--nofilesystem=xdg-run/gvfs \
--nofilesystem=xdg-run/gvfsd \
--filesystem=~/repos/wekan:rw \
--device=all \
--socket=wayland \
--socket=x11 \
--share=network
If you have already set wrong Chrome sandbox env earlier, remove it:
sudo flatpak override --unset-env=CHROME_DEVEL_SANDBOX com.visualstudio.code
Why: inside this Flatpak, /usr/sbin/chrome-devel-sandbox does not exist, and Chromium aborts immediately if that env points there.
Now when you go to File -> Open Folder:
~/repos/wekan.These were found already present in this sandboxed setup:
/home/wekan/repos/wekan/.tools/node-v22.13.1-linux-x64/bin/node/home/wekan/repos/wekan/.tools/node-v22.13.1-linux-x64/bin/npm/home/wekan/repos/wekan/.tools/node-v22.13.1-linux-x64/bin/npx/home/wekan/.meteor/meteor/home/wekan/.var/app/com.visualstudio.code/cache/ms-playwright/chromium-1223/chrome-linux64/chrome/app/extra/vscode/chrome-sandboxOpen VS Code integrated terminal and run:
cd /home/wekan/repos/wekan
# 1) Use repo-local Node/npm/npx
export PATH="$PWD/.tools/node-v22.13.1-linux-x64/bin:$PATH"
# 2) Use Meteor CLI installed at ~/.meteor (if present)
export PATH="/home/wekan/.meteor:$PATH"
# 3) IMPORTANT: avoid bad host path inherited from old overrides
unset CHROME_DEVEL_SANDBOX
# 4) Keep Playwright browsers in Flatpak-private cache
export PLAYWRIGHT_BROWSERS_PATH="/home/wekan/.var/app/com.visualstudio.code/cache/ms-playwright"
Quick checks:
node -v
npm -v
npx playwright --version
meteor --version
If meteor is missing first time, bootstrap it from local Node:
cd /home/wekan/repos/wekan
export PATH="$PWD/.tools/node-v22.13.1-linux-x64/bin:$PATH"
npx -y meteor
export PATH="/home/wekan/.meteor:$PATH"
If you keep --nofilesystem=home, allow Meteor directory explicitly:
sudo flatpak override com.visualstudio.code --filesystem=~/.meteor:rw
Install Playwright deps and run Chromium-only tests:
cd /home/wekan/repos/wekan/tests/playwright
export PATH="/home/wekan/repos/wekan/.tools/node-v22.13.1-linux-x64/bin:$PATH"
unset CHROME_DEVEL_SANDBOX
export PLAYWRIGHT_BROWSERS_PATH="/home/wekan/.var/app/com.visualstudio.code/cache/ms-playwright"
npm install
npx playwright test --project=chromium
This runs headless browser tests inside Flatpak sandboxed VS Code terminal (no external/native browser window needed).
By default this repo runs only the chromium Playwright project.
To enable firefox and webkit projects, set:
export WEKAN_PLAYWRIGHT_ALL=1
Then run for example:
cd /home/wekan/repos/wekan/tests/playwright
export HOME="/home/wekan/repos/wekan/.tools"
unset CHROME_DEVEL_SANDBOX
export PLAYWRIGHT_BROWSERS_PATH="/home/wekan/.var/app/com.visualstudio.code/cache/ms-playwright"
export WEKAN_PLAYWRIGHT_ALL=1
/home/wekan/repos/wekan/.tools/.meteor/meteor npm exec playwright test -- --project=firefox
/home/wekan/repos/wekan/.tools/.meteor/meteor npm exec playwright test -- --project=webkit
Without WEKAN_PLAYWRIGHT_ALL=1, Playwright config exposes only chromium, and --project=firefox/--project=webkit will fail with "Project not found".
playwright install-deps fails because of unrelated apt repo keysOn some hosts, this command can fail even when browser deps are already installed:
sudo npx playwright install-deps
Example failure:
NO_PUBKEY ...The repository ... is not signedThis is usually caused by a third-party apt source (PPA/repo), not by Playwright itself.
Use either of these approaches:
sudo apt install -y \
libgtk-4-1 \
libxml2 \
libevent-2.1-7t64 \
libflite1 \
libjpeg-turbo8 \
libmanette-0.2-0 \
libenchant-2-2 \
libwoff1
install-deps, then re-enable it.In this sandbox workflow, manual apt package install is enough and avoids failures caused by unrelated repositories.
After applying the sandbox env settings from this document and running with:
cd /home/wekan/repos/wekan/tests/playwright
export HOME="/home/wekan/repos/wekan/.tools"
unset CHROME_DEVEL_SANDBOX
export PLAYWRIGHT_BROWSERS_PATH="/home/wekan/.var/app/com.visualstudio.code/cache/ms-playwright"
export WEKAN_PLAYWRIGHT_ALL=1
/home/wekan/repos/wekan/.tools/.meteor/meteor npm exec playwright test -- --project=webkit
validated result:
105 passed (WebKit project)cd /home/wekan/repos/wekan/tests/playwright
export PATH="/home/wekan/repos/wekan/.tools/node-v22.13.1-linux-x64/bin:$PATH"
unset CHROME_DEVEL_SANDBOX
node -e "(async()=>{const {chromium}=require('playwright');const b=await chromium.launch({headless:true,args:['--no-sandbox']});const p=await b.newPage();await p.goto('about:blank');console.log('PW_OK');await b.close();})().catch(e=>{console.error(e);process.exit(1);});"
If output is PW_OK, headless Chromium launch is working inside sandbox.
These were verified while running the full Playwright suite in this exact sandbox setup.
WRITABLE_PATHIf WRITABLE_PATH is missing, app startup can fail with:
WRITABLE_PATH environment variable missing and/or unset
Use a local writable test directory before starting app:
cd /home/wekan/repos/wekan
export WRITABLE_PATH="$PWD/.test-writable"
mkdir -p "$WRITABLE_PATH/files/attachments" "$WRITABLE_PATH/files/avatars"
Then run app:
/home/wekan/.meteor/meteor --port 3000
mongoshPlaywright fixtures seed test data via tests/playwright/helpers/db.js, which calls mongosh.
If missing, tests fail early with:
Error: spawnSync mongosh ENOENT
Install mongosh as a dependency in Playwright test project:
cd /home/wekan/repos/wekan
/home/wekan/.meteor/meteor npm --prefix tests/playwright install mongosh
The helper now also searches tests/playwright/node_modules/.bin so this works in sandbox without system-wide mongosh.
.tools/node... does not existIn some sandboxes the .tools Node path is missing. You can still run commands via Meteor wrapper:
/home/wekan/.meteor/meteor npm -v
/home/wekan/.meteor/meteor npm exec playwright --version
Terminal 1 (start app):
cd /home/wekan/repos/wekan
export WRITABLE_PATH="$PWD/.test-writable"
mkdir -p "$WRITABLE_PATH/files/attachments" "$WRITABLE_PATH/files/avatars"
unset CHROME_DEVEL_SANDBOX
/home/wekan/.meteor/meteor --port 3000
Terminal 2 (run tests):
cd /home/wekan/repos/wekan/tests/playwright
unset CHROME_DEVEL_SANDBOX
export PLAYWRIGHT_BROWSERS_PATH="/home/wekan/.var/app/com.visualstudio.code/cache/ms-playwright"
/home/wekan/.meteor/meteor npm exec playwright test -- --project=chromium
Expected result from this validated setup:
105 passed (Chromium project)meteor test in this sandboxmeteor test --driver-package meteortesting:mocha can start successfully but still report 0 passing in this environment due to test discovery/driver behavior.
For reliable headless validation inside this sandbox, prefer Playwright run described above.
If you get EROFS errors writing to ~/.meteor/packages (read-only home mount), run Meteor from the repo-local copy and point HOME to .tools:
cd /home/wekan/repos/wekan
export HOME="$PWD/.tools"
unset METEOR_WAREHOUSE_DIR
export WRITABLE_PATH="$PWD/.test-writable"
mkdir -p "$WRITABLE_PATH/files/attachments" "$WRITABLE_PATH/files/avatars"
unset CHROME_DEVEL_SANDBOX
"$PWD/.tools/.meteor/meteor" test --once --driver-package meteortesting:mocha --full-app --test server/lib/tests/attachmentApi.authContext.tests.js
Use this when you want one command block that prepares required paths/dependencies and runs Playwright Chromium tests.
Note: this assumes Wekan app is already running at http://localhost:3000 in another terminal.
cd /home/wekan/repos/wekan
# Ensure test writable directories exist
export WRITABLE_PATH="$PWD/.test-writable"
mkdir -p "$WRITABLE_PATH/files/attachments" "$WRITABLE_PATH/files/avatars"
# Sandbox-safe browser env
unset CHROME_DEVEL_SANDBOX
export PLAYWRIGHT_BROWSERS_PATH="/home/wekan/.var/app/com.visualstudio.code/cache/ms-playwright"
# Ensure Playwright-side mongosh exists for DB seeding
/home/wekan/.meteor/meteor npm --prefix tests/playwright install mongosh
# Run Chromium tests
cd tests/playwright
/home/wekan/.meteor/meteor npm exec playwright test -- --project=chromium
If you also need to start app in a separate terminal:
cd /home/wekan/repos/wekan
export WRITABLE_PATH="$PWD/.test-writable"
mkdir -p "$WRITABLE_PATH/files/attachments" "$WRITABLE_PATH/files/avatars"
unset CHROME_DEVEL_SANDBOX
/home/wekan/.meteor/meteor --port 3000
Terminal 1:
cd /home/wekan/repos/wekan
export WRITABLE_PATH="$PWD/.test-writable"
mkdir -p "$WRITABLE_PATH/files/attachments" "$WRITABLE_PATH/files/avatars"
unset CHROME_DEVEL_SANDBOX
/home/wekan/.meteor/meteor --port 3000
Terminal 2:
cd /home/wekan/repos/wekan
unset CHROME_DEVEL_SANDBOX
export PLAYWRIGHT_BROWSERS_PATH="/home/wekan/.var/app/com.visualstudio.code/cache/ms-playwright"
/home/wekan/.meteor/meteor npm --prefix tests/playwright install mongosh
/home/wekan/.meteor/meteor npm --prefix tests/playwright exec playwright test -- --project=chromium