Class: I2X::SQLDetector
Overview
SQLDetector
Detec changes in SQL databases. MySQL support only.
Instance Attribute Summary
Attributes inherited from Detector
#agent, #content, #identifier, #objects, #payloads, #templates
Instance Method Summary collapse
-
#detect(object) ⇒ Object
Detect the changes.
Methods inherited from Detector
Constructor Details
This class inherits a constructor from I2X::Detector
Instance Method Details
#detect(object) ⇒ Object
Detect the changes
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 |
# File 'lib/i2x/sqldetector.rb', line 17 def detect object puts "Detecting SQL to #{object[:identifier]}" begin @client = Mysql2::Client.new(:host => object[:host], :username => object[:username] , :password => object[:password] , :database => object[:database]) @client.query(@agent[:payload][:query]).each(:symbolize_keys => false) do |row| unless object[:cache].nil? then @cache = Cashier.verify row[object[:cache]], object, row, object[:seed] else @cache = Cashier.verify row["id"], object, row, object[:seed] end # The actual processing # if @cache[:status] == 100 then # add row data to payload from selectors (key => key, value => column name) payload = Hash.new JSON.parse(object[:selectors]).each do |selector| selector.each do |k,v| payload[k] = row[v] end end # add payload object to payloads list @payloads.push payload end end rescue Exception => e end end |