package.json: update settings description to mark dangerous settings
Also add 'go.inferGopath' to the dangerous setting list.
For golang/vscode-go#1094
Change-Id: If5c936d6a875b92aef6d8368e14d02c66bbae7ce
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/283256
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Suzy Mueller <suzmue@golang.org>
diff --git a/docs/settings.md b/docs/settings.md
index 7a48be4..6d34ef7 100644
--- a/docs/settings.md
+++ b/docs/settings.md
@@ -50,7 +50,7 @@
### `go.alternateTools`
-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.
+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".
| Properties | Description |
| --- | --- |
@@ -286,13 +286,13 @@
### `go.gopath`
-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.
+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".
efault: `<nil>`
### `go.goroot`
-Specifies the GOROOT to use when no environment variable is set.
+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".
efault: `<nil>`
@@ -314,7 +314,7 @@
### `go.inferGopath`
-Infer GOPATH from the workspace root.
+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".
Default: `false`
@@ -464,7 +464,7 @@
### `go.toolsGopath`
-Location to install the Go tools that the extension depends on if you don't want them in your GOPATH.
+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".
efault: `<nil>`
diff --git a/package.json b/package.json
index 2753baf..878070c 100644
--- a/package.json
+++ b/package.json
@@ -1378,7 +1378,7 @@
"go.inferGopath": {
"type": "boolean",
"default": false,
- "description": "Infer GOPATH from the workspace root.",
+ "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\".",
"scope": "resource"
},
"go.gopath": {
@@ -1387,7 +1387,7 @@
"null"
],
"default": null,
- "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.",
+ "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\".",
"scope": "machine-overridable"
},
"go.toolsGopath": {
@@ -1396,7 +1396,7 @@
"null"
],
"default": null,
- "description": "Location to install the Go tools that the extension depends on if you don't want them in your GOPATH.",
+ "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\".",
"scope": "machine-overridable"
},
"go.goroot": {
@@ -1405,7 +1405,7 @@
"null"
],
"default": null,
- "description": "Specifies the GOROOT to use when no environment variable is set.",
+ "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\".",
"scope": "machine-overridable"
},
"go.testOnSave": {
@@ -2066,7 +2066,7 @@
"go.alternateTools": {
"type": "object",
"default": {},
- "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.",
+ "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\".",
"scope": "resource",
"properties": {
"go": {
diff --git a/src/config.ts b/src/config.ts
index 677dae2..93ca127 100644
--- a/src/config.ts
+++ b/src/config.ts
@@ -8,7 +8,7 @@
const WORKSPACE_IS_TRUSTED_KEY = 'WORKSPACE_IS_TRUSTED_KEY';
const SECURITY_SENSITIVE_CONFIG: string[] = [
- 'goroot', 'gopath', 'toolsGopath', 'alternateTools'
+ 'goroot', 'gopath', 'toolsGopath', 'alternateTools', 'inferGopath'
];
let defaultConfig: Configuration = null;
diff --git a/test/integration/config.test.ts b/test/integration/config.test.ts
index 500cc58..a854a3c 100644
--- a/test/integration/config.test.ts
+++ b/test/integration/config.test.ts
@@ -21,21 +21,23 @@
assert.strictEqual(got1, want, `cfg[${key}] = ${got1}, want ${want}`);
}
- test('trusted workspace', () => {
+ test('trusted workspace accepts all workspace settings', () => {
check(true, { goroot: 'goroot_val' }, 'goroot', 'goroot_val');
check(true, { gopath: 'gopath_val' }, 'gopath', 'gopath_val');
check(true, { toolsGopath: 'toolsGopath_val' }, 'toolsGopath', 'toolsGopath_val');
check(true, { alternateTools: { go: 'foo' } }, 'alternateTools', { go: 'foo' });
+ check(true, { inferGopath: true }, 'inferGopath', true);
check(true, { buildFlags: ['-v'] }, 'buildFlags', ['-v']);
check(true, { languageServerFlags: ['-rpc.trace'] }, 'languageServerFlags', ['-rpc.trace']);
});
- test('untrusted workspace', () => {
+ test('untrusted workspace ignores dangerous settings', () => {
check(false, { goroot: 'goroot_val' }, 'goroot', null);
check(false, { gopath: 'gopath_val' }, 'gopath', null);
check(false, { toolsGopath: 'toolsGopath_val' }, 'toolsGopath', null);
check(false, { alternateTools: { go: 'foo' } }, 'alternateTools', {});
+ check(false, { inferGopath: true }, 'inferGopath', false);
check(false, { buildFlags: ['-v'] }, 'buildFlags', ['-v']);
check(false, { languageServerFlags: ['-rpc.trace'] }, 'languageServerFlags', ['-rpc.trace']);
@@ -52,12 +54,14 @@
assert.strictEqual(got1, want, `cfg[${key}] = ${got1}, want ${want}`);
}
- test('trusted workspace (gopls settings)', () => {
+ test('trusted workspace (gopls settings) accepts all settings', () => {
+ // unaffected settings.
checkGopls(true, { buildFlags: '-v' }, 'buildFlags', '-v');
checkGopls(true, { env: { GOBIN: 'foo' } }, 'env', { GOBIN: 'foo' });
});
- test('untrusted workspace (gopls settings)', () => {
+ test('untrusted workspace (gopls settings) ignores dangerous settings', () => {
+ // unaffected settings
checkGopls(false, { buildFlags: '-v' }, 'buildFlags', '-v');
checkGopls(false, { env: { GOBIN: 'foo' } }, 'env', { GOBIN: 'foo' });
});