From 22859c794dbff1ae1f62da14cb925c0dedd4ecb1 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Thu, 31 Mar 2022 10:33:20 -0700 Subject: [PATCH] feat(cli): add disable-file-downloads to cli --- src/node/cli.ts | 11 +++++++++++ test/unit/node/cli.test.ts | 4 ++++ test/unit/node/plugin.test.ts | 1 + 3 files changed, 16 insertions(+) diff --git a/src/node/cli.ts b/src/node/cli.ts index 6dd260c19124..17f134d8f3a1 100644 --- a/src/node/cli.ts +++ b/src/node/cli.ts @@ -49,6 +49,7 @@ export interface UserProvidedCodeArgs { category?: string "github-auth"?: string "disable-update-check"?: boolean + "disable-file-downloads"?: boolean } /** @@ -157,6 +158,11 @@ export const options: Options> = { "Disable update check. Without this flag, code-server checks every 6 hours against the latest github release and \n" + "then notifies you once every week that a new release is available.", }, + "disable-file-downloads": { + type: "boolean", + description: + "Disable file downloads from Code. Defaults to true.", + }, // --enable can be used to enable experimental features. These features // provide no guarantees. enable: { type: "string[]" }, @@ -445,6 +451,7 @@ export interface DefaultedArgs extends ConfigArgs { usingEnvHashedPassword: boolean "extensions-dir": string "user-data-dir": string + "disable-file-downloads": boolean /* Positional arguments. */ _: string[] } @@ -556,6 +563,10 @@ export async function setDefaults(cliArgs: UserProvidedArgs, configArgs?: Config const proxyDomains = new Set((args["proxy-domain"] || []).map((d) => d.replace(/^\*\./, ""))) args["proxy-domain"] = Array.from(proxyDomains) + if (!args["disable-file-downloads"]) { + args["disable-file-downloads"] = false + } + if (typeof args._ === "undefined") { args._ = [] } diff --git a/test/unit/node/cli.test.ts b/test/unit/node/cli.test.ts index 0b04adadb4af..0945914ca42e 100644 --- a/test/unit/node/cli.test.ts +++ b/test/unit/node/cli.test.ts @@ -31,6 +31,7 @@ const defaults = { host: "localhost", port: 8080, "proxy-domain": [], + "disable-file-downloads": false, usingEnvPassword: false, usingEnvHashedPassword: false, "extensions-dir": path.join(paths.data, "extensions"), @@ -92,6 +93,8 @@ describe("parser", () => { "--port=8081", + "--disable-file-downloads", + ["--host", "0.0.0.0"], "4", "--", @@ -108,6 +111,7 @@ describe("parser", () => { cert: { value: path.resolve("path/to/cert"), }, + "disable-file-downloads": true, enable: ["feature1", "feature2"], help: true, host: "0.0.0.0", diff --git a/test/unit/node/plugin.test.ts b/test/unit/node/plugin.test.ts index 73923415b57e..88210fd8594a 100644 --- a/test/unit/node/plugin.test.ts +++ b/test/unit/node/plugin.test.ts @@ -38,6 +38,7 @@ describe("plugin", () => { "proxy-domain": [], config: "~/.config/code-server/config.yaml", verbose: false, + "disable-file-downloads": false, usingEnvPassword: false, usingEnvHashedPassword: false, "extensions-dir": "",