Skip to content

MWB: Firewall for subnet only should be configured according to setting value #39492

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 0 commits into from

Conversation

vanzue
Copy link
Contributor

@vanzue vanzue commented May 16, 2025

Summary of the Pull Request

We should not configure subnet only if user explicitly set the option to false

PR Checklist

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

Subnetonly toggle to off
image
Subnet only toggle to on:
image

var param = L"";
if (sameSubnetOnly)
{
param += "-samesubnetonly";

Check failure

Code scanning / check-spelling

Unrecognized Spelling

[samesubnetonly](#security-tab) is not a recognized word. \(unrecognized-spelling\)

This comment has been minimized.

@vanzue vanzue changed the title MWB: Firewall for subnet only should be configured by case MWB: Firewall for subnet only should be configured according to setting value May 16, 2025
@htcfreek
Copy link
Collaborator

is this respecting the group policy too?

@vanzue
Copy link
Contributor Author

vanzue commented May 19, 2025

is this respecting the group policy too?

Good catch, you are right, we should use a higher level wrapper instead of the raw property to consider the gpo.

@vanzue
Copy link
Contributor Author

vanzue commented May 19, 2025

When user clicks the button to switch 'same subnet only' option, we should at least let users know that they need to click another button to make it work in firewall, use #39574 to track

@vanzue vanzue requested a review from Copilot May 19, 2025 10:26
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the firewall rule configuration for MouseWithoutBorders so that the subnet-only option is only applied when explicitly enabled.

  • Updated the SendCustomAction method signature to include an optional value parameter and modified AddFirewallRule accordingly.
  • Adjusted the firewall rule launch process to conditionally add the subnet restriction based on the provided parameter.
  • Updated the spell-check expectations to include the new "samesubnetonly" parameter name.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/settings-ui/Settings.UI/ViewModels/MouseWithoutBordersViewModel.cs Added an optional parameter to SendCustomAction and updated AddFirewallRule to conditionally append the subnet-only flag.
src/modules/MouseWithoutBorders/ModuleInterface/dllmain.cpp Modified the firewall process launcher to accept parameters and conditionally include the subnet restriction.
.github/actions/spell-check/expect.txt Added "samesubnetonly" to the list of allowed words for spell-checking.
Comments suppressed due to low confidence (1)

.github/actions/spell-check/expect.txt:1413

  • [nitpick] Verify that the naming convention for 'samesubnetonly' remains consistent across the codebase; consider aligning with the property name if necessary.
samesubnetonly

Comment on lines 1205 to 1210
var param = string.Empty;
if (SameSubnetOnly)
{
param += "-samesubnetonly";
}

Copy link
Preview

Copilot AI May 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider using a more scalable approach (such as a collection or an argument builder) to construct command parameters in case additional flags need to be appended in the future.

Suggested change
var param = string.Empty;
if (SameSubnetOnly)
{
param += "-samesubnetonly";
}
var parameters = new List<string>();
if (SameSubnetOnly)
{
parameters.Add("-samesubnetonly");
}
var param = string.Join(" ", parameters);

Copilot uses AI. Check for mistakes.

@@ -567,7 +567,16 @@ class MouseWithoutBorders : public PowertoyModuleIface
executable_args.append(L"\" & echo \"Adding an inbound firewall rule for PowerToys.MouseWithoutBorders.exe\"");
executable_args.append(L" & netsh advfirewall firewall add rule name=\"PowerToys.MouseWithoutBorders\" dir=in action=allow program=\"");
executable_args.append(executable_path);
executable_args.append(L"\" enable=yes remoteip=LocalSubnet profile=any protocol=tcp & pause\"");

std::wstring extra_rule_params = L"";
Copy link
Preview

Copilot AI May 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider adding a comment to clarify the purpose of the '-samesubnetonly' flag to improve code readability for future maintainers.

Suggested change
std::wstring extra_rule_params = L"";
std::wstring extra_rule_params = L"";
// If the '-samesubnetonly' flag is present, restrict the firewall rule to apply only to devices on the same subnet.

Copilot uses AI. Check for mistakes.

@vanzue
Copy link
Contributor Author

vanzue commented May 20, 2025

Offline talked with @yeelam-gordon , instead of adding such firewall, and maintain a copy of logic in code to check subnet, we more intend to maintain the subnet control in code, so the fix should be just delete the subnet toggle in firewall set up

@vanzue vanzue closed this May 20, 2025
@vanzue vanzue force-pushed the dev/vanzue/fix-mwb-firewall branch from 390c868 to 75121ca Compare May 20, 2025 02:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants