Skip to content

Commit 2dab716

Browse files
authored
Merge pull request #1 from gitpod-io/pde-128-disable-npm-scripts
Disable npm lifecycle scripts and npx for security
2 parents 3665db2 + 76420cb commit 2dab716

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

.gitpod.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ tasks:
44
init: |
55
mkdir node_modules
66
cp -r /home/gitpod/.cache/workspace/* ./node_modules
7-
yarn
7+
yarn --ignore-scripts
88
yarn compile
99
command: |
1010
touch __init_task_done__

Dockerfile

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
11
FROM gitpod/workspace-full
22

3+
# Disable npm lifecycle scripts and npx for security
4+
RUN npm config set ignore-scripts true --location=user && \
5+
echo 'ignore-scripts true' >> ~/.yarnrc && \
6+
NPX_PATH=$(which npx) && \
7+
rm -f "$NPX_PATH" && \
8+
echo '#!/bin/sh' > "$NPX_PATH" && \
9+
echo 'echo "npx is disabled for security reasons. Use explicit package installation instead." >&2' >> "$NPX_PATH" && \
10+
echo 'exit 1' >> "$NPX_PATH" && \
11+
chmod +x "$NPX_PATH"
12+
313
# Create a new image and publish it to dockerhub, then use it directly in .gitpod.yml
414
# as prebuils for integration test makes no sense because a new environment is created
515
# every time
616
RUN cd /tmp \
717
&& git clone https://github.com/gitpod-io/python-test-workspace --depth=1 --single-branch --branch=master \
818
&& cd python-test-workspace \
9-
&& yarn \
19+
&& yarn --ignore-scripts \
1020
&& mkdir -p /home/gitpod/.cache/workspace \
1121
&& cp -r ./node_modules /home/gitpod/.cache/workspace \
1222
&& python3 -m pip install --upgrade ipykernel \
13-
&& npm_config_yes=true npx playwright install-deps \
14-
&& npm_config_yes=true npx playwright install
23+
&& yarn playwright install-deps \
24+
&& yarn playwright install

0 commit comments

Comments
 (0)