-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Replace npx with pinned npm-tools and add security hardening #21166
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
Changes from all commits
e168a9c
2897ffa
22f22b7
a1f2efa
8fe30fd
abac094
f15e31b
11c9a0a
7f2dcb5
1fcaecb
d543b64
fdb7c7b
fae8573
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -93,7 +93,7 @@ ARG TARGETOS | |
|
|
||
| # Install dependencies | ||
| USER root | ||
| ARG LEEWAY_VERSION=0.10.4 | ||
| ARG LEEWAY_VERSION=0.10.6 | ||
| ENV LEEWAY_MAX_PROVENANCE_BUNDLE_SIZE=8388608 | ||
| ENV LEEWAY_WORKSPACE_ROOT=/workspace/gitpod | ||
| ENV LEEWAY_REMOTE_CACHE_BUCKET=leeway-cache-dev-3ac8ef5 | ||
|
|
@@ -334,8 +334,32 @@ ENV HOME=/root | |
| RUN curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash \ | ||
| && bash -c ". $HOME/.nvm/nvm.sh \ | ||
| && nvm install v${NODE_VERSION} \ | ||
| && nvm alias default v${NODE_VERSION} \ | ||
| && npm install -g typescript yarn pnpm node-gyp @anthropic-ai/claude-code" | ||
| && nvm alias default v${NODE_VERSION}" | ||
|
|
||
| # Disable npm/yarn lifecycle scripts by default (security hardening) | ||
| # To allow specific packages, use: npm rebuild <package> or yarn rebuild <package> | ||
| RUN npm config set ignore-scripts true --location=global && \ | ||
| npm config set ignore-scripts true --location=user && \ | ||
| echo 'ignore-scripts true' >> ~/.yarnrc | ||
|
|
||
| # Disable npx (security hardening - prevents arbitrary package execution) | ||
| # Remove npx from NVM and replace with stub that prints warning | ||
| RUN rm -f /usr/bin/npx /usr/local/bin/npx && \ | ||
| rm -f /root/.nvm/versions/node/v${NODE_VERSION}/bin/npx && \ | ||
| rm -f /root/.nvm/versions/node/v${NODE_VERSION}/lib/node_modules/npm/bin/npx-cli.js && \ | ||
| echo '#!/bin/sh' > /usr/local/bin/npx && \ | ||
| echo 'echo "npx is disabled for security reasons. Use explicit package installation instead." >&2' >> /usr/local/bin/npx && \ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Works: |
||
| echo 'exit 1' >> /usr/local/bin/npx && \ | ||
| chmod +x /usr/local/bin/npx | ||
|
|
||
| # Install npm-tools with locked dependencies | ||
| COPY dev/npm-tools/package.json dev/npm-tools/package-lock.json /opt/npm-tools/ | ||
| RUN cd /opt/npm-tools && \ | ||
| npm ci && \ | ||
| for bin in /opt/npm-tools/node_modules/.bin/*; do \ | ||
| ln -sf "$bin" /usr/local/bin/$(basename "$bin"); \ | ||
| done && \ | ||
| rm -rf ~/.npm/_cacache | ||
|
|
||
| ENV PATH=$PATH:/root/.aws-iam:/root/.terraform:/workspace/bin | ||
|
|
||
|
|
||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,9 +15,10 @@ jobs: | |
| run: | | ||
| curl -fsSL https://github.com/csweichel/oci-tool/releases/download/v0.2.1/oci-tool_0.2.1_linux_amd64.tar.gz | tar xz -C /usr/local/bin | ||
| chmod +x /usr/local/bin/oci-tool | ||
| cd ./components/ide/gha-update-image/ | ||
| cd ./dev/npm-tools && npm ci | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit, non-blocking: But, I think we can live with this, for the short time Classic remains. |
||
| echo "$PWD/node_modules/.bin" >> $GITHUB_PATH | ||
| cd $GITHUB_WORKSPACE/components/ide/gha-update-image/ | ||
| yarn | ||
| npm i -g bun | ||
| - name: Check for updates | ||
| id: updates | ||
| run: | | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Built the image like: