Commit Graph

36 Commits

Author SHA1 Message Date
Asher eb498b0d6d
Remove humanPath (#6404)
The tilde is ambiguous and it can be helpful to know exactly what paths
code-server is trying to use, especially if it is running as a different
user than you expected.
2023-08-29 14:25:24 -08:00
Asher d477972c68
Add origin checks to web sockets (#6048)
* Move splitOnFirstEquals to util

I will be making use of this to parse the forwarded header.

* Type splitOnFirstEquals with two items

Also add some test cases.

* Check origin header on web sockets

* Update changelog with origin check

* Fix web sockets not closing with error code
2023-03-03 03:12:34 -06:00
Daniil Gentili b562d4a880
Allow opening files at a specific line and column (fixes #5619) (#5620)
* Allow opening files at a specific line and column (fixes #5619)

* Add isDirectory test
2022-10-06 11:12:21 -07:00
Joe Previte 61138b4a61
refactor: open function (#5257)
* refactor: fix type annotations in open

There was no clear reason as to why we needed to use type assertions
when initializing both `args` and `options` in `open` so I refactored
them both.

* refactor: create constructOpenOptions

* refactor: add urlSearch and remove options

* feat: add tests for constructOpenOptions
2022-06-15 20:53:07 +00:00
Joe Previte a96162d075
feat: add tests for node/util.open (#5256) 2022-06-13 21:16:46 +00:00
Joe Previte 2c1cf0259e
feat: add tests for isWsl (#5251)
* refactor: add docs to isWsl and make easier to test

* feat: add tests for isWsl

* fixup!: refactor isWsl and tests

* Update test/unit/node/util.test.ts

Co-authored-by: Asher <ash@coder.com>

* Update test/unit/node/util.test.ts

Co-authored-by: Asher <ash@coder.com>

Co-authored-by: Asher <ash@coder.com>
2022-06-10 20:00:20 +00:00
Joe Previte d75883bcc6
feat: add additional test for handlePasswordValidation (#5243) 2022-06-06 11:20:22 -07:00
Joe Previte 3207bfd4ad
feat: add test for isFile when error (#5182)
This adds an additional test for the `isFile` utility function to ensure
it returns `false` in the event of an error.
2022-05-09 23:24:40 +00:00
Joe Previte 25b1340771
revert: @node-rs/argon2 -> node-argon2 (#4829)
* revert: partial revert of 723469ab5b

This reverts part of the changes introduced in refactor: migrate from argon2 ->
@node-rs/argon2 (#4733)

Switching to @node-rs/argon2 introduced bugs that we couldn't solve due to
limitations in npm.

see here
https://github.com/coder/code-server/issues/4804#issuecomment-1030338395
2022-02-04 15:52:42 -07:00
Joe Previte 00224fa73a
feat: add test for hash when error (#4814) 2022-02-03 14:22:16 -07:00
Joe Previte 723469ab5b
refactor: migrate from argon2 -> @node-rs/argon2 (#4733)
* chore(deps): replace argon2 w/@node-rs/argon2

* refactor: clean up hashPassword functions

* refactor(util): pass in process.platform

* fix: use correct settings for test-extension

Before, it was running into errors with an @types package.

Now, we're correctly running `tsc` so it picks up our `tsconfig.json` and we're
telling TypeScript to not typecheck our lib and exclude `node_modules`
2022-01-18 16:13:39 -07:00
Joe Previte 65d7420ee7
feat: add test for onLine throw error (#4542) 2021-11-22 20:18:58 +00:00
Joe Previte 0a072f7532
feat(testing): refactor humanPath and add tests (#4511)
* feat: add test for humanPath

* refactor: make humanPath pure and pass in homedir
2021-11-15 19:40:34 +00:00
Teffen Ellis d8c344beda Refactor vscode endpoints to use fork directly. 2021-09-30 19:14:17 -04:00
Joe Previte 7a6ec202ba
refactor: match /test/unit structure to /src 2021-07-29 09:48:40 -07:00
Joe Previte 911cb034f5
feat: add registerRequireOnSelf on function 2021-07-21 15:30:54 -07:00
Joe Previte 6e33dccb40
feat: add tests for isFile 2021-07-21 11:12:00 -07:00
Joe Previte 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
Joe Previte fc16f7e06d
refactor: clean up testing files 2021-07-12 17:05:44 -07:00
Joe Previte 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
Joe Previte 2092f82270
fixup! fix: escape error.message on login failure 2021-07-01 10:43:37 -07:00
Joe Previte 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
Joe Previte 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
Asher 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
Asher add55ecd62
Import utils as a group in tests
This should simplify testing new utils a bit.
2021-06-29 12:03:38 -05:00
Joe Previte 1e55a648a5
feat: check for empty str in isHashMatch 2021-06-08 15:10:59 -07:00
Joe Previte 3b50bfc17d
fix: sanitize password and cookie key 2021-06-08 14:33:17 -07:00
Joe Previte 6020480b30
feat: add isCookieValid function and tests 2021-06-08 14:33:16 -07:00
Joe Previte a14ea39c4a
feat: add handlePasswordValidation + tests 2021-06-08 14:33:15 -07:00
Joe Previte 7ff4117531
feat: add getPasswordMethod & test for it 2021-06-08 14:33:15 -07:00
Joe Previte fd3cb6cfa0
refactor: update unit tests for hash fns
Since the hash and isHashMatch are now async, I had to update the tests
accordingly. Now everything is working.
2021-06-08 14:33:13 -07:00
Joe Previte fc3326f1f2
feat: add tests using real hashes 2021-06-08 14:33:12 -07:00
Joe Previte aaf044728f
refactor: add functions to check hash password 2021-06-08 14:33:12 -07:00
Joe Previte f35120c0a3
feat: add unit test for hash function 2021-06-08 14:33:12 -07:00
Joe Previte 46fe77d464
chore: update CHANGELOG 2021-05-13 12:10:22 -07:00
Joe Previte 2a657ab930
feat: add tests for getEnvPaths 2021-05-13 12:10:21 -07:00