Skip to content

Fix/issue #286 #365

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions packages/server/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,24 @@ if (isCli) {
password = buffer.toString("hex");
}

// If CLI password was provided, obsfucate password from process title
if (options.password) {
const parts = [process.title];
for (let i = 2; i < process.argv.length; i++) {
if (process.argv[i].startsWith("--password=")) {
parts.push(process.argv[i].replace(/=.*/, "=****"));
} else if (process.argv[i] === "--password") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, I didn't include -P in my example but we'll need that as well. No need to check for -P= though since = isn't used with short options.

parts.push(process.argv[i++], "****")
} else if (process.argv[i] === "--") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another unfortunate edge case comes to mind:

code-server --data-dir -- password pass

That is, -- is only interpreted as the end of options if it isn't the argument for another option.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's possible we should use an environment variable and/or configuration file instead of a command line argument for the password. Or possibly a prompt, although I'm not really keen on that solution.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we have another issue for that #349

parts.push(...process.argv.slice(i));
break;
} else {
parts.push(process.argv[i]);
}
}
process.title = parts.join(" ");
}

const hasCustomHttps = certData && certKeyData;
const app = await createApp({
allowHttp: options.allowHttp,
Expand Down