如何在制作自定义的VS Code构建时禁用扩展库?

huangapple go评论61阅读模式
英文:

How can I disable the Extension Gallery when making a custom VS Code build?

问题

I need to disable the online extension gallery cause I don't want developers to download any extension that could be potentially dangerous. Is there any simple setting that allow it?

Options:

  • I could use the --no-proxy-server option to avoid access to the extension gallery. However some extensions require it.

  • I could use a read-only extension folder and the --extensions-dir option. However some extensions need write permissions on that folder.

  • I found out that there is a a key called "extensionsGallery" in resources\app\product.json I think I could remove those URLs:

    "nlsBaseUrl": "https://www.vscode-unpkg.net/_lp/",
    "serviceUrl": "https://marketplace.visualstudio.com/_apis/public/gallery",
    "cacheUrl": "https://vscode.blob.core.windows.net/gallery/index",
    "itemUrl": "https://marketplace.visualstudio.com/items",
    "publisherUrl": "https://marketplace.visualstudio.com/publishers",
    "resourceUrlTemplate": "https://{publisher}.vscode-unpkg.net/{publisher}/{name}/{version}/{path}",
    "controlUrl": "https://az764295.vo.msecnd.net/extensions/marketplace.json",
    "recommendationsUrl": "https://az764295.vo.msecnd.net/extensions/workspaceRecommendations.json.gz"

but I'm not sure if I break something important. Is it safe to remove those URLs?

Is there a setting I can just set to avoid installing extensions freely? I want to build a custom flavored VS Code with some extensions but not allowing users to do everything.

英文:

I need to disable the online extension gallery cause I don't want developers to download any extension that could be potentially dangerous. Is there any simple setting that allow it?

Options:

  • I could use the --no-proxy-server option to avoid access to the extension gallery. However some extensions require it.

  • I could use a read-only extension folder and the --extensions-dir option. However some extensions need write permissions on that folder.

  • I found out that there is a a key called "extensionsGallery" in resources\app\product.json I think I could remove those URLs:

		"nlsBaseUrl": "https://www.vscode-unpkg.net/_lp/",
		"serviceUrl": "https://marketplace.visualstudio.com/_apis/public/gallery",
		"cacheUrl": "https://vscode.blob.core.windows.net/gallery/index",
		"itemUrl": "https://marketplace.visualstudio.com/items",
		"publisherUrl": "https://marketplace.visualstudio.com/publishers",
		"resourceUrlTemplate": "https://{publisher}.vscode-unpkg.net/{publisher}/{name}/{version}/{path}",
		"controlUrl": "https://az764295.vo.msecnd.net/extensions/marketplace.json",
		"recommendationsUrl": "https://az764295.vo.msecnd.net/extensions/workspaceRecommendations.json.gz"

but I'm not sure if I break something important. Is it safe to remove those URLs?

Is there a setting I can just set to avoid installing extensiones freely? I want to build a custom flavored VS Code with some extensions but not allowing users to do everything.

答案1

得分: 1

> 我想要构建一个自定义味道的 VS Code,带有一些扩展功能,但不允许用户做任何事情。

然后创建一个 product.json 文件来实现这一点。另请参阅@chrisdias(VS Code 团队成员)的这条评论

> 我发现在 resources\app\product.json 中有一个名为 "extensionsGallery" 的键,我认为我可以删除这些URL,但我不确定是否会破坏重要内容。删除这些URL是否安全?

默认/模板 product.json 甚至没有定义这些属性,如果你查看 VS Code 的 IproductConfigurationsrc/vs/base/common/product.ts 中的类型定义,你会看到 extensionsGallery 属性是可为空的。如果类型定义表示 extensionsGallery 属性可以省略,我认为那意味着可以不写。扩展视图将不具备任何后端服务,但用户仍然可以通过下载 VSIX 文件并使用 code --install-extension 安装它们。

英文:

> I want to build a custom flavored VS Code with some extensions but not allowing users to do everything.

Then make a product.json that does that. See also this comment from @chrisdias (a member of the VS Code team).

> I found out that there is a a key called "extensionsGallery" in resources\app\product.json I think I could remove those URLs, but I'm not sure if I break something important. Is it safe to remove those URLs?

The default/template product.json doesn't even have those properties defined, and if you look at VS Code's type definition of IproductConfiguration in src/vs/base/common/product.ts, you'll see that the extensionsGallery property is nullable. If the type definition says the extensionsGallery property can be left out, I think that means it's fine to leave out. The Extensions View will not have any backing service, but users will still be able to install extensions by downloading VSIXes and installing them with code --install-extension.

huangapple
  • 本文由 发表于 2023年5月30日 01:01:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/76359133.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定