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

Update the PhishingController to v2 and update phishing warning page #17835

Merged
merged 2 commits into from
Feb 24, 2023

Conversation

Gudahtt
Copy link
Member

@Gudahtt Gudahtt commented Feb 20, 2023

The PhishingController has been updated to v2. This release should dramatically reduce network traffic and double the update speed of the phishing list.

This was accomplished by combining both of our phishing configurations into one list (the "stalelist"), then creating a separate list of the changes just the past few days (the "hotlist"). Now users will download a smaller list more frequently (every 30 minutes rather than every hour), whereas the full list is only updated every 4 days.

The combined configuration means that we no longer know which list was responsible for each block. The phishing warning page has been updated to dynamically look this information up, to ensure users are still directed to the correct place to dispute a block. This update to the phishing warning page also includes the recent redesign.

Screenshots/Screencaps

The architectural changes can't be seen visually, but this PR also includes the phishing warning page redesign.

You can see those differences visually by looking at this the description for this PR: MetaMask/phishing-warning#52

Manual Testing Steps

To test the new phishing warning page design, you can go through the usual steps to test the phishing warning page (see our phishing warning e2e tests for a few example workflows).

For the architectural changes to how the phishing configuration is updated, we can prepare and install a build, then wait for a phishing config update (maybe we can coordinate with one of the eth-phishing-detect maintainers to merge something at the right time). You should see the update within 0-60 minutes (max 30 minute delay on our API updating, and max 30 minute delay on the client requesting the updated config from the API). You could leave the background process dev tools open to see the network request, and confirm that it is a relatively small diff.

Pre-merge author checklist

  • I've clearly explained:
    • What problem this PR is solving
    • How this problem was solved
    • How reviewers can test my changes
  • Sufficient automated test coverage has been added

Pre-merge reviewer checklist

  • Manual testing (e.g. pull and build branch, run in browser, test code being changed)
  • PR is linked to the appropriate GitHub issue
  • IF this PR fixes a bug in the release milestone, add this PR to the release milestone

If further QA is required (e.g. new feature, complex testing steps, large refactor), add the Extension QA Board label.

In this case, a QA Engineer approval will be be required.

@socket-security
Copy link

socket-security bot commented Feb 20, 2023

Socket Security Pull Request Report

👍 No new dependency issues detected in pull request

Pull request report summary
Issue Status
Install scripts ✅ 0 issues
Native code ✅ 0 issues
Bin script shell injection ✅ 0 issues
Unresolved require ✅ 0 issues
Invalid package.json ✅ 0 issues
HTTP dependency ✅ 0 issues
Git dependency ✅ 0 issues
Potential typo squat ✅ 0 issues
Known Malware ✅ 0 issues
Telemetry ✅ 0 issues
Protestware/Troll package ✅ 0 issues
Bot Commands

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of package-name@version specifiers. e.g. @SocketSecurity ignore [email protected] [email protected]

Powered by socket.dev

@Gudahtt Gudahtt force-pushed the update-phishing-controller branch 4 times, most recently from 6e7b856 to f712ac3 Compare February 20, 2023 19:55
@@ -341,6 +356,22 @@ async function setupMocking(server, testSpecificMock) {
});

testSpecificMock(server);

// Mocks below this line can be overridden by test-specific mocks
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 wanted to set default mocks for these requests, but override them in the phishing tests. I found that this only worked if they were declared below this line. Presumably the first handler wins with mockttp.

cc @PeterYinusa , tagging you in case I'm missing something here, since you set this up.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for tagging me here. I think I should probably add some comment blocks/documentation to provide clarity on the mocks.
Personally, I feel it needs to be cleaned up a little, as the use cases increased as we added additional test cases. Here's some general info on how it's intended to work at the moment.

  1. Global mocks: Mocks in this file are supposed to be global (across all tests). These mocks are set up before the extension is installed.
  2. Local mocks: Some mocks are specific to a single test. In this case, we use do not put them in the global mocks file, but instead place them directly in the test. Another reason we may place the mock directly in the test, is so we can do assertions on the requests.
  3. Local pre-installation mocks: These are mocks that need to be in place before the extension is installed and are specific to a single test.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, that all makes sense.

This case still isn't clear though. Here I want to use a global mock, but override it for a specific test. Does placing it here before the invocation of the local pre-installation mocks make sense? Should we let all global mocks be overridden in this way?

Copy link
Contributor

Choose a reason for hiding this comment

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

Created an issue here to tidy things up #17843

Copy link
Contributor

Choose a reason for hiding this comment

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

Presumably the first handler wins with mockttp.

I believe this is the case.

Copy link
Contributor

@PeterYinusa PeterYinusa Feb 21, 2023

Choose a reason for hiding this comment

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

Does placing it here before the invocation of the local pre-installation mocks make sense? Should we let all global mocks be overridden in this way?

This makes sense to me. Then we can actually remove the usage of a reset here and make it a test-specific mock

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, in reference to my comment above, we would still need a way to do assertions on a request.
But your suggestion seems sound to me.

@Gudahtt Gudahtt changed the base branch from develop to update-metamask-utils February 20, 2023 20:00
@Gudahtt

This comment was marked as resolved.

