Skip to content

Commit

Permalink
SettingsValidator: Disallow changing network tunnel
Browse files Browse the repository at this point in the history
This ensures that we cannot change the network tunnel configuration via the
API at all; the only way to do so would be to edit the settings file
directly while Rancher Desktop is not running.

Signed-off-by: Mark Yen <[email protected]>
  • Loading branch information
mook-as committed Jul 23, 2024
1 parent 83f052f commit b0aa155
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ describe(SettingsValidator, () => {
['experimental', 'virtualMachine', 'mount', '9p', 'protocolVersion'],
['experimental', 'virtualMachine', 'mount', '9p', 'securityModel'],
['experimental', 'virtualMachine', 'mount', 'type'],
['experimental', 'virtualMachine', 'networkingTunnel'], // Cannot be set
['experimental', 'virtualMachine', 'type'],
['experimental', 'virtualMachine', 'useRosetta'],
['experimental', 'virtualMachine', 'proxy', 'noproxy'],
Expand All @@ -88,17 +89,16 @@ describe(SettingsValidator, () => {

// Fields that can only be set on specific platforms.
const platformSpecificFields: Record<string, ReturnType<typeof os.platform>> = {
'application.adminAccess': 'linux',
'experimental.virtualMachine.networkingTunnel': 'win32',
'experimental.virtualMachine.proxy.enabled': 'win32',
'experimental.virtualMachine.proxy.address': 'win32',
'experimental.virtualMachine.proxy.password': 'win32',
'experimental.virtualMachine.proxy.port': 'win32',
'experimental.virtualMachine.proxy.username': 'win32',
'kubernetes.ingress.localhostOnly': 'win32',
'virtualMachine.hostResolver': 'win32',
'virtualMachine.memoryInGB': 'darwin',
'virtualMachine.numberCPUs': 'linux',
'application.adminAccess': 'linux',
'experimental.virtualMachine.proxy.enabled': 'win32',
'experimental.virtualMachine.proxy.address': 'win32',
'experimental.virtualMachine.proxy.password': 'win32',
'experimental.virtualMachine.proxy.port': 'win32',
'experimental.virtualMachine.proxy.username': 'win32',
'kubernetes.ingress.localhostOnly': 'win32',
'virtualMachine.hostResolver': 'win32',
'virtualMachine.memoryInGB': 'darwin',
'virtualMachine.numberCPUs': 'linux',
};

const spyValidateSettings = jest.spyOn(subject, 'validateSettings');
Expand Down
4 changes: 2 additions & 2 deletions pkg/rancher-desktop/main/commandServer/settingsValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ export default class SettingsValidator {
// see https://github.com/rancher-sandbox/rancher-desktop/issues/6953
// The setting will be removed once the legacy Windows networking mode is disabled, so until
// then we will allow changing the setting on all platforms to avoid the profile error.
// Changing the setting will have no effect on macOS/Linux anyways.
networkingTunnel: this.checkBoolean,
// Changing the setting will have no effect on macOS/Linux anyways.1
networkingTunnel: this.checkUnchanged,
useRosetta: this.checkPlatform('darwin', this.checkRosetta),
type: this.checkPlatform('darwin', this.checkMulti(
this.checkEnum(...Object.values(VMType)),
Expand Down

0 comments on commit b0aa155

Please sign in to comment.