Skip to content

Commit

Permalink
remote: allow _ in ext host resolvedauthority (#168883)
Browse files Browse the repository at this point in the history
* remote: allow _ in ext host resolvedauthority (#168649)

Fixes https://github.com/microsoft/vscode-remote-release/issues/7661

This character was allowed in #167635,
but the extension host side did a separate check that I didn't update.

* fix remaining occurrences of the security token regexp

Co-authored-by: Martin Aeschlimann <[email protected]>
  • Loading branch information
connor4312 and aeschli authored Dec 13, 2022
1 parent 371d042 commit 93987e8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/vs/server/node/serverConnectionToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ export async function parseServerConnectionToken(args: ServerParsedArgs, default
}

if (!connectionTokenRegex.test(rawConnectionToken)) {
return new ServerConnectionTokenParseError(`The connection token defined in '${connectionTokenFile} does not adhere to the characters 0-9, a-z, A-Z or -.`);
return new ServerConnectionTokenParseError(`The connection token defined in '${connectionTokenFile} does not adhere to the characters 0-9, a-z, A-Z, _, or -.`);
}

return new MandatoryServerConnectionToken(rawConnectionToken);
}

if (typeof connectionToken !== 'undefined') {
if (!connectionTokenRegex.test(connectionToken)) {
return new ServerConnectionTokenParseError(`The connection token '${connectionToken} does not adhere to the characters 0-9, a-z, A-Z or -.`);
return new ServerConnectionTokenParseError(`The connection token '${connectionToken} does not adhere to the characters 0-9, a-z, A-Z, _, or -.`);
}

if (compatibility) {
Expand Down
4 changes: 2 additions & 2 deletions src/vs/server/node/serverEnvironmentService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export interface ServerParsedArgs {

/**
* A secret token that must be provided by the web client with all requests.
* Use only `[0-9A-Za-z\-]`.
* Use only `[0-9A-Za-z_-]`.
*
* By default, a UUID will be generated every time the server starts up.
*
Expand All @@ -113,7 +113,7 @@ export interface ServerParsedArgs {
* A path to a filename which will be read on startup.
* Consider placing this file in a folder readable only by the same user (a `chmod 0700` directory).
*
* The contents of the file will be used as the connection token. Use only `[0-9A-Z\-]` as contents in the file.
* The contents of the file will be used as the connection token. Use only `[0-9A-Za-z_-]` as contents in the file.
* The file can optionally end in a `\n` which will be ignored.
*
* This secret must be communicated to any vscode instance via the resolver or embedder API.
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/api/common/extHostTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ export class ResolvedAuthority {
throw illegalArgument('port');
}
if (typeof connectionToken !== 'undefined') {
if (typeof connectionToken !== 'string' || connectionToken.length === 0 || !/^[0-9A-Za-z\-]+$/.test(connectionToken)) {
if (typeof connectionToken !== 'string' || connectionToken.length === 0 || !/^[0-9A-Za-z_\-]+$/.test(connectionToken)) {
throw illegalArgument('connectionToken');
}
}
Expand Down

0 comments on commit 93987e8

Please sign in to comment.