This repository has been archived by the owner on Jan 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #203 from brave/fix-13296
Ensuring phishfort urls are always taken in to consideration for phishing detection
- Loading branch information
Showing
1 changed file
with
16 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,30 @@ | ||
import { PhishingController } from '@metamask/controllers' | ||
|
||
const PhishingDetector = require('eth-phishing-detect/src/detector') | ||
|
||
export default class BravePhishingController extends PhishingController { | ||
constructor (config, state) { | ||
super(config, state) | ||
this.configUrl = 'https://mainnet-infura-api.brave.com/blacklist' | ||
this.phishfortResourceUrl = 'https://mainnet-infura-api.brave.com/phishfort' | ||
} | ||
|
||
async updatePhishingLists () { | ||
if (this.disabled) { | ||
return | ||
} | ||
|
||
// Whitelists and tolerances still need to be fetched from the original endpoint | ||
await super.updatePhishingLists() | ||
|
||
async fetchPhishfortDenyList () { | ||
const phishFortDenylist = await fetch(this.phishfortResourceUrl) // eslint-disable-line no-undef | ||
const parsedList = await phishFortDenylist.json() | ||
return await phishFortDenylist.json() | ||
} | ||
|
||
if (parsedList && this.detector) { | ||
this.detector.blacklist = parsedList | ||
async update (state, overwrite = false) { | ||
if (state.phishing && state.phishing.blacklist) { | ||
const denyList = await this.fetchPhishfortDenyList() | ||
if (denyList) { | ||
state.phishing.blacklist = [ | ||
...state.phishing.blacklist, | ||
...denyList, | ||
] | ||
this.detector = new PhishingDetector(state.phishing) | ||
} | ||
} | ||
super.update(state, overwrite) | ||
} | ||
} |