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
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/arii/xmldetector.rb', line 15
def detect object
ARII::Config.log.info(self.class.name) { "Monitoring #{object[:uri]}" } unless object[:uri].nil?
begin
if object[:uri] == '' then
@doc = Nokogiri::XML(object[:content])
else
@doc = Nokogiri::XML(open(object[:uri]))
end
@doc.remove_namespaces!
@doc.xpath(object[:query]).each do |element|
element.xpath(object[:cache]).each do |c|
@response = Cashier.verify c.content, object, c.content, object[:seed]
end
@cache = JSON.parse(@response, {:symbolize_names => true})
unless @cache[:templates].nil? then
@cache[:templates].each do |t|
@templates.push t
end
end
if @cache[:cache][:status] == 100 then
ARII::Config.log.info(self.class.name) { "Not on cache, generating payload" }
payload = Hash.new
object[:selectors].each do |selector|
selector.each do |k, v|
element.xpath(v).each do |el|
payload[k] = el.content
end
end
end
@payloads.push payload
end
end
end
rescue Exception => e
ARII::Config.log.error(self.class.name) { "Processing error: #{e}" }
end
|