WhatWeb
WhatWeb copied to clipboard
-p argument fails for plugin names when both names and paths are provided
Issue
The -p
argument fails for plugin names when both plugin names and plugin paths are provided.
Priority
Low
Logs
$ ./whatweb -p title,plugins/robots.txt.rb whatweb.net
Error: The following plugins were not found: title
No plugins selected, exiting.
$ ./whatweb -p plugins/title.rb,plugins/robots.txt.rb whatweb.net
http://whatweb.net [200] Title[WhatWeb.net - Online Scan]
Cause
whatweb
at around line 360:
# load files from plugin_dirs unless a file is minused
plugin_dirs.each do |d|
# if a folder, then load all files
if File.directory?(d)
(Dir.glob("#{d}/*.rb")-minus_files).each {|x| load_plugin(x) }
elsif File.exists?(d)
load_plugin(d)
else
error("Error: #{d} is not Dir or File")
end
end
this calls load_plugins()
which overwrites Plugins.registered
which becomes an issue about 20 lines further on:
if b.map {|c| c.modifier }.include?(nil)
selected_plugin_names=[]
else
selected_plugin_names = Plugin.registered_plugins.map {|n,p| n.downcase }
end
Using the example:
$ ./whatweb -p title,plugins/robots.txt.rb whatweb.net
Plugin.registered_plugins
is set to the details of only the robots.txt
plugin, thus title
will never match.
Does anyone want to try fixing this?
I have managed to fix it for the scenario above, ran all rake all
tests and it was passing (except Ruby 1.9 see PR #239).
The solution was to run first with the plugins added by file get the names and store a list of those so that they can be in selected_plugin_names
and then load all plugins by folders.