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

Normalize ipfs gateway links to CIDs #83309

Merged
merged 2 commits into from
Dec 18, 2024

Conversation

umar-ahmed
Copy link
Contributor

@umar-ahmed umar-ahmed commented Sep 17, 2024

  • Update clean:blocklist script to normalize and extract CIDs from IPFS subdomain gateway links
  • Run script to clean up existing config and remove some duplicates as a result
  • Add a test case to cover the IPFS normalization codepath

@umar-ahmed umar-ahmed marked this pull request as ready for review September 17, 2024 00:59
@umar-ahmed umar-ahmed changed the title chore: manually normalize ipfs links to CIDs chore: normalize ipfs links to CIDs Sep 17, 2024
@umar-ahmed umar-ahmed changed the title chore: normalize ipfs links to CIDs Normalize ipfs links to CIDs Sep 17, 2024
@umar-ahmed umar-ahmed changed the title Normalize ipfs links to CIDs Normalize ipfs gateway links to CIDs Sep 17, 2024
@umar-ahmed umar-ahmed force-pushed the umar/normalize-ipfs-entries branch 2 times, most recently from e8a39ac to 1e475e4 Compare September 22, 2024 17:36
@mindofmar
Copy link
Contributor

Why do we want to only store the IPFS CIDs instead of the full URL? Will this break existing functionality?

@umar-ahmed
Copy link
Contributor Author

Why do we want to only store the IPFS CIDs instead of the full URL?

From my reading of the IPFS code merged into core, it looks like that's how they are expected to be stored in the blocklist.

We currently have duplicate entries in the blocklist as a result of not normalizing, and I'm frankly not even sure if the IPFS blocking is working as intended as a result.

Will this break existing functionality?

I think it will make the blocklist work more effectively for different gateways. So I'd consider this more of a bug fix than a breaking change.


Aside: One thing I didn't fix yet is normalizing the CIDs to a canonical version. It's probably best to normalize to CIDv1 because it has a case-insensitive base32 encoding (https://cid.ipfs.tech/#QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR). But to do this, the detector code in core will need to be updated as well to apply the same transformation from CIDv0 to CIDv1, so I've kept it out of scope for now

@mindofmar
Copy link
Contributor

@umar-ahmed ah I see. So the goal is to be able to block asdf as an IPFS CID regardless of whether a user navigates to it from ipfs.io/ipfs/asdf or asdf.ipfs.dweb.link?

@409H can you confirm that the Phishing Controller now supports just CID as input to block these as intended above?

@umar-ahmed
Copy link
Contributor Author

@umar-ahmed ah I see. So the goal is to be able to block asdf as an IPFS CID regardless of whether a user navigates to it from ipfs.io/ipfs/asdf or asdf.ipfs.dweb.link?

Yup 👍

Those should theoretically be the same content, just available at different gateways, so I think it makes most sense that EPD and PhishingController treat them as such for better coverage

Copy link
Collaborator

@409H 409H left a comment

Choose a reason for hiding this comment

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

lgtm

@409H
Copy link
Collaborator

409H commented Oct 16, 2024

@mindofmar yes looks like it was merged in https://github.com/MetaMask/core/blob/main/packages/phishing-controller/src/PhishingDetector.ts#L119 (MetaMask/phishing-controller@12.0.3)

@409H 409H self-requested a review October 16, 2024 17:59
Copy link
Collaborator

@409H 409H left a comment

Choose a reason for hiding this comment

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

We will wait to merge until rollout complete

@mindofmar
Copy link
Contributor

Hey @umar-ahmed would you mind fixing the merge conflict? We are now ready to deploy this.

@umar-ahmed
Copy link
Contributor Author

Hey @umar-ahmed would you mind fixing the merge conflict? We are now ready to deploy this.

Yup, I can fix those up

@umar-ahmed umar-ahmed force-pushed the umar/normalize-ipfs-entries branch from daf513b to 323f080 Compare December 6, 2024 19:52
@umar-ahmed umar-ahmed requested a review from 409H December 6, 2024 19:54
@umar-ahmed
Copy link
Contributor Author

@mindofmar I've rebased this PR on latest main branch. I decided to remove the changes to config.json from running yarn clean:blocklist to avoid the risk of future conflicts

Once this is merged in, I can create a separate PR to clean up the config.json file

Copy link
Contributor

@AugmentedMode AugmentedMode left a comment

Choose a reason for hiding this comment

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

lgtm

@AugmentedMode AugmentedMode merged commit aa97769 into MetaMask:main Dec 18, 2024
5 checks passed
@umar-ahmed umar-ahmed deleted the umar/normalize-ipfs-entries branch January 7, 2025 20:29
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.

4 participants