-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Harden macOS system-proxy service resolution to prevent apiInvoke toggle failures
#617
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4a3bf97
Initial plan
Copilot cc00bfa
fix(core): robust mac network service detection for system proxy
Copilot 140f8dc
test(core): cover mac proxy service parsing edge cases
Copilot a666f03
fix(core): remove pipe from macOS proxy service fallback, add per-ste…
Copilot 4785aa4
fix(core): prompt for admin authorization when networksetup requires …
Copilot bef21c1
fix: update pnpm-lock.yaml to include request dependency in packages/…
Copilot 0863799
Merge branch 'master' into copilot/fix-system-proxy-error-macos
cute-omega caf9d6c
Changes before error encountered
Copilot 6b442b3
Merge branch 'master' into copilot/fix-system-proxy-error-macos
cute-omega File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| const assert = require('node:assert') | ||
| const setSystemProxy = require('../src/shell/scripts/set-system-proxy') | ||
|
|
||
| // eslint-disable-next-line no-undef | ||
| describe('set-system-proxy mac helpers', () => { | ||
| // eslint-disable-next-line no-undef | ||
| it('should parse service by device from listnetworkserviceorder output', () => { | ||
| const networkServiceOrder = ` | ||
| (1) Wi-Fi | ||
| (Hardware Port: Wi-Fi, Device: en0) | ||
| (2) Thunderbolt Bridge | ||
| (Hardware Port: Thunderbolt Bridge, Device: bridge0) | ||
| `.trim() | ||
| const service = setSystemProxy.parseMacNetworkServiceByDevice(networkServiceOrder, 'en0') | ||
| assert.strictEqual(service, 'Wi-Fi') | ||
| assert.strictEqual(setSystemProxy.parseMacNetworkServiceByDevice('', 'en0'), null) | ||
| assert.strictEqual(setSystemProxy.parseMacNetworkServiceByDevice(networkServiceOrder, ''), null) | ||
| }) | ||
|
|
||
| // eslint-disable-next-line no-undef | ||
| it('should parse route device from route output', () => { | ||
| const routeOutput = ` | ||
| route to: default | ||
| interface: en0 | ||
| flags: <UP,GATEWAY,DONE,STATIC,PRCLONING,GLOBAL> | ||
| `.trim() | ||
| const device = setSystemProxy.parseMacRouteDevice(routeOutput) | ||
| assert.strictEqual(device, 'en0') | ||
| assert.strictEqual(setSystemProxy.parseMacRouteDevice(''), null) | ||
| assert.strictEqual(setSystemProxy.parseMacRouteDevice(null), null) | ||
| }) | ||
|
|
||
| // eslint-disable-next-line no-undef | ||
| it('should fallback to preferred Wi-Fi service when available', () => { | ||
| const listAllNetworkServicesOutput = ` | ||
| USB 10/100/1000 LAN | ||
| Wi-Fi | ||
| Thunderbolt Bridge | ||
| `.trim() | ||
| const service = setSystemProxy.pickMacNetworkService(listAllNetworkServicesOutput) | ||
| assert.strictEqual(service, 'Wi-Fi') | ||
| }) | ||
|
|
||
| // eslint-disable-next-line no-undef | ||
| it('should fallback to first service when preferred service is unavailable', () => { | ||
| const listAllNetworkServicesOutput = ` | ||
| USB 10/100/1000 LAN | ||
| Thunderbolt Bridge | ||
| `.trim() | ||
| const service = setSystemProxy.pickMacNetworkService(listAllNetworkServicesOutput) | ||
| assert.strictEqual(service, 'USB 10/100/1000 LAN') | ||
| }) | ||
|
|
||
| // eslint-disable-next-line no-undef | ||
| it('should support disabled service prefix and empty input', () => { | ||
| const listAllNetworkServicesOutput = ` | ||
| *Wi-Fi | ||
| Thunderbolt Bridge | ||
| `.trim() | ||
| const service = setSystemProxy.pickMacNetworkService(listAllNetworkServicesOutput) | ||
| assert.strictEqual(service, 'Wi-Fi') | ||
| assert.strictEqual(setSystemProxy.pickMacNetworkService(''), null) | ||
| assert.strictEqual(setSystemProxy.pickMacNetworkService(null), null) | ||
| }) | ||
|
|
||
| // eslint-disable-next-line no-undef | ||
| it('should ignore the "An asterisk" header line produced by networksetup -listallnetworkservices', () => { | ||
| const fullOutput = `An asterisk (*) denotes that a network service is disabled. | ||
| Ethernet | ||
| Wi-Fi | ||
| Thunderbolt Bridge` | ||
| assert.strictEqual(setSystemProxy.pickMacNetworkService(fullOutput), 'Wi-Fi') | ||
|
|
||
| const fullOutputEthernetOnly = `An asterisk (*) denotes that a network service is disabled. | ||
| Ethernet | ||
| Thunderbolt Bridge` | ||
| assert.strictEqual(setSystemProxy.pickMacNetworkService(fullOutputEthernetOnly), 'Ethernet') | ||
| }) | ||
| }) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.