urbanadventurer / WhatWeb

Next generation web scanner
https://www.morningstarsecurity.com/research/whatweb
GNU General Public License v2.0
5.19k stars 885 forks source link

Fix #311 - JSON Logging fails... UTF-8 can't modify frozen String #359

Closed juananpe closed 3 years ago

juananpe commented 3 years ago

The problem is in lib/helper.rb, convert_to_utf8 method. It tries to change a frozen String. Probably because whatweb detects a multi-version CMS (e.g., Wordpress 4.x and 4.y.)

https://github.com/urbanadventurer/WhatWeb/blob/1b3516975571c3f59d686f82a6d2dbf6f1011029/lib/helper.rb#L38-L47

Tracing the origin of this bug I think that the main reason is the following:

https://github.com/urbanadventurer/WhatWeb/blob/1b3516975571c3f59d686f82a6d2dbf6f1011029/lib/plugins.rb#L58-L59

Plugins's names are frozen, so trying to encode them twice (or more) to UTF-8 (due to multiple-version detection) will yield the error.

With this PR I propose a simple workaround in lib/helper.rb.

I don't have a Ruby 2.0 version available here to test that branch of the if conditional. In fact, I'd suggest to remove that branch and ask for at least Ruby 2.1 (available since 2013!)

What do you think?

urbanadventurer commented 3 years ago

This LGTM. Dropping Ruby 2.0 support seems reasonable too. Thanks @juananpe