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

Append phishfort blocklist #715

Merged
merged 25 commits into from
Jun 1, 2022

Conversation

moosthuizen42
Copy link
Contributor

@moosthuizen42 moosthuizen42 commented Mar 8, 2022

PhishFort phishing blacklist

Included PhishFort blacklist in the default blacklist used to perform phishing detection.

Description

  • ADDED:

    • Fetch of public PhishFort blacklist via cdnjs / GitHub.
    • Inclusion of entries in the PhishFort blacklist into the one used by default (published as part of MetaMask/eth-phishing-detect)
    • Some tests to check for successful detection of entries from the PhishFort blacklist.

Checklist

  • Tests are included if applicable
  • Any added code is fully documented

@moosthuizen42 moosthuizen42 requested a review from a team as a code owner March 8, 2022 17:48
@korn101
Copy link
Contributor

korn101 commented Mar 9, 2022

Submitted w/ explanation to @sethkfman via email.

@sethkfman sethkfman changed the title Append phishfort blacklist Append phishfort blocklist Mar 17, 2022
@moosthuizen42
Copy link
Contributor Author

I have updated the PR with the following:

  • Removal of duplicates before appending the PhishFort hotlist.
  • Graceful failure if only one list is accessible.
  • Updated queryConfig to make the above possible (it no longer throws errors for certain HTTP codes and not for others).

The only thing discussed above but not yet catered for is tying back a specific blocklist entry to a list. The Detector from eth-phishing-detect would likely also need to change to do this, or alternatively the architecture of the PhishingController would need a revamp to allow for multiple PhishingDetector instances.

I would like to get this merged for the sake of getting users protected sooner rather than later, while we work out list separation separately, preferably in its own PR.

@moosthuizen42 moosthuizen42 marked this pull request as draft March 24, 2022 12:48
@moosthuizen42 moosthuizen42 marked this pull request as ready for review March 24, 2022 12:50
@Gudahtt
Copy link
Member

Gudahtt commented Mar 24, 2022

Good point that the detector would require an update to distinguish which list the block came from. Still, I think that is important enough to block this. eth-phishing-detect is difficult enough to maintain as it is, I don't want to make their jobs any more difficult. I can take a look at updating the detector within the next few days.

@moosthuizen42
Copy link
Contributor Author

@Gudahtt Noted. My understanding is that you intend to make the required changes to eth-phishing-detect to allow for multiple list inputs. What are you envisioning in terms of input to the PhishingController? I could suggest the following:

{
    version: number;
    tolerance: number;
    blacklist: string[];
    fuzzylist: string[];
    whitelist: string[];
    provider: string; // eg. MetaMask, PhishFort, Umbrella Corporation, etc.
    disputeUrl: string; // Or reportingUrl if that does not cause ambiguity
}[]

@Gudahtt
Copy link
Member

Gudahtt commented Apr 6, 2022

I have a PR up now that implements support for multiple configurations on the phishing detector: MetaMask/eth-phishing-detect#7079

Thanks for the suggested configuration @moosthuizen42 . I mostly used that, except I omitted disputeUrl because we can consider that to be outside the responsibilities of the phishing detector. Returning the config name with the match is sufficient for the user of the detector to add whatever metadata they want, which might extend beyond just a dispute URL.

@moosthuizen42
Copy link
Contributor Author

Thanks @Gudahtt. I'll keep an eye on #7079. Once merged, I intend to update the version of eth-phishing-detect used in our fork, and then integrate both configurations.

@Gudahtt
Copy link
Member

Gudahtt commented Apr 19, 2022

v1.2.0 of eth-phishing-detect was just published with support for multiple phishing configurations. Let me know how it works out!

@Gudahtt
Copy link
Member

Gudahtt commented Apr 22, 2022

That would be ideal, yeah. We do want to have all properties tested. Though it seems there aren't any fuzzylist tests right now, so those would need to be added. We could use tests for the multi-config setup as well.

@Gudahtt
Copy link
Member

Gudahtt commented Apr 22, 2022

Not sure how much of the test improvements to ask you to complete here. I try to ensure that all new changes are fully tested but not to require adding tests that were already missing in the first place, as a general rule. So if you wanted to add fuzzylist tests, that would be great, but I would accept this with just additional assertions for the type property on the current test(...) tests, plus a few more tests to ensure that the "allow" and "block" cases work properly with multiple configs, with assertions for the config name.

@moosthuizen42
Copy link
Contributor Author

Done. A sequence of fuzzylist tests added as well. @Gudahtt, once you have taken a look, please confirm that everything you expect to see is there.

