Changeset 1342
- Timestamp:
- 03/07/08 14:32:21 (6 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
hive/trunk/data_webapp/app/controllers/hc_database_controller.rb
r1293 r1342 1 1 require 'base64' 2 require ' yaml'2 require 'rbyaml' 3 3 4 4 class HcDatabaseController < ApplicationController … … 44 44 obj_hash = obj_str 45 45 else 46 obj_hash = YAML.load(obj_str)46 obj_hash = RbYAML.load(obj_str) 47 47 end 48 48 count = 0 … … 63 63 # Removes all references from the queue. 64 64 def insert_history_urls(obj_str) 65 obj_hash = YAML.load(obj_str)65 obj_hash = RbYAML.load(obj_str) 66 66 cid = obj_hash.delete("client_id") 67 67 hid = Client.find(cid).host_id … … 104 104 # Insert fingerprints from a suspicious VM 105 105 def insert_fingerprint(obj_str) 106 obj_hash = YAML.load(obj_str)106 obj_hash = RbYAML.load(obj_str) 107 107 108 108 # Remove compromise time from fingerprint and use to update related client object … … 113 113 114 114 def insert_client(obj_str) 115 obj_hash = YAML.load(obj_str)115 obj_hash = RbYAML.load(obj_str) 116 116 insert(Client,obj_hash) 117 117 end 118 118 119 119 def set_client_compromised(id_str) 120 cid = YAML.load(id_str)120 cid = RbYAML.load(id_str) 121 121 Client.update(cid,{:status => "compromised"}) 122 122 end 123 123 124 124 def set_client_suspended(id_str) 125 cid = YAML.load(id_str)125 cid = RbYAML.load(id_str) 126 126 Client.update(cid,{:status => "suspended"}) 127 127 end 128 128 129 129 def set_client_running(id_str) 130 cid = YAML.load(id_str)130 cid = RbYAML.load(id_str) 131 131 Client.update(cid,{:status => "running"}) 132 132 end 133 133 134 134 def set_client_deleted(id_str) 135 cid = YAML.load(id_str)135 cid = RbYAML.load(id_str) 136 136 Client.update(cid,{:status => "deleted"}) 137 137 end 138 138 139 139 def set_client_bug(id_str) 140 cid = YAML.load(id_str)140 cid = RbYAML.load(id_str) 141 141 Client.update(cid,{:status => "bug"}) 142 142 end 143 143 144 144 def set_client_unknown(id_str) 145 cid = YAML.load(id_str)145 cid = RbYAML.load(id_str) 146 146 Client.update(cid,{:status => "unknown"}) 147 147 end … … 149 149 # Input YAML encoded hash table of format {"client_id" => <int>, "compromise" => <timestamp>} 150 150 def set_client_suspicious(compromise_str) 151 compromise_hash = YAML.load(compromise_str)151 compromise_hash = RbYAML.load(compromise_str) 152 152 cid = compromise_hash.delete("client_id") 153 153 time = compromise_hash.delete("compromise") … … 197 197 # Return the urls as a hash table url/priority pairs (e.g. {"http://www.honeyclient.org" => 1}) 198 198 url_hash = Hash[*urls.collect {|u| [u.url,u.priority]}.flatten] 199 YAML.dump(url_hash)199 RbYAML.dump(url_hash) 200 200 end 201 201 202 202 # Get the list of client IDs that have been marked as "bug" on a given host. 203 203 def get_broken_clients(obj_str) 204 obj_hash = YAML.load(obj_str)204 obj_hash = RbYAML.load(obj_str) 205 205 hostname = obj_hash.delete("hostname") 206 206 hid = Host.find(:first, :conditions => { :hostname => hostname }).id … … 209 209 # Return the clients as a hash table cid/id pairs (e.g. {"xxxxxxxxxx" => 1}) 210 210 clients_hash = Hash[*clients.collect {|c| [c.cid,c.id]}.flatten] 211 YAML.dump(clients_hash)211 RbYAML.dump(clients_hash) 212 212 end 213 213 end
