WhatWeb icon indicating copy to clipboard operation
WhatWeb copied to clipboard

-p argument fails for plugin names when both names and paths are provided

Open bcoles opened this issue 13 years ago • 2 comments

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.

bcoles avatar Apr 05 '11 16:04 bcoles

Does anyone want to try fixing this?

urbanadventurer avatar Dec 01 '17 22:12 urbanadventurer

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.

andrericardo avatar Feb 10 '18 18:02 andrericardo