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

Only load IPFS subresources within IPFS/IPNS schemes #7194

Merged
merged 8 commits into from
Nov 27, 2020
Merged

Conversation

bbondy
Copy link
Member

@bbondy bbondy commented Nov 19, 2020

When a local node is installed, by visiting a page that allows you to load IPFS resources, it will then make you a host of any resources that the page loads. To avoid this, this PR makes ipfs:// and ipns subresources only load when the top level main frame is also ipfs:// or ipns://.

This PR also fixes a problem where iframes would not load at all that were ipfs scheme.

It also removes the external protocol handler that existed.

Resolves brave/brave-browser#12546
Resolves brave/brave-browser#12931

Submitter Checklist:

  • There is a ticket for my issue.
  • Used Github auto-closing keywords in the commit message.
  • Wrote a good PR/commit description
  • 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).
  • Requested a security/privacy review as needed.

Reviewer Checklist:

  • 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:

@bbondy bbondy requested review from iefremov and a team as code owners November 19, 2020 16:00
@bbondy bbondy self-assigned this Nov 19, 2020
@yrliou yrliou self-requested a review November 19, 2020 16:31
@bbondy bbondy force-pushed the ipfs-same-scheme branch 2 times, most recently from d706b02 to afe446d Compare November 19, 2020 17:20
Copy link
Collaborator

@mkarolin mkarolin 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 override LGTM

Copy link
Member

@yrliou yrliou left a comment

Choose a reason for hiding this comment

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

LGTM!

namespace network_utils {

bool IsURLHandledByNetworkService(const GURL& url) {
if (url.SchemeIs("ipns") || url.SchemeIs("ipfs")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

minor, but I'd try to transform all of "ipfs"/"ipns" to some constant defined somewhere at ipfs_constants.h

Copy link
Member Author

Choose a reason for hiding this comment

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

I think I'd have to patch in a dependency in that case no?

Copy link
Contributor

Choose a reason for hiding this comment

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

right, np then

ASSERT_TRUE(ExecuteScriptAndExtractBool(

std::string location;
ASSERT_TRUE(ExecuteScriptAndExtractString(
Copy link
Contributor

Choose a reason for hiding this comment

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

ExecuteScriptAndExtractString is deprecated in favor of EvalJs (see browser_test_utils.h). Also it should be possible to set an onload handler (i.e. avoid using the timer)

Copy link
Member Author

Choose a reason for hiding this comment

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

ok thanks

"}, 100);",
&location));

ASSERT_EQ(location, "chrome-error://chromewebdata/");
Copy link
Contributor

Choose a reason for hiding this comment

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

I think EXPECT_EQ is more widespreaded across the codebase

Copy link
Member Author

Choose a reason for hiding this comment

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

I think they are different, expect eq keeps running the test but assert eq fails the test instantly

Copy link
Contributor

Choose a reason for hiding this comment

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

They are indeed different, and the default choice is typically EXPECT_EQ. Not something important, especially for the last assertion in a test, just style

@bbondy bbondy force-pushed the ipfs-same-scheme branch 2 times, most recently from 13a83ad to 8d5e0ae Compare November 25, 2020 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants