Changeset 1342

Show
Ignore:
Timestamp:
03/07/08 14:32:21 (6 months ago)
Author:
kindlund
Message:

Fixing bug with YAML library, re: ticket #146

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • hive/trunk/data_webapp/app/controllers/hc_database_controller.rb

    r1293 r1342  
    11require 'base64' 
    2 require 'yaml' 
     2require 'rbyaml' 
    33 
    44class HcDatabaseController < ApplicationController 
     
    4444      obj_hash = obj_str 
    4545    else 
    46       obj_hash = YAML.load(obj_str) 
     46      obj_hash = RbYAML.load(obj_str) 
    4747    end 
    4848    count = 0 
     
    6363  # Removes all references from the queue. 
    6464  def insert_history_urls(obj_str) 
    65     obj_hash = YAML.load(obj_str) 
     65    obj_hash = RbYAML.load(obj_str) 
    6666    cid = obj_hash.delete("client_id") 
    6767    hid = Client.find(cid).host_id 
     
    104104  # Insert fingerprints from a suspicious VM 
    105105  def insert_fingerprint(obj_str) 
    106     obj_hash = YAML.load(obj_str) 
     106    obj_hash = RbYAML.load(obj_str) 
    107107 
    108108    # Remove compromise time from fingerprint and use to update related client object 
     
    113113 
    114114  def insert_client(obj_str) 
    115     obj_hash = YAML.load(obj_str) 
     115    obj_hash = RbYAML.load(obj_str) 
    116116    insert(Client,obj_hash) 
    117117  end 
    118118 
    119119  def set_client_compromised(id_str) 
    120     cid = YAML.load(id_str) 
     120    cid = RbYAML.load(id_str) 
    121121    Client.update(cid,{:status => "compromised"}) 
    122122  end 
    123123 
    124124  def set_client_suspended(id_str) 
    125     cid = YAML.load(id_str) 
     125    cid = RbYAML.load(id_str) 
    126126    Client.update(cid,{:status => "suspended"}) 
    127127  end 
    128128 
    129129  def set_client_running(id_str) 
    130     cid = YAML.load(id_str) 
     130    cid = RbYAML.load(id_str) 
    131131    Client.update(cid,{:status => "running"}) 
    132132  end 
    133133   
    134134  def set_client_deleted(id_str) 
    135     cid = YAML.load(id_str) 
     135    cid = RbYAML.load(id_str) 
    136136    Client.update(cid,{:status => "deleted"}) 
    137137  end 
    138138 
    139139  def set_client_bug(id_str) 
    140     cid = YAML.load(id_str) 
     140    cid = RbYAML.load(id_str) 
    141141    Client.update(cid,{:status => "bug"}) 
    142142  end 
    143143 
    144144  def set_client_unknown(id_str) 
    145     cid = YAML.load(id_str) 
     145    cid = RbYAML.load(id_str) 
    146146    Client.update(cid,{:status => "unknown"}) 
    147147  end 
     
    149149  # Input YAML encoded hash table of format {"client_id" => <int>, "compromise" => <timestamp>} 
    150150  def set_client_suspicious(compromise_str) 
    151     compromise_hash = YAML.load(compromise_str) 
     151    compromise_hash = RbYAML.load(compromise_str) 
    152152    cid = compromise_hash.delete("client_id") 
    153153    time = compromise_hash.delete("compromise") 
     
    197197    # Return the urls as a hash table url/priority pairs (e.g. {"http://www.honeyclient.org" => 1}) 
    198198    url_hash = Hash[*urls.collect {|u| [u.url,u.priority]}.flatten] 
    199     YAML.dump(url_hash) 
     199    RbYAML.dump(url_hash) 
    200200  end 
    201201 
    202202  # Get the list of client IDs that have been marked as "bug" on a given host.  
    203203  def get_broken_clients(obj_str) 
    204     obj_hash = YAML.load(obj_str) 
     204    obj_hash = RbYAML.load(obj_str) 
    205205    hostname = obj_hash.delete("hostname") 
    206206    hid = Host.find(:first, :conditions => { :hostname => hostname }).id 
     
    209209    # Return the clients as a hash table cid/id pairs (e.g. {"xxxxxxxxxx" => 1}) 
    210210    clients_hash = Hash[*clients.collect {|c| [c.cid,c.id]}.flatten] 
    211     YAML.dump(clients_hash) 
     211    RbYAML.dump(clients_hash) 
    212212  end 
    213213end