-
Notifications
You must be signed in to change notification settings - Fork 965
Advanced server selection ux #25089
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
Advanced server selection ux #25089
Conversation
4de31c7
to
9390ef8
Compare
1cef4c4
to
0aaa6dc
Compare
A Storybook has been deployed to preview UI for the latest push |
618fbfe
to
b490aea
Compare
A Storybook has been deployed to preview UI for the latest push |
A Storybook has been deployed to preview UI for the latest push |
A Storybook has been deployed to preview UI for the latest push |
be17e54
to
02989ef
Compare
243e82b
to
1bcc82e
Compare
components/brave_vpn/browser/connection/brave_vpn_region_data_manager.cc
Show resolved
Hide resolved
Resolve desktop unittest
9100adc
to
6965c93
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
components/brave_vpn/resources LGTM with some nits
components/brave_vpn/resources/panel/components/main-panel/index.tsx
Outdated
Show resolved
Hide resolved
components/brave_vpn/resources/panel/components/main-panel/index.tsx
Outdated
Show resolved
Hide resolved
components/brave_vpn/resources/panel/components/main-panel/style.ts
Outdated
Show resolved
Hide resolved
components/brave_vpn/resources/panel/components/select-region-list/index.tsx
Show resolved
Hide resolved
components/brave_vpn/resources/panel/components/select-region-list/index.tsx
Show resolved
Hide resolved
components/brave_vpn/resources/panel/components/select-region-list/index.tsx
Show resolved
Hide resolved
components/brave_vpn/resources/panel/components/select-region-list/style.ts
Show resolved
Hide resolved
components/brave_vpn/resources/panel/components/select-region-list/style.ts
Outdated
Show resolved
Hide resolved
}) | ||
|
||
handler.on(Actions.purchaseExpired.getType(), async (store) => { | ||
const [{ currentRegion }, { regions }] = await Promise.all([ | ||
getPanelBrowserAPI().serviceHandler.getSelectedRegion(), | ||
getPanelBrowserAPI().serviceHandler.getAllRegions() | ||
getPanelBrowserAPI().serviceHandler.getAllRegions( | ||
REGION_PRECISION_CITY_BY_COUNTRY |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we ever call this function with a different precision?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, we only call with this arg.
@deeppandya maybe we don't need to have param for this api(GetAllRegions
)?
If you don't mind, I could change this method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assumed that it may be useful for the desktop as it provides a different response based on the region_precision. If it's not useful for the desktop, we can surely get rid of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed by 6f24b64
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whoops accidentally commented instead of approving
[puLL-Merge] - brave/brave-core@25089 DescriptionThis PR implements significant changes to the Brave VPN feature, particularly focusing on the server selection functionality and UI improvements. The changes include updates to the region data structure, new API endpoints, UI enhancements for server selection, and modifications to the VPN service handling. ChangesChanges
Possible Issues
Security HotspotsNo significant security hotspots were identified in this change. However, as with any network-related feature, careful review of the new API endpoints and data handling should be conducted to ensure no sensitive information is exposed. |
@@ -24,13 +28,36 @@ export const getLocale = (key: string, replacements?: Record<string, string>) => | |||
|
|||
if (replacements) { | |||
for (let item in replacements) { | |||
returnVal = returnVal.replace(new RegExp('\\[\\[\\s*' + item + '\\s*\\]\\]'), replacements[item].toString()) | |||
returnVal = returnVal.replace( | |||
new RegExp('\\[\\[\\s*' + item + '\\s*\\]\\]'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reported by reviewdog 🐶
[semgrep] RegExp() called with a replacements
function argument, this might allow an attacker to cause a Regular Expression Denial-of-Service (ReDoS) within your application as RegExP blocks the main thread. For this reason, it is recommended to use hardcoded regexes instead. If your regex is run on user-controlled input, consider performing input validation or use a regex checking/sanitization library such as https://www.npmjs.com/package/recheck to verify that the regex does not appear vulnerable to ReDoS.
Source: https://semgrep.dev/r/javascript.lang.security.audit.detect-non-literal-regexp.detect-non-literal-regexp
Cc @thypon
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just a formatting change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm thanks @simonhong !
Thanks for great review :) |
#if BUILDFLAG(IS_ANDROID) | ||
api_request_->GetServerRegions( | ||
base::BindOnce(&BraveVpnService::OnFetchRegionList, | ||
base::Unretained(this), std::move(callback)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reported by reviewdog 🐶
[semgrep] base::Unretained is most of the time unrequited, and a weak reference is better suited for secure coding.
Consider swapping Unretained for a weak reference.
base::Unretained usage may be acceptable when a callback owner is guaranteed
to be destroyed with the object base::Unretained is pointing to, for example:
- PrefChangeRegistrar
- base::*Timer
- mojo::Receiver
- any other class member destroyed when the class is deallocated
Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/client/chromium-uaf.yaml
Cc @thypon @goodov @iefremov
Resolves brave/brave-browser#36277
Resolves brave/brave-browser#38186
Submitter Checklist:
QA/Yes
orQA/No
;release-notes/include
orrelease-notes/exclude
;OS/...
) to the associated issuenpm run test -- brave_browser_tests
,npm run test -- brave_unit_tests
wikinpm run presubmit
wiki,npm run gn_check
,npm run tslint
git rebase master
(if needed)Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on
Test Plan:
Android
Automatic
Server selection
pageAutomatic
should be selectedOptimal
server location from the selected regionServer selection
pageUSA
as regionOptimal
Best
server location would be selected and it could give different location based on the available resources on the location at the time.Specific server selection
Server selection
pageUSA
as regionAtlanta
Atlanta
should be selected as server locationUpgrade
scenarioServer selection
pageOptimal
should be selected as we didn't have a granular details from previous version.Desktop
BraveVPNServiceTest.*
BraveVPNUtilsUnitTest.*
Optimal
or city name.Optimal
sub entry and its citiesWhen click connect on
Optimal
, main panel's sub label hasOptimal
or city name if clicked on each city entry like the screen shot above at 1 stepWhen click connen on country, it goes with

optimal
.Select server panel has

Automatic
entry at the top. When clicks it, it picks current timezone's regionExisting users will see previously selected country with
Optimal
region