@Gudahtt Gudahtt force-pushed the update-phishing-controller branch from f712ac3 to 5b8597f Compare February 20, 2023 20:04
@Gudahtt

This comment was marked as resolved.

Base automatically changed from update-metamask-utils to develop February 21, 2023 14:49
@Gudahtt Gudahtt force-pushed the update-phishing-controller branch 2 times, most recently from d7e3284 to 5a05979 Compare February 21, 2023 19:55
@Gudahtt Gudahtt marked this pull request as ready for review February 21, 2023 19:55
@Gudahtt Gudahtt requested a review from a team as a code owner February 21, 2023 19:55
@Gudahtt Gudahtt requested a review from digiwand February 21, 2023 19:55
@metamaskbot
Copy link
Collaborator

Builds ready [5a05979]
Page Load Metrics (1645 ± 74 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint104148121115
domContentLoaded14372012160315173
load14782111164515574
domInteractive14372012160315173
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 2949 bytes
  • ui: 0 bytes
  • common: 0 bytes

@Gudahtt Gudahtt marked this pull request as draft February 21, 2023 21:06
@Gudahtt

This comment was marked as resolved.

@Gudahtt Gudahtt marked this pull request as ready for review February 21, 2023 22:06
@Gudahtt Gudahtt added the needs-qa Label will automate into QA workspace label Feb 21, 2023
@Gudahtt Gudahtt changed the title Update the PhishingController to v2 Update the PhishingController to v2 and update phishing warning page Feb 22, 2023
@danjm
Copy link
Contributor

danjm commented Feb 22, 2023

@Gudahtt looking at the other PR you linked, I saw this unresolved question: https://github.com/MetaMask/phishing-warning/pull/52/files#r1106413619

Was it addressed at some point?

const mux = setupMultiplex(connectionStream);
const phishingStream = mux.createStream('phishing');
phishingStream.write({ hostname, newIssueUrl });
Copy link
Contributor

Choose a reason for hiding this comment

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

should newIssueUrl be removed from the redirectToPhishingWarning function in contentScript as well?

const { newIssueUrl } = data;

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, great catch

Copy link
Member Author

Choose a reason for hiding this comment

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

Done here: 5ab6a37

Copy link
Contributor

@danjm danjm left a comment

Choose a reason for hiding this comment

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

I have a couple of questions and can approve from a code review perspective once they are resolved.

Also, I see that this has been marked for manual QA from the QA team @PeterYinusa @chloeYue @tmashuang

@Gudahtt
Copy link
Member Author

Gudahtt commented Feb 22, 2023

Was it addressed at some point?

Yes, just replied to that with a link to the PR where the test was restored. Though all of those tests were later replaced by Playwright tests anyway.

@Gudahtt Gudahtt force-pushed the update-phishing-controller branch from 5a05979 to 5ab6a37 Compare February 22, 2023 20:36
@metamaskbot
Copy link
Collaborator

Builds ready [5ab6a37]
Page Load Metrics (1505 ± 38 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint932371163215
domContentLoaded1379164314816531
load1379164915057838
domInteractive1379164314816531
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 2949 bytes
  • ui: 0 bytes
  • common: 0 bytes

danjm
danjm previously approved these changes Feb 23, 2023
Copy link
Contributor

@danjm danjm left a comment

Choose a reason for hiding this comment

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

LGTM

brad-decker
brad-decker previously approved these changes Feb 23, 2023
Copy link
Contributor

@brad-decker brad-decker left a comment

Choose a reason for hiding this comment

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

LGTM

The PhishingController has been updated to v2. This release should
dramatically reduce network traffic and double the update speed of the
phishing list.

This was accomplished by combining both of our phishing configurations
into one list (the "stalelist"), then creating a separate list of the
changes just the past few days (the "hotlist"). Now users will download
a smaller list more frequently (every 30 minutes rather than every
hour), whereas the full list is only updated every 4 days.

The combined configuration means that we no longer know which list was
responsible for each block. The phishing warning page has been updated
to dynamically look this information up, to ensure users are still
directed to the correct place to dispute a block. This update to the
phishing warning page also includes the recent redesign.
@Gudahtt Gudahtt dismissed stale reviews from brad-decker and danjm via 37cb677 February 24, 2023 13:35
@Gudahtt Gudahtt force-pushed the update-phishing-controller branch from 5ab6a37 to 37cb677 Compare February 24, 2023 13:35
@Gudahtt
Copy link
Member Author

Gudahtt commented Feb 24, 2023

Rebased to resolve a conflict in package.json

@chloeYue
Copy link
Contributor

QA test OK, LGTM, thanks!

@metamaskbot
Copy link
Collaborator

Builds ready [37cb677]
Page Load Metrics (1509 ± 42 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint912911144120
domContentLoaded1393167814887335
load1405167815098742
domInteractive1393167814887335
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 2949 bytes
  • ui: 0 bytes
  • common: 0 bytes

@Gudahtt Gudahtt merged commit 2ccc197 into develop Feb 24, 2023
@Gudahtt Gudahtt deleted the update-phishing-controller branch February 24, 2023 15:09
@github-actions github-actions bot locked and limited conversation to collaborators Feb 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs-qa Label will automate into QA workspace rc-cherry-picked team-extension-platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants