Skip to content
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

Polygon for DNS resolution #13202

Merged
merged 7 commits into from
May 13, 2022
Merged

Polygon for DNS resolution #13202

merged 7 commits into from
May 13, 2022

Conversation

supermassive
Copy link
Collaborator

@supermassive supermassive commented Apr 28, 2022

Resolves brave/brave-browser#22147
Resolves brave/brave-browser#22151

Submitter Checklist:

  • I confirm that no security/privacy review is needed, or that I have requested one
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Squashed any review feedback or "fixup" commits before merge, so that history is a record of what happened in the repo, not your PR
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally: npm run test -- brave_browser_tests, npm run test -- brave_unit_tests, npm run lint, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed)

Reviewer Checklist:

  • A security review is not needed, or a link to one is included in the PR description
  • New files have MPL-2.0 license header
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

These domains could be used to test polygon DNS resolution
uns-devtest-fda7a9.x (transaction)
uns-devtest-brave.x(transaction)
both should redirect to https://brave.com/

@supermassive supermassive requested review from a team and iefremov as code owners April 28, 2022 12:24
@github-actions github-actions bot added the CI/run-network-audit Run network-audit label Apr 28, 2022
@supermassive supermassive force-pushed the PolygonDNSResolution branch 2 times, most recently from c82bc9a to d684445 Compare April 29, 2022 04:18
@supermassive supermassive added this to the 1.40.x - Nightly milestone Apr 29, 2022
@supermassive supermassive force-pushed the PolygonDNSResolution branch 4 times, most recently from 57dac57 to 632878d Compare April 29, 2022 06:50
@supermassive supermassive changed the title [WIP] Polygon for DNS resolution Polygon for DNS resolution Apr 29, 2022
@yrliou yrliou self-requested a review May 3, 2022 16:01
@supermassive supermassive force-pushed the PolygonDNSResolution branch 2 times, most recently from 6a730ce to 04732b0 Compare May 5, 2022 12:25
@supermassive supermassive requested a review from a team as a code owner May 5, 2022 12:25
Copy link
Member

@kdenhartog kdenhartog left a comment

Choose a reason for hiding this comment

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

Few comments for the sec team, but I didn't see a security review issue opened for this yet, but it looks like we're code owners on some of the changed files.

@diracdeltas
Copy link
Member

does https://github.com/brave/brave-browser/wiki/Resolve-Methods-for-Unstoppable-Domains need an update here?

also could you remind me what is the expected behavior in Tor windows?

@supermassive
Copy link
Collaborator Author

does https://github.com/brave/brave-browser/wiki/Resolve-Methods-for-Unstoppable-Domains need an update here?

There are some issues in parallel regarding deprecation of DNS over HTTPS UD resolver:
brave/brave-browser#22148
brave/brave-browser#22149
Was going to update wiki as a part of this
#13256 (comment)

also could you remind me what is the expected behavior in Tor windows?

UD and ENS resolvers are disabled for incognito browsers:

ctx->browser_context->IsOffTheRecord() || !g_browser_process) {

@@ -622,6 +622,8 @@ const char kAffiliateAddress[] = "0xbd9420A98a7Bd6B89765e5715e169481602D9c3d";

const int64_t kBlockTrackerDefaultTimeInSeconds = 20;

const char kPolygonMainnetEndpoint[] = "https://mainnet-polygon.brave.com/";
Copy link
Contributor

Choose a reason for hiding this comment

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

constexpr

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added many of them
7d207e0

@@ -92,37 +82,11 @@ void OnBeforeURLRequest_EnsRedirectWork(
void OnBeforeURLRequest_UnstoppableDomainsRedirectWork(
const brave::ResponseCallback& next_callback,
std::shared_ptr<brave::BraveRequestInfo> ctx,
Copy link
Member

Choose a reason for hiding this comment

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

I think we should refactor std::shared_ptr out. not in this PR, but as a separate issue.
cc @iefremov

Copy link
Contributor

Choose a reason for hiding this comment

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

actually it has been with us for so long that I'm thinking of keeping it as a memorial
(just kidding)

"https://brave",
"https://brave.com",
"https://brave.zil",
};
Copy link
Member

Choose a reason for hiding this comment

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

the test could be simplified with struct TestCase { domain, is_valid } to keep only one for and altering an expected value inside.

// for more details.
const constexpr char* const kRecordKeys[] = {
"dweb.ipfs.hash", "ipfs.html.value", "dns.A",
"dns.AAAA", "browser.redirect_url", "ipfs.redirect_domain.value"};
Copy link
Member

Choose a reason for hiding this comment

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

a trailing comma can make such lists look better (and in-sync with the enum above).

"dweb.ipfs.hash", "ipfs.html.value", "dns.A",
"dns.AAAA", "browser.redirect_url", "ipfs.redirect_domain.value"};
static_assert(static_cast<size_t>(RecordKeys::RECORD_KEY_COUNT) ==
sizeof(kRecordKeys) / sizeof(kRecordKeys[0]),
Copy link
Member

Choose a reason for hiding this comment

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

std::size(kRecordKeys) should do the trick (it's now allowed).

namespace brave_wallet::unstoppable_domains {

namespace {
enum RecordKeys {
Copy link
Member

Choose a reason for hiding this comment

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

enum class

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

kept plain enum so there are no static_casts when used as index in vector

DNS_AAAA,
BROWSER_REDIRECT_URL,
IPFS_REDIRECT_DOMAIN_VALUE,
RECORD_KEY_COUNT,
Copy link
Member

Choose a reason for hiding this comment

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

kStyled constants are preferred around Chromium. see also brave_wallet_types.h.
https://google.github.io/styleguide/cppguide.html#Enumerator_Names

Copy link
Member

@goodov goodov left a comment

Choose a reason for hiding this comment

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

chromium_src lgtm, but some other parts can be improved.

@supermassive
Copy link
Collaborator Author

@diracdeltas @kdenhartog PTAL

"dns.AAAA", "browser.redirect_url", "ipfs.redirect_domain.value"};
static_assert(static_cast<size_t>(RecordKeys::RECORD_KEY_COUNT) ==
sizeof(kRecordKeys) / sizeof(kRecordKeys[0]),
"dns.AAAA", "browser.redirect_url", "ipfs.redirect_domain.value",
Copy link
Member

@goodov goodov May 12, 2022

Choose a reason for hiding this comment

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

huh, I was expecting that it will become a one column thing :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It seems it doesn't work like that :D

Copy link
Member

Choose a reason for hiding this comment

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

if you add one more item then it will. I guess there's some logic "if it fits into two rows, keep it, otherwise do a column".

Copy link
Member

@kdenhartog kdenhartog left a comment

Choose a reason for hiding this comment

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

Thanks, my concerns have been addressed. Looks good to me

EDIT: checked with Yan as well and she's good with this going forward. LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI/run-network-audit Run network-audit
Projects
None yet
6 participants