urbanadventurer / WhatWeb

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

Race condition at launch #277

Closed mlvl42 closed 5 years ago

mlvl42 commented 5 years ago

Infos

whatweb --version
WhatWeb version 0.4.9 ( http://www.morningstarsecurity.com/research/whatweb/ )
ruby --version
ruby 2.5.5p157 (2019-03-15 revision 67260)

whatweb command sample: whatweb https://www.google.com

Problem

After launching whatweb several times with the default parameters and a single url, it randomly exited without returning any information. (This will likely be hard to reproduce) After digging in the source code and debugging a bit, it appears that this condition https://github.com/urbanadventurer/WhatWeb/blob/master/whatweb#L1024 sometimes is true at the very first iteration

target_queue.num_waiting = 25
alive = 25
result_queue.empty? = true

And thus nothing is displayed. I've managed to mitigate this issue by also waiting for the target_queue to be empty:

- alive == target_queue.num_waiting and result_queue.empty?
+ alive == target_queue.num_waiting and result_queue.empty? and target_queue.empty?
urbanadventurer commented 5 years ago

Hi @mguillau42,

You are a champion 🏆 for tracking down this bug! I can't thank you enough. 🙇