3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/dradis/plugins/mediawiki/filters.rb', line 3
def query(params={})
results = []
host = Dradis::Plugins::Mediawiki::Engine.settings.host
path = Dradis::Plugins::Mediawiki::Engine.settings.path
port = Dradis::Plugins::Mediawiki::Engine.settings.port
scheme = Dradis::Plugins::Mediawiki::Engine.settings.scheme
port = (scheme == 'https' ? 443 : 80) if port.blank?
begin
filter_params = {
action: 'query',
prop: 'revisions',
generator: 'search',
gsrwhat: 'text',
gsrsearch: CGI::escape(params[:query]), rvprop: 'content',
format: 'xml'
}
Net::HTTP.start(host, port, use_ssl: scheme == 'https') do |http|
res = http.get("#{path}?#{filter_params.to_query}")
xml_doc = Nokogiri::XML( res.body )
results += xml_doc.xpath('api/query/pages/page').map do |xml_page|
Dradis::Plugins::Import::Result.new(
title: xml_page[:title],
description: fields_from_wikitext(xml_page.at_xpath('revisions/rev').text())
)
end
end
end
return results
end
|