-
-
Notifications
You must be signed in to change notification settings - Fork 136
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
Possibe to remove nokogiri dependency? #100
Comments
Hi Mike, Thanks for asking this question. I think we can get to a decision point pretty quickly, but first I'd like to provide some context. Nokogiri, through either libxml2 or xerces/nekohtml, does a decent job of validating and fixing broken markup. Building a valid DOM is actually quite valuable for the sanitization function that Loofah is performing for Rails. Historically, most XSS (and other HTML/js) attack vectors have intentionally used invalid or broken markup to sneak through sanitization. Some historical examples are here:
which are taken directly from the We run these tests in Loofah's test suite to ensure that we're adequately protecting sites; though you'll notice that Loofah itself contains no logic to actually detect or handle invalid markup -- Loofah relies entirely on Nokogiri (and therefore libxml2 and xerces) to catch and remove-or-fix these cases. All of this is to say that, if you wanted to experiment with porting Loofah to use Oga or Ox, as long Loofah's test suite and Rails's sanitization tests all pass, then we can have a more serious conversation about whether to replace Nokogiri entirely, or else have it use a pluggable parser. Does all that make sense? |
(Note my previous comment has been slightly edited.) |
Yeah, you're totally reasonable and I had a feeling this was a Big Change. Removing nokogiri as a Rails dependency is on my wish list but I guess I'll have to ask Santa this year. |
Replacing Nokogiri with X depends on how closely Loofah is tied into the API of Nokogiri. Oga's API is quite different in a bunch of places so I doubt a simple find-replace would suffice. For those interested there's a guide for migrating from Nokogiri to Oga which can be found at http://code.yorickpeterse.com/oga/latest/file.migrating_from_nokogiri.html. |
@yorickpeterse the point I was trying to make above is that this may not be as simple as a mechanical transformation from one backend's API to another's. The behavior of the parser is actually important to the function of sanitization, and so I'm happy to have a conversation about using other backends if we know the test suite will pass. |
@flavorjones Sure, a working test suite is absolutely vital. Also, if the choice is ever made to switch from Nokogiri to X a set of benchmarks would be useful to ensure performance isn't suddenly 9000 times worse. Either way if any help/info is ever needed for Oga feel free to ping me on GitHub or the Twitters. |
No one should be using Nokogiri until they can make it work on OS X with a simple |
@mikbe, thanks for your comment. I've actually participated in dozens of threads and issues for literally hundreds of hours of my life over the last few years, trying to diagnose a wide variety of issues related to Nokogiri working well on OSX. I don't remember seeing your name in any of those threads. Are you familiar with the underlying challenges that you seem to think are so simple to fix? If so, why haven't you shared your diagnoses and participating in fixing the issues? If not, then I don't understand why you'd make a comment like this. I see ruby-talk email from you in my inbox from 2012 and 2011 that appear to be from a kind, thoughtful, empathetic individual. Why did you take time out of your day to make this rude, disrespectful, and (worst of all) contentless comment, exactly? You know there are humans who read these comments, yes? And that those people are not obligated to provide services to you? Don't bother responding. I'm going lock this ticket. Though I would certainly welcome your help in the future, should you decide to participate constructively in the community. |
Nokogiri is a huge native dependency and every Rails install pulls in nokogiri through loofah. Would it be tractable to move to Oga, which has a much smaller native component or Ox?
The text was updated successfully, but these errors were encountered: