Compare commits

...

29 Commits

Author SHA1 Message Date
cdrci
9fe7eb79d5 Update Code to 1.124.2 (#7846) 2026-06-15 22:28:49 -08:00
Asher
1ccd4f04d2 Update brace-expansion, js-yaml, and ws 2026-06-15 16:42:17 -08:00
Asher
364cf99338 Strip token from cookies before proxying
Since this functionality requires information placed onto the request by
code-server (req.args) and Express (req.cookies), move the standalone
tests into the integration tests as the proxy can no longer run
correctly on its own without that context.

We could strip the header elsewhere or refactor in some way (pass in a
callback function for the stripping or something) but this seems like
the simplest and safest place at the moment to ensure we catch all uses
of the proxy.

In any case, I think it does lend more confidence to know we are testing
the proxy the way it will be used in practice.  The downside is some
additional complexity when setting up tests, but at the moment I do not
think that exchange is overly burdensome.
2026-06-15 16:42:17 -08:00
ka-ishimoto
92a7dce46f Fix false positive CVE alerts by setting package name to code-oss-dev (#7839)
The VS Code build process sets the bundled lib/vscode/package.json name to "code-server" (from product.json nameShort), causing vulnerability scanners to misidentify it and flag non-applicable CVEs. Override the name to "code-oss-dev" in build-release.sh after merging package.json.
Fixes #7071

Signed-off-by: ka-ishimoto <ka-ishimoto@kddi.com>
2026-06-10 11:59:45 -08:00
cdrci
d0d53d924e Update Helm chart and changelog with 4.123.0 (#7838) 2026-06-04 10:50:04 -08:00
Asher
77d880d0c3 Drop armhf builds 2026-06-03 12:06:07 -08:00
Asher
559d73a636 Update Code to 1.123.0 (#7837) 2026-06-03 11:33:49 -08:00
Asher
6fd40c04c7 Fix Helm chart version bump script
Instead of relying on semver which is not installed, just parse it with
bash.
2026-06-02 11:29:19 -08:00
cdrci
63c071959f Update Helm chart and changelog with 4.122.1 (#7835) 2026-06-02 10:42:18 -08:00
cdrci
7be257b252 Update Code to 1.122.1 (#7825) 2026-06-01 14:06:15 -08:00
Asher
923cb753b8 Fix automatic release major version
It was using the VS Code major version instead of code-server's.
2026-06-01 14:05:20 -08:00
dependabot[bot]
6cad75773e chore: bump basic-ftp from 5.3.0 to 5.3.1 (#7786) 2026-06-01 13:56:12 -08:00
Asher
cb2548f989 Make Helm and changelog commit more specific 2026-05-29 10:20:19 -08:00
cdrci
f87e243225 Update to 4.122.0 (#7823) 2026-05-29 10:19:24 -08:00
Asher
d98fcd3598 Fix macos release tag 2026-05-28 13:22:08 -08:00
cdrci
93d3ee8ab1 Update Code to 1.122.0 (#7822) 2026-05-28 12:02:35 -08:00
Asher
030bdcf771 Still finish checklist if a step failed
The point is to get as far as we can.
2026-05-28 11:04:14 -08:00
dependabot[bot]
4a50b99b67 chore: bump ip-address from 10.1.0 to 10.2.0 (#7785) 2026-05-28 10:26:53 -08:00
dependabot[bot]
382aa3ba87 chore: bump dorny/paths-filter from 3.0.3 to 4.0.1 (#7771) 2026-05-28 10:25:20 -08:00
dependabot[bot]
2243efb2e6 chore: bump docker/login-action from 3.7.0 to 4.2.0 (#7772) 2026-05-28 10:24:40 -08:00
dependabot[bot]
477c0b11b8 chore: bump qs from 6.15.0 to 6.15.2 (#7814) 2026-05-28 10:23:44 -08:00
Micah Zoltu
2396092ae9 Make app-name configurable via environment variable (#7818) 2026-05-26 12:26:48 -08:00
dependabot[bot]
4f9c23893a chore: bump robinraju/release-downloader from 1.12 to 1.13 (#7770) 2026-05-22 12:30:42 -08:00
dependabot[bot]
62e5c450f7 chore: bump prettier from 3.6.2 to 3.8.3 (#7776) 2026-05-22 12:29:05 -08:00
dependabot[bot]
265713561c chore: bump ws from 8.19.0 to 8.20.1 (#7804) 2026-05-22 12:28:29 -08:00
dependabot[bot]
c9faf343ba chore: bump aquasecurity/trivy-action (#7769) 2026-05-22 12:27:36 -08:00
Asher
99bfbd5931 Update e2e example commands
I think the syntax changed when we moved from yarn to npm.
2026-05-21 13:30:44 -08:00
Micah Zoltu
238769e535 Apply --app-name to web page titles (#7794) 2026-05-21 12:22:29 -08:00
cdrci
bf61384523 Update to 4.121.0 (#7808) 2026-05-20 15:41:27 -08:00
29 changed files with 329 additions and 145 deletions

View File

@@ -26,7 +26,7 @@ jobs:
helm: ${{ steps.filter.outputs.helm }} helm: ${{ steps.filter.outputs.helm }}
steps: steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: dorny/paths-filter@d1c1ffe0248fe513906c8e24db8ea791d46f8590 # v3 - uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1
id: filter id: filter
with: with:
filters: | filters: |

View File

@@ -38,7 +38,7 @@ jobs:
with: with:
node-version-file: .node-version node-version-file: .node-version
- uses: robinraju/release-downloader@daf26c55d821e836577a15f77d86ddc078948b05 # v1.12 - uses: robinraju/release-downloader@28fc21f50d76778e7023361aa1f863e717d3d56f # v1.13
with: with:
repository: "coder/code-server" repository: "coder/code-server"
tag: ${{ env.TAG }} tag: ${{ env.TAG }}
@@ -112,23 +112,23 @@ jobs:
- uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0 - uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0
- uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0 - uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
- uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3 - uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
with: with:
username: ${{ secrets.DOCKER_USERNAME }} username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }} password: ${{ secrets.DOCKER_PASSWORD }}
- uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3 - uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
with: with:
registry: ghcr.io registry: ghcr.io
username: ${{ github.actor }} username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }} password: ${{ secrets.GITHUB_TOKEN }}
- uses: robinraju/release-downloader@daf26c55d821e836577a15f77d86ddc078948b05 # v1.12 - uses: robinraju/release-downloader@28fc21f50d76778e7023361aa1f863e717d3d56f # v1.13
with: with:
repository: "coder/code-server" repository: "coder/code-server"
tag: v${{ env.VERSION }} tag: v${{ env.VERSION }}
fileName: "*.deb" fileName: "*.deb"
out-file-path: "release-packages" out-file-path: "release-packages"
- uses: robinraju/release-downloader@daf26c55d821e836577a15f77d86ddc078948b05 # v1.12 - uses: robinraju/release-downloader@28fc21f50d76778e7023361aa1f863e717d3d56f # v1.13
with: with:
repository: "coder/code-server" repository: "coder/code-server"
tag: v${{ env.VERSION }} tag: v${{ env.VERSION }}
@@ -159,7 +159,7 @@ jobs:
git config --global user.email opensource@coder.com git config --global user.email opensource@coder.com
git checkout -b "helm/$VERSION" git checkout -b "helm/$VERSION"
git add . git add .
git commit -m "Update to $VERSION" git commit -m "Update Helm chart and changelog with $VERSION"
git push -u origin "$(git branch --show)" git push -u origin "$(git branch --show)"
gh pr create \ gh pr create \
--repo coder/code-server \ --repo coder/code-server \

View File

@@ -39,9 +39,6 @@ jobs:
- npm_arch: arm64 - npm_arch: arm64
vscode_arch: arm64 vscode_arch: arm64
package_arch: arm64 package_arch: arm64
- npm_arch: arm
vscode_arch: armhf
package_arch: armv7l
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -72,10 +69,12 @@ jobs:
curl -sSfL https://github.com/goreleaser/nfpm/releases/download/v2.3.1/nfpm_2.3.1_`uname -s`_`uname -m`.tar.gz | tar -C ~/.local/bin -zxv nfpm curl -sSfL https://github.com/goreleaser/nfpm/releases/download/v2.3.1/nfpm_2.3.1_`uname -s`_`uname -m`.tar.gz | tar -C ~/.local/bin -zxv nfpm
echo "$HOME/.local/bin" >> $GITHUB_PATH echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Strip update/ and v from tag - name: Strip update/ and v from tag and set major version
run: | run: |
version=${TAG#update/} version=${TAG#update/}
echo "VERSION=${version#v}" >> $GITHUB_ENV version=${version#v}
version=4${version:1}
echo "VERSION=$version" >> $GITHUB_ENV
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with: with:
@@ -148,7 +147,7 @@ jobs:
env: env:
VSCODE_TARGET: ${{ matrix.vscode_target }} VSCODE_TARGET: ${{ matrix.vscode_target }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ inputs.version || github.ref_name }} TAG: ${{ inputs.version || github.event.pull_request.head.ref || github.ref_name }}
# Ensure native modules are built from source to avoid prebuilds. # Ensure native modules are built from source to avoid prebuilds.
npm_config_build_from_source: true npm_config_build_from_source: true
@@ -164,10 +163,12 @@ jobs:
curl -sSfL https://github.com/goreleaser/nfpm/releases/download/v2.3.1/nfpm_2.3.1_`uname -s`_`uname -m`.tar.gz | tar -C ~/.local/bin -zxv nfpm curl -sSfL https://github.com/goreleaser/nfpm/releases/download/v2.3.1/nfpm_2.3.1_`uname -s`_`uname -m`.tar.gz | tar -C ~/.local/bin -zxv nfpm
echo "$HOME/.local/bin" >> $GITHUB_PATH echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Strip update/ and v from tag - name: Strip update/ and v from tag and set major version
run: | run: |
version=${TAG#update/} version=${TAG#update/}
echo "VERSION=${version#v}" >> $GITHUB_ENV version=${version#v}
version=4${version:1}
echo "VERSION=$version" >> $GITHUB_ENV
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with: with:

View File

@@ -51,7 +51,7 @@ jobs:
fetch-depth: 0 fetch-depth: 0
- name: Run Trivy vulnerability scanner in repo mode - name: Run Trivy vulnerability scanner in repo mode
uses: aquasecurity/trivy-action@97e0b3872f55f89b95b2f65b3dbab56962816478 # latest uses: aquasecurity/trivy-action@314ff8b43182423b84c50b1670b0e10f858f2d98 # latest
with: with:
scan-type: "fs" scan-type: "fs"
scan-ref: "." scan-ref: "."

View File

@@ -49,7 +49,7 @@ jobs:
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Run Trivy vulnerability scanner in image mode - name: Run Trivy vulnerability scanner in image mode
uses: aquasecurity/trivy-action@97e0b3872f55f89b95b2f65b3dbab56962816478 # latest uses: aquasecurity/trivy-action@314ff8b43182423b84c50b1670b0e10f858f2d98 # latest
with: with:
image-ref: "docker.io/codercom/code-server:latest" image-ref: "docker.io/codercom/code-server:latest"
ignore-unfixed: true ignore-unfixed: true

View File

@@ -1 +1 @@
22.22.1 24.15.0

View File

@@ -22,6 +22,58 @@ Code v99.99.999
## Unreleased ## Unreleased
Code v1.124.2
### Security
- Strip code-server's session token from the cookie before proxying to a local
port. Previously, when you used built-in password authentication, the cookie
would be sent to the local proxied port, which meant if the service was
malicious and not already running as your code-server user it could use the
cookie to log into code-server and execute commands as your code-server user.
### Changed
- Update to Code 1.124.2
## [4.123.0](https://github.com/coder/code-server/releases/tag/v4.123.0) - 2026-06-03
Code v1.123.0
### Changed
- Update to Code 1.123.0
- Microsoft dropped support for armhf remotes so there will no longer be any
builds for armhf.
## [4.122.1](https://github.com/coder/code-server/releases/tag/v4.122.1) - 2026-06-02
Code v1.122.1
### Changed
- Update to Code 1.122.1
## [4.122.0](https://github.com/coder/code-server/releases/tag/v4.122.0) - 2026-05-29
Code v1.122.0
### Changed
- Update to Code 1.122.0
### Fixed
- `--app-name` will now affect window titles within the editor (it is now used
as the value for `${appName}` in the title template) as well as some other
places like the help > about dialog.
### Added
- App name can now be set with the `CODE_SERVER_APP_NAME` environment variable.
## [4.121.0](https://github.com/coder/code-server/releases/tag/v4.121.0) - 2026-05-20
Code v1.121.0 Code v1.121.0
### Changed ### Changed

View File

@@ -128,7 +128,9 @@ bundle_vscode() {
# Merge the package.json for the web/remote server so we can include # Merge the package.json for the web/remote server so we can include
# dependencies, since we want to ship this via NPM. # dependencies, since we want to ship this via NPM.
jq --slurp '.[0] * .[1]' \ # Also override the name to prevent vulnerability scanners from
# misidentifying this package as VS Code (see #7071).
jq --slurp '.[0] * .[1] | .name = "code-oss-dev"' \
"$VSCODE_SRC_PATH/remote/package.json" \ "$VSCODE_SRC_PATH/remote/package.json" \
"$VSCODE_OUT_PATH/package.json" > "$VSCODE_OUT_PATH/package.json.merged" "$VSCODE_OUT_PATH/package.json" > "$VSCODE_OUT_PATH/package.json.merged"
mv "$VSCODE_OUT_PATH/package.json.merged" "$VSCODE_OUT_PATH/package.json" mv "$VSCODE_OUT_PATH/package.json.merged" "$VSCODE_OUT_PATH/package.json"

View File

@@ -2,16 +2,65 @@
set -Eeuo pipefail set -Eeuo pipefail
function update_helm() { # Given versions $1 and $2 figure out the first component that is different
local current # (major, minor, patch).
current=$(yq .version ci/helm-chart/Chart.yaml) function find_version_diff() {
local next # shellcheck disable=SC2206
next=$(semver "$current" -i minor) local a=( ${1//./ } )
echo "Bumping version from $current to $next..." # shellcheck disable=SC2206
sed -i.bak "s/^version: $current\$/version: $next/" ci/helm-chart/Chart.yaml local b=( ${2//./ } )
echo "Setting app version and image to $version..." if [[ ${a[0]} != "${b[0]}" ]] ; then
echo major
elif [[ ${a[1]} != "${b[1]}" ]] ; then
echo minor
else
echo patch
fi
}
# Bump $1 by the bump type (major, minor, patch) in $2.
function bump_version() {
# shellcheck disable=SC2206
local a=( ${1//./ } )
case $2 in
major)
((a[0]++))
a[1]=0
a[2]=0
;;
minor)
((a[1]++))
a[2]=0
;;
*)
((a[2]++))
;;
esac
echo "${a[0]}.${a[1]}.${a[2]}"
}
function update_helm() {
local chart_version
chart_version=$(yq .version ci/helm-chart/Chart.yaml)
local app_version
app_version=$(yq .appVersion ci/helm-chart/Chart.yaml)
local image_version
image_version=$(yq .image.tag ci/helm-chart/values.yaml)
local bump_type
bump_type=$(find_version_diff "$app_version" "$version")
local chart_version_bump
chart_version_bump=$(bump_version "$chart_version" "$bump_type")
# Use sed to replace because yq will reformat.
echo "Bumping version from $chart_version to $chart_version_bump..."
sed -i.bak "s/^version: $chart_version\$/version: $chart_version_bump/" ci/helm-chart/Chart.yaml
echo "Bumping app version from $app_version to $version..."
sed -i.bak "s/^appVersion: .\+\$/appVersion: $version/" ci/helm-chart/Chart.yaml sed -i.bak "s/^appVersion: .\+\$/appVersion: $version/" ci/helm-chart/Chart.yaml
echo "Bumping image version from $image_version to $version..."
sed -i.bak "s/^ tag: .\+\$/ tag: '$version'/" ci/helm-chart/values.yaml sed -i.bak "s/^ tag: .\+\$/ tag: '$version'/" ci/helm-chart/values.yaml
} }
@@ -37,7 +86,8 @@ function main() {
"Update changelog" "update_changelog" "Update changelog" "update_changelog"
) )
run-steps "${steps[@]}" # Even if a step failed, still output the last checkmark.
run-steps "${steps[@]}" || true
# This step is always manual. # This step is always manual.
echo "- [ ] https://github.com/coder/code-server-aur/pulls" >> .cache/checklist echo "- [ ] https://github.com/coder/code-server-aur/pulls" >> .cache/checklist

View File

@@ -146,7 +146,8 @@ function main() {
"Add changelog note" "add_changelog" "Add changelog note" "add_changelog"
) )
run-steps "${steps[@]}" # Even if a step failed, still output the last checkmark.
run-steps "${steps[@]}" || true
# This step is always manual. # This step is always manual.
echo "- [ ] Verify changelog" >> .cache/checklist echo "- [ ] Verify changelog" >> .cache/checklist

View File

@@ -15,9 +15,9 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes # This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version. # to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/) # Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 3.35.0 version: 3.38.0
# This is the version number of the application being deployed. This version number should be # This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to # incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using. # follow Semantic Versioning. They should reflect the version the application is using.
appVersion: 4.116.0 appVersion: 4.123.0

View File

@@ -6,7 +6,7 @@ replicaCount: 1
image: image:
repository: codercom/code-server repository: codercom/code-server
tag: '4.116.0' tag: '4.123.0'
pullPolicy: Always pullPolicy: Always
# Specifies one or more secrets to be used when pulling images from a # Specifies one or more secrets to be used when pulling images from a

85
package-lock.json generated
View File

@@ -13,6 +13,7 @@
"@coder/logger": "^3.0.1", "@coder/logger": "^3.0.1",
"argon2": "^0.44.0", "argon2": "^0.44.0",
"compression": "^1.7.4", "compression": "^1.7.4",
"cookie": "^1.1.1",
"cookie-parser": "^1.4.6", "cookie-parser": "^1.4.6",
"env-paths": "^2.2.1", "env-paths": "^2.2.1",
"express": "^5.0.1", "express": "^5.0.1",
@@ -58,7 +59,7 @@
"eslint-plugin-import": "^2.28.1", "eslint-plugin-import": "^2.28.1",
"eslint-plugin-prettier": "^5.0.0", "eslint-plugin-prettier": "^5.0.0",
"globals": "^16.1.0", "globals": "^16.1.0",
"prettier": "3.6.2", "prettier": "3.8.3",
"prettier-plugin-sh": "^0.18.0", "prettier-plugin-sh": "^0.18.0",
"ts-node": "^10.9.1", "ts-node": "^10.9.1",
"typescript": "^5.6.2", "typescript": "^5.6.2",
@@ -968,9 +969,9 @@
} }
}, },
"node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion": { "node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion": {
"version": "5.0.5", "version": "5.0.6",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.5.tgz", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.6.tgz",
"integrity": "sha512-VZznLgtwhn+Mact9tfiwx64fA9erHH/MCXEUfB/0bX/6Fz6ny5EGTXYltMocqg4xFAQZtnO3DHWWXi8RiuN7cQ==", "integrity": "sha512-kLpxurY4Z4r9sgMsyG0Z9uzsBlgiU/EFKhj/h91/8yHu0edo7XuixOIH3VcJ8kkxs6/jPzoI6U9Vj3WqbMQ94g==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
@@ -1639,9 +1640,9 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/basic-ftp": { "node_modules/basic-ftp": {
"version": "5.3.0", "version": "5.3.1",
"resolved": "https://registry.npmjs.org/basic-ftp/-/basic-ftp-5.3.0.tgz", "resolved": "https://registry.npmjs.org/basic-ftp/-/basic-ftp-5.3.1.tgz",
"integrity": "sha512-5K9eNNn7ywHPsYnFwjKgYH8Hf8B5emh7JKcPaVjjrMJFQQwGpwowEnZNEtHs7DfR7hCZsmaK3VA4HUK0YarT+w==", "integrity": "sha512-bopVNp6ugyA150DDuZfPFdt1KZ5a94ZDiwX4hMgZDzF+GttD80lEy8kj98kbyhLXnPvhtIo93mdnLIjpCAeeOw==",
"license": "MIT", "license": "MIT",
"engines": { "engines": {
"node": ">=10.0.0" "node": ">=10.0.0"
@@ -1936,12 +1937,16 @@
} }
}, },
"node_modules/cookie": { "node_modules/cookie": {
"version": "0.7.2", "version": "1.1.1",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz", "resolved": "https://registry.npmjs.org/cookie/-/cookie-1.1.1.tgz",
"integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==", "integrity": "sha512-ei8Aos7ja0weRpFzJnEA9UHJ/7XQmqglbRwnf2ATjcB9Wq874VKH9kfjjirM6UhU2/E5fFYadylyhFldcqSidQ==",
"license": "MIT", "license": "MIT",
"engines": { "engines": {
"node": ">= 0.6" "node": ">=18"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
} }
}, },
"node_modules/cookie-parser": { "node_modules/cookie-parser": {
@@ -1957,6 +1962,15 @@
"node": ">= 0.8.0" "node": ">= 0.8.0"
} }
}, },
"node_modules/cookie-parser/node_modules/cookie": {
"version": "0.7.2",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz",
"integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/cookie-signature": { "node_modules/cookie-signature": {
"version": "1.0.6", "version": "1.0.6",
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
@@ -2953,6 +2967,15 @@
"url": "https://opencollective.com/express" "url": "https://opencollective.com/express"
} }
}, },
"node_modules/express/node_modules/cookie": {
"version": "0.7.2",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz",
"integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/express/node_modules/cookie-signature": { "node_modules/express/node_modules/cookie-signature": {
"version": "1.2.2", "version": "1.2.2",
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz", "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz",
@@ -3637,9 +3660,9 @@
} }
}, },
"node_modules/ip-address": { "node_modules/ip-address": {
"version": "10.1.0", "version": "10.2.0",
"resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.1.0.tgz", "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.2.0.tgz",
"integrity": "sha512-XXADHxXmvT9+CRxhXg56LJovE+bmWnEWB78LB83VZTprKTmaC5QfruXocxzTZ2Kl0DNwKuBdlIhjL8LeY8Sf8Q==", "integrity": "sha512-/+S6j4E9AHvW9SWMSEY9Xfy66O5PWvVEJ08O0y5JGyEKQpojb0K0GKpz/v5HJ/G0vi3D2sjGK78119oXZeE0qA==",
"license": "MIT", "license": "MIT",
"engines": { "engines": {
"node": ">= 12" "node": ">= 12"
@@ -4130,9 +4153,19 @@
"license": "ISC" "license": "ISC"
}, },
"node_modules/js-yaml": { "node_modules/js-yaml": {
"version": "4.1.1", "version": "4.2.0",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.2.0.tgz",
"integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==", "integrity": "sha512-ePWsvanv0DWuDRsW8dnt+R4jQ31SCRCQ7hhNcPXZPsoBZiemuZNYGf7adZdqX2D86j6rvKp3RpCxVTSb8WQlOw==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/puzrin"
},
{
"type": "github",
"url": "https://github.com/sponsors/nodeca"
}
],
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"argparse": "^2.0.1" "argparse": "^2.0.1"
@@ -5100,9 +5133,9 @@
} }
}, },
"node_modules/prettier": { "node_modules/prettier": {
"version": "3.6.2", "version": "3.8.3",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.6.2.tgz", "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.8.3.tgz",
"integrity": "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==", "integrity": "sha512-7igPTM53cGHMW8xWuVTydi2KO233VFiTNyF5hLJqpilHfmn8C8gPf+PS7dUT64YcXFbiMGZxS9pCSxL/Dxm/Jw==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"bin": { "bin": {
@@ -5197,9 +5230,9 @@
} }
}, },
"node_modules/qs": { "node_modules/qs": {
"version": "6.15.0", "version": "6.15.2",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.15.0.tgz", "resolved": "https://registry.npmjs.org/qs/-/qs-6.15.2.tgz",
"integrity": "sha512-mAZTtNCeetKMH+pSjrb76NAM8V9a05I9aBZOHztWy/UqcJdQYNsf59vrRKWnojAT9Y+GbIvoTBC++CPHqpDBhQ==", "integrity": "sha512-Rzq0KEyX/w/tEybncDgdkZrJgVUsUMk3xjh3t5bv3S1HTAtg+uOYt72+ZfwiQwKdysThkTBdL/rTi6HDmX9Ddw==",
"license": "BSD-3-Clause", "license": "BSD-3-Clause",
"dependencies": { "dependencies": {
"side-channel": "^1.1.0" "side-channel": "^1.1.0"
@@ -6613,9 +6646,9 @@
"license": "ISC" "license": "ISC"
}, },
"node_modules/ws": { "node_modules/ws": {
"version": "8.19.0", "version": "8.21.0",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.19.0.tgz", "resolved": "https://registry.npmjs.org/ws/-/ws-8.21.0.tgz",
"integrity": "sha512-blAT2mjOEIi0ZzruJfIhb3nps74PRWTCz1IjglWEEpQl5XS/UNama6u2/rjFkDDouqr4L67ry+1aGIALViWjDg==", "integrity": "sha512-Vsp28b7DRcimFQvrqu2Wek3z1iYxDCWqHYB8Qsnk/S4RfaCQzPGPyBNuVjJV3cd6UiKtUtp6sNM77gWvzcCH+g==",
"license": "MIT", "license": "MIT",
"engines": { "engines": {
"node": ">=10.0.0" "node": ">=10.0.0"

View File

@@ -60,7 +60,7 @@
"eslint-plugin-import": "^2.28.1", "eslint-plugin-import": "^2.28.1",
"eslint-plugin-prettier": "^5.0.0", "eslint-plugin-prettier": "^5.0.0",
"globals": "^16.1.0", "globals": "^16.1.0",
"prettier": "3.6.2", "prettier": "3.8.3",
"prettier-plugin-sh": "^0.18.0", "prettier-plugin-sh": "^0.18.0",
"ts-node": "^10.9.1", "ts-node": "^10.9.1",
"typescript": "^5.6.2", "typescript": "^5.6.2",
@@ -70,6 +70,7 @@
"@coder/logger": "^3.0.1", "@coder/logger": "^3.0.1",
"argon2": "^0.44.0", "argon2": "^0.44.0",
"compression": "^1.7.4", "compression": "^1.7.4",
"cookie": "^1.1.1",
"cookie-parser": "^1.4.6", "cookie-parser": "^1.4.6",
"env-paths": "^2.2.1", "env-paths": "^2.2.1",
"express": "^5.0.1", "express": "^5.0.1",

46
patches/app-name.diff Normal file
View File

@@ -0,0 +1,46 @@
Apply --app-name to VS Code web page titles
VS Code's `${appName}` title variable comes from `productService.nameLong` in the
web client. code-server already injects per-request product configuration into
VS Code's web bootstrap, so set `nameShort`/`nameLong` from the existing
`--app-name` CLI arg there.
This keeps the patch minimal and makes browser tab titles honor `--app-name`
without changing unrelated product metadata.
Index: code-server/lib/vscode/src/vs/server/node/serverEnvironmentService.ts
===================================================================
--- code-server.orig/lib/vscode/src/vs/server/node/serverEnvironmentService.ts
+++ code-server/lib/vscode/src/vs/server/node/serverEnvironmentService.ts
@@ -24,6 +24,7 @@ export const serverOptions: OptionDescri
'disable-getting-started-override': { type: 'boolean' },
'locale': { type: 'string' },
'link-protection-trusted-domains': { type: 'string[]' },
+ 'app-name': { type: 'string' },
/* ----- server setup ----- */
@@ -124,6 +125,7 @@ export interface ServerParsedArgs {
'disable-getting-started-override'?: boolean,
'locale'?: string
'link-protection-trusted-domains'?: string[],
+ 'app-name'?: string,
/* ----- server setup ----- */
Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
===================================================================
--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts
+++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts
@@ -366,8 +366,11 @@ export class WebClientServer {
linkProtectionTrustedDomains.push(...this._productService.linkProtectionTrustedDomains);
}
+ const appName = this._environmentService.args['app-name'];
const productConfiguration: Partial<Mutable<IProductConfiguration>> = {
codeServerVersion: this._productService.codeServerVersion,
+ nameShort: appName,
+ nameLong: appName,
rootEndpoint: rootBase,
updateEndpoint: !this._environmentService.args['disable-update-check'] ? rootBase + '/update/check' : undefined,
logoutEndpoint: this._environmentService.args['auth'] && this._environmentService.args['auth'] !== "none" ? rootBase + '/logout' : undefined,

View File

@@ -263,7 +263,7 @@ Index: code-server/lib/vscode/src/vs/code/browser/workbench/workbench.ts
} }
private startListening(): void { private startListening(): void {
@@ -584,17 +585,6 @@ class WorkspaceProvider implements IWork @@ -590,17 +591,6 @@ class WorkspaceProvider implements IWork
} }
} }
@@ -281,7 +281,7 @@ Index: code-server/lib/vscode/src/vs/code/browser/workbench/workbench.ts
(function () { (function () {
// Find config by checking for DOM // Find config by checking for DOM
@@ -604,8 +594,8 @@ function readCookie(name: string): strin @@ -610,8 +600,8 @@ function readCookie(name: string): strin
if (!configElement || !configElementAttribute) { if (!configElement || !configElementAttribute) {
throw new Error('Missing web configuration element'); throw new Error('Missing web configuration element');
} }

View File

@@ -2,8 +2,8 @@ Index: code-server/lib/vscode/build/gulpfile.extensions.ts
=================================================================== ===================================================================
--- code-server.orig/lib/vscode/build/gulpfile.extensions.ts --- code-server.orig/lib/vscode/build/gulpfile.extensions.ts
+++ code-server/lib/vscode/build/gulpfile.extensions.ts +++ code-server/lib/vscode/build/gulpfile.extensions.ts
@@ -294,6 +294,29 @@ export const compileCopilotExtensionBuil @@ -291,6 +291,29 @@ export const compileCopilotExtensionBuil
gulp.task(compileCopilotExtensionBuildTask); task.task(compileCopilotExtensionBuildTask);
/** /**
+ * Compiles the built-in copilot extension with proper `.vscodeignore` filtering + * Compiles the built-in copilot extension with proper `.vscodeignore` filtering
@@ -26,7 +26,7 @@ Index: code-server/lib/vscode/build/gulpfile.extensions.ts
+ return Promise.resolve(); + return Promise.resolve();
+ }) + })
+)); +));
+gulp.task(compileCopilotExtensionFullBuildTask); +task.task(compileCopilotExtensionFullBuildTask);
+ +
+/** +/**
* Compiles the extensions for the build. * Compiles the extensions for the build.
@@ -36,15 +36,15 @@ Index: code-server/lib/vscode/build/lib/extensions.ts
=================================================================== ===================================================================
--- code-server.orig/lib/vscode/build/lib/extensions.ts --- code-server.orig/lib/vscode/build/lib/extensions.ts
+++ code-server/lib/vscode/build/lib/extensions.ts +++ code-server/lib/vscode/build/lib/extensions.ts
@@ -24,6 +24,7 @@ import { getProductionDependencies } fro @@ -21,6 +21,7 @@ import { getProductionDependencies } fro
import { type IExtensionDefinition, getExtensionStream } from './builtInExtensions.ts'; import { type IExtensionDefinition, getExtensionStream } from './builtInExtensions.ts';
import { fetchUrls, fetchGithub } from './fetch.ts'; import { fetchUrls, fetchGithub } from './fetch.ts';
import { createTsgoStream, spawnTsgo } from './tsgo.ts'; import { createTsgoStream, spawnTsgo } from './tsgo.ts';
+import { prepareBuiltInCopilotRipgrepShim } from './copilot.ts'; +import { prepareBuiltInCopilotRipgrepShim } from './copilot.ts';
import vzip from 'gulp-vinyl-zip'; import watcher from './watch/index.ts';
import { createRequire } from 'module'; import { createRequire } from 'module';
@@ -492,6 +493,116 @@ export function packageCopilotExtensionS @@ -483,6 +484,116 @@ export function packageCopilotExtensionS
).pipe(util2.setExecutableBit(['**/*.sh'])); ).pipe(util2.setExecutableBit(['**/*.sh']));
} }

View File

@@ -7,7 +7,7 @@ Index: code-server/lib/vscode/src/vs/workbench/contrib/extensions/browser/extens
=================================================================== ===================================================================
--- code-server.orig/lib/vscode/src/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService.ts --- code-server.orig/lib/vscode/src/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService.ts
+++ code-server/lib/vscode/src/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService.ts +++ code-server/lib/vscode/src/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService.ts
@@ -342,6 +342,10 @@ export class Extension implements IExten @@ -345,6 +345,10 @@ export class Extension implements IExten
if (this.type === ExtensionType.System && this.productService.quality === 'stable' && !this.productService.builtInExtensionsEnabledWithAutoUpdates?.some(id => id.toLowerCase() === this.identifier.id.toLowerCase())) { if (this.type === ExtensionType.System && this.productService.quality === 'stable' && !this.productService.builtInExtensionsEnabledWithAutoUpdates?.some(id => id.toLowerCase() === this.identifier.id.toLowerCase())) {
return false; return false;
} }

View File

@@ -18,7 +18,7 @@ Index: code-server/lib/vscode/src/vs/server/node/serverServices.ts
import { ProtocolConstants } from '../../base/parts/ipc/common/ipc.net.js'; import { ProtocolConstants } from '../../base/parts/ipc/common/ipc.net.js';
import { IConfigurationService } from '../../platform/configuration/common/configuration.js'; import { IConfigurationService } from '../../platform/configuration/common/configuration.js';
import { ConfigurationService } from '../../platform/configuration/common/configurationService.js'; import { ConfigurationService } from '../../platform/configuration/common/configurationService.js';
@@ -358,6 +358,9 @@ export async function setupServerService @@ -359,6 +359,9 @@ export async function setupServerService
socketServer.registerChannel('mcpManagement', new McpManagementChannel(mcpManagementService, (ctx: RemoteAgentConnectionContext) => getUriTransformer(ctx.remoteAuthority))); socketServer.registerChannel('mcpManagement', new McpManagementChannel(mcpManagementService, (ctx: RemoteAgentConnectionContext) => getUriTransformer(ctx.remoteAuthority)));

View File

@@ -104,7 +104,7 @@ Index: code-server/lib/vscode/src/vs/code/browser/workbench/workbench.ts
import type { IURLCallbackProvider } from '../../../workbench/services/url/browser/urlService.js'; import type { IURLCallbackProvider } from '../../../workbench/services/url/browser/urlService.js';
import { create } from '../../../workbench/workbench.web.main.internal.js'; import { create } from '../../../workbench/workbench.web.main.internal.js';
@@ -606,6 +607,39 @@ class WorkspaceProvider implements IWork @@ -612,6 +613,39 @@ class WorkspaceProvider implements IWork
settingsSyncOptions: config.settingsSyncOptions ? { enabled: config.settingsSyncOptions.enabled, } : undefined, settingsSyncOptions: config.settingsSyncOptions ? { enabled: config.settingsSyncOptions.enabled, } : undefined,
workspaceProvider: WorkspaceProvider.create(config), workspaceProvider: WorkspaceProvider.create(config),
urlCallbackProvider: new LocalStorageURLCallbackProvider(config.callbackRoute), urlCallbackProvider: new LocalStorageURLCallbackProvider(config.callbackRoute),

View File

@@ -23,3 +23,4 @@ display-language.diff
trusted-domains.diff trusted-domains.diff
signature-verification.diff signature-verification.diff
copilot.diff copilot.diff
app-name.diff

View File

@@ -6,7 +6,7 @@ Index: code-server/lib/vscode/build/gulpfile.reh.ts
=================================================================== ===================================================================
--- code-server.orig/lib/vscode/build/gulpfile.reh.ts --- code-server.orig/lib/vscode/build/gulpfile.reh.ts
+++ code-server/lib/vscode/build/gulpfile.reh.ts +++ code-server/lib/vscode/build/gulpfile.reh.ts
@@ -261,10 +261,15 @@ function packageTask(type: string, platf @@ -296,10 +296,15 @@ function packageTask(type: string, platf
const destination = path.join(BUILD_ROOT, destinationFolderName); const destination = path.join(BUILD_ROOT, destinationFolderName);
return () => { return () => {

View File

@@ -41,7 +41,7 @@ Index: code-server/lib/vscode/src/vs/workbench/services/environment/browser/envi
=================================================================== ===================================================================
--- code-server.orig/lib/vscode/src/vs/workbench/services/environment/browser/environmentService.ts --- code-server.orig/lib/vscode/src/vs/workbench/services/environment/browser/environmentService.ts
+++ code-server/lib/vscode/src/vs/workbench/services/environment/browser/environmentService.ts +++ code-server/lib/vscode/src/vs/workbench/services/environment/browser/environmentService.ts
@@ -223,7 +223,7 @@ export class BrowserWorkbenchEnvironment @@ -226,7 +226,7 @@ export class BrowserWorkbenchEnvironment
@memoize @memoize
get webviewExternalEndpoint(): string { get webviewExternalEndpoint(): string {
@@ -70,8 +70,8 @@ Index: code-server/lib/vscode/src/vs/workbench/contrib/webview/browser/pre/index
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta http-equiv="Content-Security-Policy" <meta http-equiv="Content-Security-Policy"
- content="default-src 'none'; script-src 'sha256-q+WTr+fBXpLLE3++yWNaxT6BTWQtsKscoeIlynBRk4E=' 'self'; frame-src 'self'; style-src 'unsafe-inline';"> - content="default-src 'none'; script-src 'sha256-nXjtuhBilO++r8hfxl5VjEScSmdm07wDAk6jw228DgM=' 'self'; frame-src 'self'; style-src 'unsafe-inline';">
+ content="default-src 'none'; script-src 'sha256-m1DlJtsIJd46QuWYNcsaYIG1xI+9FyjKQu+cfp+zq5Q=' 'self'; frame-src 'self'; style-src 'unsafe-inline';"> + content="default-src 'none'; script-src 'sha256-A6/szVNdTzyi4hDa+9OLbzS8tSd2iUV4CqimLNWex2Y=' 'self'; frame-src 'self'; style-src 'unsafe-inline';">
<!-- Disable pinch zooming --> <!-- Disable pinch zooming -->
<meta name="viewport" <meta name="viewport"

View File

@@ -677,9 +677,7 @@ export async function setDefaults(cliArgs: UserProvidedArgs, configArgs?: Config
} }
args["proxy-domain"] = finalProxies args["proxy-domain"] = finalProxies
if (!args["app-name"]) { args["app-name"] ??= process.env.CODE_SERVER_APP_NAME || "code-server"
args["app-name"] = "code-server"
}
args._ = getResolvedPathsFromArgs(args) args._ = getResolvedPathsFromArgs(args)

View File

@@ -1,5 +1,7 @@
import * as cookie from "cookie"
import type { Request } from "express"
import proxyServer from "http-proxy" import proxyServer from "http-proxy"
import { HttpCode } from "../common/http" import { getCookieSessionName, HttpCode } from "../common/http"
export const proxy = proxyServer.createProxyServer({}) export const proxy = proxyServer.createProxyServer({})
@@ -18,6 +20,19 @@ proxy.on("error", (error, _, res) => {
} }
}) })
// Strip the code-server cookie if it exists to avoid transmitting the cookie
// to potentially malicious local ports.
proxy.on("proxyReq", (preq, req) => {
const cookieSessionName = getCookieSessionName((req as Request).args["cookie-suffix"])
preq.setHeader(
"Cookie",
cookie.stringifyCookie({
...(req as Request).cookies,
[cookieSessionName]: undefined,
}),
)
})
// Intercept the response to rewrite absolute redirects against the base path. // Intercept the response to rewrite absolute redirects against the base path.
// Is disabled when the request has no base path which means /absproxy is in use. // Is disabled when the request has no base path which means /absproxy is in use.
proxy.on("proxyRes", (res, req) => { proxy.on("proxyRes", (res, req) => {

9
test/e2e/appName.test.ts Normal file
View File

@@ -0,0 +1,9 @@
import { version } from "../../src/node/constants"
import { describe, test, expect } from "./baseFixture"
const appName = "testnäme"
describe("--app-name", [`--app-name=${appName}`], {}, () => {
test("should use app-name for the title", async ({ codeServerPage }) => {
expect(await codeServerPage.page.title()).toContain(appName)
})
})

View File

@@ -5,10 +5,10 @@ import path from "path"
// The default configuration runs all tests in three browsers with workers equal // The default configuration runs all tests in three browsers with workers equal
// to half the available threads. See 'npm run test:e2e --help' to customize // to half the available threads. See 'npm run test:e2e --help' to customize
// from the command line. For example: // from the command line. For example:
// npm run test:e2e --workers 1 # Run with one worker // npm run test:e2e -- --workers 1 # Run with one worker
// npm run test:e2e --project Chromium # Only run on Chromium // npm run test:e2e -- --project Chromium # Only run on Chromium
// npm run test:e2e --grep login # Run tests matching "login" // npm run test:e2e -- --grep login # Run tests matching "login"
// PWDEBUG=1 npm run test:e2e # Run Playwright inspector // PWDEBUG=1 npm run test:e2e # Run Playwright inspector
const config: PlaywrightTestConfig = { const config: PlaywrightTestConfig = {
testDir: path.join(__dirname, "e2e"), // Search for tests in this directory. testDir: path.join(__dirname, "e2e"), // Search for tests in this directory.
timeout: 60000, // Each test is given 60 seconds. timeout: 60000, // Each test is given 60 seconds.

View File

@@ -1,15 +1,12 @@
import * as express from "express" import * as express from "express"
import * as http from "http"
import nodeFetch from "node-fetch"
import { HttpCode } from "../../../src/common/http" import { HttpCode } from "../../../src/common/http"
import { proxy } from "../../../src/node/proxy"
import { wss, Router as WsRouter } from "../../../src/node/wsRouter" import { wss, Router as WsRouter } from "../../../src/node/wsRouter"
import { getAvailablePort, mockLogger } from "../../utils/helpers" import { mockLogger } from "../../utils/helpers"
import * as httpserver from "../../utils/httpserver" import * as httpserver from "../../utils/httpserver"
import * as integration from "../../utils/integration" import * as integration from "../../utils/integration"
describe("proxy", () => { describe("proxy", () => {
const nhooyrDevServer = new httpserver.HttpServer() const proxyTarget = new httpserver.HttpServer()
const wsApp = express.default() const wsApp = express.default()
const wsRouter = WsRouter() const wsRouter = WsRouter()
let codeServer: httpserver.HttpServer | undefined let codeServer: httpserver.HttpServer | undefined
@@ -19,21 +16,22 @@ describe("proxy", () => {
beforeAll(async () => { beforeAll(async () => {
wsApp.use("/", wsRouter.router) wsApp.use("/", wsRouter.router)
await nhooyrDevServer.listen((req, res) => { await proxyTarget.listen((req, res) => {
e(req, res) e(req, res)
}) })
nhooyrDevServer.listenUpgrade(wsApp) proxyTarget.listenUpgrade(wsApp)
proxyPath = `/proxy/${nhooyrDevServer.port()}/wsup` proxyPath = `/proxy/${proxyTarget.port()}/wsup`
absProxyPath = proxyPath.replace("/proxy/", "/absproxy/") absProxyPath = proxyPath.replace("/proxy/", "/absproxy/")
}) })
afterAll(async () => { afterAll(async () => {
await nhooyrDevServer.dispose() await proxyTarget.dispose()
}) })
beforeEach(() => { beforeEach(() => {
e = express.default() e = express.default()
mockLogger() mockLogger()
delete process.env.PASSWORD
}) })
afterEach(async () => { afterEach(async () => {
@@ -283,65 +281,42 @@ describe("proxy", () => {
const resp = await codeServer.fetch(proxyPath, { method: "OPTIONS" }) const resp = await codeServer.fetch(proxyPath, { method: "OPTIONS" })
expect(resp.status).toBe(200) expect(resp.status).toBe(200)
}) })
})
// NOTE@jsjoeio it("should return a 500 when no target is running ", async () => {
// Both this test suite and the one above it are very similar const target = new httpserver.HttpServer()
// The main difference is this one uses http and node-fetch await target.listen(() => {})
// and specifically tests the proxy in isolation vs. using const port = target.port()
// the httpserver abstraction we've built. target.dispose()
// codeServer = await integration.setup(["--auth=none"], "")
// Leaving this as a separate test suite for now because const resp = await codeServer.fetch(`/proxy/${port}/wsup`)
// we may consider refactoring the httpserver abstraction expect(resp.status).toBe(HttpCode.ServerError)
// in the future. expect(resp.statusText).toBe("Internal Server Error")
// })
// If you're writing a test specifically for code in
// src/node/proxy.ts, you should probably add it to
// this test suite.
describe("proxy (standalone)", () => {
let URL = ""
let PROXY_URL = ""
let testServer: http.Server
let proxyTarget: http.Server
beforeEach(async () => { it("should strip token cookie", async () => {
const PORT = await getAvailablePort() const token = "my-super-secure-token"
const PROXY_PORT = await getAvailablePort() process.env.HASHED_PASSWORD = token
URL = `http://localhost:${PORT}` codeServer = await integration.setup(["--auth=password"])
PROXY_URL = `http://localhost:${PROXY_PORT}`
// Define server and a proxy server // Set up a listener that just prints the cookies it got.
testServer = http.createServer((req, res) => { e.get("/wsup/cookies", (req, res) => {
proxy.web(req, res, { res.writeHead(HttpCode.Ok, { "Content-Type": "text/plain" })
target: PROXY_URL, res.end(req.headers.cookie)
})
}) })
proxyTarget = http.createServer((req, res) => { // Send the token along with other cookies which should be preserved.
res.writeHead(200, { "Content-Type": "text/plain" }) // Encode one to make sure they are being re-encoded properly.
res.end() const value = "hello=there"
const encodedValue = encodeURIComponent(value)
const resp = await codeServer.fetch(proxyPath + "/cookies", {
headers: {
cookie: `cookie1=${encodedValue}; code-server-session=${token}; cookie2=hello;`,
},
}) })
// Start both servers // The proxied listener should not have printed the code-server token.
proxyTarget.listen(PROXY_PORT)
testServer.listen(PORT)
})
afterEach(async () => {
testServer.close()
proxyTarget.close()
})
it("should return a 500 when proxy target errors ", async () => {
// Close the proxy target so that proxy errors
proxyTarget.close()
const errorResp = await nodeFetch(`${URL}/error`)
expect(errorResp.status).toBe(HttpCode.ServerError)
expect(errorResp.statusText).toBe("Internal Server Error")
})
it("should proxy correctly", async () => {
const resp = await nodeFetch(`${URL}/route`)
expect(resp.status).toBe(200) expect(resp.status).toBe(200)
expect(resp.statusText).toBe("OK") const text = await resp.text()
expect(text).toBe(`cookie1=${encodedValue}; cookie2=hello`)
}) })
}) })