47 Commits

Author SHA1 Message Date
705e821741 fix(testing): revert change & fix playwright tests (#4310)
* fix(testing): revert change & fix playwright tests

* fix(constants): add type to import statement

* refactor(e2e): delete browser test

This test was originally added to ensure playwright was working.

At this point, we know it works so removing this test because it doesn't help
with anything specific to code-server and only adds unnecessary code to the
codebase plus increases the e2e test job duration.

* chore(e2e): use 1 worker for e2e test

I don't know if it's a resources issue, playwright, or code-server but it seems
like the e2e tests choke when multiple workers are used.

This change is okay because our CI runner only has 2 cores so it would only use
1 worker anyway, but by specifying it in our playwright config, we ensure more
stability in our e2e tests working correctly.

See these PRs:
- https://github.com/cdr/code-server/pull/3263
- https://github.com/cdr/code-server/pull/4310

* revert(vscode): add missing route with redirect

* chore(vscode): update to latest fork

* Touch up compilation step.

* Bump vendor.

* Fix VS Code minification step

* Move ClientConfiguration to common

Common code must not import Node code as it is imported by the browser.

* Ensure lib directory exists before curling

cURL errors now because VS Code was moved and the directory does not
exist.

* Update incorrect e2e test help output

Revert workers change as well; this can be overridden when desired.

* Add back extension compilation step

* Include missing resources in release

This includes a favicon, for example.  I opted to include the entire
directory to make sure we do not miss anything.  Some of the other
stuff looks potentially useful (like completions).

* Set quality property in product configuration

When httpWebWorkerExtensionHostIframe.html is fetched it uses the web
endpoint template (in which we do not include the commit) but if the
quality is not set it prepends the commit to the web endpoint instead.
The new static endpoint does not use/handle commits so this 404s.

Long-term we might want to make the new static endpoint use commits like
the old one but we will also need to update the various other static
URLs to include the commit.

For now I just fixed this by adding the quality since:
  1. Probably faster than trying to find and update all static uses.
  2. VS Code probably expects it anyway.
  3. Gives us better control over the endpoint.

* Update VS Code

This fixes several build issues.

* Bump vscode.

* Bump.

* Bump.

* Use CLI directly.

* Update tests to reflect new upstream behavior.

* Move unit tests to after the build

Our code has new dependencies on VS Code that are pulled in when the
unit tests run.  Because of this we need to build VS Code before running
the unit tests (as it only pulls built code).

* Upgrade proxy-agent dependencies

This resolves a security report with one of its dependencies (vm2).

* Symlink VS Code output directory before unit tests

This is necessary now that we import from the out directory.

* Fix issues surrounding persistent processes between tests.

* Update VS Code cache directories

These were renamed so the cached paths need to be updated.  I changed
the key as well to force a rebuild.

* Move test symlink to script

This way it works for local testing as well.

I had to use out-build instead of out-vscode-server-min because Jest
throws some obscure error about a handlebars haste map.

* Fix listening on a socket

* Update VS Code

It contains fixes for missing files in the build.

* Standardize disposals

* Dispose HTTP server

Shares code with the test HTTP server.  For now it is a function but
maybe we should make it a class that is extended by tests.

* Dispose app on exit

* Fix logging link errors

Unfortunately the logger currently chokes when provided with error
objects.

Also for some reason the bracketed text was not displaying...

* Update regex used by e2e to extract address

The address was recently changed to use URL which seems to add a
trailing slash when using toString, causing the regex match to fail.

* Log browser console in e2e tests

* Add base back to login page

This is used to set cookies when using a base path.

* Remove login page test

The file this was testing no longer exists.

* Use path.posix for static base

Since this is a web path and not platform-dependent.

* Add test for invalid password

Co-authored-by: Teffen Ellis <teffen@nirri.us>
Co-authored-by: Asher <ash@coder.com>
2021-10-28 15:27:17 -05:00
d8c344beda Refactor vscode endpoints to use fork directly. 2021-09-30 19:14:17 -04:00
a3cea88f51 feat: add tests for src/node/app.ts 2021-09-20 10:57:31 -07:00
ca617df135 [Security] Fix ReDoS
Fix potential ReDoS
2021-09-11 18:40:47 +05:30
5c61318592 refactor: only accept string in pathToFsPath
CodeQL caught a path where we were passing in req.query.path
to pathToFsPath, which may not have been a string.

So we refactored some things to ensure we only pass it a string
which also let us change the parameter type to string
instead of string | string[].
2021-07-21 11:11:59 -07:00
7ce9ee0db6 fix: check path is string in pathToFsPath
There's a chance this function can be called with a path that is not a string.

To catch that, we check if path is of a different type and throw an error if it
is.

This also adds a couple tests for this function.
2021-07-12 16:39:42 -07:00
2092f82270 fixup! fix: escape error.message on login failure 2021-07-01 10:43:37 -07:00
c505fc45a8 feat: add escapeHtml function
This can be used to escape any special characters in a string with HTML before
sending from the server back to the client. This is important to prevent a
cross-site scripting attack.
2021-07-01 10:43:36 -07:00
7f12fab3ca fix(isHashMatch): check that hash starts with $
Previously, we used argon2 to verify the hash with the password.

If the hash didn't start with a $, then it would enter the catch block.

Now we check the hash before trying to verify it and we also throw an Error if
the verify fails.

This makes the isHashMatch function more robust.
2021-06-30 15:00:21 -07:00
49c44818d9 Move onLine to utilities
This way it can be used by the tests when spawning code-server on a
random port to look for the address.
2021-06-29 12:04:31 -05:00
dbb34ad710 chore: upgrade to Playwright 1.12 with its new test-runner 2021-06-10 15:09:38 +02:00
1e55a648a5 feat: check for empty str in isHashMatch 2021-06-08 15:10:59 -07:00
3b50bfc17d fix: sanitize password and cookie key 2021-06-08 14:33:17 -07:00
8c2bb61af9 refactor: parse options with multiple = in cli
There was a case with the hashed-password which had multiple equal signs in the
value and it wasn't being parsed correctly. This uses a new function and adds a
few tests.
2021-06-08 14:33:17 -07:00
6020480b30 feat: add isCookieValid function and tests 2021-06-08 14:33:16 -07:00
a14ea39c4a feat: add handlePasswordValidation + tests 2021-06-08 14:33:15 -07:00
7ff4117531 feat: add getPasswordMethod & test for it 2021-06-08 14:33:15 -07:00
70197bb2a5 refactor: use argon2 instead of bcrypt
This uses argon2 instead of bcrypt.

Note: this means the hash functions are now async which means we have to
refactor a lot of other code around auth.
2021-06-08 14:33:13 -07:00
aaf044728f refactor: add functions to check hash password 2021-06-08 14:33:12 -07:00
cac667317e refactor: use bcrypt in hash function 2021-06-08 14:33:11 -07:00
46fe77d464 chore: update CHANGELOG 2021-05-13 12:10:22 -07:00
a57ee69822 feat: add runtime to getEnvPaths 2021-05-13 12:10:21 -07:00
cb65590b98 refactor: move tmpdir into src/node/constants 2021-04-23 14:35:32 -07:00
964ebe8d0a Replace fs-extra with fs.promises
Remove the Mac directory copy instead of refactoring it since we've had
this for a long time now and I think it's safe to assume that users
running code-server on Mac don't have the old directory anymore.
2021-03-16 12:51:08 -05:00
f13ba9401b fix(TS error): add void to promise in util 2021-01-21 10:11:10 -07:00
e1702a1d21 Merge branch master into code-asher/ch1385 2020-11-12 11:52:02 -06:00
c10450c4c5 Move isFile into util
That allows its use in entry.ts as well.
2020-11-03 15:27:20 -06:00
a1b61d1659 src/node/util.ts: Mark generated certificates as CA
Required for access under iPad.
2020-10-30 13:36:53 -04:00
bae28727bd src/node/cli.ts: Add --cert-host to configure generated certificate hostname 2020-10-30 13:36:53 -04:00
8b85006996 src/node/util.ts: Make certificate generation "modern"
Now we add a subject alt name, set extendedKeyUsage and use the
correct certificate extension.

The above allow it to be properly trusted by iOS.

See https://support.apple.com/en-us/HT210176

*.cert isn't a real extension for certificates, *.crt is correct
for it to be recognized by e.g. keychain or when importing as a profile
into iOS.

Updates #1566

I've been able to successfully connect from my iPad Pro now to my
code-server instance with a self signed certificate! Next commit
will be docs.
2020-10-30 13:36:53 -04:00
10b3028196 util: Generate self signed certificate into data directory
Closes #1778
2020-10-30 13:36:53 -04:00
fe19391c03 Read most recent socket path from file 2020-10-09 16:57:43 -05:00
d8568ebaa9 Enforce import order 2020-08-13 17:11:35 -05:00
f7790c9719 Remove unused deep merge code 2020-08-13 17:11:34 -05:00
f7f11ad6c2 Fix paths from Windows client to non-Windows server
Fixes #1659
Fixes #1642
2020-05-18 15:06:11 -05:00
a0a77e379e Add doc/guide.md 2020-05-14 05:24:23 -04:00
d6ea9d78f6 Configuration file bug fixes based on @code-asher's review 2020-05-12 19:59:54 -04:00
00d164b67f Add default config file and improve config/data directory detection 2020-05-12 19:59:54 -04:00
d0d5461a67 Remove SSH server
Closes #1502
2020-04-27 09:27:45 -04:00
3463d56114 SSH server & endpoint 2020-03-16 15:14:53 -05:00
51a5c77cb8 Add binary extraction
I temporarily removed this during the refactor so it needed to be added
back. This time I bundled it with the nbin loader code since it's all
related (will also make it easier to remove).
2020-02-19 14:15:01 -06:00
4aa15401c3 Format and lint 2020-02-14 20:00:19 -05:00
8cc11d1688 Improve routing 2020-02-05 13:07:07 -06:00
b29346ecdf Implement new structure 2020-02-04 14:31:44 -06:00
2018024810 Hash password
Fixes issues with unexpected characters breaking things when setting the
cookie (like semicolons).

This change as-is does not affect the security of code-server
itself (we've just replaced the static password with a static hash) but
if we were to add a salt in the future it would let us invalidate keys
by rehashing with a new salt which could be handy.
2019-11-07 15:57:57 -06:00
e7945bea94 Enable password authentication by default
Fixes #1062.
2019-10-24 12:35:26 -05:00
548d095611 Add support for running extensions in the browser 2019-10-04 18:14:19 -05:00