Skip to content

Commit e1a6cb4

Browse files
committed
package.json: update settings description to mark dangerous settings
Also add 'go.inferGopath' to the dangerous setting list. For #1094 Change-Id: If5c936d6a875b92aef6d8368e14d02c66bbae7ce Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/283256 Run-TryBot: Hyang-Ah Hana Kim <[email protected]> TryBot-Result: kokoro <[email protected]> Trust: Hyang-Ah Hana Kim <[email protected]> Reviewed-by: Suzy Mueller <[email protected]>
1 parent bc8b63e commit e1a6cb4

File tree

4 files changed

+19
-15
lines changed

4 files changed

+19
-15
lines changed

docs/settings.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Default:{<br/>
5050

5151
### `go.alternateTools`
5252

53-
Alternate tools or alternate paths for the same tools used by the Go extension. Provide either absolute path or the name of the binary in GOPATH/bin, GOROOT/bin or PATH. Useful when you want to use wrapper script for the Go tools or versioned tools from https://gopkg.in.
53+
Alternate tools or alternate paths for the same tools used by the Go extension. Provide either absolute path or the name of the binary in GOPATH/bin, GOROOT/bin or PATH. Useful when you want to use wrapper script for the Go tools or versioned tools from https://gopkg.in. When specified as a workspace setting, the setting is used only when the workspace is marked trusted with "Go: Toggle Workspace Trust Flag".
5454

5555
| Properties | Description |
5656
| --- | --- |
@@ -286,13 +286,13 @@ Default: `go`
286286

287287
### `go.gopath`
288288

289-
Specify GOPATH here to override the one that is set as environment variable. The inferred GOPATH from workspace root overrides this, if go.inferGopath is set to true.
289+
Specify GOPATH here to override the one that is set as environment variable. The inferred GOPATH from workspace root overrides this, if go.inferGopath is set to true. When specified as a workspace setting, the setting is used only when the workspace is marked trusted with "Go: Toggle Workspace Trust Flag".
290290

291291
efault: `<nil>`
292292

293293
### `go.goroot`
294294

295-
Specifies the GOROOT to use when no environment variable is set.
295+
Specifies the GOROOT to use when no environment variable is set. When specified as a workspace setting, the setting is used only when the workspace is marked trusted with "Go: Toggle Workspace Trust Flag".
296296

297297
efault: `<nil>`
298298

@@ -314,7 +314,7 @@ Default: `false`
314314

315315
### `go.inferGopath`
316316

317-
Infer GOPATH from the workspace root.
317+
Infer GOPATH from the workspace root. This is ignored when using Go Modules. When specified as a workspace setting, the setting is used only when the workspace is marked trusted with "Go: Toggle Workspace Trust Flag".
318318

319319
Default: `false`
320320

@@ -464,7 +464,7 @@ Environment variables that will be passed to the tools that run the Go tools (e.
464464

465465
### `go.toolsGopath`
466466

467-
Location to install the Go tools that the extension depends on if you don't want them in your GOPATH.
467+
Location to install the Go tools that the extension depends on if you don't want them in your GOPATH. When specified as a workspace setting, the setting is used only when the workspace is marked trusted with "Go: Toggle Workspace Trust Flag".
468468

469469
efault: `<nil>`
470470

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,7 +1378,7 @@
13781378
"go.inferGopath": {
13791379
"type": "boolean",
13801380
"default": false,
1381-
"description": "Infer GOPATH from the workspace root.",
1381+
"description": "Infer GOPATH from the workspace root. This is ignored when using Go Modules. When specified as a workspace setting, the setting is used only when the workspace is marked trusted with \"Go: Toggle Workspace Trust Flag\".",
13821382
"scope": "resource"
13831383
},
13841384
"go.gopath": {
@@ -1387,7 +1387,7 @@
13871387
"null"
13881388
],
13891389
"default": null,
1390-
"description": "Specify GOPATH here to override the one that is set as environment variable. The inferred GOPATH from workspace root overrides this, if go.inferGopath is set to true.",
1390+
"description": "Specify GOPATH here to override the one that is set as environment variable. The inferred GOPATH from workspace root overrides this, if go.inferGopath is set to true. When specified as a workspace setting, the setting is used only when the workspace is marked trusted with \"Go: Toggle Workspace Trust Flag\".",
13911391
"scope": "machine-overridable"
13921392
},
13931393
"go.toolsGopath": {
@@ -1396,7 +1396,7 @@
13961396
"null"
13971397
],
13981398
"default": null,
1399-
"description": "Location to install the Go tools that the extension depends on if you don't want them in your GOPATH.",
1399+
"description": "Location to install the Go tools that the extension depends on if you don't want them in your GOPATH. When specified as a workspace setting, the setting is used only when the workspace is marked trusted with \"Go: Toggle Workspace Trust Flag\".",
14001400
"scope": "machine-overridable"
14011401
},
14021402
"go.goroot": {
@@ -1405,7 +1405,7 @@
14051405
"null"
14061406
],
14071407
"default": null,
1408-
"description": "Specifies the GOROOT to use when no environment variable is set.",
1408+
"description": "Specifies the GOROOT to use when no environment variable is set. When specified as a workspace setting, the setting is used only when the workspace is marked trusted with \"Go: Toggle Workspace Trust Flag\".",
14091409
"scope": "machine-overridable"
14101410
},
14111411
"go.testOnSave": {
@@ -2066,7 +2066,7 @@
20662066
"go.alternateTools": {
20672067
"type": "object",
20682068
"default": {},
2069-
"description": "Alternate tools or alternate paths for the same tools used by the Go extension. Provide either absolute path or the name of the binary in GOPATH/bin, GOROOT/bin or PATH. Useful when you want to use wrapper script for the Go tools or versioned tools from https://gopkg.in.",
2069+
"description": "Alternate tools or alternate paths for the same tools used by the Go extension. Provide either absolute path or the name of the binary in GOPATH/bin, GOROOT/bin or PATH. Useful when you want to use wrapper script for the Go tools or versioned tools from https://gopkg.in. When specified as a workspace setting, the setting is used only when the workspace is marked trusted with \"Go: Toggle Workspace Trust Flag\".",
20702070
"scope": "resource",
20712071
"properties": {
20722072
"go": {

src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { getFromWorkspaceState, updateWorkspaceState } from './stateUtils';
88

99
const WORKSPACE_IS_TRUSTED_KEY = 'WORKSPACE_IS_TRUSTED_KEY';
1010
const SECURITY_SENSITIVE_CONFIG: string[] = [
11-
'goroot', 'gopath', 'toolsGopath', 'alternateTools'
11+
'goroot', 'gopath', 'toolsGopath', 'alternateTools', 'inferGopath'
1212
];
1313

1414
let defaultConfig: Configuration = null;

test/integration/config.test.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,23 @@ suite('GoConfiguration Tests', () => {
2121
assert.strictEqual(got1, want, `cfg[${key}] = ${got1}, want ${want}`);
2222
}
2323

24-
test('trusted workspace', () => {
24+
test('trusted workspace accepts all workspace settings', () => {
2525
check(true, { goroot: 'goroot_val' }, 'goroot', 'goroot_val');
2626
check(true, { gopath: 'gopath_val' }, 'gopath', 'gopath_val');
2727
check(true, { toolsGopath: 'toolsGopath_val' }, 'toolsGopath', 'toolsGopath_val');
2828
check(true, { alternateTools: { go: 'foo' } }, 'alternateTools', { go: 'foo' });
29+
check(true, { inferGopath: true }, 'inferGopath', true);
2930

3031
check(true, { buildFlags: ['-v'] }, 'buildFlags', ['-v']);
3132
check(true, { languageServerFlags: ['-rpc.trace'] }, 'languageServerFlags', ['-rpc.trace']);
3233
});
3334

34-
test('untrusted workspace', () => {
35+
test('untrusted workspace ignores dangerous settings', () => {
3536
check(false, { goroot: 'goroot_val' }, 'goroot', null);
3637
check(false, { gopath: 'gopath_val' }, 'gopath', null);
3738
check(false, { toolsGopath: 'toolsGopath_val' }, 'toolsGopath', null);
3839
check(false, { alternateTools: { go: 'foo' } }, 'alternateTools', {});
40+
check(false, { inferGopath: true }, 'inferGopath', false);
3941

4042
check(false, { buildFlags: ['-v'] }, 'buildFlags', ['-v']);
4143
check(false, { languageServerFlags: ['-rpc.trace'] }, 'languageServerFlags', ['-rpc.trace']);
@@ -52,12 +54,14 @@ suite('GoConfiguration Tests', () => {
5254
assert.strictEqual(got1, want, `cfg[${key}] = ${got1}, want ${want}`);
5355
}
5456

55-
test('trusted workspace (gopls settings)', () => {
57+
test('trusted workspace (gopls settings) accepts all settings', () => {
58+
// unaffected settings.
5659
checkGopls(true, { buildFlags: '-v' }, 'buildFlags', '-v');
5760
checkGopls(true, { env: { GOBIN: 'foo' } }, 'env', { GOBIN: 'foo' });
5861
});
5962

60-
test('untrusted workspace (gopls settings)', () => {
63+
test('untrusted workspace (gopls settings) ignores dangerous settings', () => {
64+
// unaffected settings
6165
checkGopls(false, { buildFlags: '-v' }, 'buildFlags', '-v');
6266
checkGopls(false, { env: { GOBIN: 'foo' } }, 'env', { GOBIN: 'foo' });
6367
});

0 commit comments

Comments
 (0)