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

Persist phishing state controller state. #16643

Merged
merged 3 commits into from
Jan 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,13 @@ export default class MetamaskController extends EventEmitter {
},
});

this.phishingController = new PhishingController();
this.phishingController.updatePhishingLists();
this.phishingController = new PhishingController(
{},
initState.PhishingController,
);

this.phishingController.maybeUpdatePhishingLists();

if (process.env.IN_TEST) {
this.phishingController.setRefreshInterval(5 * SECOND);
}
Expand Down Expand Up @@ -1094,6 +1099,7 @@ export default class MetamaskController extends EventEmitter {
TokensController: this.tokensController,
SmartTransactionsController: this.smartTransactionsController,
NftController: this.nftController,
PhishingController: this.phishingController,
///: BEGIN:ONLY_INCLUDE_IN(flask)
SnapController: this.snapController,
CronjobController: this.cronjobController,
Expand Down Expand Up @@ -3480,10 +3486,7 @@ export default class MetamaskController extends EventEmitter {

if (sender.url) {
const { hostname } = new URL(sender.url);
const phishingListsAreOutOfDate = this.phishingController.isOutOfDate();
if (phishingListsAreOutOfDate) {
this.phishingController.updatePhishingLists();
}
this.phishingController.maybeUpdatePhishingLists();
// Check if new connection is blocked if phishing detection is on
const phishingTestResponse = this.phishingController.test(hostname);
if (usePhishDetect && phishingTestResponse?.result) {
Expand Down
7 changes: 1 addition & 6 deletions lavamoat/browserify/beta/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -1081,18 +1081,13 @@
"fetch": true
},
"packages": {
"@metamask/base-controller": true,
"@metamask/controller-utils": true,
"@metamask/controller-utils>isomorphic-fetch": true,
"@metamask/phishing-controller>@metamask/base-controller": true,
"@metamask/phishing-controller>eth-phishing-detect": true,
"punycode": true
}
},
"@metamask/phishing-controller>@metamask/base-controller": {
"packages": {
"immer": true
}
},
"@metamask/phishing-controller>eth-phishing-detect": {
"packages": {
"eslint>optionator>fast-levenshtein": true
Expand Down
7 changes: 1 addition & 6 deletions lavamoat/browserify/flask/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -1093,18 +1093,13 @@
"fetch": true
},
"packages": {
"@metamask/base-controller": true,
"@metamask/controller-utils": true,
"@metamask/controller-utils>isomorphic-fetch": true,
"@metamask/phishing-controller>@metamask/base-controller": true,
"@metamask/phishing-controller>eth-phishing-detect": true,
"punycode": true
}
},
"@metamask/phishing-controller>@metamask/base-controller": {
"packages": {
"immer": true
}
},
"@metamask/phishing-controller>eth-phishing-detect": {
"packages": {
"eslint>optionator>fast-levenshtein": true
Expand Down
7 changes: 1 addition & 6 deletions lavamoat/browserify/main/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -1081,18 +1081,13 @@
"fetch": true
},
"packages": {
"@metamask/base-controller": true,
"@metamask/controller-utils": true,
"@metamask/controller-utils>isomorphic-fetch": true,
"@metamask/phishing-controller>@metamask/base-controller": true,
"@metamask/phishing-controller>eth-phishing-detect": true,
"punycode": true
}
},
"@metamask/phishing-controller>@metamask/base-controller": {
"packages": {
"immer": true
}
},
"@metamask/phishing-controller>eth-phishing-detect": {
"packages": {
"eslint>optionator>fast-levenshtein": true
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@
"@metamask/notification-controller": "^1.0.0",
"@metamask/obs-store": "^5.0.0",
"@metamask/permission-controller": "^1.0.0",
"@metamask/phishing-controller": "^1.0.0",
"@metamask/phishing-controller": "^1.1.0",
"@metamask/post-message-stream": "^6.0.0",
"@metamask/providers": "^10.2.1",
"@metamask/rate-limit-controller": "^1.0.0",
Expand Down Expand Up @@ -563,7 +563,8 @@
"web3>web3-shh": false,
"@keystonehq/metamask-airgapped-keyring>@keystonehq/base-eth-keyring>hdkey>secp256k1": false,
"@metamask/base-controller>simple-git-hooks": false,
"@storybook/core>@storybook/core-server>webpack>watchpack>watchpack-chokidar2>chokidar>fsevents": false
"@storybook/core>@storybook/core-server>webpack>watchpack>watchpack-chokidar2>chokidar>fsevents": false,
"resolve-url-loader>es6-iterator>es5-ext": false
}
},
"packageManager": "[email protected]"
Expand Down
14 changes: 7 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3735,17 +3735,17 @@ __metadata:
languageName: node
linkType: hard

"@metamask/phishing-controller@npm:^1.0.0":
version: 1.0.0
resolution: "@metamask/phishing-controller@npm:1.0.0"
"@metamask/phishing-controller@npm:^1.1.0":
version: 1.1.0
resolution: "@metamask/phishing-controller@npm:1.1.0"
dependencies:
"@metamask/base-controller": ~1.0.0
"@metamask/controller-utils": ~1.0.0
"@metamask/base-controller": ^1.1.1
"@metamask/controller-utils": ^1.0.0
"@types/punycode": ^2.1.0
eth-phishing-detect: ^1.2.0
isomorphic-fetch: ^3.0.0
punycode: ^2.1.1
checksum: e5e31f68611c14b30cfd639b99a97921cac1d13af534fa1586bce63075895486d89c554aaa5f5201245f51981a0a8a1f9aeeea8652e22c9523b01f8880de4de6
checksum: bc8c066dd9ed3fff9456ffd2d888c5c78e45a4f4b8e19903caa47b07f42bb298c95956d5df22aef805dbbf2dac6dfb5291f605636fb0725417ae6e0d1c14528a
languageName: node
linkType: hard

Expand Down Expand Up @@ -22887,7 +22887,7 @@ __metadata:
"@metamask/notification-controller": ^1.0.0
"@metamask/obs-store": ^5.0.0
"@metamask/permission-controller": ^1.0.0
"@metamask/phishing-controller": ^1.0.0
"@metamask/phishing-controller": ^1.1.0
"@metamask/phishing-warning": ^1.2.1
"@metamask/post-message-stream": ^6.0.0
"@metamask/providers": ^10.2.1
Expand Down