mirror of
https://github.com/coder/code-server.git
synced 2026-06-16 05:39:11 -05:00
Compare commits
12 Commits
dependabot
...
v4.124.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9fe7eb79d5 | ||
|
|
1ccd4f04d2 | ||
|
|
364cf99338 | ||
|
|
92a7dce46f | ||
|
|
d0d53d924e | ||
|
|
77d880d0c3 | ||
|
|
559d73a636 | ||
|
|
6fd40c04c7 | ||
|
|
63c071959f | ||
|
|
7be257b252 | ||
|
|
923cb753b8 | ||
|
|
6cad75773e |
21
.github/workflows/release.yaml
vendored
21
.github/workflows/release.yaml
vendored
@@ -39,9 +39,6 @@ jobs:
|
||||
- npm_arch: arm64
|
||||
vscode_arch: arm64
|
||||
package_arch: arm64
|
||||
- npm_arch: arm
|
||||
vscode_arch: armhf
|
||||
package_arch: armv7l
|
||||
|
||||
env:
|
||||
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
|
||||
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: |
|
||||
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
|
||||
with:
|
||||
@@ -111,7 +110,7 @@ jobs:
|
||||
- run: |
|
||||
sed "/^## Unreleased/,/^## / ! d" CHANGELOG.md | head -n -2 | tail -n +3 > .cache/release-notes
|
||||
if: ${{ matrix.vscode_arch == 'x64' }}
|
||||
- uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3.0.0
|
||||
- uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
|
||||
if: ${{ matrix.vscode_arch == 'x64' }}
|
||||
with:
|
||||
draft: true
|
||||
@@ -124,7 +123,7 @@ jobs:
|
||||
# Platform-specific release.
|
||||
- run: KEEP_MODULES=1 npm run release
|
||||
- run: npm run package
|
||||
- uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3.0.0
|
||||
- uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
|
||||
with:
|
||||
draft: true
|
||||
discussion_category_name: "📣 Announcements"
|
||||
@@ -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
|
||||
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: |
|
||||
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
|
||||
with:
|
||||
@@ -188,7 +189,7 @@ jobs:
|
||||
- run: npm run test:native
|
||||
|
||||
- run: npm run package
|
||||
- uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3.0.0
|
||||
- uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
|
||||
with:
|
||||
draft: true
|
||||
discussion_category_name: "📣 Announcements"
|
||||
|
||||
@@ -1 +1 @@
|
||||
22.22.1
|
||||
24.15.0
|
||||
|
||||
32
CHANGELOG.md
32
CHANGELOG.md
@@ -22,6 +22,38 @@ Code v99.99.999
|
||||
|
||||
## 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
|
||||
|
||||
@@ -128,7 +128,9 @@ bundle_vscode() {
|
||||
|
||||
# Merge the package.json for the web/remote server so we can include
|
||||
# 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_OUT_PATH/package.json" > "$VSCODE_OUT_PATH/package.json.merged"
|
||||
mv "$VSCODE_OUT_PATH/package.json.merged" "$VSCODE_OUT_PATH/package.json"
|
||||
|
||||
@@ -2,16 +2,65 @@
|
||||
|
||||
set -Eeuo pipefail
|
||||
|
||||
function update_helm() {
|
||||
local current
|
||||
current=$(yq .version ci/helm-chart/Chart.yaml)
|
||||
local next
|
||||
next=$(semver "$current" -i minor)
|
||||
echo "Bumping version from $current to $next..."
|
||||
sed -i.bak "s/^version: $current\$/version: $next/" ci/helm-chart/Chart.yaml
|
||||
# Given versions $1 and $2 figure out the first component that is different
|
||||
# (major, minor, patch).
|
||||
function find_version_diff() {
|
||||
# shellcheck disable=SC2206
|
||||
local a=( ${1//./ } )
|
||||
# shellcheck disable=SC2206
|
||||
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
|
||||
|
||||
echo "Bumping image version from $image_version to $version..."
|
||||
sed -i.bak "s/^ tag: .\+\$/ tag: '$version'/" ci/helm-chart/values.yaml
|
||||
}
|
||||
|
||||
|
||||
@@ -15,9 +15,9 @@ type: application
|
||||
# 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.
|
||||
# Versions are expected to follow Semantic Versioning (https://semver.org/)
|
||||
version: 3.37.0
|
||||
version: 3.38.0
|
||||
|
||||
# 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
|
||||
# follow Semantic Versioning. They should reflect the version the application is using.
|
||||
appVersion: 4.122.0
|
||||
appVersion: 4.123.0
|
||||
|
||||
@@ -6,7 +6,7 @@ replicaCount: 1
|
||||
|
||||
image:
|
||||
repository: codercom/code-server
|
||||
tag: '4.122.0'
|
||||
tag: '4.123.0'
|
||||
pullPolicy: Always
|
||||
|
||||
# Specifies one or more secrets to be used when pulling images from a
|
||||
|
||||
Submodule lib/vscode updated: 6a49527b96...6928394f91
65
package-lock.json
generated
65
package-lock.json
generated
@@ -13,6 +13,7 @@
|
||||
"@coder/logger": "^3.0.1",
|
||||
"argon2": "^0.44.0",
|
||||
"compression": "^1.7.4",
|
||||
"cookie": "^1.1.1",
|
||||
"cookie-parser": "^1.4.6",
|
||||
"env-paths": "^2.2.1",
|
||||
"express": "^5.0.1",
|
||||
@@ -968,9 +969,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion": {
|
||||
"version": "5.0.5",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.5.tgz",
|
||||
"integrity": "sha512-VZznLgtwhn+Mact9tfiwx64fA9erHH/MCXEUfB/0bX/6Fz6ny5EGTXYltMocqg4xFAQZtnO3DHWWXi8RiuN7cQ==",
|
||||
"version": "5.0.6",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.6.tgz",
|
||||
"integrity": "sha512-kLpxurY4Z4r9sgMsyG0Z9uzsBlgiU/EFKhj/h91/8yHu0edo7XuixOIH3VcJ8kkxs6/jPzoI6U9Vj3WqbMQ94g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -1639,9 +1640,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/basic-ftp": {
|
||||
"version": "5.3.0",
|
||||
"resolved": "https://registry.npmjs.org/basic-ftp/-/basic-ftp-5.3.0.tgz",
|
||||
"integrity": "sha512-5K9eNNn7ywHPsYnFwjKgYH8Hf8B5emh7JKcPaVjjrMJFQQwGpwowEnZNEtHs7DfR7hCZsmaK3VA4HUK0YarT+w==",
|
||||
"version": "5.3.1",
|
||||
"resolved": "https://registry.npmjs.org/basic-ftp/-/basic-ftp-5.3.1.tgz",
|
||||
"integrity": "sha512-bopVNp6ugyA150DDuZfPFdt1KZ5a94ZDiwX4hMgZDzF+GttD80lEy8kj98kbyhLXnPvhtIo93mdnLIjpCAeeOw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
@@ -1936,12 +1937,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/cookie": {
|
||||
"version": "0.7.2",
|
||||
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz",
|
||||
"integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==",
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/cookie/-/cookie-1.1.1.tgz",
|
||||
"integrity": "sha512-ei8Aos7ja0weRpFzJnEA9UHJ/7XQmqglbRwnf2ATjcB9Wq874VKH9kfjjirM6UhU2/E5fFYadylyhFldcqSidQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
"node": ">=18"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/express"
|
||||
}
|
||||
},
|
||||
"node_modules/cookie-parser": {
|
||||
@@ -1957,6 +1962,15 @@
|
||||
"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": {
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
|
||||
@@ -2953,6 +2967,15 @@
|
||||
"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": {
|
||||
"version": "1.2.2",
|
||||
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz",
|
||||
@@ -4130,9 +4153,19 @@
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/js-yaml": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz",
|
||||
"integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==",
|
||||
"version": "4.2.0",
|
||||
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.2.0.tgz",
|
||||
"integrity": "sha512-ePWsvanv0DWuDRsW8dnt+R4jQ31SCRCQ7hhNcPXZPsoBZiemuZNYGf7adZdqX2D86j6rvKp3RpCxVTSb8WQlOw==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/puzrin"
|
||||
},
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/nodeca"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"argparse": "^2.0.1"
|
||||
@@ -6613,9 +6646,9 @@
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/ws": {
|
||||
"version": "8.20.1",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.20.1.tgz",
|
||||
"integrity": "sha512-It4dO0K5v//JtTXuPkfEOaI3uUN87iYPnqo/ZzqCoG3g8uhA66QUMs/SrM0YK7/NAu+r4LMh/9dq2A7k+rHs+w==",
|
||||
"version": "8.21.0",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.21.0.tgz",
|
||||
"integrity": "sha512-Vsp28b7DRcimFQvrqu2Wek3z1iYxDCWqHYB8Qsnk/S4RfaCQzPGPyBNuVjJV3cd6UiKtUtp6sNM77gWvzcCH+g==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
|
||||
@@ -70,6 +70,7 @@
|
||||
"@coder/logger": "^3.0.1",
|
||||
"argon2": "^0.44.0",
|
||||
"compression": "^1.7.4",
|
||||
"cookie": "^1.1.1",
|
||||
"cookie-parser": "^1.4.6",
|
||||
"env-paths": "^2.2.1",
|
||||
"express": "^5.0.1",
|
||||
|
||||
@@ -263,7 +263,7 @@ Index: code-server/lib/vscode/src/vs/code/browser/workbench/workbench.ts
|
||||
}
|
||||
|
||||
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 () {
|
||||
|
||||
// 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) {
|
||||
throw new Error('Missing web configuration element');
|
||||
}
|
||||
|
||||
@@ -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/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())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -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 { 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,
|
||||
workspaceProvider: WorkspaceProvider.create(config),
|
||||
urlCallbackProvider: new LocalStorageURLCallbackProvider(config.callbackRoute),
|
||||
|
||||
@@ -6,7 +6,7 @@ Index: code-server/lib/vscode/build/gulpfile.reh.ts
|
||||
===================================================================
|
||||
--- code-server.orig/lib/vscode/build/gulpfile.reh.ts
|
||||
+++ code-server/lib/vscode/build/gulpfile.reh.ts
|
||||
@@ -255,10 +255,15 @@ function packageTask(type: string, platf
|
||||
@@ -296,10 +296,15 @@ function packageTask(type: string, platf
|
||||
const destination = path.join(BUILD_ROOT, destinationFolderName);
|
||||
|
||||
return () => {
|
||||
|
||||
@@ -70,8 +70,8 @@ Index: code-server/lib/vscode/src/vs/workbench/contrib/webview/browser/pre/index
|
||||
<meta charset="UTF-8">
|
||||
|
||||
<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-m1DlJtsIJd46QuWYNcsaYIG1xI+9FyjKQu+cfp+zq5Q=' '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-A6/szVNdTzyi4hDa+9OLbzS8tSd2iUV4CqimLNWex2Y=' 'self'; frame-src 'self'; style-src 'unsafe-inline';">
|
||||
|
||||
<!-- Disable pinch zooming -->
|
||||
<meta name="viewport"
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import * as cookie from "cookie"
|
||||
import type { Request } from "express"
|
||||
import proxyServer from "http-proxy"
|
||||
import { HttpCode } from "../common/http"
|
||||
import { getCookieSessionName, HttpCode } from "../common/http"
|
||||
|
||||
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.
|
||||
// Is disabled when the request has no base path which means /absproxy is in use.
|
||||
proxy.on("proxyRes", (res, req) => {
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
import * as express from "express"
|
||||
import * as http from "http"
|
||||
import nodeFetch from "node-fetch"
|
||||
import { HttpCode } from "../../../src/common/http"
|
||||
import { proxy } from "../../../src/node/proxy"
|
||||
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 integration from "../../utils/integration"
|
||||
|
||||
describe("proxy", () => {
|
||||
const nhooyrDevServer = new httpserver.HttpServer()
|
||||
const proxyTarget = new httpserver.HttpServer()
|
||||
const wsApp = express.default()
|
||||
const wsRouter = WsRouter()
|
||||
let codeServer: httpserver.HttpServer | undefined
|
||||
@@ -19,21 +16,22 @@ describe("proxy", () => {
|
||||
|
||||
beforeAll(async () => {
|
||||
wsApp.use("/", wsRouter.router)
|
||||
await nhooyrDevServer.listen((req, res) => {
|
||||
await proxyTarget.listen((req, res) => {
|
||||
e(req, res)
|
||||
})
|
||||
nhooyrDevServer.listenUpgrade(wsApp)
|
||||
proxyPath = `/proxy/${nhooyrDevServer.port()}/wsup`
|
||||
proxyTarget.listenUpgrade(wsApp)
|
||||
proxyPath = `/proxy/${proxyTarget.port()}/wsup`
|
||||
absProxyPath = proxyPath.replace("/proxy/", "/absproxy/")
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
await nhooyrDevServer.dispose()
|
||||
await proxyTarget.dispose()
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
e = express.default()
|
||||
mockLogger()
|
||||
delete process.env.PASSWORD
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
@@ -283,65 +281,42 @@ describe("proxy", () => {
|
||||
const resp = await codeServer.fetch(proxyPath, { method: "OPTIONS" })
|
||||
expect(resp.status).toBe(200)
|
||||
})
|
||||
})
|
||||
|
||||
// NOTE@jsjoeio
|
||||
// Both this test suite and the one above it are very similar
|
||||
// The main difference is this one uses http and node-fetch
|
||||
// and specifically tests the proxy in isolation vs. using
|
||||
// the httpserver abstraction we've built.
|
||||
//
|
||||
// Leaving this as a separate test suite for now because
|
||||
// we may consider refactoring the httpserver abstraction
|
||||
// in the future.
|
||||
//
|
||||
// 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
|
||||
it("should return a 500 when no target is running ", async () => {
|
||||
const target = new httpserver.HttpServer()
|
||||
await target.listen(() => {})
|
||||
const port = target.port()
|
||||
target.dispose()
|
||||
codeServer = await integration.setup(["--auth=none"], "")
|
||||
const resp = await codeServer.fetch(`/proxy/${port}/wsup`)
|
||||
expect(resp.status).toBe(HttpCode.ServerError)
|
||||
expect(resp.statusText).toBe("Internal Server Error")
|
||||
})
|
||||
|
||||
beforeEach(async () => {
|
||||
const PORT = await getAvailablePort()
|
||||
const PROXY_PORT = await getAvailablePort()
|
||||
URL = `http://localhost:${PORT}`
|
||||
PROXY_URL = `http://localhost:${PROXY_PORT}`
|
||||
// Define server and a proxy server
|
||||
testServer = http.createServer((req, res) => {
|
||||
proxy.web(req, res, {
|
||||
target: PROXY_URL,
|
||||
})
|
||||
it("should strip token cookie", async () => {
|
||||
const token = "my-super-secure-token"
|
||||
process.env.HASHED_PASSWORD = token
|
||||
codeServer = await integration.setup(["--auth=password"])
|
||||
|
||||
// Set up a listener that just prints the cookies it got.
|
||||
e.get("/wsup/cookies", (req, res) => {
|
||||
res.writeHead(HttpCode.Ok, { "Content-Type": "text/plain" })
|
||||
res.end(req.headers.cookie)
|
||||
})
|
||||
|
||||
proxyTarget = http.createServer((req, res) => {
|
||||
res.writeHead(200, { "Content-Type": "text/plain" })
|
||||
res.end()
|
||||
// Send the token along with other cookies which should be preserved.
|
||||
// Encode one to make sure they are being re-encoded properly.
|
||||
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
|
||||
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`)
|
||||
// The proxied listener should not have printed the code-server token.
|
||||
expect(resp.status).toBe(200)
|
||||
expect(resp.statusText).toBe("OK")
|
||||
const text = await resp.text()
|
||||
expect(text).toBe(`cookie1=${encodedValue}; cookie2=hello`)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user