test_results_PhishingController

Other minor changes:

  • EthPhishingDetectResult was missing match?: string, fixed.
  • Tests intended to verify behaviour for inaccessible configs changed to HTTP 500 instead of 304.

Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

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

Sorry I'm only just now realizing that the legacy config remains in use until the first update. Could you update the constructor to use the new format as well, passing in the config as an array? I think this would be simpler if we moved directly to the new format, so we wouldn't have to anticipate the two different return types.

src/third-party/PhishingController.ts Outdated Show resolved Hide resolved
@moosthuizen42
Copy link
Contributor Author

Sorry I'm only just now realizing that the legacy config remains in use until the first update. Could you update the constructor to use the new format as well, passing in the config as an array? I think this would be simpler if we moved directly to the new format, so we wouldn't have to anticipate the two different return types.

Done. Testing references to legacy config have been replaced with default config.

Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

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

LGTM, great work! The tests look fantastic except that the fuzzylist tests don't check the match property on the result. But that's fine, I can add that later.

@Gudahtt
Copy link
Member

Gudahtt commented Apr 25, 2022

Looks like I don't have permission to make commits on this branch. I can merge this after my suggestion is addressed or merged, and the lint errors are fixed.

@Gudahtt
Copy link
Member

Gudahtt commented Apr 26, 2022

More lint errors. Please run yarn lint:fix locally, and double check that the build and tests pass as well.

@moosthuizen42
Copy link
Contributor Author

Noted, haven't gotten around to linting yet. Will notify once done.

@moosthuizen42
Copy link
Contributor Author

@Gudahtt Linting done, build and test complete successfully. Please note that I am only running the PhishingController.test.ts tests.

@moosthuizen42 moosthuizen42 requested a review from Gudahtt April 28, 2022 13:14
Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

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

LGTM! Holding off a bit on merging this, as I'm going to talk this over with the product teams first and see what it would take to get this change included.

@moosthuizen42
Copy link
Contributor Author

@Gudahtt Any update on this?

@Gudahtt
Copy link
Member

Gudahtt commented May 31, 2022

Hey @moosthuizen42 , sorry for the delay! Got side-tracked for a few of weeks, was about to come back to this. I have talked to both product teams and we're all on board with including this in the next release, so this can be merged now once it's brought up to date. Can you update the branch?

@Gudahtt Gudahtt merged commit 807ba1f into MetaMask:main Jun 1, 2022
@adonesky1 adonesky1 mentioned this pull request Jun 7, 2022
MajorLift pushed a commit that referenced this pull request Oct 11, 2023
* Append PhishFort blacklist, whitelist to detection

* Typo fix

* Removed unnecessary list

* Swapped out blacklist with lighter "hotlist"

* collapse sequential queries

* Updated queryConfig, graceful failure of one list.

* Updated eth-phishing-detect to v1.2

* Add config interface, shaping of configs.

* Updated tests for multiple configs

* Return EthPhishingDetectResult from check(...)

* Tests: 'type' & 'name' checks, fuzzy & legacy cnf.

* Update src/third-party/PhishingController.ts

Co-authored-by: Mark Stacey <[email protected]>

* Updated default config & related tests

* Update src/third-party/PhishingController.ts

Co-authored-by: Mark Stacey <[email protected]>

* Update src/third-party/PhishingController.ts

Co-authored-by: Mark Stacey <[email protected]>

* Linting

Co-authored-by: korn101 <[email protected]>
Co-authored-by: Mark Stacey <[email protected]>
MajorLift pushed a commit that referenced this pull request Oct 11, 2023
* Append PhishFort blacklist, whitelist to detection

* Typo fix

* Removed unnecessary list

* Swapped out blacklist with lighter "hotlist"

* collapse sequential queries

* Updated queryConfig, graceful failure of one list.

* Updated eth-phishing-detect to v1.2

* Add config interface, shaping of configs.

* Updated tests for multiple configs

* Return EthPhishingDetectResult from check(...)

* Tests: 'type' & 'name' checks, fuzzy & legacy cnf.

* Update src/third-party/PhishingController.ts

Co-authored-by: Mark Stacey <[email protected]>

* Updated default config & related tests

* Update src/third-party/PhishingController.ts

Co-authored-by: Mark Stacey <[email protected]>

* Update src/third-party/PhishingController.ts

Co-authored-by: Mark Stacey <[email protected]>

* Linting

Co-authored-by: korn101 <[email protected]>
Co-authored-by: Mark Stacey <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants