CodingGarden / sproutkit

Apps and Components for Twitch Overlays
https://sproutkit.now.sh/
MIT License
34 stars 10 forks source link

🔒️ Improve safety of whitelist #9

Closed younesaassila closed 2 years ago

younesaassila commented 2 years ago

Hi CJ!

I worked on a way of improving the safety of Sproutkit's domain whitelist. In chat, I suggested parsing each URL as a URL object and comparing the domain, but I didn't take into account that we're also allowing domains like Imgur with specific paths/images.

Your proposition of having strings in the whitelist and converting them to regular expressions seems like the appropriate choice to resolve the problem -- so this is the method that I implemented here

Btw, feel free to close this PR if you want to implement the fix by yourself on stream :) This PR just serves as a demo, the code is not super clean and behaviors can be refined

Detailed explanations:

Recap of the rules of whitelist URLs: