Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ea2caf0

Browse files
Allow setting trusted domains for links at run-time
It can be set either: 1. In the product.json (normally the product.json is embedded during the build and not read at run-time). 2. With the --link-protection-trusted-domains flag.
1 parent 3f2e334 commit ea2caf0

File tree

3 files changed

+56
-1
lines changed

3 files changed

+56
-1
lines changed

‎patches/series‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ getting-started.diff
2020
keepalive.diff
2121
clipboard.diff
2222
display-language.diff
23+
trusted-domains.diff

‎patches/trusted-domains.diff‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
Allow configuring trusted domains via product.json or flag.
2+
3+
Index: code-server/lib/vscode/src/vs/server/node/serverEnvironmentService.ts
4+
===================================================================
5+
--- code-server.orig/lib/vscode/src/vs/server/node/serverEnvironmentService.ts
6+
+++ code-server/lib/vscode/src/vs/server/node/serverEnvironmentService.ts
7+
@@ -20,6 +20,7 @@ export const serverOptions: OptionDescri
8+
'disable-file-uploads': { type: 'boolean' },
9+
'disable-getting-started-override': { type: 'boolean' },
10+
'locale': { type: 'string' },
11+
+ 'link-protection-trusted-domains': { type: 'string[]' },
12+
13+
/* ----- server setup ----- */
14+
15+
@@ -108,6 +109,7 @@ export interface ServerParsedArgs {
16+
'disable-file-uploads'?: boolean;
17+
'disable-getting-started-override'?: boolean,
18+
'locale'?: string
19+
+ 'link-protection-trusted-domains'?: string[],
20+
21+
/* ----- server setup ----- */
22+
23+
Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
24+
===================================================================
25+
--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts
26+
+++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts
27+
@@ -339,6 +339,14 @@ export class WebClientServer {
28+
scopes: [['user:email'], ['repo']]
29+
} : undefined;
30+
31+
+ const linkProtectionTrustedDomains: string[] = [];
32+
+ if (this._environmentService.args['link-protection-trusted-domains']) {
33+
+ linkProtectionTrustedDomains.push(...this._environmentService.args['link-protection-trusted-domains']);
34+
+ }
35+
+ if (this._productService.linkProtectionTrustedDomains) {
36+
+ linkProtectionTrustedDomains.push(...this._productService.linkProtectionTrustedDomains);
37+
+ }
38+
+
39+
const productConfiguration = {
40+
codeServerVersion: this._productService.codeServerVersion,
41+
rootEndpoint: rootBase,
42+
@@ -353,6 +361,7 @@ export class WebClientServer {
43+
telemetryEndpoint: this._productService.telemetryEndpoint,
44+
embedderIdentifier: 'server-distro',
45+
extensionsGallery: this._productService.extensionsGallery,
46+
+ linkProtectionTrustedDomains,
47+
} satisfies Partial<IProductConfiguration>;
48+
49+
if (!this._environmentService.isBuilt) {

‎src/node/cli.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export enum LogLevel {
3030
export class OptionalString extends Optional<string> {}
3131

3232
/**
33-
* Code flags provided by the user.
33+
* (VS) Code flags provided by the user.
3434
*/
3535
export interface UserProvidedCodeArgs {
3636
"disable-telemetry"?: boolean
@@ -54,6 +54,7 @@ export interface UserProvidedCodeArgs {
5454
"disable-proxy"?: boolean
5555
"session-socket"?: string
5656
"abs-proxy-base-path"?: string
57+
"link-protection-trusted-domains"?: string[]
5758
}
5859

5960
/**
@@ -194,6 +195,10 @@ export const options: Options<Required<UserProvidedArgs>> = {
194195
enable: { type: "string[]" },
195196
help: { type: "boolean", short: "h", description: "Show this output." },
196197
json: { type: "boolean" },
198+
"link-protection-trusted-domains": {
199+
type: "string[]",
200+
description: "Links matching a trusted domain can be opened without link protection.",
201+
},
197202
locale: {
198203
// The preferred way to set the locale is via the UI.
199204
type: "string",

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /