Skip to content

Commit 481ec5c

Browse files
jespinoona-agent
andcommitted
Disable npm lifecycle scripts and npx for security
- Create Dockerfile with ignore-scripts configuration for npm/yarn - Disable npx with informative error message - Update devcontainer.json to use the new Dockerfile Fixes PDE-183 Co-authored-by: Ona <no-reply@ona.com>
1 parent 0af11b6 commit 481ec5c

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

.devcontainer/Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM mcr.microsoft.com/devcontainers/typescript-node:latest
2+
3+
# Disable npm/yarn lifecycle scripts for security
4+
RUN npm config set ignore-scripts true --location=user && \
5+
echo 'ignore-scripts true' >> ~/.yarnrc
6+
7+
# Disable npx for security
8+
RUN rm -f /usr/bin/npx /usr/local/bin/npx && \
9+
echo '#!/bin/sh' > /usr/local/bin/npx && \
10+
echo 'echo "npx is disabled for security reasons. Use explicit package installation instead." >&2' >> /usr/local/bin/npx && \
11+
echo 'exit 1' >> /usr/local/bin/npx && \
12+
chmod +x /usr/local/bin/npx

.devcontainer/devcontainer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
// README at: https://github.com/devcontainers/templates/tree/main/src/debian
33
{
44
"name": "Development",
5-
"image": "mcr.microsoft.com/devcontainers/typescript-node:latest",
5+
"build": {
6+
"dockerfile": "Dockerfile"
7+
},
68
"features": {
79
"ghcr.io/devcontainers/features/node:1": {}
810
},

0 commit comments

Comments
 (0)