filter search result using comma delimited fields
parent
389b015047
commit
6955a9a58b
|
@ -5,7 +5,7 @@ module Msf::DBManager::Module
|
|||
metadata = Msf::Modules::Metadata::Cache.instance.get_metadata
|
||||
metadata.each { |module_metadata|
|
||||
if is_match(module_metadata, opts)
|
||||
search_results << module_metadata.full_name
|
||||
search_results << get_fields(module_metadata, opts)
|
||||
end
|
||||
}
|
||||
search_results
|
||||
|
@ -56,5 +56,18 @@ module Msf::DBManager::Module
|
|||
match
|
||||
end
|
||||
|
||||
def get_fields(module_metadata, opts)
|
||||
selected_fields = {}
|
||||
if opts.key? :fields
|
||||
fields = opts[:fields].split(',')
|
||||
fields.each do | field |
|
||||
if module_metadata.respond_to?(field)
|
||||
selected_fields[field] = module_metadata.send(field)
|
||||
end
|
||||
end
|
||||
end
|
||||
selected_fields.empty? ? module_metadata : selected_fields
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue